寫一個小例子反匯編找找:
class A
{
public:
int bb;
int aa;
void fun(int _aa){aa = _aa;};
};
A a;
a.bb = 4; //說明: a的地址就是bb的地址,也是this的值。(注意:地址和值的說法)
a.fun(9);
mov dword ptr ss:[ebp-8], 4
push 9 ; 參數1
lea ecx, dword ptr ss:[ebp-8] ;隱藏的參數2 this指針 a的地址 bb的地址
call 00401040 ; fun的地址
fun的匯編:
mov dword ptr ss:[ebp-4], ecx
mov eax, dword ptr ss:[ebp-4] ;傳說的this指針終于出現了。呵呵
mov ecx, dword ptr ss:[ebp+8] ;參數1 9
mov dword ptr ds:[eax+4], ecx ;eax+4 aa 的地址
太晚了。明天還要上班。今天就研究到這里。睡覺了。