?? thunk.h
字號:
/********************************************************************
Copyright 2006-2008 ZHANG Luduo. All Rights Reserved.
Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear
in supporting documentation.
********************************************************************/
/*
代碼說明 :
thunk - 動態替換CPU指令
利用這個類可以將Windows API的回調函數封裝
成C++類成員.這份代碼只能在x86的CPU上執行.
聯系方式:
作者 - 張魯奪
MSN - zhangluduo@msn.com
Email - zhangluduo@163.com
QQ群 - 34064264, 56918155
為所有愛我的人和我愛的人努力!
*/
#ifndef _THUNK_H
#define _THUNK_H
class Thunk
{
private:
// unsigned char m_ThiscallCode[10];
// unsigned char m_StdcallCode [16];
#pragma pack(push, 1)
typedef struct _THUNK_THISCALL
{
unsigned char Mov; // 0xB9
unsigned long This; // this pointer
unsigned char Jmp; // 0xE9
unsigned long Adrr; // target address
} THUNK_THISCALL, *PTHUNK_THISCALL;
typedef struct _THUNK_STDCALL
{
unsigned char Push[3]; // push dword ptr[esp] ;
unsigned long Move; // mov dword ptr [esp + 4], ?? ?? ?? ?? ;
unsigned long This; // this pointer
unsigned char Jmp; // 0xE9
unsigned long Adrr; // target address
} THUNK_STDCALL, *PTHUNK_STDCALL;
#pragma pack(pop)
THUNK_THISCALL m_THISCALL;
THUNK_STDCALL m_STDCALL;
public:
template <typename T>
static unsigned long GetMemberFxnAddr(T MemberFxnName)
{
union { T _f; unsigned long _t; } ut;
ut._f = MemberFxnName;
return ut._t;
}
void* Thiscall(void* pThis, unsigned long MemberFxnAddr);
void* Stdcall (void* pThis, unsigned long MemberFxnAddr);
};
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -