The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Twister on July 06, 2010, 07:48:12 AM

Title: GenuineIntel
Post by: Twister on July 06, 2010, 07:48:12 AM
I am having a strange problem with comparing the two simple strings. Putting the processor string into the buffer works fine. It's just comparing them that's not fine.

Lines (37-45)
.586p
.model flat, stdcall

ExitProcess proto :dword
MessageBoxA proto :dword,:dword,:dword,:dword

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.data

buffer db 13 dup (0)
strcap db "GenuineIntel",0
strnotgen db "Your shit is not legit",0
strgen db "Your shits geniune, legit",0

.code

start:

pushfd
pop eax
mov ecx, eax
xor eax, 200000h
push eax
popfd
pushfd
pop eax
xor eax, ecx
jz @f
xor eax, eax
cpuid
mov dword ptr ds:[buffer], ebx ; ebx = 756E6547
mov dword ptr ds:[buffer+4h], edx ; edx = 49656E69
mov dword ptr ds:[buffer+8h], ecx ; ecx = 6C65746E
mov ecx, 3h
@loop:
test ecx, ecx
je @nloop
mov eax, dword ptr ds:[buffer+ecx*4] ; eax = 6E654700
mov ecx, dword ptr ds:[strcap+ecx*4] ; ecx = 756F5900
cmp eax, esi
jnz @f
dec ecx
jmp @loop
@nloop:
push 0
push offset strcap
push offset strgen
push 0
call MessageBoxA
jmp @exit
@@:
push 0
push offset strcap
push offset strnotgen
push 0
call MessageBoxA
@exit:
push 0
call ExitProcess

end start
Title: Re: GenuineIntel
Post by: clive on July 06, 2010, 03:26:12 PM
Perhaps this should be in the CAMPUS

mov ecx, 3h
@loop:
test ecx, ecx
je @nloop
DEC ECX ; (0 .. 2)
mov eax, dword ptr [buffer+ecx*4]
mov ESI, dword ptr [strcap+ecx*4]
cmp eax, esi
jnz @f
jmp @loop



mov ecx, 3h
@loop:
test ecx, ecx
je @nloop
DEC ECX ; (0 .. 2)
mov eax, dword ptr [buffer+ecx*4]
CMP EAX, dword ptr [strcap+ecx*4]
jnz @f
jmp @loop
Title: Re: GenuineIntel
Post by: GregL on July 06, 2010, 03:35:06 PM
Radio,

Clive posted when I was looking at your code. At cmp eax, esi,  esi = 0 so the compare  fails.


Title: Re: GenuineIntel
Post by: clive on July 06, 2010, 04:34:32 PM
Quote from: Greg Lyon
Clive posted when I was looking at your code. At cmp eax, esi,  esi = 0 so the compare  fails.

You also have to pre-decrement ECX, otherwise your first comparison occurs at buffer+12 (ie beyond the string/buffer), and the last a buffer+4, which is clearly not what you want to achieve.

You compare ECX with zero at the being of the loop, so it will be at least ONE immediately after the branch, decrementing it will given it a value of 2, 1, 0 for each iteration respectively.
Title: Re: GenuineIntel
Post by: Twister on July 06, 2010, 05:24:14 PM
Thanks, clive. That is what was screwing me up all a long.