定义thiscall函数指针

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiongya8888/article/details/86544477

在编写类的时候,可以按照下面的方式定义并使用成员函数指针。

class MyClass
{
public:
	typedef bool(MyClass::*pfnMyFunction)(std::string &p);
	bool myFunction(std::string &p)
	{
		printf(p.c_str());
		return false;
	}
	void test()
	{
		pfnMyFunction func=&MyClass::myFunction;
		std::string p="hello";
		(this->*func)(p);
	}
};

但有时候我们需要hook thiscall函数,定义thiscall函数编译器会报错,这个时候可以定义fastcall函数代替thiscall,fastcall第一个参数为ecx,第二个参数为edx,其它和thiscall一样

typedef PVOID (__fastcall *pfnHookedFunction)(PVOID Parameter1,PVOID Parameter2,PVOID Parameter3);

猜你喜欢

转载自blog.csdn.net/xiongya8888/article/details/86544477
今日推荐