Advertisement
Guest User

Untitled

a guest
Jan 31st, 2019
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. #include "FuncHook.h"
  6. #include "headers/CapstoneDisassembler.hpp"
  7. #include "headers/Detour/x64Detour.hpp"
  8.  
  9. #define offset_somme_func 0x140013B40
  10. int *p_offset_som = (int*)offset_somme_func;
  11.  
  12. typedef int(*sum)(int x, int y);
  13. sum originalSum = (sum)offset_somme_func;
  14.  
  15. PLH::x64Detour* PLHhk;
  16.  
  17.  
  18. uint64_t hookPrintfTramp = NULL;
  19. NOINLINE int __cdecl h_hookPrintf(const char* format, ...){
  20.     //return PLH::FnCast(hookPrintfTramp, originalSum)(12, 80);
  21.     return 14;
  22. }
  23.  
  24.  
  25.  
  26.  
  27. void Main(LPVOID pParam){
  28.     std::cout << "new thread" << std::endl;
  29.     PLH::CapstoneDisassembler dis(PLH::Mode::x64);
  30.     PLHhk = new PLH::x64Detour((char*)&p_offset_som, (char*)&h_hookPrintf, &hookPrintfTramp, dis);
  31.     PLHhk->hook();
  32. }
  33.  
  34. BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID lpReserved){
  35.     if (ul_reason_for_call == DLL_PROCESS_ATTACH){
  36.         DisableThreadLibraryCalls(hinstDLL);
  37.         CreateRemoteThread(GetCurrentProcess(), 0, 0, (LPTHREAD_START_ROUTINE)Main, hinstDLL, 0, 0);
  38.         std::cout << "injected" << std::endl;
  39.     }
  40.     return TRUE;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement