diff --git a/README.md b/README.md index 9671512..a6329f2 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,6 @@ Simple external esp using gdi overlay to render esp boxes on top of cs2 highlighting your enemies and teammates including their health, name and health number. If you want to check out discord overlay rendering check [discord-overlay-esp](https://github.com/IMXNOOBX/cs2-external-esp/tree/discord-overlay) -## ❗️Notice - -cs2 just updated and the offsets are no longer working, you can update them manually and create a pull request or wait until its updated - ## Video Showcase [![Cs2ESP](https://cdn.discordapp.com/attachments/903283950267564094/1148569148318822461/image.png)](https://youtu.be/SV_lddIxQ5w) diff --git a/memory-external/classes/globals.hpp b/memory-external/classes/globals.hpp index ee834d1..a81cdc3 100644 --- a/memory-external/classes/globals.hpp +++ b/memory-external/classes/globals.hpp @@ -4,4 +4,6 @@ namespace g { inline HDC hdcBuffer = NULL; inline HBITMAP hbmBuffer = NULL; + + RECT gameBounds; } diff --git a/memory-external/classes/vector.hpp b/memory-external/classes/vector.hpp index 414bf75..730acdd 100644 --- a/memory-external/classes/vector.hpp +++ b/memory-external/classes/vector.hpp @@ -2,8 +2,7 @@ #include #include -int screen_x = GetSystemMetrics(SM_CXSCREEN); -int screen_y = GetSystemMetrics(SM_CYSCREEN); +#include "globals.hpp" struct view_matrix_t { float* operator[ ](int index) { @@ -91,11 +90,11 @@ struct Vector3 _x *= inv_w; _y *= inv_w; - float x = screen_x * .5f; - float y = screen_y * .5f; + float x = g::gameBounds.right * .5f; + float y = g::gameBounds.bottom * .5f; - x += 0.5f * _x * screen_x + 0.5f; - y -= 0.5f * _y * screen_y + 0.5f; + x += 0.5f * _x * g::gameBounds.right + 0.5f; + y -= 0.5f * _y * g::gameBounds.bottom + 0.5f; return { x, y, w }; } diff --git a/memory-external/hacks/hack.hpp b/memory-external/hacks/hack.hpp index ab5ed93..d4eff2b 100644 --- a/memory-external/hacks/hack.hpp +++ b/memory-external/hacks/hack.hpp @@ -3,14 +3,16 @@ #include "classes/globals.hpp" #include "../classes/render.hpp" -#define dwLocalPlayer 0x1713348 -#define dwEntityList 0x1679C38 +// last offset update 9/5/2023 +#define dwLocalPlayer 0x1675770 +#define dwEntityList 0x167ABA8 +#define dwViewMatrix 0x1714C70 + #define dwPawnHealth 0x808 #define dwPlayerPawn 0x5dc -#define dwViewMatrix 0x1713CF0 #define dwSanitizedName 0x720 -#define m_iTeamNum 0x3bf -#define m_vecOrigin 0x12AC +#define m_iTeamNum 0x3bf +#define m_vecOrigin 0x12AC namespace hack { std::shared_ptr process; diff --git a/memory-external/main.cpp b/memory-external/main.cpp index ff947a3..08e1154 100644 --- a/memory-external/main.cpp +++ b/memory-external/main.cpp @@ -7,8 +7,7 @@ #include "classes/vector.hpp" #include "hacks/hack.hpp" #include "classes/globals.hpp" - -// https://www.unknowncheats.me/forum/3846642-post734.html +#include "classes/render.hpp" LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -17,7 +16,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_CREATE: { g::hdcBuffer = CreateCompatibleDC(NULL); - g::hbmBuffer = CreateCompatibleBitmap(GetDC(hWnd), screen_x, screen_y); + g::hbmBuffer = CreateCompatibleBitmap(GetDC(hWnd), g::gameBounds.right, g::gameBounds.bottom); SelectObject(g::hdcBuffer, g::hbmBuffer); SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED); @@ -39,10 +38,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (GetForegroundWindow() == hack::process->hwnd_) { + //render::RenderText(g::hdcBuffer, 10, 10, "cs2 | ESP", RGB(75, 175, 175), 15); hack::loop(); } - BitBlt(hdc, 0, 0, screen_x, screen_y, g::hdcBuffer, 0, 0, SRCCOPY); + BitBlt(hdc, 0, 0, g::gameBounds.right, g::gameBounds.bottom, g::hdcBuffer, 0, 0, SRCCOPY); EndPaint(hWnd, &ps); InvalidateRect(hWnd, NULL, TRUE); @@ -76,10 +76,16 @@ int main() { hack::base_module = hack::process->GetModule("client.dll"); if (hack::base_module.base == 0) { std::this_thread::sleep_for(std::chrono::seconds(1)); - std::cout << "[cs2] Failed to find module client.dll" << std::endl; + std::cout << "[cs2] Failed to find module client.dll, waiting for the game to load it..." << std::endl; } } while (hack::base_module.base == 0); + std::cout << "[overlay] Waiting to focus game to create the overlay..." << std::endl; + while (GetForegroundWindow() != hack::process->hwnd_) { + std::this_thread::sleep_for(std::chrono::seconds(1)); + hack::process->UpdateHWND(); + ShowWindow(hack::process->hwnd_, TRUE); + } std::cout << "[overlay] Creating window overlay..." << std::endl; WNDCLASSEXA wc = { 0 }; @@ -93,20 +99,19 @@ int main() { RegisterClassExA(&wc); - RECT gameBounds; - GetClientRect(hack::process->hwnd_, &gameBounds); + GetClientRect(hack::process->hwnd_, &g::gameBounds); // Create the window HINSTANCE hInstance = NULL; HWND hWnd = CreateWindowExA(WS_EX_TRANSPARENT | WS_EX_TOPMOST | WS_EX_LAYERED | WS_EX_TOOLWINDOW, " ", "cs2-external-esp", WS_POPUP, - gameBounds.left, gameBounds.top, gameBounds.right - gameBounds.left, gameBounds.bottom + gameBounds.left, NULL, NULL, hInstance, NULL); // NULL, NULL); + g::gameBounds.left, g::gameBounds.top, g::gameBounds.right - g::gameBounds.left, g::gameBounds.bottom + g::gameBounds.left, NULL, NULL, hInstance, NULL); // NULL, NULL); if (hWnd == NULL) return 0; SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); ShowWindow(hWnd, TRUE); - SetActiveWindow(hack::process->hwnd_); + //SetActiveWindow(hack::process->hwnd_); // Message loop MSG msg; @@ -120,6 +125,8 @@ int main() { DeleteDC(g::hdcBuffer); DeleteObject(g::hbmBuffer); + DestroyWindow(hWnd); + std::cout << "[cs2] Deataching from process" << std::endl; hack::process->Close(); diff --git a/memory-external/memory/memory.cpp b/memory-external/memory/memory.cpp index 7c1fe0d..8adbd72 100644 --- a/memory-external/memory/memory.cpp +++ b/memory-external/memory/memory.cpp @@ -108,6 +108,12 @@ bool pProcess::AttachWindow(const char* WindowName) return false; } +bool pProcess::UpdateHWND() +{ + hwnd_ = this->GetWindowHandleFromProcessId(pid_); + return hwnd_ == nullptr; +} + ProcessModule pProcess::GetModule(const char* lModule) { std::wstring wideModule; diff --git a/memory-external/memory/memory.hpp b/memory-external/memory/memory.hpp index 66ddc92..4dab227 100644 --- a/memory-external/memory/memory.hpp +++ b/memory-external/memory/memory.hpp @@ -25,6 +25,7 @@ public: public: bool AttachProcess(const char* process_name); bool AttachWindow(const char* window_name); + bool UpdateHWND(); void Close(); public: