Advertisement
Guest User

original code

a guest
Jul 29th, 2018
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. //Original Code:
  2.  
  3. // dllmain.cpp : Defines the entry point for the DLL application.
  4. #include <Windows.h>
  5. #include "MinHook.h"
  6. #include "PatternScan.h"
  7.  
  8. typedef int(*origSum)(int x, int y);
  9.  
  10. DWORD AddressOfSum = NULL;
  11. uintptr_t base = NULL;
  12. origSum oSum = (origSum)AddressOfSum;
  13.  
  14. //Another Version:
  15. //DWORD AddressOfSumWithOffset = (DWORD)base + 0xFFFFFFFF; No offset yet - check x64dbg later...
  16.  
  17. int hookedSum(int x, int y)
  18. {
  19.     x += 500;
  20.     y += 500;
  21.     return oSum(x ,y);
  22. }
  23.  
  24. DWORD WINAPI MainThread(LPVOID lpParam)
  25. {
  26.     base = (uintptr_t)GetModuleHandle(NULL); //Grabs base address of host executable
  27.     return 0;
  28. }
  29.  
  30.  
  31. BOOL APIENTRY DllMain(HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
  32. {
  33.     switch (ul_reason_for_call)
  34.     {
  35.     case DLL_PROCESS_ATTACH:
  36.  
  37.         AddressOfSum = FindPattern("testhook.exe", "89 54 24 10 89 4C 24 08 55");
  38.         if (MH_Initialize() != MH_OK) return 1;
  39.         if (MH_CreateHook((LPVOID)oSum, &hookedSum, NULL) != MH_OK) return 1;
  40.         if (MH_EnableHook((LPVOID)oSum) != MH_OK) return 1;
  41.  
  42.     case DLL_THREAD_ATTACH:
  43.     case DLL_THREAD_DETACH:
  44.     case DLL_PROCESS_DETACH:
  45.         //Didn't add MinHook uninitalize code yet...
  46.         break;
  47.     }
  48.     return TRUE;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement