[CS:GO] ESP Code [NEED HELP] Cheat not drawing ESP Boxes!

Posts 115 of 18 · Page 1 of 2
[CS:GO] ESP Code [NEED HELP] Cheat not drawing ESP Boxes!
Okay, so my code wont draw me the boxes.
And yes, i have updated the offsets but still cant get it to work

Win32 Console Application -> Console Application

I took some parts from fleeps code. So if this hack is working, credits to him.

process.h
Code:
#include <Windows.h>
#include <TlHelp32.h>
#include <iostream>
#include <conio.h>
#include <thread>
#include <stdio.h>
#include <string>
#include <sstream>
#include <math.h>  
#include <vector>
#include <algorithm> 
 
class CHackProcess
{
public:
 
    PROCESSENTRY32 __gameProcess;
    HANDLE __HandleProcess;
    HWND __HWNDCsgo;
    DWORD __dwordClient;
    DWORD __dwordEngine;
    DWORD __dwordOverlay;
    DWORD __dwordVGui;
    DWORD __dwordServer;
    DWORD __dwordLibCef;
    DWORD __dwordSteam;
    DWORD FindProcessName(const char *__ProcessName, PROCESSENTRY32 *pEntry)
    {
        PROCESSENTRY32 __ProcessEntry;
        __ProcessEntry.dwSize = sizeof(PROCESSENTRY32);
        HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
        if (hSnapshot == INVALID_HANDLE_VALUE) return 0;        if (!Process32First(hSnapshot, &__ProcessEntry))
        {
            CloseHandle(hSnapshot);
            return 0;
        }
        do{
            if (!_strcmpi(__ProcessEntry.szExeFile, __ProcessName))
            {
                memcpy((void *)pEntry, (void *)&__ProcessEntry, sizeof(PROCESSENTRY32));
                CloseHandle(hSnapshot);
                return __ProcessEntry.th32ProcessID;
            }
        } while (Process32Next(hSnapshot, &__ProcessEntry));
        CloseHandle(hSnapshot);
        return 0;
    }
 
    DWORD getThreadByProcess(DWORD __DwordProcess)
    {
        THREADENTRY32 __ThreadEntry;
        __ThreadEntry.dwSize = sizeof(THREADENTRY32);
        HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
        if (hSnapshot == INVALID_HANDLE_VALUE) return 0;
 
        if (!Thread32First(hSnapshot, &__ThreadEntry)) { CloseHandle(hSnapshot); return 0; }
 
        do {
            if (__ThreadEntry.th32OwnerProcessID == __DwordProcess)
            {
                CloseHandle(hSnapshot);
                return __ThreadEntry.th32ThreadID;
            }
        } while (Thread32Next(hSnapshot, &__ThreadEntry));
        CloseHandle(hSnapshot);
        return 0;
    }
 
    DWORD GetModuleNamePointer(LPSTR LPSTRModuleName, DWORD __DwordProcessId)
    {
        MODULEENTRY32 lpModuleEntry = { 0 };
        HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, __DwordProcessId);
        if (!hSnapShot)
            return NULL;
        lpModuleEntry.dwSize = sizeof(lpModuleEntry);
        BOOL __RunModule = Module32First(hSnapShot, &lpModuleEntry);
        while (__RunModule)
        {
            if (!strcmp(lpModuleEntry.szModule, LPSTRModuleName))
            {
                CloseHandle(hSnapShot);
                return (DWORD)lpModuleEntry.modBaseAddr;
            }
            __RunModule = Module32Next(hSnapShot, &lpModuleEntry);
        }
        CloseHandle(hSnapShot);
        return NULL;
    }
 
    void runSetDebugPrivs()
    {
        HANDLE __HandleProcess = GetCurrentProcess(), __HandleToken;
        TOKEN_PRIVILEGES priv;
        LUID __LUID;
        OpenProcessToken(__HandleProcess, TOKEN_ADJUST_PRIVILEGES, &__HandleToken);
        LookupPrivilegeValue(0, "seDebugPrivilege", &__LUID);
        priv.PrivilegeCount = 1;
        priv.Privileges[0].Luid = __LUID;
        priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
        AdjustTokenPrivileges(__HandleToken, false, &priv, 0, 0, 0);
        CloseHandle(__HandleToken);
        CloseHandle(__HandleProcess);
    }
 
    void RunProcess()
    {
        runSetDebugPrivs();
        while (!FindProcessName("csgo.exe", &__gameProcess)) Sleep(12);
        while (!(getThreadByProcess(__gameProcess.th32ProcessID))) Sleep(12);
        __HandleProcess = OpenProcess(PROCESS_ALL_ACCESS, false, __gameProcess.th32ProcessID);
        while (__dwordClient == 0x0) __dwordClient = GetModuleNamePointer("client.dll", __gameProcess.th32ProcessID);
        while (__dwordEngine == 0x0) __dwordEngine = GetModuleNamePointer("engine.dll", __gameProcess.th32ProcessID);
        while (__dwordVGui == 0x0) __dwordVGui = GetModuleNamePointer("vguimatsurface.dll", __gameProcess.th32ProcessID);
        while (__dwordServer == 0x0)__dwordServer = GetModuleNamePointer("server.dll", __gameProcess.th32ProcessID);
        __HWNDCsgo = FindWindow(NULL, "Counter-Strike: Global Offensive");
    }
};
 
