#include <Windows.h>
#include <TlHelp32.h>
#include <iostream>
using namespace std;
LPCSTR ProcessName = "csgo.exe";
DWORD FindProcessByName(LPCSTR ProcessName)
{
HANDLE hSnapshot;
PROCESSENTRY32 pEntry = { 0 };
pEntry.dwSize = sizeof(pEntry);
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if (hSnapshot == INVALID_HANDLE_VALUE)
{
CloseHandle(hSnapshot);
return 0;
}
if (Process32First(hSnapshot, &pEntry))
{
while (Process32Next(hSnapshot, &pEntry))
{
if (!lstrcmpi(ProcessName, pEntry.szExeFile))
{
CloseHandle(hSnapshot);
return pEntry.th32ProcessID;
}
}
}
CloseHandle(hSnapshot);
return FALSE;
}
DWORD ProcessID = FindProcessByName(ProcessName);
DWORD GetModuleNamePointer(LPCSTR MoudleName, DWORD ProcessID)
{
MODULEENTRY32 mEntry = { 0 };
HANDLE hSnapshot;
mEntry.dwSize = sizeof(mEntry);
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessID);
if (hSnapshot == INVALID_HANDLE_VALUE)
{
CloseHandle(hSnapshot);
return 0;
}
if (Module32First(hSnapshot, &mEntry))
{
while (Module32Next(hSnapshot, &mEntry))
{
if (!lstrcmpi(mEntry.szModule, MoudleName))
{
CloseHandle(hSnapshot);
return (DWORD)mEntry.modBaseAddr;
}
}
}
CloseHandle(hSnapshot);
return FALSE;
}
class GetModulePointer
{
public:
DWORD DLLServer = GetModuleNamePointer("server.dll", ProcessID);
DWORD DLLEngine = GetModuleNamePointer("engine.dll", ProcessID);
DWORD DLLClient = GetModuleNamePointer("client.dll", ProcessID);
DWORD DLLVGUI = GetModuleNamePointer("vguimatsurface.dll", ProcessID);
};
GetModulePointer ModulePointer;
HANDLE Handle(DWORD ProcessID)
{
HANDLE HandleProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, ProcessID);
if (HandleProcess) return HandleProcess;
CloseHandle(HandleProcess);
cout << "ErrorTakeHandle!" << endl;
return NULL;
}
HANDLE HandleProcess = Handle(ProcessID);