【发布时间】:2011-06-22 08:08:23
【问题描述】:
我有以下代码:
class Base {
public:
int x,y;
Base() { x=10; y=20; }
virtual void myfunction() { }
};
int main() {
Base *b = new Base();
return 0;
}
反汇编给了我类似的东西:
push 0Ch ; size of Base
call j_<some giberrish> ; IDA gives the comment "operator new(uint)"
add esp, 4 ; function epilogue
mov [ebp+var_E0], eax
几行之后,您将调用构造函数。
mov ecx, [ebp+var_E0]
call j_Base__Base
mov [ebp+var_F4], eax
- 起初我以为
var_E0将包含指向实例的指针,但现在我很确定var_F4确实如此,因为它包含构造函数的返回值。 - 在那种情况下,
var_E0到底包含什么?为什么在调用构造函数之前将其移动到ecx?
【问题讨论】:
-
嗯,为什么要在调用构造函数之前将其加载到 ecx 中? ://
-
@uki 是
this指针
标签: c++ class assembly reverse-engineering