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.

1.16 C++ classes<br />

I placed a C++ classes description here intentionally after structures description, because internally, C++<br />

classes representation is almost the same as structures representation.<br />

Let’s try an example with two variables, couple of construc<strong>to</strong>rs and one method:<br />

#include <br />

class c<br />

{<br />

private:<br />

int v1;<br />

int v2;<br />

public:<br />

c() // c<strong>to</strong>r<br />

{<br />

v1=667;<br />

v2=999;<br />

};<br />

};<br />

c(int a, int b) // c<strong>to</strong>r<br />

{<br />

v1=a;<br />

v2=b;<br />

};<br />

void dump()<br />

{<br />

printf ("%d; %d\n", v1, v2);<br />

};<br />

int main()<br />

{<br />

class c c1;<br />

class c c2(5,6);<br />

};<br />

c1.dump();<br />

c2.dump();<br />

return 0;<br />

Here is how main() function looks like translated in<strong>to</strong> assembler:<br />

_c2$ = -16 ; size = 8<br />

_c1$ = -8 ; size = 8<br />

_main PROC<br />

push ebp<br />

mov ebp, esp<br />

sub esp, 16 ; 00000010H<br />

lea ecx, DWORD PTR _c1$[ebp]<br />

call ??0c@@QAE@XZ ; c::c<br />

push 6<br />

push 5<br />

79

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

Saved successfully!

Ooh no, something went wrong!