Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <detours.h>
- class CDetour
- {
- public:
- bool My_MemFn(unsigned int unk1);
- static bool (CDetour::* Real_MemFn)(unsigned int);
- };
- bool CDetour::My_MemFn(unsigned int unk1)
- {
- /* do stuff here */
- return (this->*Real_MemFn)(unk1);
- }
- typedef bool (CDetour::* MemFn_t)(unsigned int unk1);
- MemFn_t CDetour::Real_MemFn= *(MemFn_t *)((void*)0x231F48D0); // Is this even correct?
- BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
- {
- switch (dwReason)
- {
- case DLL_PROCESS_ATTACH:
- {
- DetourTransactionBegin();
- DetourUpdateThread(GetCurrentThread());
- DetourAttach(&(PVOID&)CDetour::Real_MemFn, *(PBYTE*)&CDetour::My_MemFn); // ERROR: C2440: 'type cast' : cannot convert from 'bool __thiscall CDetour::* )(unsigned int)' to 'PBYTE *'
- DetourTransactionCommit();
- break;
- }
- }
- return TRUE;
- }
Add Comment
Please, Sign In to add comment