Added new gdi overlay
- Now you can see name in the esp - not you can also see the hp number
This commit is contained in:
@@ -1,20 +1,16 @@
|
||||
# 🎡 CS2 External ESP
|
||||
|
||||
Simple external esp using discord's overlay to render a box on top of cs2 highlighting your enemies and teammates including their health.
|
||||
Simple external esp using an overlay to render a box on top of cs2 highlighting your enemies and teammates including their health. It now uses gdi overlay to render esp boxes, if you want to check out discord overlay rendering check [discord-overlay-esp](https://github.com/IMXNOOBX/cs2-external-esp/tree/discord-overlay)
|
||||
|
||||
## Video Showcase
|
||||
|
||||
[](https://youtu.be/SV_lddIxQ5w)
|
||||
[](https://youtu.be/SV_lddIxQ5w)
|
||||
## 🌳 Simple Use
|
||||
|
||||
1. Go to the [**releases**](https://github.com/IMXNOOBX/cs2-external-esp/releases) tab.
|
||||
2. Find the latest release and download it
|
||||
3. Open the binary file and cs2 (doesnt matter which one goes first)
|
||||
|
||||
* ❗ You must have discord overlay enabled! Settings > Game Overlay > Enable
|
||||
* ❗ Make sure you have enabled the overlay in for that game in Registered Games
|
||||
* ❗ Make you have `-insecure` in csgo launch parameters for the overlay to work or [trustedmode-bypass](https://github.com/exploitmafia/trustedmode-bypass) // i will make another version soon with normal overlay
|
||||
|
||||
## 📘 Developer Instructions
|
||||
|
||||
1. Build the program using Visual Studio 2022
|
||||
@@ -26,6 +22,5 @@ Simple external esp using discord's overlay to render a box on top of cs2 highli
|
||||
|
||||
## 💫 Credits
|
||||
|
||||
* SamuelTulach's [OverlayCord](https://github.com/SamuelTulach/OverlayCord) for making the discord overlay hijack.
|
||||
* [UnnamedZ03](https://github.com/UnnamedZ03) for providing [offsets](https://www.unknowncheats.me/forum/3846642-post734.html) and guide with his [CS2-external-base](https://github.com/UnnamedZ03/CS2-external-base)
|
||||
* Unknowncheats comunity for their reseach!
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
* https://github.com/SamuelTulach/OverlayCord
|
||||
*/
|
||||
|
||||
#ifndef OVERLAYCORD_H
|
||||
#define OVERLAYCORD_H
|
||||
|
||||
#include <Windows.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace OverlayCord
|
||||
{
|
||||
namespace Communication
|
||||
{
|
||||
typedef struct _Header
|
||||
{
|
||||
UINT Magic;
|
||||
UINT FrameCount;
|
||||
UINT NoClue;
|
||||
UINT Width;
|
||||
UINT Height;
|
||||
BYTE Buffer[1];
|
||||
} Header;
|
||||
|
||||
typedef struct _ConnectedProcessInfo
|
||||
{
|
||||
UINT ProcessId;
|
||||
HANDLE File;
|
||||
Header* MappedAddress;
|
||||
} ConnectedProcessInfo;
|
||||
|
||||
inline bool ConnectToProcess(ConnectedProcessInfo& processInfo)
|
||||
{
|
||||
std::string mappedFilename = "DiscordOverlay_Framebuffer_Memory_" + std::to_string(processInfo.ProcessId);
|
||||
processInfo.File = OpenFileMappingA(FILE_MAP_ALL_ACCESS, false, mappedFilename.c_str());
|
||||
if (!processInfo.File || processInfo.File == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
|
||||
processInfo.MappedAddress = static_cast<Header*>(MapViewOfFile(processInfo.File, FILE_MAP_ALL_ACCESS, 0, 0, 0));
|
||||
return processInfo.MappedAddress;
|
||||
}
|
||||
|
||||
inline void DisconnectFromProcess(ConnectedProcessInfo& processInfo)
|
||||
{
|
||||
UnmapViewOfFile(processInfo.MappedAddress);
|
||||
processInfo.MappedAddress = nullptr;
|
||||
|
||||
CloseHandle(processInfo.File);
|
||||
processInfo.File = nullptr;
|
||||
}
|
||||
|
||||
inline void SendFrame(ConnectedProcessInfo& processInfo, UINT width, UINT height, void* frame, UINT size)
|
||||
{
|
||||
// frame is in B8G8R8A8 format
|
||||
// size can be nearly anything since it will get resized
|
||||
// for the screen appropriately, although the maximum size is
|
||||
// game window width * height * 4 (BGRA)
|
||||
processInfo.MappedAddress->Width = width;
|
||||
processInfo.MappedAddress->Height = height;
|
||||
|
||||
memcpy(processInfo.MappedAddress->Buffer, frame, size);
|
||||
|
||||
processInfo.MappedAddress->FrameCount++; // this will cause the internal module to copy over the framebuffer
|
||||
}
|
||||
}
|
||||
|
||||
namespace Drawing
|
||||
{
|
||||
typedef struct _Frame
|
||||
{
|
||||
UINT Width;
|
||||
UINT Height;
|
||||
UINT Size;
|
||||
void* Buffer;
|
||||
} Frame;
|
||||
|
||||
typedef struct _Pixel
|
||||
{
|
||||
BYTE B, G, R, A;
|
||||
} Pixel;
|
||||
|
||||
inline Frame CreateFrame(UINT width, UINT height)
|
||||
{
|
||||
Frame output;
|
||||
output.Width = width;
|
||||
output.Height = height;
|
||||
output.Size = width * height * 4;
|
||||
|
||||
output.Buffer = malloc(output.Size);
|
||||
memset(output.Buffer, 0, output.Size);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
inline void CleanFrame(Frame& frame)
|
||||
{
|
||||
memset(frame.Buffer, 0, frame.Size);
|
||||
}
|
||||
|
||||
inline void SetPixel(Frame& frame, UINT x, UINT y, Pixel color)
|
||||
{
|
||||
if (x < frame.Width && y < frame.Height)
|
||||
{
|
||||
Pixel* buf = static_cast<Pixel*>(frame.Buffer);
|
||||
buf[y * frame.Width + x] = color;
|
||||
}
|
||||
}
|
||||
|
||||
inline void DrawLine(Frame& frame, UINT x1, UINT y1, UINT x2, UINT y2, Pixel color)
|
||||
{
|
||||
int dx = abs(static_cast<int>(x2 - x1)), sx = x1 < x2 ? 1 : -1;
|
||||
int dy = -abs(static_cast<int>(y2 - y1)), sy = y1 < y2 ? 1 : -1;
|
||||
int err = dx + dy, e2;
|
||||
|
||||
while (true)
|
||||
{
|
||||
SetPixel(frame, x1, y1, color);
|
||||
if (x1 == x2 && y1 == y2)
|
||||
break;
|
||||
e2 = 2 * err;
|
||||
if (e2 >= dy) { err += dy; x1 += sx; }
|
||||
if (e2 <= dx) { err += dx; y1 += sy; }
|
||||
}
|
||||
}
|
||||
|
||||
inline void DrawRectangle(Frame& frame, UINT x1, UINT y1, UINT width, UINT height, Pixel color)
|
||||
{
|
||||
for (UINT x = x1; x < x1 + width; x++)
|
||||
{
|
||||
SetPixel(frame, x, y1, color);
|
||||
SetPixel(frame, x, y1 + height - 1, color);
|
||||
}
|
||||
|
||||
for (UINT y = y1; y < y1 + height; y++)
|
||||
{
|
||||
SetPixel(frame, x1, y, color);
|
||||
SetPixel(frame, x1 + width - 1, y, color);
|
||||
}
|
||||
}
|
||||
|
||||
inline void DrawCircle(Frame& frame, UINT x0, UINT y0, UINT radius, Pixel color)
|
||||
{
|
||||
int x = radius;
|
||||
int y = 0;
|
||||
int radiusError = 1 - x;
|
||||
|
||||
while (x >= y)
|
||||
{
|
||||
SetPixel(frame, x0 + x, y0 + y, color);
|
||||
SetPixel(frame, x0 - x, y0 + y, color);
|
||||
SetPixel(frame, x0 - x, y0 - y, color);
|
||||
SetPixel(frame, x0 + x, y0 - y, color);
|
||||
SetPixel(frame, x0 + y, y0 + x, color);
|
||||
SetPixel(frame, x0 - y, y0 + x, color);
|
||||
SetPixel(frame, x0 - y, y0 - x, color);
|
||||
SetPixel(frame, x0 + y, y0 - x, color);
|
||||
|
||||
y++;
|
||||
if (radiusError < 0)
|
||||
{
|
||||
radiusError += 2 * y + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
x--;
|
||||
radiusError += 2 * (y - x + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include <wtypes.h>
|
||||
|
||||
namespace g {
|
||||
inline HDC hdcBuffer = NULL;
|
||||
inline HBITMAP hbmBuffer = NULL;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
#include <wtypes.h>
|
||||
|
||||
namespace render {
|
||||
void DrawBorderBox(HDC hdc, int x, int y, int w, int h, COLORREF borderColor)
|
||||
{
|
||||
HBRUSH hBorderBrush = CreateSolidBrush(borderColor);
|
||||
HBRUSH hOldBrush = (HBRUSH)SelectObject(hdc, hBorderBrush);
|
||||
|
||||
RECT rect = { x, y, x + w, y + h };
|
||||
FrameRect(hdc, &rect, hBorderBrush);
|
||||
|
||||
SelectObject(hdc, hOldBrush); // Restore the original brush
|
||||
DeleteObject(hBorderBrush); // Delete the temporary brush
|
||||
}
|
||||
|
||||
void SetTextSize(HDC hdc, int textSize)
|
||||
{
|
||||
LOGFONT lf;
|
||||
HFONT hFont, hOldFont;
|
||||
|
||||
// Initialize the LOGFONT structure
|
||||
ZeroMemory(&lf, sizeof(LOGFONT));
|
||||
lf.lfHeight = -textSize; // Set the desired text height (negative for height)
|
||||
lf.lfWeight = FW_NORMAL; // Set the font weight (e.g., FW_NORMAL for normal)
|
||||
lf.lfQuality = ANTIALIASED_QUALITY; // Enable anti-aliasing
|
||||
|
||||
// Create a new font based on the LOGFONT structure
|
||||
hFont = CreateFontIndirect(&lf);
|
||||
|
||||
// Select the new font into the device context and save the old font
|
||||
hOldFont = (HFONT)SelectObject(hdc, hFont);
|
||||
|
||||
// Clean up the old font (when done using it)
|
||||
DeleteObject(hOldFont);
|
||||
}
|
||||
|
||||
void RenderText(HDC hdc, int x, int y, const char* text, COLORREF textColor, int textSize)
|
||||
{
|
||||
SetTextSize(hdc, textSize); // Set the desired text size
|
||||
SetTextColor(hdc, textColor);
|
||||
TextOutA(hdc, x, y, text, strlen(text));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
#include <thread>
|
||||
#include "../memory/memory.hpp"
|
||||
#include "classes/globals.hpp"
|
||||
#include "../classes/render.hpp"
|
||||
|
||||
#define dwLocalPlayer 0x1713348
|
||||
#define dwEntityList 0x1679C38
|
||||
#define dwPawnHealth 0x808
|
||||
#define dwPlayerPawn 0x5dc
|
||||
#define dwViewMatrix 0x1713CF0
|
||||
#define dwSanitizedName 0x720
|
||||
#define m_iTeamNum 0x3bf
|
||||
#define m_vecOrigin 0x12AC
|
||||
|
||||
namespace hack {
|
||||
std::shared_ptr<pProcess> process;
|
||||
ProcessModule base_module;
|
||||
|
||||
void loop() {
|
||||
uintptr_t localPlayer = process->read<uintptr_t>(base_module.base + dwLocalPlayer);
|
||||
if (!localPlayer) return;
|
||||
|
||||
int localTeam = process->read<int>(localPlayer + m_iTeamNum);
|
||||
|
||||
view_matrix_t view_matrix = process->read<view_matrix_t>(base_module.base + dwViewMatrix);
|
||||
|
||||
Vector3 localOrigin = process->read<Vector3>(localPlayer + m_vecOrigin);
|
||||
|
||||
uintptr_t entity_list = process->read<uintptr_t>(base_module.base + dwEntityList);
|
||||
|
||||
for (int i = 1; i < 32; i++) {
|
||||
uintptr_t list_entry = process->read<uintptr_t>(entity_list + (8 * (i & 0x7FFF) >> 9) + 16);
|
||||
if (!list_entry) continue;
|
||||
uintptr_t player = process->read<uintptr_t>(list_entry + 120 * (i & 0x1FF));
|
||||
|
||||
if (!player) continue;
|
||||
|
||||
int playerHealth = process->read<int>(player + dwPawnHealth);
|
||||
if (playerHealth <= 0 || playerHealth > 100) continue;
|
||||
|
||||
// https://github.com/UnnamedZ03/CS2-external-base/blob/main/source/CSSPlayer.hpp#L132
|
||||
std::uint32_t playerpawn = process->read<std::uint32_t>(player + dwPlayerPawn);
|
||||
|
||||
uintptr_t list_entry2 = process->read<uintptr_t>(entity_list + 0x8 * ((playerpawn & 0x7FFF) >> 9) + 16);
|
||||
if (!list_entry2) continue;
|
||||
uintptr_t pCSPlayerPawn = process->read<uintptr_t>(list_entry2 + 120 * (playerpawn & 0x1FF));
|
||||
|
||||
if (pCSPlayerPawn == localPlayer) continue;
|
||||
|
||||
int playerTeam = process->read<int>(player + m_iTeamNum);
|
||||
|
||||
std::string playerName = "Invalid Name";
|
||||
DWORD64 playerNameAddress = process->read<DWORD64>(player + dwSanitizedName);
|
||||
if (playerNameAddress) {
|
||||
char buf[256];
|
||||
process->read_raw(playerNameAddress, buf, sizeof(buf));
|
||||
playerName = std::string(buf);
|
||||
}
|
||||
|
||||
// https://github.com/UnnamedZ03/CS2-external-base/blob/main/source/CSSPlayer.hpp#L132
|
||||
Vector3 origin = process->read<Vector3>(pCSPlayerPawn + m_vecOrigin);
|
||||
|
||||
//if ((localOrigin - origin).length2d() > 1000) return;
|
||||
|
||||
Vector3 head;
|
||||
head.x = origin.x;
|
||||
head.y = origin.y;
|
||||
head.z = origin.z + 75.f;
|
||||
|
||||
Vector3 screenpos = origin.world_to_screen(view_matrix);
|
||||
Vector3 screenhead = head.world_to_screen(view_matrix);
|
||||
|
||||
float height = screenpos.y - screenhead.y;
|
||||
float width = height / 2.4f;
|
||||
if (screenpos.z >= 0.01f) {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
}
|
||||
+92
-121
@@ -1,161 +1,132 @@
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <Windows.h>
|
||||
|
||||
#include "memory/memory.hpp"
|
||||
#include "classes/vector.hpp"
|
||||
#include "classes/OverlayCord.h"
|
||||
#include "hacks/hack.hpp"
|
||||
#include "classes/globals.hpp"
|
||||
|
||||
// https://www.unknowncheats.me/forum/3846642-post734.html
|
||||
|
||||
#define dwLocalPlayer 0x1713348
|
||||
#define dwEntityList 0x1679C38
|
||||
#define dwPawnHealth 0x808
|
||||
#define dwPlayerPawn 0x5dc
|
||||
#define dwViewMatrix 0x1713CF0
|
||||
#define m_iTeamNum 0x3bf
|
||||
#define m_vecOrigin 0x12AC
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
g::hdcBuffer = CreateCompatibleDC(NULL);
|
||||
g::hbmBuffer = CreateCompatibleBitmap(GetDC(hWnd), screen_x, screen_y);
|
||||
SelectObject(g::hdcBuffer, g::hbmBuffer);
|
||||
|
||||
SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
|
||||
|
||||
SetLayeredWindowAttributes(hWnd, RGB(255, 255, 255), 0, LWA_COLORKEY);
|
||||
|
||||
std::cout << "[overlay] Window created successfully" << std::endl;
|
||||
break;
|
||||
}
|
||||
case WM_ERASEBKGND: // We handle this message to avoid flickering
|
||||
return TRUE;
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc = BeginPaint(hWnd, &ps);
|
||||
|
||||
//DOUBLE BUFFERING
|
||||
FillRect(g::hdcBuffer, &ps.rcPaint, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
||||
|
||||
|
||||
if (GetForegroundWindow() == hack::process->hwnd_) {
|
||||
hack::loop();
|
||||
}
|
||||
|
||||
BitBlt(hdc, 0, 0, screen_x, screen_y, g::hdcBuffer, 0, 0, SRCCOPY);
|
||||
|
||||
EndPaint(hWnd, &ps);
|
||||
InvalidateRect(hWnd, NULL, TRUE);
|
||||
break;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
DeleteDC(g::hdcBuffer);
|
||||
DeleteObject(g::hbmBuffer);
|
||||
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
SetConsoleTitle("cs2 external esp");
|
||||
SetConsoleTitle("cs2-external-esp");
|
||||
|
||||
std::shared_ptr<pProcess> process = std::make_shared<pProcess>();
|
||||
hack::process = std::make_shared<pProcess>();
|
||||
|
||||
std::cout << "[cs2] Waiting for cs2.exe..." << std::endl;
|
||||
|
||||
while (!process->AttachProcess("cs2.exe"))
|
||||
while (!hack::process->AttachProcess("cs2.exe"))
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
|
||||
std::cout << "[cs2] Attached to cs2.exe" << std::endl;
|
||||
|
||||
ProcessModule base_module;
|
||||
|
||||
do {
|
||||
base_module = process->GetModule("client.dll");
|
||||
if (base_module.base == 0) {
|
||||
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;
|
||||
}
|
||||
} while (base_module.base == 0);
|
||||
} while (hack::base_module.base == 0);
|
||||
|
||||
std::cout << "[overlay] Connecting to the process..." << std::endl;
|
||||
OverlayCord::Communication::ConnectedProcessInfo processInfo = { 0 };
|
||||
processInfo.ProcessId = process->pid_;
|
||||
std::cout << "[overlay] Creating window overlay..." << std::endl;
|
||||
|
||||
bool status = false;
|
||||
do {
|
||||
status = OverlayCord::Communication::ConnectToProcess(processInfo);
|
||||
if (!status) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
std::cout << "[overlay] Failed to connect to the process overlay backend" << std::endl;
|
||||
}
|
||||
} while (!status);
|
||||
WNDCLASSEXA wc = { 0 };
|
||||
wc.cbSize = sizeof(WNDCLASSEXA);
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.hbrBackground = WHITE_BRUSH;
|
||||
wc.hInstance = reinterpret_cast<HINSTANCE>(GetWindowLongA(hack::process->hwnd_, (-6))); // GWL_HINSTANCE));
|
||||
wc.lpszMenuName = " ";
|
||||
wc.lpszClassName = " ";
|
||||
|
||||
std::cout << "[overlay] Connected to the process with mapped address 0x" << processInfo.MappedAddress << std::endl;
|
||||
RegisterClassExA(&wc);
|
||||
|
||||
OverlayCord::Drawing::Frame mainFrame = OverlayCord::Drawing::CreateFrame(screen_x, screen_y);
|
||||
RECT gameBounds;
|
||||
GetClientRect(hack::process->hwnd_, &gameBounds);
|
||||
|
||||
OverlayCord::Drawing::Pixel enemy_color = { 75, 75, 175, 255 }; // BYTE B, G, R, A;
|
||||
OverlayCord::Drawing::Pixel team_color = { 75, 175, 75, 255 };
|
||||
// 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);
|
||||
|
||||
std::cout << "[cs2] Fully set up, running main loop now" << std::endl;
|
||||
if (hWnd == NULL)
|
||||
return 0;
|
||||
|
||||
while (!(GetAsyncKeyState(VK_END) & 0x8000)) {
|
||||
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
ShowWindow(hWnd, TRUE);
|
||||
SetActiveWindow(hack::process->hwnd_);
|
||||
|
||||
// Message loop
|
||||
MSG msg;
|
||||
while (!(GetAsyncKeyState(VK_END) & 0x8000) && GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
|
||||
uintptr_t localPlayer = process->read<uintptr_t>(base_module.base + dwLocalPlayer);
|
||||
|
||||
if (!localPlayer) continue;
|
||||
|
||||
int localTeam = process->read<int>(localPlayer + m_iTeamNum);
|
||||
|
||||
view_matrix_t view_matrix = process->read<view_matrix_t>(base_module.base + dwViewMatrix);
|
||||
|
||||
Vector3 localOrigin = process->read<Vector3>(localPlayer + m_vecOrigin);
|
||||
|
||||
OverlayCord::Drawing::CleanFrame(mainFrame);
|
||||
|
||||
uintptr_t entity_list = process->read<uintptr_t>(base_module.base + dwEntityList);
|
||||
|
||||
for (int i = 1; i < 32; i++) {
|
||||
uintptr_t list_entry = process->read<uintptr_t>(entity_list + (8 * (i & 0x7FFF) >> 9) + 16);
|
||||
if (!list_entry) continue;
|
||||
uintptr_t player = process->read<uintptr_t>(list_entry + 120 * (i & 0x1FF));
|
||||
|
||||
if (!player) continue;
|
||||
|
||||
int playerHealth = process->read<int>(player + dwPawnHealth);
|
||||
if (playerHealth < 0 || playerHealth > 100) continue;
|
||||
|
||||
int playerTeam = process->read<int>(player + m_iTeamNum);
|
||||
|
||||
// https://github.com/UnnamedZ03/CS2-external-base/blob/main/source/CSSPlayer.hpp#L132
|
||||
std::uint32_t playerpawn = process->read<std::uint32_t>(player + dwPlayerPawn);
|
||||
|
||||
uintptr_t list_entry2 = process->read<uintptr_t>(entity_list + 0x8 * ((playerpawn & 0x7FFF) >> 9) + 16);
|
||||
if (!list_entry2) continue;
|
||||
uintptr_t pCSPlayerPawn = process->read<uintptr_t>(list_entry2 + 120 * (playerpawn & 0x1FF));
|
||||
|
||||
if (pCSPlayerPawn == localPlayer) continue;
|
||||
|
||||
// https://github.com/UnnamedZ03/CS2-external-base/blob/main/source/CSSPlayer.hpp#L132
|
||||
Vector3 origin = process->read<Vector3>(pCSPlayerPawn + m_vecOrigin);
|
||||
|
||||
//if ((localOrigin - origin).length2d() > 1000) continue;
|
||||
|
||||
Vector3 head;
|
||||
head.x = origin.x;
|
||||
head.y = origin.y;
|
||||
head.z = origin.z + 75.f;
|
||||
|
||||
Vector3 screenpos = origin.world_to_screen(view_matrix);
|
||||
Vector3 screenhead = head.world_to_screen(view_matrix);
|
||||
|
||||
float height = screenpos.y - screenhead.y;
|
||||
float width = height / 2.4f;
|
||||
if (screenpos.z >= 0.01f) {
|
||||
OverlayCord::Drawing::Pixel health_color = { 75,
|
||||
(unsigned char)(55 + playerHealth * 2),
|
||||
(unsigned char)(255 - playerHealth),
|
||||
255
|
||||
};
|
||||
|
||||
OverlayCord::Drawing::DrawRectangle(
|
||||
mainFrame,
|
||||
screenhead.x - 25.f,
|
||||
screenhead.y,
|
||||
width,
|
||||
height,
|
||||
(localTeam == playerTeam ? team_color : enemy_color)
|
||||
);
|
||||
|
||||
OverlayCord::Drawing::DrawRectangle(
|
||||
mainFrame,
|
||||
screenhead.x - 30.f,
|
||||
screenhead.y + (height * (100 - playerHealth) / 100),
|
||||
2,
|
||||
height - (height * (100 - playerHealth) / 100),
|
||||
health_color
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
OverlayCord::Drawing::DrawCircle(mainFrame, 15, 15, i, enemy_color);
|
||||
|
||||
OverlayCord::Communication::SendFrame(processInfo, mainFrame.Width, mainFrame.Height, mainFrame.Buffer, mainFrame.Size);
|
||||
}
|
||||
|
||||
std::cout << "[overlay] Cleaning frame" << std::endl;
|
||||
OverlayCord::Drawing::CleanFrame(mainFrame);
|
||||
std::cout << "[overlay] Disconnecting from process" << std::endl;
|
||||
OverlayCord::Communication::DisconnectFromProcess(processInfo);
|
||||
std::cout << "[overlay] Destroying overlay window." << std::endl;
|
||||
DeleteDC(g::hdcBuffer);
|
||||
DeleteObject(g::hbmBuffer);
|
||||
|
||||
std::cout << "[cs2] Deataching from process" << std::endl;
|
||||
process->Close();
|
||||
hack::process->Close();
|
||||
|
||||
#ifdef NDEBUG
|
||||
std::cout << "[cs2] Press any key to close" << std::endl;
|
||||
std::cin.get();
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -79,8 +79,9 @@
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -94,10 +95,11 @@
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -111,6 +113,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -128,6 +131,7 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
@@ -135,8 +139,10 @@
|
||||
<ClCompile Include="memory\memory.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="classes\OverlayCord.h" />
|
||||
<ClInclude Include="classes\globals.hpp" />
|
||||
<ClInclude Include="classes\render.hpp" />
|
||||
<ClInclude Include="classes\vector.hpp" />
|
||||
<ClInclude Include="hacks\hack.hpp" />
|
||||
<ClInclude Include="memory\memory.hpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
||||
@@ -26,10 +26,16 @@
|
||||
<ClInclude Include="memory\memory.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="classes\OverlayCord.h">
|
||||
<ClInclude Include="classes\vector.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="classes\vector.hpp">
|
||||
<ClInclude Include="hacks\hack.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="classes\globals.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="classes\render.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user