📄 thunk.h
字号:
// FileName : Thunk.h
/*
* Copyright (c) 2006 - 2007 All Rights Reserved
*
* 程序作者:
* 张鲁夺(zhangluduo) : 为所有爱我的人和我爱的人努力!
*
* 联系方式:
* zhangluduo@msn.com
* QQ群:34064264
*
* 更新时间:
* 2007-10-30
*
* 功能描述:
* thunk : 动态改变CPU指令的一种技术.
* 利用这个类可以将Windows API的回调函数封装成C++类成员. 这份代码要
* 求在x86上执行.
*
* 授权声明:
* 许可任何单位,个人随意使用,拷贝,修改,散布及出售这份代码,及其相关的
* 开发文档,但是必须保留此版权信息,以慰藉作者辛勤的劳动,及表明此代码
* 的来源,如若此份代码有任何BUG或者您有更好的修改建议, 请通知作者,以
* 便弥补作者由于水平所限而导致的一些错误和不足,谢谢!
*/
#ifndef _THUNK_H
#define _THUNK_H
#ifndef _UNION_CAST
#define _UNION_CAST
template <class ToType, class FromType>
ToType union_cast (FromType f)
{
union
{
FromType _f;
ToType _t;
} ut;
ut._f = f;
return ut._t;
}
#endif
class Thunk
{
private:
unsigned char m_ThiscallCode[10];
unsigned char m_StdcallCode [16];
public:
template <typename T> static unsigned long GetAddr(T FunctionName)
{
return union_cast<unsigned long>(FunctionName);
}
void* thiscall(void* pThis, unsigned long FunctionAddr);
void* stdcall (void* pThis, unsigned long FunctionAddr);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -