Advertisement
Guest User

Untitled

a guest
Sep 30th, 2013
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <Windows.h>
  4. #include <TlHelp32.h>
  5. #include <stdio.h>
  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 __csgoexe;
  27. DWORD FindProcessName(const char *__ProcessName, PROCESSENTRY32 *pEntry)
  28. {
  29. PROCESSENTRY32 __ProcessEntry;
  30. __ProcessEntry.dwSize = sizeof(PROCESSENTRY32);
  31. HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  32. if (hSnapshot == INVALID_HANDLE_VALUE) return 0; if (!Process32First(hSnapshot, &__ProcessEntry))
  33. {
  34. CloseHandle(hSnapshot);
  35. return 0;
  36. }
  37. do{if (!_strcmpi(__ProcessEntry.szExeFile, __ProcessName))
  38. {
  39. memcpy((void *)pEntry, (void *)&__ProcessEntry, sizeof(PROCESSENTRY32));
  40. CloseHandle(hSnapshot);
  41. return __ProcessEntry.th32ProcessID;
  42. }} while (Process32Next(hSnapshot, &__ProcessEntry));
  43. CloseHandle(hSnapshot);
  44. return 0;
  45. }
  46.  
  47.  
  48. DWORD getThreadByProcess(DWORD __DwordProcess)
  49. {
  50. THREADENTRY32 __ThreadEntry;
  51. __ThreadEntry.dwSize = sizeof(THREADENTRY32);
  52. HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
  53. if (hSnapshot == INVALID_HANDLE_VALUE) return 0;
  54.  
  55. if (!Thread32First(hSnapshot, &__ThreadEntry)) {CloseHandle(hSnapshot); return 0; }
  56.  
  57. do {if (__ThreadEntry.th32OwnerProcessID == __DwordProcess)
  58. {
  59. CloseHandle(hSnapshot);
  60. return __ThreadEntry.th32ThreadID;
  61. }} while (Thread32Next(hSnapshot, &__ThreadEntry));
  62. CloseHandle(hSnapshot);
  63. return 0;
  64. }
  65.  
  66. DWORD GetModuleNamePointer(LPSTR LPSTRModuleName, DWORD __DwordProcessId)
  67. {
  68. MODULEENTRY32 lpModuleEntry = {0};
  69. HANDLE hSnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, __DwordProcessId);
  70. if(!hSnapShot)
  71. return NULL;
  72. lpModuleEntry.dwSize = sizeof(lpModuleEntry);
  73. BOOL __RunModule = Module32First( hSnapShot, &lpModuleEntry );
  74. while(__RunModule)
  75. {
  76. if(!strcmp(lpModuleEntry.szModule, LPSTRModuleName ) )
  77. {CloseHandle( hSnapShot );
  78. return (DWORD)lpModuleEntry.modBaseAddr;
  79. }
  80. __RunModule = Module32Next( hSnapShot, &lpModuleEntry );
  81. }
  82. CloseHandle( hSnapShot );
  83. return NULL;
  84. }
  85.  
  86.  
  87. void runSetDebugPrivs()
  88. {
  89. HANDLE __HandleProcess=GetCurrentProcess(), __HandleToken;
  90. TOKEN_PRIVILEGES priv;
  91. LUID __LUID;
  92. OpenProcessToken(__HandleProcess, TOKEN_ADJUST_PRIVILEGES, &__HandleToken);
  93. LookupPrivilegeValue(0, "seDebugPrivilege", &__LUID);
  94. priv.PrivilegeCount = 1;
  95. priv.Privileges[0].Luid = __LUID;
  96. priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  97. AdjustTokenPrivileges(__HandleToken, false, &priv, 0, 0, 0);
  98. CloseHandle(__HandleToken);
  99. CloseHandle(__HandleProcess);
  100. }
  101.  
  102.  
  103.  
  104. void RunProcess()
  105. {
  106. //commented lines are for non steam versions of the game
  107. runSetDebugPrivs();
  108. while (!FindProcessName("csgo.exe", &__gameProcess)) Sleep(12);
  109. while (!(getThreadByProcess(__gameProcess.th32ProcessID))) Sleep(12);
  110. __HandleProcess = OpenProcess(PROCESS_ALL_ACCESS, false, __gameProcess.th32ProcessID);
  111. while(__dwordClient == 0x0) __dwordClient = GetModuleNamePointer("client.dll", __gameProcess.th32ProcessID);
  112. while(__dwordEngine == 0x0) __dwordEngine = GetModuleNamePointer("engine.dll", __gameProcess.th32ProcessID);
  113. while(__csgoexe == 0x0) __csgoexe = GetModuleNamePointer("csgo.exe", __gameProcess.th32ProcessID);
  114. //while(__dwordOverlay == 0x0) __dwordOverlay = GetModuleNamePointer("gameoverlayrenderer.dll", __gameProcess.th32ProcessID);
  115. //while(__dwordVGui == 0x0) __dwordVGui = GetModuleNamePointer("vguimatsurface.dll", __gameProcess.th32ProcessID);
  116. //while(__dwordLibCef == 0x0) __dwordLibCef = GetModuleNamePointer("libcef.dll", __gameProcess.th32ProcessID);
  117. // while(__dwordSteam == 0x0) __dwordSteam = GetModuleNamePointer("steam.dll", __gameProcess.th32ProcessID);
  118. __HWNDCss = FindWindow(NULL, "Counter-Strike: Global Offensive");
  119. }
  120. };
  121.  
  122.  
  123. bool Compare(const BYTE* pData, const BYTE* bMask, const char* szMask)
  124. {
  125. for(;*szMask;++szMask,++pData,++bMask)
  126. if(*szMask=='x' && *pData!=*bMask) return 0;
  127. return (*szMask) == NULL;
  128. }
  129.  
  130. DWORD Pattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask)
  131. {
  132. for(DWORD i=0; i<dwLen; i++)
  133. if (Compare((BYTE*)(dwAddress+i),bMask,szMask)) return (DWORD)(dwAddress+i);
  134. return 0;
  135. }
  136.  
  137. extern CHackProcess fProcess;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement