Quick introduction to reverse engineering for beginners
Quick introduction to reverse engineering for beginners
Quick introduction to reverse engineering for beginners
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
call function<br />
function:<br />
.. do something ..<br />
ret 4<br />
GCC regparm<br />
It’s fastcall evolution 5 is some sense. With the -mregparm option it’s possible <strong>to</strong> set, how many arguments<br />
will be passed via registers. 3 at maximum. Thus, EAX, EDX and ECX registers will be used.<br />
Of course, if number of arguments is less then 3, not all registers 3 will be used.<br />
Caller res<strong>to</strong>res stack pointer <strong>to</strong> its initial state.<br />
2.5.4 thiscall<br />
In C++, it’s a this pointer <strong>to</strong> object passing in<strong>to</strong> function-method.<br />
In MSVC, this is usually passed in ECX register.<br />
In GCC, this pointer is passed as a first function-method argument. Thus it will be seen that internally<br />
all function-methods has extra argument <strong>for</strong> it.<br />
2.5.5 x86-64<br />
win64<br />
The method of arguments passing in Win64 is somewhat resembling <strong>to</strong> fastcall. First 4 arguments are<br />
passed via RCX, RDX, R8, R9, others — via stack. Caller also must prepare a place <strong>for</strong> 32 bytes or 4 64-bit<br />
values, so then callee can save there first 4 arguments. Short functions may use argument values just from<br />
registers, but larger may save its values <strong>for</strong> further use.<br />
Caller also should return stack pointer in<strong>to</strong> initial state.<br />
This calling convention is also used in Windows x86-64 system DLLs (instead if stdcall in win32).<br />
2.5.6 Returning values of float and double type<br />
In all conventions except of Win64, values of type float or double returning via FPU register ST(0).<br />
In Win64, return values of float and double types are returned in XMM0 register instead of ST(0).<br />
5 http://www.ohse.de/uwe/articles/gcc-attributes.html#func-regparm<br />
119