SHARE
TWEET

Diplomacy Plugin

a guest Dec 21st, 2017 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "patcher_x86.hpp"
  2.  
  3. Patcher* _P;
  4. PatcherInstance* _PI;
  5. static _bool_ plugin_On = 0;
  6.  
  7. int __stdcall testHook(LoHook* h, HookContext* c)
  8. {
  9.   c->eax *= 2;
  10.  
  11.   return EXEC_DEFAULT;
  12. }
  13.  
  14. int __stdcall testHook2(LoHook* h, HookContext* c)
  15. {
  16. c->esi = max(1, (c->esi) >> 2);
  17. return EXEC_DEFAULT;
  18. }
  19.  
  20. int __stdcall testHook3(LoHook* h, HookContext* c)
  21. {
  22. c->edi = max(1, (c->edi) >> 2);
  23. return EXEC_DEFAULT;
  24. }
  25.  
  26. int __stdcall testHook4(LoHook* h, HookContext* c)
  27. {
  28. c->ebx += (c->ebx) >> 1;
  29. return EXEC_DEFAULT;
  30. }
  31.  
  32.  
  33. BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
  34. {
  35.   switch ( ul_reason_for_call )
  36.   {
  37.      case DLL_PROCESS_ATTACH:
  38.        
  39.         if ( !plugin_On )
  40.         {
  41.            plugin_On = 1;
  42.            _P = GetPatcher();
  43.            _PI = _P->CreateInstance("HD.Plugin.TestPlugin");
  44.            _PI->WriteLoHook(0x44467E, testHook);
  45.            _PI->WriteLoHook(0x4A6C88, testHook2);
  46.            _PI->WriteLoHook(0x4A6EE8, testHook3);
  47.            _PI->WriteLoHook(0x4A73DC, testHook4);
  48.         }
  49.  
  50.      case DLL_THREAD_ATTACH:
  51.      case DLL_THREAD_DETACH:
  52.      case DLL_PROCESS_DETACH:
  53.         break;
  54.   }
  55.  
  56.   return TRUE;
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top