Advertisement
Guest User

HP.h

a guest
May 8th, 2014
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.81 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <Windows.h>
  4. #include <TlHelp32.h>
  5.  
  6. class CHackProcess
  7. {
  8. public:
  9.  
  10.     PROCESSENTRY32 __gameProcess;
  11.     HANDLE __HandleProcess;
  12.     HWND __HWNDCss;
  13.     DWORD __dwordClient;
  14.     DWORD __dwordEngine;
  15.     DWORD __dwordOverlay;
  16.     DWORD __dwordVGui;
  17.     DWORD __dwordLibCef;
  18.     DWORD __dwordSteam;
  19.     DWORD FindProcessName(const char *__ProcessName, PROCESSENTRY32 *pEntry)
  20.     {    
  21.         PROCESSENTRY32 __ProcessEntry;
  22.         __ProcessEntry.dwSize = sizeof(PROCESSENTRY32);
  23.         HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  24.         if (hSnapshot == INVALID_HANDLE_VALUE) return 0;        if (!Process32First(hSnapshot, &__ProcessEntry))
  25.         {
  26.             CloseHandle(hSnapshot);
  27.             return 0;
  28.         }
  29.         do{if (!_strcmpi(__ProcessEntry.szExeFile, __ProcessName))
  30.         {
  31.             memcpy((void *)pEntry, (void *)&__ProcessEntry, sizeof(PROCESSENTRY32));
  32.             CloseHandle(hSnapshot);
  33.             return __ProcessEntry.th32ProcessID;
  34.         }} while (Process32Next(hSnapshot, &__ProcessEntry));
  35.         CloseHandle(hSnapshot);
  36.         return 0;
  37. }
  38.  
  39.  
  40. DWORD getThreadByProcess(DWORD __DwordProcess)
  41. {    
  42.         THREADENTRY32 __ThreadEntry;
  43.         __ThreadEntry.dwSize = sizeof(THREADENTRY32);
  44.         HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
  45.         if (hSnapshot == INVALID_HANDLE_VALUE) return 0;
  46.  
  47.         if (!Thread32First(hSnapshot, &__ThreadEntry)) {CloseHandle(hSnapshot); return 0; }
  48.  
  49.         do {if (__ThreadEntry.th32OwnerProcessID == __DwordProcess)
  50.         {
  51.             CloseHandle(hSnapshot);
  52.             return __ThreadEntry.th32ThreadID;
  53.         }} while (Thread32Next(hSnapshot, &__ThreadEntry));
  54.         CloseHandle(hSnapshot);      
  55.         return 0;
  56. }
  57.  
  58. DWORD GetModuleNamePointer(LPSTR LPSTRModuleName, DWORD __DwordProcessId)
  59. {
  60.         MODULEENTRY32 lpModuleEntry = {0};
  61.         HANDLE hSnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, __DwordProcessId);
  62.         if(!hSnapShot)
  63.             return NULL;  
  64.         lpModuleEntry.dwSize = sizeof(lpModuleEntry);
  65.         BOOL __RunModule = Module32First( hSnapShot, &lpModuleEntry );
  66.         while(__RunModule)
  67.         {
  68.             if(!strcmp(lpModuleEntry.szModule, LPSTRModuleName ) )
  69.             {CloseHandle( hSnapShot );
  70.             return (DWORD)lpModuleEntry.modBaseAddr;
  71.             }
  72.             __RunModule = Module32Next( hSnapShot, &lpModuleEntry );
  73.         }
  74.         CloseHandle( hSnapShot );
  75.         return NULL;
  76. }
  77.  
  78.  
  79. void runSetDebugPrivs()
  80. {
  81.     HANDLE __HandleProcess=GetCurrentProcess(), __HandleToken;
  82.     TOKEN_PRIVILEGES priv;
  83.     LUID __LUID;
  84.     OpenProcessToken(__HandleProcess, TOKEN_ADJUST_PRIVILEGES, &__HandleToken);
  85.     LookupPrivilegeValue(0, "seDebugPrivilege", &__LUID);
  86.     priv.PrivilegeCount = 1;
  87.     priv.Privileges[0].Luid = __LUID;
  88.     priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  89.     AdjustTokenPrivileges(__HandleToken, false, &priv, 0, 0, 0);
  90.     CloseHandle(__HandleToken);
  91.     CloseHandle(__HandleProcess);
  92. }
  93.    
  94.    
  95.    
  96. void RunProcess()
  97. {
  98.     //commented lines are for non steam versions of the game
  99.     runSetDebugPrivs();
  100.     while (!FindProcessName("hl2.exe", &__gameProcess)) Sleep(12);
  101.     while (!(getThreadByProcess(__gameProcess.th32ProcessID))) Sleep(12);
  102.     __HandleProcess = OpenProcess(PROCESS_ALL_ACCESS, false, __gameProcess.th32ProcessID);
  103.     while(__dwordClient == 0x0) __dwordClient = GetModuleNamePointer("client.dll", __gameProcess.th32ProcessID);
  104.     while(__dwordEngine == 0x0) __dwordEngine = GetModuleNamePointer("engine.dll", __gameProcess.th32ProcessID);
  105.     //while(__dwordOverlay == 0x0) __dwordOverlay = GetModuleNamePointer("gameoverlayrenderer.dll", __gameProcess.th32ProcessID);
  106.     while(__dwordServer == 0x0) __dwordVGui = GetModuleNamePointer("server.dll", __gameProcess.th32ProcessID);
  107.     //while(__dwordLibCef == 0x0) __dwordLibCef = GetModuleNamePointer("libcef.dll", __gameProcess.th32ProcessID);
  108. //  while(__dwordSteam == 0x0) __dwordSteam = GetModuleNamePointer("steam.dll", __gameProcess.th32ProcessID);
  109.     __HWNDCss = FindWindow(NULL, "Counter-Strike Source");
  110. }
  111. };
  112.  
  113. extern CHackProcess fProcess;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement