Broihon

Untitled

Jun 16th, 2020
763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. HINSTANCE hInjectionMod = LoadLibrary(GH_INJ_MOD_PATH);
  2.  
  3. ValidateInjectionFunctions = (f_ValidateInjectionFunctions)GetProcAddress(hInjectionMod, "ValidateInjectionFunctions");
  4. RestoreInjectionFunctions = (f_RestoreInjectionFunctions)GetProcAddress(hInjectionMod, "RestoreInjectionFunctions");
  5.  
  6. HANDLE hProc = GetProcessByName(TARGET);
  7. DWORD TargetProcessId = GetProcessId(hProc);
  8.  
  9. HookInfo info[30];
  10. DWORD err1, err2;
  11. UINT CountOut = 0;
  12. auto val_ret = ValidateInjectionFunctions(TargetProcessId, err1, err2, info, 30, &CountOut);
  13.  
  14. if (!val_ret)
  15. {
  16.     printf("ValidateInjectionFunctions failed:\n\t%08X\n\t%08X\n", err1, err2);
  17.     return false;
  18. }
  19.  
  20. printf("Injection functions validated\n");
  21.  
  22. UINT Changed = 0;
  23. for (UINT i = 0; i != CountOut; ++i)
  24. {
  25.     if (info[i].ChangeCount && !info[i].ErrorCode)
  26.     {
  27.         printf("Hook detected: %s->%s (%d)\n", info[i].ModuleName, info[i].FunctionName, info[i].ChangeCount);
  28.         ++Changed;
  29.     }
  30. }
  31.  
  32. if (Changed)
  33. {
  34.     printf("Restoring hooks\n");
  35.  
  36.     auto res_ret = RestoreInjectionFunctions(TargetProcessId, err1, err2, info, CountOut, &CountOut);
  37.  
  38.     if (!res_ret)
  39.     {
  40.         printf("RestoreInjectionFunctions failed:\n\t%08X\n\t%08X\n", err1, err2);
  41.  
  42.         return false;
  43.     }
  44.  
  45.     printf("Hooks restored\n");
  46. }
  47. else
  48. {
  49.     printf("No hooks found\n");
  50. }
Add Comment
Please, Sign In to add comment