Guest User

Untitled

a guest
Oct 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <windows.h>
  2. #include <detours.h>
  3.  
  4. class CDetour
  5. {
  6. public:
  7. bool My_MemFn(unsigned int unk1);
  8. static bool (CDetour::* Real_MemFn)(unsigned int);
  9. };
  10.  
  11. bool CDetour::My_MemFn(unsigned int unk1)
  12. {
  13. /* do stuff here */
  14. return (this->*Real_MemFn)(unk1);
  15. }
  16.  
  17. typedef bool (CDetour::* MemFn_t)(unsigned int unk1);
  18.  
  19. MemFn_t CDetour::Real_MemFn= *(MemFn_t *)((void*)0x231F48D0); // Is this even correct?
  20.  
  21. BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
  22. {
  23. switch (dwReason)
  24. {
  25. case DLL_PROCESS_ATTACH:
  26. {
  27. DetourTransactionBegin();
  28. DetourUpdateThread(GetCurrentThread());
  29. DetourAttach(&(PVOID&)CDetour::Real_MemFn, *(PBYTE*)&CDetour::My_MemFn); // ERROR: C2440: 'type cast' : cannot convert from 'bool __thiscall CDetour::* )(unsigned int)' to 'PBYTE *'
  30. DetourTransactionCommit();
  31. break;
  32. }
  33. }
  34.  
  35. return TRUE;
  36. }
Add Comment
Please, Sign In to add comment