类的权限控制只是编译器的产物,在汇编层次无法体现
类的构造函数VC特征
1.调用时,传递this指针。例如:lea ecx, [ebp+testb] ; this
2.函数内部,先处理this指针。例如:mov [ebp+this], ecx
3.若是有虚函数,则虚函数表赋值.例如:mov dword ptr [eax], offset ??_7CTestA@@6B@ ; const CTestA::`vftable'
4.返回this指针.例如:mov eax, [ebp+this]
类的析构函数VC特征
1.调用时,传递this指针。例如:lea ecx, [ebp+testb] ; this
2.函数内部,先处理this指针。例如:mov [ebp+this], ecx
3.若是有虚函数,则虚函数表赋值.mov dword ptr [eax], offset ??_7CTestA@@6B@ ; const CTestA::`vftable'
4.无返回值
类的成员函数VC特征
1.调用时,传递this指针。例如:lea ecx, [ebp+testb] ; this
2.函数内部,先处理this指针。例如:mov [ebp+this], ecx
3.函数地址引用,只有CALL指令。
类的内联成员函数VC特征
与类的成员函数VC特征一样
类的虚成员函数VC特征
1.调用时,传递this指针。例如:lea ecx, [ebp+testb] ; this
2.函数内部,先处理this指针。例如:mov [ebp+this], ecx
3.函数地址引用,能在虚表中找到。例如:
.rdata:00402394 ; const CTestA::`vftable'
.rdata:00402394 ??_7CTestA@@6B@ dd offset ?Sub@CTestA@@UAEHHH@Z
.rdata:00402394 ; DATA XREF: CTestA::CTestA(int,char,int)+Ao
.rdata:00402394 ; CTestA::CTestA(void)+Ao ...
.rdata:00402394 ; CTestA::Sub(int,int)
.rdata:00402398 dd offset ?Sub@CTestA@@UAEHXZ ; CTestA::Sub(void)
.rdata:0040239C dd 0
类的内联虚成员函数VC特征
与类的虚成员函数VC特征一样
类的静态成员函数VC特征
1.与普通函数无异。
VC++类成员函数特性解析

本文详细介绍了VC++编译器下类的各种成员函数(包括构造函数、析构函数、成员函数、内联成员函数、虚成员函数及静态成员函数)的汇编语言级特性。重点讲解了this指针的使用、虚函数表的建立与应用。
1万+

被折叠的 条评论
为什么被折叠?