extern CHackProcess fProcess;
pesp.cpp
Code:
#include <Windows.h>
#include <TlHelp32.h>
#include <iostream>
#include <conio.h>
#include <thread>
#include <stdio.h>
#include <string>
#include <sstream>
#include <math.h>  
#include <vector>
#include <algorithm> 
#include "process.h"
 
CHackProcess fProcess;
using namespace std;
 
#define F6_Key 0x75
#define RIGHT_MOUSE 0x02
 
DWORD EntityPlayer_Base = 0x4A13284;
DWORD EntityLoopDistance = 0x10;
DWORD Player_Base = 0xA7094C;
DWORD dw_chIDoffset = 0x23F8;
DWORD dw_flagOffset = 0x100;
DWORD dw_mTeamOffset = 0xF0;
DWORD dw_Health = 0xFC;
DWORD dw_isDefusing = 0x1C00; //bool
DWORD dw_WeaponID = 0x12C0;
DWORD dw_ActiveWeapon = 0x1684;
DWORD dw_Pos = 0x134;
int dw_numberOfActivePlayers = 10;
int NumofPlayers = 10;
 
RECT m_Rect;
HDC HDC_Desktop;
HBRUSH EnemyBrush;
HFONT Font;
 
HWND TargetWnd;
HWND Handle;
DWORD DwProcId;
 
COLORREF SnapLineCOLOR;
COLORREF TextCOLOR;
 
typedef struct
{
    float flMatrix[4][4];
}WorldToScreenMatrix_t;
 
float Get3dDistance(float * myCoords, float * enemyCoords)
{
    return sqrt(
        pow(double(enemyCoords[0] - myCoords[0]), 2.0) +
        pow(double(enemyCoords[1] - myCoords[1]), 2.0) +
        pow(double(enemyCoords[2] - myCoords[2]), 2.0));
 
}
 
 
void SetupDrawing(HDC hDesktop, HWND handle)
{
    HDC_Desktop = hDesktop;
    Handle = handle;
    EnemyBrush = CreateSolidBrush(RGB(255, 0, 0));
    //Color
    SnapLineCOLOR = RGB(0, 0, 255);
    TextCOLOR = RGB(0, 255, 0);
}
 
 
struct MyPlayer_t
{
    DWORD CLocalPlayer;
    int Team;
    int Health;
    WorldToScreenMatrix_t WorldToScreenMatrix;
    float Position[3];
    void ReadInformation()
    {
        ReadProcessMemory(fProcess.__HandleProcess, (PBYTE*)(fProcess.__dwordClient + Player_Base), &CLocalPlayer, sizeof(DWORD), 0);
        ReadProcessMemory(fProcess.__HandleProcess, (PBYTE*)(CLocalPlayer + dw_mTeamOffset), &Team, sizeof(int), 0);   
        ReadProcessMemory(fProcess.__HandleProcess, (PBYTE*)(CLocalPlayer + dw_Health), &Health, sizeof(int), 0); 
        ReadProcessMemory(fProcess.__HandleProcess, (PBYTE*)(CLocalPlayer + dw_Pos), &Position, sizeof(float[3]), 0);
    }
}MyPlayer;
 
struct PlayerList_t
{
    DWORD CBaseEntity;
    int Team;
    int Health;
    float Position[3];
 
    void ReadInformation(int Player)
    {
        ReadProcessMemory(fProcess.__HandleProcess, (PBYTE*)(fProcess.__dwordClient + EntityPlayer_Base + (Player * EntityLoopDistance)), &CBaseEntity, sizeof(DWORD), 0);
        ReadProcessMemory(fProcess.__HandleProcess, (PBYTE*)(CBaseEntity + dw_mTeamOffset), &Team, sizeof(int), 0);   
        ReadProcessMemory(fProcess.__HandleProcess, (PBYTE*)(CBaseEntity + dw_Health), &Health, sizeof(int), 0);
        ReadProcessMemory(fProcess.__HandleProcess, (PBYTE*)(CBaseEntity + dw_Pos), &Position, sizeof(float[3]), 0);
    }
}PlayerList[10];
 
 
bool WorldToScreen(float * from, float * to)
{
    float w = 0.0f;
 
    to[0] = MyPlayer.WorldToScreenMatrix.flMatrix[0][0] * from[0] + MyPlayer.WorldToScreenMatrix.flMatrix[0][1] * from[1] + MyPlayer.WorldToScreenMatrix.flMatrix[0][2] * from[2] + MyPlayer.WorldToScreenMatrix.flMatrix[0][3];
    to[1] = MyPlayer.WorldToScreenMatrix.flMatrix[1][0] * from[0] + MyPlayer.WorldToScreenMatrix.flMatrix[1][1] * from[1] + MyPlayer.WorldToScreenMatrix.flMatrix[1][2] * from[2] + MyPlayer.WorldToScreenMatrix.flMatrix[1][3];
    w = MyPlayer.WorldToScreenMatrix.flMatrix[3][0] * from[0] + MyPlayer.WorldToScreenMatrix.flMatrix[3][1] * from[1] + MyPlayer.WorldToScreenMatrix.flMatrix[3][2] * from[2] + MyPlayer.WorldToScreenMatrix.flMatrix[3][3];
 
    if (w < 0.01f)
        return false;
 
    float invw = 1.0f / w;
 
    to[0] *= invw;
    to[1] *= invw;
 
    int width = (int)(m_Rect.right - m_Rect.left);
    int height = (int)(m_Rect.bottom - m_Rect.top);
 
    float x = width / 2;
    float y = height / 2;
 
    x += 0.5 * to[0] * width + 0.5;
    y -= 0.5 * to[1] * height + 0.5;
 
    to[0] = x + m_Rect.left;
    to[1] = y + m_Rect.top;
 
    return true;
}
 
 
void DrawFilledRect(int x, int y, int w, int h)
{
    RECT rect = { x, y, x + w, y + h };
    FillRect(HDC_Desktop, &rect, EnemyBrush);
}
 
 
void DrawBorderBox(int x, int y, int w, int h, int thickness)
{
    DrawFilledRect(x, y, w, thickness);
    DrawFilledRect(x, y, thickness, h);
    DrawFilledRect((x + w), y, thickness, h);
    DrawFilledRect(x, y + h, w + thickness, thickness);
}
 
 
void DrawLine(float StartX, float StartY, float EndX, float EndY, COLORREF Pen)
{
    int a, b = 0;
    HPEN hOPen;
    HPEN hNPen = CreatePen(PS_SOLID, 2, Pen);
    hOPen = (HPEN)SelectObject(HDC_Desktop, hNPen);
    MoveToEx(HDC_Desktop, StartX, StartY, NULL);
    a = LineTo(HDC_Desktop, EndX, EndY);
    DeleteObject(SelectObject(HDC_Desktop, hOPen));
}
 
 
void DrawString(int x, int y, COLORREF color, const char* text)
{
    SetTextAlign(HDC_Desktop, TA_CENTER | TA_NOUPDATECP);
 
    SetBkColor(HDC_Desktop, RGB(0, 0, 0));
    SetBkMode(HDC_Desktop, TRANSPARENT);
 
    SetTextColor(HDC_Desktop, color);
 
    SelectObject(HDC_Desktop, Font);
 
    TextOutA(HDC_Desktop, x, y, text, strlen(text));
 
    DeleteObject(Font);
}
 
 
void DrawESP(int x, int y, float distance)
{
    //ESP RECTANGLE
    int width = 18100 / distance;
    int height = 36000 / distance;
    DrawBorderBox(x - (width / 2), y - height, width, height, 1);
 
    //Sandwich ++
    DrawLine((m_Rect.right - m_Rect.left) / 2,
        m_Rect.bottom - m_Rect.top, x, y,
        SnapLineCOLOR);
 
 
}
 
