Fixed merge conflicts, thanks @tucucu for your contribution!
This commit is contained in:
+29
-123
@@ -1,48 +1,20 @@
|
||||
#include <thread>
|
||||
#include <cmath>
|
||||
#include "../memory/memory.hpp"
|
||||
#include "../classes/globals.hpp"
|
||||
#include "reader.hpp"
|
||||
#include "../classes/render.hpp"
|
||||
#include "../classes/config.hpp"
|
||||
#include "../classes/globals.hpp"
|
||||
|
||||
namespace hack {
|
||||
std::shared_ptr<pProcess> process;
|
||||
ProcessModule base_client;
|
||||
ProcessModule base_engine;
|
||||
|
||||
void loop() {
|
||||
const view_matrix_t view_matrix = process->read<view_matrix_t>(base_client.base + updater::offsets::dwViewMatrix);
|
||||
const uintptr_t entity_list = process->read<uintptr_t>(base_client.base + updater::offsets::dwEntityList);
|
||||
|
||||
const uintptr_t localPlayer = process->read<uintptr_t>(base_client.base + updater::offsets::dwLocalPlayer);
|
||||
if (!localPlayer)
|
||||
return;
|
||||
|
||||
const int localTeam = process->read<int>(localPlayer + updater::offsets::m_iTeamNum);
|
||||
const std::uint32_t localPlayerPawn = process->read<std::uint32_t>(localPlayer + updater::offsets::m_hPlayerPawn);
|
||||
if (!localPlayerPawn)
|
||||
return;
|
||||
|
||||
const uintptr_t localList_entry2 = process->read<uintptr_t>(entity_list + 0x8 * ((localPlayerPawn & 0x7FFF) >> 9) + 16);
|
||||
const uintptr_t localpCSPlayerPawn = process->read<uintptr_t>(localList_entry2 + 120 * (localPlayerPawn & 0x1FF));
|
||||
if (!localpCSPlayerPawn)
|
||||
return;
|
||||
|
||||
const Vector3 localOrigin = process->read<Vector3>(localpCSPlayerPawn + updater::offsets::m_vecOrigin);
|
||||
|
||||
bool c4IsPlanted = process->read<bool>(base_client.base + updater::offsets::dwPlantedC4 - 0x8);
|
||||
if (c4IsPlanted)
|
||||
if (g_game.isC4Planted)
|
||||
{
|
||||
const uintptr_t planted_c4 = process->read<uintptr_t>(process->read<uintptr_t>(base_client.base + updater::offsets::dwPlantedC4));
|
||||
|
||||
const uintptr_t c4Node = process->read<uintptr_t>(planted_c4 + updater::offsets::m_pGameSceneNode);
|
||||
|
||||
const Vector3 c4Origin = process->read<Vector3>(c4Node + updater::offsets::m_vecAbsOrigin);
|
||||
|
||||
const Vector3 c4ScreenPos = c4Origin.world_to_screen(view_matrix);
|
||||
Vector3 c4Origin = g_game.c4.get_origin();
|
||||
const Vector3 c4ScreenPos = g_game.world_to_screen(&c4Origin);
|
||||
|
||||
if (c4ScreenPos.z >= 0.01f) {
|
||||
float c4Distance = localOrigin.calculate_distance(c4Origin);
|
||||
float c4Distance = g_game.localOrigin.calculate_distance(c4Origin);
|
||||
float c4RoundedDistance = std::round(c4Distance / 500.f);
|
||||
|
||||
float height = 10 - c4RoundedDistance;
|
||||
@@ -76,51 +48,10 @@ namespace hack {
|
||||
*
|
||||
* (This could have been done by getting a entity list count from the engine, but I'm too lazy to do that)
|
||||
**/
|
||||
while (true) {
|
||||
playerIndex++;
|
||||
list_entry = process->read<uintptr_t>(entity_list + (8 * (playerIndex & 0x7FFF) >> 9) + 16);
|
||||
if (!list_entry)
|
||||
break;
|
||||
|
||||
const uintptr_t player = process->read<uintptr_t>(list_entry + 120 * (playerIndex & 0x1FF));
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
/**
|
||||
* Skip rendering your own character and teammates
|
||||
*
|
||||
* 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 + updater::offsets::m_iTeamNum);
|
||||
if (config::team_esp && (playerTeam == localTeam))
|
||||
continue;
|
||||
|
||||
const std::uint32_t playerPawn = process->read<std::uint32_t>(player + updater::offsets::m_hPlayerPawn);
|
||||
|
||||
const uintptr_t list_entry2 = process->read<uintptr_t>(entity_list + 0x8 * ((playerPawn & 0x7FFF) >> 9) + 16);
|
||||
if (!list_entry2)
|
||||
continue;
|
||||
|
||||
const uintptr_t pCSPlayerPawn = process->read<uintptr_t>(list_entry2 + 120 * (playerPawn & 0x1FF));
|
||||
if (!pCSPlayerPawn)
|
||||
continue;
|
||||
|
||||
const int playerHealth = process->read<int>(pCSPlayerPawn + updater::offsets::m_iHealth);
|
||||
const int playerArmor = process->read<int>(pCSPlayerPawn + updater::offsets::m_ArmorValue);
|
||||
if (playerHealth <= 0 || playerHealth > 100)
|
||||
continue;
|
||||
|
||||
if (config::team_esp && (pCSPlayerPawn == localPlayer))
|
||||
continue;
|
||||
|
||||
std::string playerName = "Invalid Name";
|
||||
const DWORD64 playerNameAddress = process->read<DWORD64>(player + updater::offsets::m_sSanitizedPlayerName);
|
||||
if (playerNameAddress) {
|
||||
char buf[256];
|
||||
process->read_raw(playerNameAddress, buf, sizeof(buf));
|
||||
playerName = std::string(buf);
|
||||
}
|
||||
for (auto player = g_game.players.begin(); player < g_game.players.end(); player++) {
|
||||
const Vector3 screenPos = g_game.world_to_screen(&player->origin);
|
||||
const Vector3 screenHead = g_game.world_to_screen(&player->head);
|
||||
const Vector3 screenHeadPos = g_game.world_to_screen(&player->skull);
|
||||
|
||||
const Vector3 origin = process->read<Vector3>(pCSPlayerPawn + updater::offsets::m_vecOrigin);
|
||||
const Vector3 head = { origin.x, origin.y, origin.z + 75.f };
|
||||
@@ -144,7 +75,7 @@ namespace hack {
|
||||
const float height = screenPos.y - screenHead.y;
|
||||
const float width = height / 2.4f;
|
||||
|
||||
float distance = localOrigin.calculate_distance(origin);
|
||||
float distance = g_game.localOrigin.calculate_distance(player->origin);
|
||||
int roundedDistance = std::round(distance / 10.f);
|
||||
|
||||
if (config::show_head_tracker)
|
||||
@@ -169,27 +100,27 @@ namespace hack {
|
||||
screenHead.y,
|
||||
width,
|
||||
height,
|
||||
(localTeam == playerTeam ? config::esp_box_color_team : config::esp_box_color_enemy)
|
||||
(g_game.localTeam == player->team ? config::esp_box_color_team : config::esp_box_color_enemy)
|
||||
);
|
||||
|
||||
render::DrawBorderBox(
|
||||
g::hdcBuffer,
|
||||
screenHead.x - (width / 2 + 10),
|
||||
screenHead.y + (height * (100 - playerArmor) / 100),
|
||||
screenHead.y + (height * (100 - player->armor) / 100),
|
||||
2,
|
||||
height - (height * (100 - playerArmor) / 100),
|
||||
height - (height * (100 - player->armor) / 100),
|
||||
RGB(0, 185, 255)
|
||||
);
|
||||
|
||||
render::DrawBorderBox(
|
||||
g::hdcBuffer,
|
||||
screenHead.x - (width / 2 + 5),
|
||||
screenHead.y + (height * (100 - playerHealth) / 100),
|
||||
screenHead.y + (height * (100 - player->health) / 100),
|
||||
2,
|
||||
height - (height * (100 - playerHealth) / 100),
|
||||
height - (height * (100 - player->health) / 100),
|
||||
RGB(
|
||||
(255 - playerHealth),
|
||||
(55 + playerHealth * 2),
|
||||
(255 - player->health),
|
||||
(55 + player->health * 2),
|
||||
75
|
||||
)
|
||||
);
|
||||
@@ -198,7 +129,7 @@ namespace hack {
|
||||
g::hdcBuffer,
|
||||
screenHead.x + (width / 2 + 5),
|
||||
screenHead.y,
|
||||
playerName.c_str(),
|
||||
player->name.c_str(),
|
||||
config::esp_name_color,
|
||||
10
|
||||
);
|
||||
@@ -213,10 +144,10 @@ namespace hack {
|
||||
g::hdcBuffer,
|
||||
screenHead.x + (width / 2 + 5),
|
||||
screenHead.y + 10,
|
||||
(std::to_string(playerHealth) + "hp").c_str(),
|
||||
(std::to_string(player->health) + "hp").c_str(),
|
||||
RGB(
|
||||
(255 - playerHealth),
|
||||
(55 + playerHealth * 2),
|
||||
(255 - player->health),
|
||||
(55 + player->health * 2),
|
||||
75
|
||||
),
|
||||
10
|
||||
@@ -226,10 +157,10 @@ namespace hack {
|
||||
g::hdcBuffer,
|
||||
screenHead.x + (width / 2 + 5),
|
||||
screenHead.y + 20,
|
||||
(std::to_string(playerArmor) + "armor").c_str(),
|
||||
(std::to_string(player->armor) + "armor").c_str(),
|
||||
RGB(
|
||||
(255 - playerArmor),
|
||||
(55 + playerArmor * 2),
|
||||
(255 - player->armor),
|
||||
(55 + player->armor * 2),
|
||||
75
|
||||
),
|
||||
10
|
||||
@@ -237,36 +168,11 @@ namespace hack {
|
||||
|
||||
if (config::show_extra_flags)
|
||||
{
|
||||
/*
|
||||
* Reading values for extra flags is now seperated from the other reads
|
||||
* This removes unnecessary memory reads, improving performance when not showing extra flags
|
||||
*/
|
||||
const bool isDefusing = process->read<bool>(pCSPlayerPawn + updater::offsets::m_bIsDefusing);
|
||||
const uintptr_t playerMoneyServices = process->read<uintptr_t>(player + updater::offsets::m_pInGameMoneyServices);
|
||||
const int32_t money = process->read<int32_t>(playerMoneyServices + updater::offsets::m_iAccount);
|
||||
const float flashAlpha = process->read<float>(pCSPlayerPawn + updater::offsets::m_flFlashOverlayAlpha);
|
||||
|
||||
const auto clippingWeapon = process->read<std::uint64_t>(pCSPlayerPawn + updater::offsets::m_pClippingWeapon);
|
||||
const auto weaponData = process->read<std::uint64_t>(clippingWeapon + 0x360);
|
||||
const auto weaponNameAddress = process->read<std::uint64_t>(weaponData + updater::offsets::m_szName);
|
||||
std::string weaponName = "Invalid Weapon Name";
|
||||
|
||||
if (!weaponNameAddress) {
|
||||
weaponName = "Invalid Weapon Name";
|
||||
}
|
||||
else {
|
||||
char buf[32];
|
||||
process->read_raw(weaponNameAddress, buf, sizeof(buf));
|
||||
weaponName = std::string(buf);
|
||||
if (weaponName.compare(0, 7, "weapon_") == 0)
|
||||
weaponName = weaponName.substr(7, weaponName.length()); // Remove weapon_ prefix
|
||||
}
|
||||
|
||||
render::RenderText(
|
||||
g::hdcBuffer,
|
||||
screenHead.x + (width / 2 + 5),
|
||||
screenHead.y + 30,
|
||||
weaponName.c_str(),
|
||||
player->weapon.c_str(),
|
||||
config::esp_distance_color,
|
||||
10
|
||||
);
|
||||
@@ -284,12 +190,12 @@ namespace hack {
|
||||
g::hdcBuffer,
|
||||
screenHead.x + (width / 2 + 5),
|
||||
screenHead.y + 50,
|
||||
("$" + std::to_string(money)).c_str(),
|
||||
("$" + std::to_string(player->money)).c_str(),
|
||||
RGB(0, 125, 0),
|
||||
10
|
||||
);
|
||||
|
||||
if (flashAlpha > 100)
|
||||
if (player->flashAlpha > 100)
|
||||
{
|
||||
render::RenderText(
|
||||
g::hdcBuffer,
|
||||
@@ -301,7 +207,7 @@ namespace hack {
|
||||
);
|
||||
}
|
||||
|
||||
if (isDefusing)
|
||||
if (player->is_defusing)
|
||||
{
|
||||
const std::string defuText = "Player is defusing";
|
||||
render::RenderText(
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
#include "reader.hpp"
|
||||
#include <thread>
|
||||
#include "../classes/auto_updater.hpp"
|
||||
#include "../classes/config.hpp"
|
||||
|
||||
// CC4
|
||||
uintptr_t CC4::get_planted() {
|
||||
return g_game.process->read<uintptr_t>(g_game.process->read<uintptr_t>(g_game.base_client.base + updater::offsets::dwPlantedC4));
|
||||
}
|
||||
|
||||
uintptr_t CC4::get_node() {
|
||||
return g_game.process->read<uintptr_t>(get_planted() + updater::offsets::m_pGameSceneNode);
|
||||
}
|
||||
|
||||
Vector3 CC4::get_origin() {
|
||||
return g_game.process->read<Vector3>(get_node() + updater::offsets::m_vecAbsOrigin);
|
||||
}
|
||||
|
||||
// CGame
|
||||
void CGame::init() {
|
||||
std::cout << "[cs2] Waiting for cs2.exe..." << std::endl;
|
||||
|
||||
process = std::make_shared<pProcess>();
|
||||
while (!process->AttachProcessHj("cs2.exe"))
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
|
||||
std::cout << "[cs2] Attached to cs2.exe\n" << std::endl;
|
||||
|
||||
do {
|
||||
base_client = process->GetModule("client.dll");
|
||||
base_engine = process->GetModule("engine2.dll");
|
||||
if (base_client.base == 0 || base_engine.base == 0) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
std::cout << "[cs2] Failed to find module client.dll/engine2.dll, waiting for the game to load it..." << std::endl;
|
||||
}
|
||||
} while (base_client.base == 0 || base_engine.base == 0);
|
||||
|
||||
GetClientRect(process->hwnd_, &game_bounds);
|
||||
|
||||
buildNumber = process->read<uintptr_t>(base_engine.base + updater::offsets::dwBuildNumber);
|
||||
}
|
||||
|
||||
void CGame::close() {
|
||||
std::cout << "[cs2] Deatachig from process" << std::endl;
|
||||
process->Close();
|
||||
}
|
||||
|
||||
void CGame::loop() {
|
||||
inGame = false;
|
||||
isC4Planted = false;
|
||||
|
||||
localPlayer = process->read<uintptr_t>(base_client.base + updater::offsets::dwLocalPlayer);
|
||||
if (!localPlayer) return;
|
||||
|
||||
localPlayerPawn = process->read<std::uint32_t>(localPlayer + updater::offsets::m_hPlayerPawn);
|
||||
if (!localPlayerPawn) return;
|
||||
|
||||
entity_list = process->read<uintptr_t>(base_client.base + updater::offsets::dwEntityList);
|
||||
|
||||
const uintptr_t localList_entry2 = process->read<uintptr_t>(entity_list + 0x8 * ((localPlayerPawn & 0x7FFF) >> 9) + 16);
|
||||
const uintptr_t localpCSPlayerPawn = process->read<uintptr_t>(localList_entry2 + 120 * (localPlayerPawn & 0x1FF));
|
||||
if (!localpCSPlayerPawn) return;
|
||||
|
||||
view_matrix = process->read<view_matrix_t>(base_client.base + updater::offsets::dwViewMatrix);
|
||||
|
||||
localTeam = process->read<int>(localPlayer + updater::offsets::m_iTeamNum);
|
||||
localOrigin = process->read<Vector3>(localpCSPlayerPawn + updater::offsets::m_vecOrigin);
|
||||
isC4Planted = process->read<bool>(base_client.base + updater::offsets::dwPlantedC4 - 0x8);
|
||||
|
||||
inGame = true;
|
||||
int playerIndex = 0;
|
||||
std::vector<CPlayer> list;
|
||||
|
||||
while (true) {
|
||||
playerIndex++;
|
||||
uintptr_t list_entry = process->read<uintptr_t>(entity_list + (8 * (playerIndex & 0x7FFF) >> 9) + 16);
|
||||
if (!list_entry) break;
|
||||
|
||||
CPlayer player;
|
||||
|
||||
player.entity = process->read<uintptr_t>(list_entry + 120 * (playerIndex & 0x1FF));
|
||||
if (!player.entity) continue;
|
||||
|
||||
/**
|
||||
* Skip rendering your own character and teammates
|
||||
*
|
||||
* 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
|
||||
**/
|
||||
player.team = process->read<int>(player.entity + updater::offsets::m_iTeamNum);
|
||||
if (config::team_esp && (player.team == localTeam)) continue;
|
||||
|
||||
const std::uint32_t playerPawn = process->read<std::uint32_t>(player.entity + updater::offsets::m_hPlayerPawn);
|
||||
|
||||
const uintptr_t list_entry2 = process->read<uintptr_t>(entity_list + 0x8 * ((playerPawn & 0x7FFF) >> 9) + 16);
|
||||
if (!list_entry2) continue;
|
||||
|
||||
player.pCSPlayerPawn = process->read<uintptr_t>(list_entry2 + 120 * (playerPawn & 0x1FF));
|
||||
if (!player.pCSPlayerPawn) continue;
|
||||
|
||||
player.health = process->read<int>(player.pCSPlayerPawn + updater::offsets::m_iHealth);
|
||||
player.armor = process->read<int>(player.pCSPlayerPawn + updater::offsets::m_ArmorValue);
|
||||
if (player.health <= 0 || player.health > 100) continue;
|
||||
|
||||
if (config::team_esp && (player.pCSPlayerPawn == localPlayer)) continue;
|
||||
|
||||
player.name = read_string(player.entity + updater::offsets::m_sSanitizedPlayerName);
|
||||
|
||||
player.origin = process->read<Vector3>(player.pCSPlayerPawn + updater::offsets::m_vecOrigin);
|
||||
player.head = { player.origin.x, player.origin.y, player.origin.z + 75.f };
|
||||
|
||||
if (player.origin.x == localOrigin.x && player.origin.y == localOrigin.y && player.origin.z == localOrigin.z)
|
||||
continue;
|
||||
|
||||
if (config::render_distance != -1 && (localOrigin - player.origin).length2d() > config::render_distance) continue;
|
||||
if (player.origin.x == 0 && player.origin.y == 0) continue;
|
||||
|
||||
const uintptr_t gamescene = process->read<uint64_t>(player.pCSPlayerPawn + 0x310);
|
||||
const uintptr_t bonearray = process->read<uint64_t>(gamescene + 0x160 + 0x80);
|
||||
player.skull = process->read<Vector3>(bonearray + 6 * 32);
|
||||
|
||||
if (config::show_extra_flags) {
|
||||
/*
|
||||
* Reading values for extra flags is now seperated from the other reads
|
||||
* This removes unnecessary memory reads, improving performance when not showing extra flags
|
||||
*/
|
||||
player.is_defusing = process->read<bool>(player.pCSPlayerPawn + updater::offsets::m_bIsDefusing);
|
||||
|
||||
const uintptr_t playerMoneyServices = process->read<uintptr_t>(player.entity + updater::offsets::m_pInGameMoneyServices);
|
||||
player.money = process->read<int32_t>(playerMoneyServices + updater::offsets::m_iAccount);
|
||||
|
||||
player.flashAlpha = process->read<float>(player.pCSPlayerPawn + updater::offsets::m_flFlashOverlayAlpha);
|
||||
|
||||
const auto clippingWeapon = process->read<std::uint64_t>(player.pCSPlayerPawn + updater::offsets::m_pClippingWeapon);
|
||||
const auto weaponData = process->read<std::uint64_t>(clippingWeapon + 0x360);
|
||||
std::string weaponName = read_string(weaponData + updater::offsets::m_szName);
|
||||
if (weaponName.compare(0, 7, "weapon_") == 0)
|
||||
player.weapon = weaponName.substr(7, weaponName.length()); // Remove weapon_ prefix
|
||||
else
|
||||
player.weapon = "Invalid Weapon Name";
|
||||
}
|
||||
|
||||
list.push_back(player);
|
||||
}
|
||||
|
||||
players.clear();
|
||||
players.assign(list.begin(), list.end());
|
||||
}
|
||||
|
||||
std::string CGame::read_string(uintptr_t addr) {
|
||||
const DWORD64 address = process->read<DWORD64>(addr);
|
||||
if (address) {
|
||||
char buffer[256];
|
||||
process->read_raw(address, buffer, sizeof(buffer));
|
||||
return std::string(buffer);
|
||||
}
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
Vector3 CGame::world_to_screen(Vector3* v) {
|
||||
float _x = view_matrix[0][0] * v->x + view_matrix[0][1] * v->y + view_matrix[0][2] * v->z + view_matrix[0][3];
|
||||
float _y = view_matrix[1][0] * v->x + view_matrix[1][1] * v->y + view_matrix[1][2] * v->z + view_matrix[1][3];
|
||||
|
||||
float w = view_matrix[3][0] * v->x + view_matrix[3][1] * v->y + view_matrix[3][2] * v->z + view_matrix[3][3];
|
||||
|
||||
float inv_w = 1.f / w;
|
||||
_x *= inv_w;
|
||||
_y *= inv_w;
|
||||
|
||||
float x = game_bounds.right * .5f;
|
||||
float y = game_bounds.bottom * .5f;
|
||||
|
||||
x += 0.5f * _x * game_bounds.right + 0.5f;
|
||||
y -= 0.5f * _y * game_bounds.bottom + 0.5f;
|
||||
|
||||
return { x, y, w };
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
#pragma once
|
||||
#include "../memory/memory.hpp"
|
||||
#include "../classes/vector.hpp"
|
||||
|
||||
struct view_matrix_t {
|
||||
float* operator[ ](int index) {
|
||||
return matrix[index];
|
||||
}
|
||||
|
||||
float matrix[4][4];
|
||||
};
|
||||
|
||||
class CC4 {
|
||||
public:
|
||||
uintptr_t get_planted();
|
||||
uintptr_t get_node();
|
||||
Vector3 get_origin();
|
||||
};
|
||||
|
||||
class CPlayer {
|
||||
public:
|
||||
uintptr_t entity;
|
||||
int team;
|
||||
uintptr_t pCSPlayerPawn;
|
||||
int health;
|
||||
int armor;
|
||||
std::string name;
|
||||
Vector3 origin;
|
||||
Vector3 head;
|
||||
Vector3 skull;
|
||||
bool is_defusing;
|
||||
int32_t money;
|
||||
float flashAlpha;
|
||||
std::string weapon;
|
||||
};
|
||||
|
||||
class CGame
|
||||
{
|
||||
public:
|
||||
std::shared_ptr<pProcess> process;
|
||||
ProcessModule base_client;
|
||||
ProcessModule base_engine;
|
||||
RECT game_bounds;
|
||||
uintptr_t buildNumber;
|
||||
bool inGame;
|
||||
Vector3 localOrigin;
|
||||
bool isC4Planted;
|
||||
int localTeam;
|
||||
CC4 c4;
|
||||
std::vector<CPlayer> players = {};
|
||||
void init();
|
||||
void loop();
|
||||
void close();
|
||||
Vector3 world_to_screen(Vector3* v);
|
||||
private:
|
||||
view_matrix_t view_matrix;
|
||||
uintptr_t entity_list;
|
||||
uintptr_t localPlayer;
|
||||
std::uint32_t localPlayerPawn;
|
||||
uintptr_t localList_entry2;
|
||||
uintptr_t localpCSPlayerPawn;
|
||||
std::string read_string(uintptr_t addr);
|
||||
};
|
||||
|
||||
inline CGame g_game;
|
||||
Reference in New Issue
Block a user