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.

2.1 LEA instruction<br />

LEA (Load Effective Address) is instruction intended not <strong>for</strong> values summing but <strong>for</strong> address <strong>for</strong>ming, <strong>for</strong><br />

example, <strong>for</strong> <strong>for</strong>ming address of array element by adding array address, element index, with multiplication<br />

of element size 1 .<br />

Important property of LEA instruction is that it do not alter processor flags.<br />

int f(int a, int b)<br />

{<br />

return a*8+b;<br />

};<br />

MSVC 2010 with /Ox option:<br />

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

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

_f PROC<br />

mov eax, DWORD PTR _b$[esp-4]<br />

mov ecx, DWORD PTR _a$[esp-4]<br />

lea eax, DWORD PTR [eax+ecx*8]<br />

ret 0<br />

_f ENDP<br />

1 See also: http://en.wikipedia.org/wiki/Addressing_mode<br />

113

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

Saved successfully!

Ooh no, something went wrong!