Guest User

maxownage01 GH HackProcess.h

a guest
Sep 12th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.21 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <Windows.h>
  4. #include <TlHelp32.h>
  5.  
  6. //THIS FILE SIMPLY DOES MOST OF THE BACKEND WORK FOR US,
  7. //FROM FINDING THE PROCESS TO SETTING UP CORRECT ACCESS FOR US
  8. //TO EDIT MEMORY
  9. //IN MOST GAMES, A SIMPLER VERSION OF THIS CAN BE USED, or if you're injecting then its often not necessary
  10. //This file has been online for quite a while so credits should be shared but im using this from NubTIK
  11. //So Credits to him and thanks
  12.  
  13. class CHackProcess
  14. {
  15. public:
  16.  
  17. PROCESSENTRY32 __gameProcess;
  18. HANDLE __HandleProcess;
  19. HWND __HWNDCss;
  20. DWORD __dwordClient;
  21. DWORD __dwordEngine;
  22. DWORD __dwordOverlay;
  23. DWORD __dwordVGui;
  24. DWORD __dwordLibCef;
  25. DWORD __dwordSteam;
  26. DWORD FindProcessName(const char *__ProcessName, PROCESSENTRY32 *pEntry)
  27. {
  28. PROCESSENTRY32 __ProcessEntry;
  29. __ProcessEntry.dwSize = sizeof(PROCESSENTRY32);
  30. HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  31. if (hSnapshot == INVALID_HANDLE_VALUE) return 0; if (!Process32First(hSnapshot, &__ProcessEntry))
  32. {
  33. CloseHandle(hSnapshot);
  34. return 0;
  35. }
  36. do{if (!_strcmpi(__ProcessEntry.szExeFile, __ProcessName))
  37. {
  38. memcpy((void *)pEntry, (void *)&__ProcessEntry, sizeof(PROCESSENTRY32));
  39. CloseHandle(hSnapshot);
  40. return __ProcessEntry.th32ProcessID;
  41. }} while (Process32Next(hSnapshot, &__ProcessEntry));
  42. CloseHandle(hSnapshot);
  43. return 0;
  44. }
  45.  
  46.  
  47. DWORD getThreadByProcess(DWORD __DwordProcess)
  48. {
  49. THREADENTRY32 __ThreadEntry;
  50. __ThreadEntry.dwSize = sizeof(THREADENTRY32);
  51. HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
  52. if (hSnapshot == INVALID_HANDLE_VALUE) return 0;
  53.  
  54. if (!Thread32First(hSnapshot, &__ThreadEntry)) {CloseHandle(hSnapshot); return 0; }
  55.  
  56. do {if (__ThreadEntry.th32OwnerProcessID == __DwordProcess)
  57. {
  58. CloseHandle(hSnapshot);
  59. return __ThreadEntry.th32ThreadID;
  60. }} while (Thread32Next(hSnapshot, &__ThreadEntry));
  61. CloseHandle(hSnapshot);
  62. return 0;
  63. }
  64.  
  65. DWORD GetModuleNamePointer(LPSTR LPSTRModuleName, DWORD __DwordProcessId)
  66. {
  67. MODULEENTRY32 lpModuleEntry = {0};
  68. HANDLE hSnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, __DwordProcessId);
  69. if(!hSnapShot)
  70. return NULL;
  71. lpModuleEntry.dwSize = sizeof(lpModuleEntry);
  72. BOOL __RunModule = Module32First( hSnapShot, &lpModuleEntry );
  73. while(__RunModule)
  74. {
  75. if(!strcmp(lpModuleEntry.szModule, LPSTRModuleName ) )
  76. {CloseHandle( hSnapShot );
  77. return (DWORD)lpModuleEntry.modBaseAddr;
  78. }
  79. __RunModule = Module32Next( hSnapShot, &lpModuleEntry );
  80. }
  81. CloseHandle( hSnapShot );
  82. return NULL;
  83. }
  84.  
  85.  
  86. void runSetDebugPrivs()
  87. {
  88. HANDLE __HandleProcess=GetCurrentProcess(), __HandleToken;
  89. TOKEN_PRIVILEGES priv;
  90. LUID __LUID;
  91. OpenProcessToken(__HandleProcess, TOKEN_ADJUST_PRIVILEGES, &__HandleToken);
  92. LookupPrivilegeValue(0, "seDebugPrivilege", &__LUID);
  93. priv.PrivilegeCount = 1;
  94. priv.Privileges[0].Luid = __LUID;
  95. priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  96. AdjustTokenPrivileges(__HandleToken, false, &priv, 0, 0, 0);
  97. CloseHandle(__HandleToken);
  98. CloseHandle(__HandleProcess);
  99. }
  100.  
  101.  
  102.  
  103. void RunProcess()
  104. {
  105. //commented lines are for non steam versions of the game
  106. runSetDebugPrivs();
  107. while (!FindProcessName("csgo.exe", &__gameProcess)) Sleep(12);
  108. while (!(getThreadByProcess(__gameProcess.th32ProcessID))) Sleep(12);
  109. __HandleProcess = OpenProcess(PROCESS_ALL_ACCESS, false, __gameProcess.th32ProcessID);
  110. while(__dwordClient == 0x0) __dwordClient = GetModuleNamePointer("client.dll", __gameProcess.th32ProcessID);
  111. while(__dwordEngine == 0x0) __dwordEngine = GetModuleNamePointer("engine.dll", __gameProcess.th32ProcessID);
  112. //while(__dwordOverlay == 0x0) __dwordOverlay = GetModuleNamePointer("gameoverlayrenderer.dll", __gameProcess.th32ProcessID);
  113. while(__dwordVGui == 0x0) __dwordVGui = GetModuleNamePointer("vguimatsurface.dll", __gameProcess.th32ProcessID);
  114. //while(__dwordLibCef == 0x0) __dwordLibCef = GetModuleNamePointer("libcef.dll", __gameProcess.th32ProcessID);
  115. // while(__dwordSteam == 0x0) __dwordSteam = GetModuleNamePointer("steam.dll", __gameProcess.th32ProcessID);
  116. __HWNDCss = FindWindow(NULL, "Counter-Strike: Global Offensive");
  117. }
  118. };
  119.  
  120. extern CHackProcess fProcess;
Add Comment
Please, Sign In to add comment