Начинающий
-
Автор темы
- #1
Всем привет! Решил значит написать external glow на c++ , но компилятор надругался надо мной (уже несколько раз удалили тред) и засыпал ошибками. В инете я ответов не нашёл, а на сайт майкрософт уж тем более. Буду сильно благодарен помощникам, храни вас господь.
C++:
bool GlowEspEnabled = false;
// тут куча кода
private: System::Void guna2ToggleSwitch1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
GlowEspEnabled = guna2ToggleSwitch1->Checked;
}
C++:
#include "Main.h"
using namespace System;
using namespace System::Windows::Forms;
DWORD client_dll = 0, engine_dll = 0;
void handle_exception(const char* reason, bool critical = false)
{
critical ? MessageBoxA(NULL, reason, "Critical Error!", NULL) : printf("<WARNING> %s\n", reason);
if (critical)
{
delete mem;
exit(-1);
}
}
[STAThreadAttribute]
void main() {
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
test1::MainForm form;
Application::Run(% form);
mem = new Memory();
if (!mem->open_process("csgo.exe"))
handle_exception("Failed to open process!", true);
if (!mem->get_module_base("client.dll", client_dll))
handle_exception("Failed to get client.dll module base!", true);
if (!mem->get_module_base("engine.dll", engine_dll))
handle_exception("Failed to get engine.dll module base!", true);
while (true) {
Sleep(1);
int LocalPlayer = mem->read_memory<int>(client_dll + dwLocalPlayer);
int PlayerTeam = mem->read_memory<int>(LocalPlayer + m_iTeamNum);
if (test1::GlowEspEnabled) {
for (byte i = 0; i < 32; i++) {
int EntityList = mem->read_memory<int>(client_dll + dwEntityList + i * 0x10);
int EnemyTeam = mem->read_memory<int>(EntityList + m_iTeamNum);
if (EntityList != 0) {
if (EnemyTeam != 0 && EnemyTeam != PlayerTeam) {
int GlowIndex = mem->read_memory<int>(EntityList + m_iGlowIndex);
DrawEntityGlow(GlowIndex, 255, 0, 0);
}
}
}
}
}
}
void DrawEntityGlow(int GlowIndex, int red, int green, int blue)
{
int GlowObject = mem->read_memory<int>(client_dll+ dwGlowObjectManager);
mem->write_memory(GlowObject + (GlowIndex + 0x38) + 0x8, red / 255.0f);
mem->write_memory(GlowObject + (GlowIndex + 0x38) + 0xC, green / 255.0f);
mem->write_memory(GlowObject + (GlowIndex + 0x38) + 0x10, blue / 255.0f);
mem->write_memory(GlowObject + (GlowIndex + 0x38) + 0x14, 255 / 255.0f);
mem->write_memory(GlowObject + (GlowIndex + 0x38) + 0x28, true);
mem->write_memory(GlowObject + (GlowIndex + 0x38) + 0x29, false);
}
C++:
#pragma once
#include <Windows.h>
#include <iostream>
#include "Memory.h"
#include "Offsets.hpp"
#include <thread>
#include "MainForm.h"
using namespace Offsets::netvars;
using namespace Offsets::signatures;
extern DWORD client_dll, engine_dll;
void DrawEntityGlow(int GlowIndex, int red, int green, int blue);
C++:
#include "Memory.h"
bool Memory::open_process(const char* name)
{
HANDLE hPID = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
PROCESSENTRY32 procEntry;
procEntry.dwSize = sizeof(procEntry);
const WCHAR* procNameChar;
int nChars = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0);
procNameChar = new WCHAR[nChars];
MultiByteToWideChar(CP_ACP, 0, name, -1, (LPWSTR)procNameChar, nChars);
do
if (!wcscmp(procEntry.szExeFile, procNameChar))
{
pid = procEntry.th32ProcessID;
CloseHandle(hPID);
game_handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
return true;
}
while (Process32Next(hPID, &procEntry));
CloseHandle(hPID);
return false;
}
bool Memory::get_module_base(const char* modName, DWORD& addy)
{
HANDLE hModule = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);
MODULEENTRY32 mEntry;
mEntry.dwSize = sizeof(mEntry);
const WCHAR* modNameChar;
int nChars = MultiByteToWideChar(CP_ACP, 0, modName, -1, NULL, 0);
modNameChar = new WCHAR[nChars];
MultiByteToWideChar(CP_ACP, 0, modName, -1, (LPWSTR)modNameChar, nChars);
do
if (!wcscmp(mEntry.szModule, modNameChar))
{
break;
}
while (Module32Next(hModule, &mEntry));
CloseHandle(hModule);
if (mEntry.modBaseAddr)
{
addy = reinterpret_cast<DWORD64>(mEntry.modBaseAddr);
return true;
}
else return false;
}
C++:
#pragma once
#include <Windows.h>
#include <iostream>
#include <TlHelp32.h>
#include <vector>
#include <sstream>
class Memory
{
public:
bool open_process(const char* name);
bool get_module_base(const char* modName, DWORD& addy);
template<class T>
void write_memory(DWORD addy, T val)
{
WriteProcessMemory(game_handle, reinterpret_cast<LPVOID>(addy), &val, sizeof(T), 0);
}
template<class T>
T read_memory(DWORD addy)
{
T buf;
ReadProcessMemory(game_handle, reinterpret_cast<LPCVOID>(addy), &buf, sizeof(T), 0);
return buf;
}
private:
HANDLE game_handle;
DWORD pid;
};
inline Memory* mem;