Advertisement
Guest User

fProcess

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