23.03.2013 Views

Quick introduction to reverse engineering for beginners

Quick introduction to reverse engineering for beginners

Quick introduction to reverse engineering for beginners

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

public f2<br />

f2 proc near<br />

push ebp<br />

mov ebp, esp<br />

mov eax, ds:v<br />

imul eax, 343FDh<br />

add eax, 269EC3h<br />

mov ds:v, eax<br />

mov eax, ds:v<br />

shr eax, 10h<br />

and eax, 7FFFh<br />

pop ebp<br />

retn<br />

f2 endp<br />

bss segment dword public ’BSS’ use32<br />

assume cs:_bss<br />

dd ?<br />

bss ends<br />

4.1.4 Task 1.4<br />

This is standard C library function. Source code taken from MSVC 2010. Compiled in MSVC 2010 with<br />

/Ox flag.<br />

PUBLIC _f<br />

_TEXT SEGMENT<br />

_arg1$ = 8 ; size = 4<br />

_arg2$ = 12 ; size = 4<br />

_f PROC<br />

push esi<br />

mov esi, DWORD PTR _arg1$[esp]<br />

push edi<br />

mov edi, DWORD PTR _arg2$[esp+4]<br />

cmp BYTE PTR [edi], 0<br />

mov eax, esi<br />

je SHORT $LN7@f<br />

mov dl, BYTE PTR [esi]<br />

push ebx<br />

test dl, dl<br />

je SHORT $LN4@f<br />

sub esi, edi<br />

npad 6<br />

$LL5@f:<br />

mov ecx, edi<br />

test dl, dl<br />

je SHORT $LN2@f<br />

$LL3@f:<br />

mov dl, BYTE PTR [ecx]<br />

test dl, dl<br />

je SHORT $LN14@f<br />

movsx ebx, BYTE PTR [esi+ecx]<br />

movsx edx, dl<br />

129

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!