-
Автор темы
- #1
Код:
В чем проблема? В коде или же в оффсетах? Подскажите пожалуйста
Скрипт:
#include <iostream>
#include <windows.h>
#include <TlHelp32.h>
namespace offsets {
constexpr std::ptrdiff_t dwEntityList = 0x19BDCF0;
constexpr std::ptrdiff_t dwGlowManager = 0x1A1AF60;
constexpr std::ptrdiff_t dwLocalPlayer = 0x1825158;
constexpr std::ptrdiff_t dwGlowIndex = 0x10488;
constexpr std::ptrdiff_t m_iTeamNum = 0xF4;
constexpr std::ptrdiff_t m_bDormant = 0xED;
}
DWORD GetProcessIdByName(const wchar_t* processName) {
PROCESSENTRY32 processEntry = { sizeof(PROCESSENTRY32) };
HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (Process32First(hProcessSnap, &processEntry)) {
do {
if (!_wcsicmp(processEntry.szExeFile, processName)) {
CloseHandle(hProcessSnap);
return processEntry.th32ProcessID;
}
} while (Process32Next(hProcessSnap, &processEntry));
}
CloseHandle(hProcessSnap);
return 0;
}
HANDLE GetHandleToProcess(DWORD processId) {
return OpenProcess(PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION, FALSE, processId);
}
uintptr_t GetModuleBaseAddress(DWORD processId, const wchar_t* modName) {
uintptr_t modBaseAddr = 0;
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, processId);
if (hSnap != INVALID_HANDLE_VALUE) {
MODULEENTRY32 modEntry;
modEntry.dwSize = sizeof(modEntry);
if (Module32First(hSnap, &modEntry)) {
do {
if (!_wcsicmp(modEntry.szModule, modName)) {
modBaseAddr = (uintptr_t)modEntry.modBaseAddr;
break;
}
} while (Module32Next(hSnap, &modEntry));
}
}
CloseHandle(hSnap);
return modBaseAddr;
}
int main() {
const wchar_t* processName = L"cs2.exe";
DWORD processId = GetProcessIdByName(processName);
if (processId == 0) {
std::cerr << "Процесс игры не найден!" << std::endl;
return 1;
}
HANDLE hProcess = GetHandleToProcess(processId);
if (!hProcess) {
std::cerr << "Не удалось открыть процесс!" << std::endl;
return 1;
}
uintptr_t clientModuleBase = GetModuleBaseAddress(processId, L"client.dll");
if (clientModuleBase == 0) {
std::cerr << "Не удалось найти базовый адрес client.dll!" << std::endl;
return 1;
}
std::cout << "Процесс игры найден и открыт. PID: " << processId << std::endl;
std::cout << "Базовый адрес client.dll: 0x" << std::hex << clientModuleBase << std::endl;
while (true) {
uintptr_t glowManagerAddr = 0;
uintptr_t localPlayerAddr = 0;
if (!ReadProcessMemory(hProcess, (BYTE*)(clientModuleBase + offsets::dwGlowManager), &glowManagerAddr, sizeof(glowManagerAddr), nullptr)) {
std::cerr << "Не удалось прочитать адрес GlowManager!" << std::endl;
continue;
}
if (!ReadProcessMemory(hProcess, (BYTE*)(clientModuleBase + offsets::dwLocalPlayer), &localPlayerAddr, sizeof(localPlayerAddr), nullptr)) {
std::cerr << "Не удалось прочитать адрес LocalPlayer!" << std::endl;
continue;
}
int localPlayerTeam = 0;
ReadProcessMemory(hProcess, (BYTE*)(localPlayerAddr + offsets::m_iTeamNum), &localPlayerTeam, sizeof(localPlayerTeam), nullptr);
std::cout << "Local Player Team: " << localPlayerTeam << std::endl;
for (int i = 0; i < 64; ++i) {
uintptr_t entityAddr = 0;
if (!ReadProcessMemory(hProcess, (BYTE*)(clientModuleBase + offsets::dwEntityList + i * 0x10), &entityAddr, sizeof(entityAddr), nullptr)) {
continue;
}
bool isDormant = false;
ReadProcessMemory(hProcess, (BYTE*)(entityAddr + offsets::m_bDormant), &isDormant, sizeof(isDormant), nullptr);
if (isDormant) {
continue;
}
int entityTeam = 0;
ReadProcessMemory(hProcess, (BYTE*)(entityAddr + offsets::m_iTeamNum), &entityTeam, sizeof(entityTeam), nullptr);
std::cout << "Entity " << i << " Team: " << entityTeam << std::endl;
if (entityTeam != localPlayerTeam) {
int glowIndex = 0;
ReadProcessMemory(hProcess, (BYTE*)(entityAddr + offsets::dwGlowIndex), &glowIndex, sizeof(glowIndex), nullptr);
std::cout << "Entity " << i << " GlowIndex: " << glowIndex << std::endl;
float glowColor[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
if (!WriteProcessMemory(hProcess, (BYTE*)(glowManagerAddr + (glowIndex * 0x38) + 0x8), &glowColor, sizeof(glowColor), nullptr)) {
std::cerr << "Ошибка записи GlowColor для сущности " << i << std::endl;
}
bool glowEnable = true;
if (!WriteProcessMemory(hProcess, (BYTE*)(glowManagerAddr + (glowIndex * 0x38) + 0x27), &glowEnable, sizeof(glowEnable), nullptr)) {
std::cerr << "Ошибка записи GlowEnable для сущности " << i << std::endl;
}
}
}
Sleep(1000);
}
CloseHandle(hProcess);
return 0;
}