diff --git a/memory-external/classes/auto_updater.cpp b/memory-external/classes/auto_updater.cpp index 146fd17..30b797e 100644 --- a/memory-external/classes/auto_updater.cpp +++ b/memory-external/classes/auto_updater.cpp @@ -184,17 +184,20 @@ 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"]; - if (data["m_iPawnArmor"].is_number()) - offsets::m_iPawnArmor = data["m_iPawnArmor"]; - if (data["dwPawnHealth"].is_number()) - offsets::dwPawnHealth = data["dwPawnHealth"]; + if (data["m_iHealth"].is_number()) + offsets::m_iHealth = data["m_iHealth"]; if (data["dwPlayerPawn"].is_number()) offsets::dwPlayerPawn = data["dwPlayerPawn"]; if (data["dwSanitizedName"].is_number()) @@ -210,12 +213,14 @@ 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; - data["m_iPawnArmor"] = offsets::m_iPawnArmor; - data["dwPawnHealth"] = offsets::dwPawnHealth; + data["m_iHealth"] = offsets::m_iHealth; data["dwPlayerPawn"] = offsets::dwPlayerPawn; data["dwSanitizedName"] = offsets::dwSanitizedName; data["m_iTeamNum"] = offsets::m_iTeamNum; diff --git a/memory-external/classes/auto_updater.hpp b/memory-external/classes/auto_updater.hpp index 70e8fb4..6d92864 100644 --- a/memory-external/classes/auto_updater.hpp +++ b/memory-external/classes/auto_updater.hpp @@ -30,14 +30,16 @@ 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"; - namespace offsets { - inline std::ptrdiff_t dwLocalPlayer = 0x1877CF8; - inline std::ptrdiff_t dwEntityList = 0x178A808; - inline std::ptrdiff_t dwViewMatrix = 0x18787E0; + inline int build_number = 13962; - inline std::ptrdiff_t m_iPawnArmor = 0x80c; - inline std::ptrdiff_t dwPawnHealth = 0x808; - inline std::ptrdiff_t dwPlayerPawn = 0x7FC; + 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_iHealth = 0x32C; + inline std::ptrdiff_t dwPlayerPawn = 0x7BC; inline std::ptrdiff_t dwSanitizedName = 0x720; inline std::ptrdiff_t m_iTeamNum = 0x3BF; inline std::ptrdiff_t m_vecOrigin = 0x1214; 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 b70f7d4..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; @@ -41,13 +38,6 @@ namespace hack { if (!player) continue; - - const int playerHealth = process->read(player + updater::offsets::dwPawnHealth); - const int playerArmor = process->read(player + updater::offsets::m_iPawnArmor); - if (playerHealth <= 0 || playerHealth > 100) - continue; - - /** * Skip rendering your own character and teammates * @@ -65,14 +55,16 @@ namespace hack { if (!list_entry2) continue; - const uintptr_t pCSPlayerPawn = process->read(list_entry2 + 120 * (playerPawn & 0x1FF)); if (!pCSPlayerPawn) continue; - if (config::team_esp && (pCSPlayerPawn == localPlayer)) + const int playerHealth = process->read(pCSPlayerPawn + updater::offsets::m_iHealth); + if (playerHealth <= 0 || playerHealth > 100) continue; + if (config::team_esp && (pCSPlayerPawn == localPlayer)) + continue; std::string playerName = "Invalid Name"; const DWORD64 playerNameAddress = process->read(player + updater::offsets::dwSanitizedName); @@ -86,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); @@ -107,7 +96,7 @@ namespace hack { if (screenPos.z >= 0.01f) { float distance = localOrigin.calculate_distance(origin); - int roundedDistance = std::round(distance / 10); + int roundedDistance = std::round(distance / 10.f); render::DrawBorderBox( g::hdcBuffer, @@ -164,20 +153,7 @@ namespace hack { render::RenderText( g::hdcBuffer, screenHead.x + (width / 2 + 5), - screenHead.y + 21, - (std::to_string(playerArmor) + "armor").c_str(), - RGB( - (255 - playerArmor), - (55 + playerArmor * 2), - 75 - ), - 10 - ); - - 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); diff --git a/offsets/offsets.json b/offsets/offsets.json index 9301b97..8fc7cbb 100644 --- a/offsets/offsets.json +++ b/offsets/offsets.json @@ -1,10 +1,11 @@ { - "dwEntityList": 24684552, - "dwLocalPlayer": 25656568, - "dwPawnHealth": 2056, - "dwPlayerPawn": 2044, + "dwEntityList": 24706184, + "dwLocalPlayer": 25027848, + "m_iPawnArmor": 808, + "m_iHealth": 812, + "dwPlayerPawn": 1980, "dwSanitizedName": 1824, - "dwViewMatrix": 25659360, + "dwViewMatrix": 25680560, "m_iTeamNum": 959, "m_vecOrigin": 4628 }