void ESP()
{
    GetWindowRect(FindWindow(NULL, "Counter-Strike Global Offensive"), &m_Rect);
 
    for (int i = 0; i < NumofPlayers; i++)
    {
        PlayerList[i].ReadInformation(i);
 
        if (PlayerList[i].Health < 2)
            continue;
 
 
        float EnemyXY[3];
            if (WorldToScreen(PlayerList[i].Position, EnemyXY))
            {
                DrawESP(EnemyXY[0] - m_Rect.left, EnemyXY[1] - m_Rect.top, Get3dDistance(MyPlayer.Position, PlayerList[i].Position));
            }
 
    }
 
}
 
struct GlowObjectDefinition_t
{
    void* pEntity;
    float r;
    float g;
    float b;
    float a;
    uint8_t unk1[16];
    bool m_bRenderWhenOccluded;
    bool m_bRenderWhenUnoccluded;
    bool m_bFullBloom;
    uint8_t unk2[10];
};
 
 
int main()
{
    fProcess.RunProcess();
    ShowWindow(FindWindowA("ConsoleWindowClass", NULL), false);
    TargetWnd = FindWindow(0, "Counter-Strike Global Offensive");
    HDC HDC_Desktop = GetDC(TargetWnd);
    SetupDrawing(HDC_Desktop, TargetWnd);
 
 
 
    while (!GetAsyncKeyState(0x75))
        {
            MyPlayer.ReadInformation();
            ESP();
        }
    return 0;
}
Quote Originally Posted by viking911 View Post
~thread
The code is messy and wierd to read, but I found a problem:

