#include <Windows.h>
#include <iostream>
#include <Psapi.h>
#pragma comment(lib, "Psapi.lib")
#define OFFSET_DW_LOCAL_PLAYER 0x1A29B8
#define OFFSET_M_I_HEALTH 0x1F8
int main() {
HWND gameWindow = FindWindowA(NULL, "Counter-Strike");
if (!gameWindow) { std::cout << "CS 1.6 не найдена" << std::endl; return 1; }
DWORD pid;
GetWindowThreadProcessId(gameWindow, &pid);
HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
HMODULE modules[1024];
DWORD needed;
EnumProcessModules(processHandle, modules, sizeof(modules), &needed);
DWORD clientBase = 0;
for (unsigned int i = 0; i < needed / sizeof(HMODULE); i++) {
char name[256];
GetModuleBaseNameA(processHandle, modules[i], name, sizeof(name));
if (strcmp(name, "hw.dll") == 0) clientBase = (DWORD)modules[i];
}
while (true) {
DWORD localPlayer;
ReadProcessMemory(processHandle, (LPCVOID)(clientBase + OFFSET_DW_LOCAL_PLAYER), &localPlayer, sizeof(DWORD), NULL);
if (localPlayer) {
int health;
ReadProcessMemory(processHandle, (LPCVOID)(localPlayer + OFFSET_M_I_HEALTH), &health, sizeof(int), NULL);
std::cout << "Здоровье: " << health << std::endl;
}
Sleep(1000);
}
return 0;
}