diff --git a/memory-external/classes/auto_updater.cpp b/memory-external/classes/auto_updater.cpp index 5f2a133..30b797e 100644 --- a/memory-external/classes/auto_updater.cpp +++ b/memory-external/classes/auto_updater.cpp @@ -184,16 +184,18 @@ namespace updater { if (data.empty()) return false; + if (data["build_number"].is_number()) + build_number = data["build_number"]; + if (data["dwLocalPlayer"].is_number()) offsets::dwLocalPlayer = data["dwLocalPlayer"]; if (data["dwEntityList"].is_number()) offsets::dwEntityList = data["dwEntityList"]; if (data["dwViewMatrix"].is_number()) offsets::dwViewMatrix = data["dwViewMatrix"]; + if (data["dwBuildNumber"].is_number()) + offsets::dwBuildNumber = data["dwBuildNumber"]; - // Disabled for now, as this is exclusive to spectator - // if (data["m_iPawnArmor"].is_number()) - // offsets::m_iPawnArmor = data["m_iPawnArmor"]; if (data["m_iHealth"].is_number()) offsets::m_iHealth = data["m_iHealth"]; if (data["dwPlayerPawn"].is_number()) @@ -211,12 +213,13 @@ namespace updater { void save() { json data; + data["build_number"] = build_number; + data["dwLocalPlayer"] = offsets::dwLocalPlayer; data["dwEntityList"] = offsets::dwEntityList; data["dwViewMatrix"] = offsets::dwViewMatrix; + data["dwBuildNumber"] = offsets::dwBuildNumber; - // Disabled for now, as this is exclusive to spectator - // data["m_iPawnArmor"] = offsets::m_iPawnArmor; data["m_iHealth"] = offsets::m_iHealth; data["dwPlayerPawn"] = offsets::dwPlayerPawn; data["dwSanitizedName"] = offsets::dwSanitizedName; diff --git a/memory-external/classes/auto_updater.hpp b/memory-external/classes/auto_updater.hpp index f8175c4..6d92864 100644 --- a/memory-external/classes/auto_updater.hpp +++ b/memory-external/classes/auto_updater.hpp @@ -30,12 +30,14 @@ namespace updater { const inline std::string github_repo_api = "https://api.github.com/repos/IMXNOOBX/cs2-external-esp/commits"; const inline std::string raw_updated_offets = "https://github.com/IMXNOOBX/cs2-external-esp/raw/main/offsets/offsets.json"; + inline int build_number = 13962; + namespace offsets { inline std::ptrdiff_t dwLocalPlayer = 0x17DE508; inline std::ptrdiff_t dwEntityList = 0x178FC88; inline std::ptrdiff_t dwViewMatrix = 0x187DAB0; + inline std::ptrdiff_t dwBuildNumber = 0x487514; - // inline std::ptrdiff_t m_iPawnArmor = 0x80c; inline std::ptrdiff_t m_iHealth = 0x32C; inline std::ptrdiff_t dwPlayerPawn = 0x7BC; inline std::ptrdiff_t dwSanitizedName = 0x720; diff --git a/memory-external/classes/config.hpp b/memory-external/classes/config.hpp index 02af005..cd8cb25 100644 --- a/memory-external/classes/config.hpp +++ b/memory-external/classes/config.hpp @@ -29,12 +29,6 @@ namespace config { inline int flag_render_distance = 200; inline bool show_extra_flags = false; - //inline bool show_distance = false; - //inline bool show_armor = false; - //inline bool head_tracker = false; - //inline bool rainbow = false; - //inline float rainbow_speed = 0.001f; - inline RGB esp_box_color_team = { 75, 175, 75 }; inline RGB esp_box_color_enemy = { 175, 75, 75 }; inline RGB esp_name_color = { 75, 75, 175 }; diff --git a/memory-external/hacks/hack.hpp b/memory-external/hacks/hack.hpp index 644ce93..a6eeb25 100644 --- a/memory-external/hacks/hack.hpp +++ b/memory-external/hacks/hack.hpp @@ -5,23 +5,20 @@ #include "../classes/render.hpp" #include "../classes/config.hpp" - - namespace hack { std::shared_ptr process; - ProcessModule base_module; - - //const float pi = 3.14159265358979323846f; + ProcessModule base_client; + ProcessModule base_engine; void loop() { - const uintptr_t localPlayer = process->read(base_module.base + updater::offsets::dwLocalPlayer); + const uintptr_t localPlayer = process->read(base_client.base + updater::offsets::dwLocalPlayer); if (!localPlayer) return; const int localTeam = process->read(localPlayer + updater::offsets::m_iTeamNum); - const view_matrix_t view_matrix = process->read(base_module.base + updater::offsets::dwViewMatrix); + const view_matrix_t view_matrix = process->read(base_client.base + updater::offsets::dwViewMatrix); const Vector3 localOrigin = process->read(localPlayer + updater::offsets::m_vecOrigin); - const uintptr_t entity_list = process->read(base_module.base + updater::offsets::dwEntityList); + const uintptr_t entity_list = process->read(base_client.base + updater::offsets::dwEntityList); int playerIndex = 0; uintptr_t list_entry; @@ -58,7 +55,6 @@ namespace hack { if (!list_entry2) continue; - const uintptr_t pCSPlayerPawn = process->read(list_entry2 + 120 * (playerPawn & 0x1FF)); if (!pCSPlayerPawn) continue; @@ -70,7 +66,6 @@ namespace hack { if (config::team_esp && (pCSPlayerPawn == localPlayer)) continue; - std::string playerName = "Invalid Name"; const DWORD64 playerNameAddress = process->read(player + updater::offsets::dwSanitizedName); @@ -83,16 +78,13 @@ namespace hack { const Vector3 origin = process->read(pCSPlayerPawn + updater::offsets::m_vecOrigin); const Vector3 head = { origin.x, origin.y, origin.z + 75.f }; const Vector3 head2 = { origin.x + 10, origin.y + 10, origin.z + 75.f }; - const Vector3 localOrigin = process->read(localPlayer + updater::offsets::m_vecOrigin); if (config::render_distance != -1 && (localOrigin - origin).length2d() > config::render_distance) continue; - - if ((localOrigin - origin).length2d() < 5) + if ((localOrigin - origin).length2d() < 10) continue; - const Vector3 screenPos = origin.world_to_screen(view_matrix); const Vector3 screenHead = head.world_to_screen(view_matrix); @@ -104,16 +96,7 @@ namespace hack { if (screenPos.z >= 0.01f) { float distance = localOrigin.calculate_distance(origin); - int roundedDistance = std::round(distance / 10); - - /** - * I know is not the best way but a simple way to not saturate the screen with a ton of information - * From IfBars - I decided to move this up here so that it will not render anything unless the player is within the flag_render_distance - * I did this so people aren't confused on why only half the players hp values are showing, however feel free to change this however you see fit - * Personally I prefer to see everyone no matter the difference, but everyone has their preferences - */ - if (roundedDistance > config::flag_render_distance) - continue; + int roundedDistance = std::round(distance / 10.f); render::DrawBorderBox( g::hdcBuffer, @@ -146,7 +129,11 @@ namespace hack { 10 ); - + /** + * I know is not the best way but a simple way to not saturate the screen with a ton of information + */ + if (roundedDistance > config::flag_render_distance) + continue; render::RenderText( g::hdcBuffer, @@ -166,7 +153,7 @@ namespace hack { render::RenderText( g::hdcBuffer, screenHead.x + (width / 2 + 5), - screenHead.y + 32, + screenHead.y + 20, (std::to_string(roundedDistance) + "m away").c_str(), config::esp_distance_color, 10 diff --git a/memory-external/main.cpp b/memory-external/main.cpp index 76e7990..99d9bd7 100644 --- a/memory-external/main.cpp +++ b/memory-external/main.cpp @@ -92,15 +92,25 @@ int main() { else std::cout << "[updater] Error reading offsets file, reseting to the default state\n" << std::endl; - std::cout << "[warn] If the esp doesnt work, consider updating offsets manually in the file offsets.json" << std::endl; - do { - hack::base_module = hack::process->GetModule("client.dll"); - if (hack::base_module.base == 0) { + hack::base_client = hack::process->GetModule("client.dll"); + hack::base_engine = hack::process->GetModule("engine2.dll"); + if (hack::base_client.base == 0 || hack::base_engine.base == 0) { std::this_thread::sleep_for(std::chrono::seconds(1)); - std::cout << "[cs2] Failed to find module client.dll, waiting for the game to load it..." << std::endl; + std::cout << "[cs2] Failed to find module client.dll/engine2.dll, waiting for the game to load it..." << std::endl; } - } while (hack::base_module.base == 0); + } while (hack::base_client.base == 0 || hack::base_engine.base == 0); + + const uintptr_t buildNumber = hack::process->read(hack::base_engine.base + updater::offsets::dwBuildNumber); + if (buildNumber != updater::build_number) { + std::cout << "[cs2] Build number doesnt match, the game has been updated and this esp most likely wont work." << std::endl; + std::cout << "[warn] If the esp doesnt work, consider updating offsets manually in the file offsets.json" << std::endl; + std::cout << "[cs2] Press any key to continue" << std::endl; + std::cin.get(); + } + else { + std::cout << "[cs2] Offsets seem to be up to date! have fun!" << std::endl; + } std::cout << "[overlay] Waiting to focus game to create the overlay..." << std::endl; std::cout << "[overlay] Make sure your game is in \"Full Screen Windowed\"" << std::endl; diff --git a/memory-external/memory/memory.cpp b/memory-external/memory/memory.cpp index e42edbe..97eed5e 100644 --- a/memory-external/memory/memory.cpp +++ b/memory-external/memory/memory.cpp @@ -71,10 +71,10 @@ bool pProcess::AttachProcess(const char* ProcessName) handle_ = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid_); EnumProcessModulesEx(this->handle_, modules, sizeof(modules), &_, LIST_MODULES_64BIT); - base_module_.base = (uintptr_t)modules[0]; + base_client_.base = (uintptr_t)modules[0]; GetModuleInformation(this->handle_, modules[0], &module_info, sizeof(module_info)); - base_module_.size = module_info.SizeOfImage; + base_client_.size = module_info.SizeOfImage; hwnd_ = this->GetWindowHandleFromProcessId(pid_); @@ -105,10 +105,10 @@ bool pProcess::AttachProcessHj(const char* ProcessName) } EnumProcessModulesEx(this->handle_, modules, sizeof(modules), &_, LIST_MODULES_64BIT); - base_module_.base = (uintptr_t)modules[0]; + base_client_.base = (uintptr_t)modules[0]; GetModuleInformation(this->handle_, modules[0], &module_info, sizeof(module_info)); - base_module_.size = module_info.SizeOfImage; + base_client_.size = module_info.SizeOfImage; hwnd_ = this->GetWindowHandleFromProcessId(pid_); @@ -132,10 +132,10 @@ bool pProcess::AttachWindow(const char* WindowName) handle_ = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid_); EnumProcessModulesEx(this->handle_, modules, sizeof(modules), &_, LIST_MODULES_64BIT); - base_module_.base = (uintptr_t)modules[0]; + base_client_.base = (uintptr_t)modules[0]; GetModuleInformation(this->handle_, modules[0], &module_info, sizeof(module_info)); - base_module_.size = module_info.SizeOfImage; + base_client_.size = module_info.SizeOfImage; hwnd_ = this->GetWindowHandleFromProcessId(pid_); @@ -185,13 +185,13 @@ LPVOID pProcess::Allocate(size_t size_in_bytes) uintptr_t pProcess::FindSignature(std::vector signature) { std::unique_ptr data; - data = std::make_unique(this->base_module_.size); + data = std::make_unique(this->base_client_.size); - if (!ReadProcessMemory(this->handle_, (void*)(this->base_module_.base), data.get(), this->base_module_.size, NULL)) { + if (!ReadProcessMemory(this->handle_, (void*)(this->base_client_.base), data.get(), this->base_client_.size, NULL)) { return 0x0; } - for (uintptr_t i = 0; i < this->base_module_.size; i++) + for (uintptr_t i = 0; i < this->base_client_.size; i++) { for (uintptr_t j = 0; j < signature.size(); j++) { @@ -201,7 +201,7 @@ uintptr_t pProcess::FindSignature(std::vector signature) if (*reinterpret_cast(reinterpret_cast(&data[i + j])) == signature.at(j)) { if (j == signature.size() - 1) - return this->base_module_.base + i; + return this->base_client_.base + i; continue; } break; @@ -229,7 +229,7 @@ uintptr_t pProcess::FindSignature(ProcessModule target_module, std::vector(reinterpret_cast(&data[i + j])) == signature.at(j)) { if (j == signature.size() - 1) - return this->base_module_.base + i; + return this->base_client_.base + i; continue; } break; diff --git a/memory-external/memory/memory.hpp b/memory-external/memory/memory.hpp index 12d703b..baf8bd0 100644 --- a/memory-external/memory/memory.hpp +++ b/memory-external/memory/memory.hpp @@ -20,7 +20,7 @@ public: DWORD pid_; // process id HANDLE handle_; // handle to process HWND hwnd_; // window handle - ProcessModule base_module_; + ProcessModule base_client_; public: bool AttachProcess(const char* process_name);