Code:
int NumofPlayers = 10;
Here is where things start to go wrong (I haven't looked much at other rpm etc stuff), you only iterate
through 10 entities, usually that will not be enough to get all the players.

Code:
for (int i = 0; i < NumofPlayers; i++)
    {
        PlayerList[i].ReadInformation(i);
 
        if (PlayerList[i].Health < 2)
            continue;
 
 
        float EnemyXY[3];
            if (WorldToScreen(PlayerList[i].Position, EnemyXY))
            {
                DrawESP(EnemyXY[0] - m_Rect.left, EnemyXY[1] - m_Rect.top, Get3dDistance(MyPlayer.Position, PlayerList[i].Position));
            }
 
    }
Which means that this code basically does nothing, maybe you'll get 1 player if you're lucky.

This is because each entity in the game is spaced out, the distance between each entity is often called EntityLoopDistance, which I see you've named it, but this is between every entity in the game, so basically the only entities you get from that iteration are boxes/chickens and if you're lucky a player, you should always iterate through at least 64 entities.

PM me if you need any more help after this.

oh and, this is basically fleeps code, not just some parts lol
Quote Originally Posted by Yemiez View Post
The code is messy and wierd to read, but I found a problem:

Code:
int NumofPlayers = 10;
Here is where things start to go wrong (I haven't looked much at other rpm etc stuff), you only iterate
through 10 entities, usually that will not be enough to get all the players.

Code:
for (int i = 0; i < NumofPlayers; i++)
    {
        PlayerList[i].ReadInformation(i);
 
        if (PlayerList[i].Health < 2)
            continue;
 
 
        float EnemyXY[3];
            if (WorldToScreen(PlayerList[i].Position, EnemyXY))
            {
                DrawESP(EnemyXY[0] - m_Rect.left, EnemyXY[1] - m_Rect.top, Get3dDistance(MyPlayer.Position, PlayerList[i].Position));
            }
 
    }
Which means that this code basically does nothing, maybe you'll get 1 player if you're lucky.

This is because each entity in the game is spaced out, the distance between each entity is often called EntityLoopDistance, which I see you've named it, but this is between every entity in the game, so basically the only entities you get from that iteration are boxes/chickens and if you're lucky a player, you should always iterate through at least 64 entities.

PM me if you need any more help after this.

oh and, this is basically fleeps code, not just some parts lol
Yes this is fleeps code, you got to start somewhere with ESP coding xaxaxaxaxa

~Knug
Quote Originally Posted by Yemiez View Post
The code is messy and wierd to read, but I found a problem:

Code:
int NumofPlayers = 10;
Here is where things start to go wrong (I haven't looked much at other rpm etc stuff), you only iterate
through 10 entities, usually that will not be enough to get all the players.

Code:
for (int i = 0; i < NumofPlayers; i++)
    {
        PlayerList[i].ReadInformation(i);
 
        if (PlayerList[i].Health < 2)
            continue;
 
 
        float EnemyXY[3];
            if (WorldToScreen(PlayerList[i].Position, EnemyXY))
            {
                DrawESP(EnemyXY[0] - m_Rect.left, EnemyXY[1] - m_Rect.top, Get3dDistance(MyPlayer.Position, PlayerList[i].Position));
            }
 
    }
Which means that this code basically does nothing, maybe you'll get 1 player if you're lucky.

This is because each entity in the game is spaced out, the distance between each entity is often called EntityLoopDistance, which I see you've named it, but this is between every entity in the game, so basically the only entities you get from that iteration are boxes/chickens and if you're lucky a player, you should always iterate through at least 64 entities.

PM me if you need any more help after this.

oh and, this is basically fleeps code, not just some parts lol

I've tried Fleep's code and a few others' using GetDC() method to draw. However, CSGO window covers the HDC drawing, rendering my drawing invisible. My drawing is only visible for a split second when I tab in/out CSGO. Any suggestions?
Quote Originally Posted by alpc View Post
I've tried Fleep's code and a few others' using GetDC() method to draw. However, CSGO window covers the HDC drawing, rendering my drawing invisible. My drawing is only visible for a split second when I tab in/out CSGO. Any suggestions?
Run CS:GO in fullscreen windowed?

Also, thanks for resurrecting this thread, we needed it.
Is this your whole code?

Where do you set WorldToScreenMatrix?
Quote Originally Posted by hhs36 View Post
Is this your whole code?

Where do you set WorldToScreenMatrix?
Read the codenz and you'll find it.

Or you could do some l33t hax1n and press CTRL + F and search for it lol
Where to i put the code like in what folder so it will start working
Quote Originally Posted by Supor88 View Post
Where to i put the code like in what folder so it will start working
Go away, we dont want you here.
Quote Originally Posted by viking911 View Post
Yes this is fleeps code, you got to start somewhere with ESP coding xaxaxaxaxa

~Knug
Just increment i from 1 to 64, the list doesn't go any higher.

Quote Originally Posted by Yemiez View Post
Go away, we dont want you here.
Ahh.. you need to be a special kind of person to leech broken code.
Quote Originally Posted by Blueblood1 View Post
Just increment i from 1 to 64, the list doesn't go any higher

Ahh.. you need to be a special kind of person to leech broken code.
Your first statement:
I already told him that.

Second statement:
No, he asked for help, I dont care what code he is using, he asked for help not for people to come and be dickheads.
Quote Originally Posted by Yemiez View Post
Your first statement:
I already told him that.

Second statement:
No, he asked for help, I dont care what code he is using, he asked for help not for people to come and be dickheads.
Apply some water on the burnt area
Quote Originally Posted by Yemiez View Post
Your first statement:
I already told him that.

Second statement:
No, he asked for help, I dont care what code he is using, he asked for help not for people to come and be dickheads.
I wasn't poking fun at the OP, i tried to help him, I was mocking the guy who came here and asked where to put the code.
Also you never mentioned that EntityList doesn't go above 64, you just said he should do at least 64, even tho there is no reason to go above it. I'm only a dick to people who either complete retards or are dicks themselves.
Quote Originally Posted by Blueblood1 View Post
I wasn't poking fun at the OP, i tried to help him, I was mocking the guy who came here and asked where to put the code.
Also you never mentioned that EntityList doesn't go above 64, you just said he should do at least 64, even tho there is no reason to go above it. I'm only a dick to people who either complete retards or are dicks themselves.
Fair enough, but yes there is no need to go above 64 hence why I took that for an example, but if you want other entities (for some reason lol :P) you may want to iterate through more ones.
Also now when looking back at this, I dont even know what I thought was badly said from you >_>
lol, have a nice day anyway :P
Hey ,what sometimes helps when it comes to debugging any piece of software is to test each function involved in the process that is not working. So for example, if you had no idea what would be causing your error, check to see if you can even draw anything. Then see if any functions are being called by adding a debug message to yourself. Sometimes when people learn from other code, they don't completely understand the control structure or flow of the program making it harder to debug. But when it comes to programming it is very rare that everything works correctly on the first compile. The fun of coding is debugging lol.
Posts 115 of 18 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?