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.

_value$ = 20 ; size = 4<br />

_insert PROC<br />

push ebp<br />

mov ebp, esp<br />

mov eax, DWORD PTR _x$[ebp]<br />

imul eax, 2400 ; 00000960H<br />

mov ecx, DWORD PTR _y$[ebp]<br />

imul ecx, 120 ; 00000078H<br />

lea edx, DWORD PTR _a[eax+ecx]<br />

mov eax, DWORD PTR _z$[ebp]<br />

mov ecx, DWORD PTR _value$[ebp]<br />

mov DWORD PTR [edx+eax*4], ecx<br />

pop ebp<br />

ret 0<br />

_insert ENDP<br />

_TEXT ENDS<br />

Nothing special. For index calculation, three input arguments are multiplying in such way <strong>to</strong> represent<br />

array as multidimensional.<br />

GCC 4.4.1:<br />

public insert<br />

insert proc near<br />

x = dword ptr 8<br />

y = dword ptr 0Ch<br />

z = dword ptr 10h<br />

value = dword ptr 14h<br />

push ebp<br />

mov ebp, esp<br />

push ebx<br />

mov ebx, [ebp+x]<br />

mov eax, [ebp+y]<br />

mov ecx, [ebp+z]<br />

lea edx, [eax+eax]<br />

mov eax, edx<br />

shl eax, 4<br />

sub eax, edx<br />

imul edx, ebx, 600<br />

add eax, edx<br />

lea edx, [eax+ecx]<br />

mov eax, [ebp+value]<br />

mov dword ptr ds:a[edx*4], eax<br />

pop ebx<br />

pop ebp<br />

retn<br />

insert endp<br />

53

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

Saved successfully!

Ooh no, something went wrong!