Implemented #20 into hack.hpp now featuring a better entity loop and fixing known bugs while cleaning the code.

Added simple config system to enable team esp, automatic updates, and render distance.

Also moved the offsets to the updater namespace and read/writte methods to the offsets.json

Implemented Handle Hijacking method requested by #19 to improve the security. Credits to Apxaey on github for the source
This commit is contained in:
IMXNOOBX
2023-10-03 17:52:46 +02:00
parent 53a65d22c2
commit 509d2b5f2d
12 changed files with 524 additions and 74 deletions
+65 -16
View File
@@ -1,6 +1,6 @@
#include <thread>
#include "../memory/memory.hpp"
#include "classes/globals.hpp"
#include "../classes/globals.hpp"
#include "../classes/render.hpp"
#include "../classes/config.hpp"
@@ -9,14 +9,14 @@ namespace hack {
ProcessModule base_module;
void loop() {
const uintptr_t localPlayer = process->read<uintptr_t>(base_module.base + config::dwLocalPlayer);
const uintptr_t localPlayer = process->read<uintptr_t>(base_module.base + updater::offsets::dwLocalPlayer);
if (!localPlayer)
return;
const int localTeam = process->read<int>(localPlayer + config::m_iTeamNum);
const view_matrix_t view_matrix = process->read<view_matrix_t>(base_module.base + config::dwViewMatrix);
const Vector3 localOrigin = process->read<Vector3>(localPlayer + config::m_vecOrigin);
const uintptr_t entity_list = process->read<uintptr_t>(base_module.base + config::dwEntityList);
const int localTeam = process->read<int>(localPlayer + updater::offsets::m_iTeamNum);
const view_matrix_t view_matrix = process->read<view_matrix_t>(base_module.base + updater::offsets::dwViewMatrix);
const Vector3 localOrigin = process->read<Vector3>(localPlayer + updater::offsets::m_vecOrigin);
const uintptr_t entity_list = process->read<uintptr_t>(base_module.base + updater::offsets::dwEntityList);
int playerIndex = 1;
uintptr_t list_entry;
@@ -37,7 +37,7 @@ namespace hack {
continue;
}
const int playerHealth = process->read<int>(player + config::dwPawnHealth);
const int playerHealth = process->read<int>(player + updater::offsets::dwPawnHealth);
if (playerHealth <= 0 || playerHealth > 100) {
playerIndex++;
continue;
@@ -49,13 +49,13 @@ namespace hack {
* If you really want you can exclude your own character from the check but
* since you are in the same team as yourself it will be excluded anyway
**/
const int playerTeam = process->read<int>(player + config::m_iTeamNum);
if (playerTeam == localTeam) {
const int playerTeam = process->read<int>(player + updater::offsets::m_iTeamNum);
if (config::team_esp && (playerTeam == localTeam)) {
playerIndex++;
continue;
}
const std::uint32_t playerPawn = process->read<std::uint32_t>(player + config::dwPlayerPawn);
const std::uint32_t playerPawn = process->read<std::uint32_t>(player + updater::offsets::dwPlayerPawn);
const uintptr_t list_entry2 = process->read<uintptr_t>(entity_list + 0x8 * ((playerPawn & 0x7FFF) >> 9) + 16);
if (!list_entry2) {
@@ -69,8 +69,13 @@ namespace hack {
continue;
}
if (config::team_esp && (pCSPlayerPawn == localPlayer)) {
playerIndex++;
continue;
}
std::string playerName = "Invalid Name";
const DWORD64 playerNameAddress = process->read<DWORD64>(player + config::dwSanitizedName);
const DWORD64 playerNameAddress = process->read<DWORD64>(player + updater::offsets::dwSanitizedName);
if (playerNameAddress) {
char buf[256];
@@ -78,9 +83,14 @@ namespace hack {
playerName = std::string(buf);
}
const Vector3 origin = process->read<Vector3>(pCSPlayerPawn + config::m_vecOrigin);
const Vector3 origin = process->read<Vector3>(pCSPlayerPawn + updater::offsets::m_vecOrigin);
const Vector3 head = { origin.x, origin.y, origin.z + 75.f };
if (config::render_distance != -1 && (localOrigin - origin).length2d() > config::render_distance) {
playerIndex++;
continue;
}
const Vector3 screenPos = origin.world_to_screen(view_matrix);
const Vector3 screenHead = head.world_to_screen(view_matrix);
@@ -91,10 +101,49 @@ namespace hack {
const COLORREF boxColor = RGB(175, 75, 75);
const COLORREF healthBarColor = RGB(255 - playerHealth, 55 + playerHealth * 2, 75);
render::DrawBorderBox(g::hdcBuffer, screenHead.x - width / 2, screenHead.y, width, height, boxColor);
render::DrawBorderBox(g::hdcBuffer, screenHead.x - (width / 2 + 5), screenHead.y + (height * (100 - playerHealth) / 100), 2, height - (height * (100 - playerHealth) / 100), healthBarColor);
render::RenderText(g::hdcBuffer, screenHead.x + (width / 2 + 5), screenHead.y, playerName.c_str(), RGB(75, 75, 175), 10);
render::RenderText(g::hdcBuffer, screenHead.x + (width / 2 + 5), screenHead.y + 10, (std::to_string(playerHealth) + "hp").c_str(), healthBarColor, 10);
render::DrawBorderBox(
g::hdcBuffer,
screenHead.x - width / 2,
screenHead.y,
width,
height,
(localTeam == playerTeam ? RGB(75, 175, 75) : RGB(175, 75, 75))
);
render::DrawBorderBox(
g::hdcBuffer,
screenHead.x - (width / 2 + 5),
screenHead.y + (height * (100 - playerHealth) / 100),
2,
height - (height * (100 - playerHealth) / 100),
RGB(
(255 - playerHealth),
(55 + playerHealth * 2),
75
)
);
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y,
playerName.c_str(),
RGB(75, 75, 175),
10
);
render::RenderText(
g::hdcBuffer,
screenHead.x + (width / 2 + 5),
screenHead.y + 10,
(std::to_string(playerHealth) + "hp").c_str(),
RGB(
(255 - playerHealth),
(55 + playerHealth * 2),
75
),
10
);
}
playerIndex++;
}