First, you need to take a look at this website.
The CPUID returns processor identification and feature information in the EAX, EBX, ECX, and EDX registers.
What the source code from my example do?
First I start with the default assembly program.
The next step is to start with resetting with xor eax,eax use cpuid.
The result of CPUID will be put into EBX.
Into section ‘.data’ data readable writeable make a structure named out_buffer.
The structure will be filled so you need to EBX, see the example:
mov [out_buffer.vendor_ebx],ebx will give us “Genu”.
The next step for test EBX is this example:
test edx,00010000000000000000000000000000b
jz .NoHTT
mov [out_buffer.htt_arch4],’YES ‘
.NoHTT:
The structure of out_buffer is :
db ‘NoHTT’,2,9,’- ‘
.htt_arch4 dd ‘NO ‘
db 9,10
Because I used MessageBox to show us the out_buffer.
The result will be No or Yes with the size of dd.
The DB can define byte variables, as well as arrays of bytes.
Fasm documentation tells us: For example db 1,2,3 will define the three bytes of values 1, 2 and 3 respectively.
The dd has 4 bytes.
The result will be this text (the result is true to the text will be YES): “NoHTT – YES”.
Let’s see one screenshot:
This is the source code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | format PE GUI 4.0 entry start include 'win32ax.inc' section '.code' code readable executable start: ; INVOKE CPUID FUNCTION 0x00000000 xor eax,eax cpuid ; EXTRACT VENDOR STRING FROM mov [out_buffer.vendor_ebx],ebx mov [out_buffer.vendor_edx],edx mov [out_buffer.vendor_ecx],ecx ; CHECK FOR FUNCTION 0x00000001 cmp eax,0x00000001 jl .NoCPUID_FN1 ; INVOKE CPUID FUNCTION 0x00000001 mov eax,0x00000001 cpuid ; TEST FOR HTT Hyper-Threading Technology test edx,00010000000000000000000000000000b jz .NoHTT mov [out_buffer.htt_arch4],'YES ' .NoHTT: ; TEST FOR MMX test edx,00000000100000000000000000000000b jz .NoMMX mov [out_buffer.mmx_ach4],'YES ' .NoMMX: ; TEST FOR SSE test edx,00000010000000000000000000000000b jz .NoSSE mov [out_buffer.sse_ach4],'YES ' .NoSSE: ; TEST FOR SSE2 test edx,00000100000000000000000000000000b jz .NoSSE2 mov [out_buffer.sse2_ach4],'YES ' .NoSSE2: ; TEST FOR SSE3 test ecx,00000000000000000000000000000001b jz .NoSSE3 mov [out_buffer.sse3_ach4],'YES ' .NoSSE3: .NoCPUID_FN1: ; DISPLAY RESULTS AND QUIT invoke MessageBox,NULL,out_buffer,'CPUID',MB_OK+MB_ICONINFORMATION invoke ExitProcess,0 jmp $ ;--- SECTION DATA STRUCTURE FOR MESSAGE BOX section '.data' data readable writeable out_buffer: db 'VENDOR',2,9,'- ' .vendor_ebx dd 0 .vendor_edx dd 0 .vendor_ecx dd 0 db 9,13,10 db 'NoHTT',2,9,'- ' .htt_arch4 dd 'NO ' db 9,10 db 'MMX',2,9,'- ' .mmx_ach4 dd 'NO ' db 9,10 db 'SSE',2,9,'- ' .sse_ach4 dd 'NO ' db 9,10 db 'SSE2',2,9,'- ' .sse2_ach4 dd 'NO ' db 9,10 db 'SSE3',2,9,'- ' .sse3_ach4 dd 'NO ' db 9,10 db 0 ; end out_buffer ;--- DEFAULT DATA INCLUDES section '.idata' import data readable library kernel32,'kernel32.dll',\ user32,'user32.dll' include 'api\kernel32.inc' include 'api\user32.inc' |