有些函数调用方式:
代码:
mov ecx, PTR push c push b push a call xxxx
但我用的VC6,不能声明__thiscall(不知高级版本vc能声明__thiscall么?),编译器报错:'__thiscall' keyword reserved for future use。我又想不用内联汇编。
怎么办呢?
网上查了下,有方法(参见:http://www.vckbase.com/document/viewdoc/?id=1818),我又不是很喜欢,而且这个方法应该是有问题的。
下面介绍我的方法:
一个函数:
代码:
typedef float (__thiscall*) t_WWWdotMOKOdotCC(PVOID ptr,char* a, int b, int c); t_WWWdotMOKOdotCC WWWdotMOKOdotCC void main() { WWWdotMOKOdotCC = 0xFFFFFFFF; WWWdotMOKOdotCC(thisptr,"是个好网站",b,c); }
不能声明__thiscall(编译器报错:'__thiscall' keyword reserved for future use。)
解决办法:
代码:
typedef float (__stdcall*) t_WWWdotMOKOdotCC(char* a, int b, int c); t_WWWdotMOKOdotCC WWWdotMOKOdotCC _declspec(naked) float __stdcall this_WWWdotMOKOdotCC(PVOID ptr,char* a, int b, int c) { _asm{ pop eax pop ecx push eax JMP WWWdotMOKOdotCC } } void main() { WWWdotMOKOdotCC = 0xFFFFFFFF; this_WWWdotMOKOdotCC(thisptr,"是个好网站",b,c); }
pop eax
pop ecx
push eax
将最后一个参数存到ecx并从stack中移除。
这个问题的详细简介,网上转的: