Reverse Engineering for Beginners

(avery) #1

CHAPTER 21. STRUCTURES CHAPTER 21. STRUCTURES


mov esi, 1
push ebx
mov eax, esi
sub esp, 18h
cpuid
mov esi, eax
and eax, 0Fh
mov [esp+8], eax
mov dword ptr [esp+4], offset aSteppingD ; "stepping=%d\n"
mov dword ptr [esp], 1
call _printf_chk
mov eax, esi
shr eax, 4
and eax, 0Fh
mov [esp+8], eax
mov dword ptr [esp+4], offset aModelD ; "model=%d\n"
mov dword ptr [esp], 1
call _printf_chk
mov eax, esi
shr eax, 8
and eax, 0Fh
mov [esp+8], eax
mov dword ptr [esp+4], offset aFamily_idD ; "familyid=%d\n"
mov dword ptr [esp], 1
call
printf_chk
mov eax, esi
shr eax, 0Ch
and eax, 3
mov [esp+8], eax
mov dword ptr [esp+4], offset aProcessor_type ; "processor_type=%d\n"
mov dword ptr [esp], 1
call ___printf_chk
mov eax, esi
shr eax, 10h
shr esi, 14h
and eax, 0Fh
and esi, 0FFh
mov [esp+8], eax
mov dword ptr [esp+4], offset aExtended_model ; "extended_modelid=%d\n"
mov dword ptr [esp], 1
call
printf_chk
mov [esp+8], esi
mov dword ptr [esp+4], offset unk_80486D0
mov dword ptr [esp], 1
call ___printf_chk
add esp, 18h
xor eax, eax
pop ebx
pop esi
mov esp, ebp
pop ebp
retn
main endp


Almost the same. The only thing worth noting is that GCC somehow combines the calculation ofextended_model_id
andextended_family_idinto one block, instead of calculating them separately before eachprintf()call.


21.6.2 Working with the float type as with a structure.


As we already noted in the section about FPU (17 on page 205), bothfloatanddoubletypes consist of asign, asignificand
(orfraction) and anexponent. But will we be able to work with these fields directly? Let’s try this withfloat.


3031 2322 0

S exponent mantissa or fraction

( S—sign)

#include <stdio.h>

Free download pdf