Code:
#include "stdafx.h"
// _____________________________________________________________________________________________________________________________
//| |
//| This file defines struct functions that belong to Toolbox.h. If you don't know what this means, you should go figure it out.|
//|_____________________________________________________________________________________________________________________________|
//
//Local vars
#pragma region LocalVars
string Settingspath = "C:\\ESP3\\offsets.ini";
DWORD DwVm = 0x49E06A4;
DWORD DwEntityList = 0x49EB114;
DWORD DwLocalPlayer = 0xA499BC;
const DWORD DwHealth = 0xFC;
const DWORD DwVecOrigin = 0x134;
const DWORD DwTeamNumber = 0xF0;
const DWORD DwEntitySize = 0x10;
const DWORD DwLifeState = 0x25B;
const DWORD DwBoneMatrix = 0xA78;
const DWORD DwVecViewOrigin = 0x104;
const DWORD DwVecPunch = 0x13DC;
int Llegbones[4] = { 28, 27, 26, 0 };
int Rlegbones[4] = { 25, 24, 23, 0 };
int Spinebones[7] = { 0, 1, 2, 3, 4, 5, 10};
int Larmbones[4] = { 9, 8, 7, 6 };
int Rarmbones[4] = { 15, 14, 13, 12 };
#pragma endregion
#pragma region ProcessFunctions
//enable SE_DEBUG_PRIVILEGE
void ProcessFunctions::EnableDebugPriv()
{
HANDLE HTOKEN;
LUID LUID;
TOKEN_PRIVILEGES TOKEN_PRIV;
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &HTOKEN);
LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &LUID);
TOKEN_PRIV.PrivilegeCount = 1;
TOKEN_PRIV.Privileges[0].Luid = LUID;
TOKEN_PRIV.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(HTOKEN, false, &TOKEN_PRIV, sizeof(TOKEN_PRIV), NULL, NULL);
CloseHandle(HTOKEN);
}
//get module handle
//NOTICE: THIS FUNCTION USES TCHAR, IF _UNICODE IS UNDEFINED, IT WILL NOT WORK. MAKE SURE YOUR APPLICATION IS SET TO USE UNICODE.
DWORD ProcessFunctions::GetModuleHandleByName(wchar_t* ModuleName, DWORD ProcID)
{
MODULEENTRY32 ENTRY;
ENTRY.dwSize = sizeof(MODULEENTRY32);
HANDLE HSNAP = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcID);
if (Module32First(HSNAP, &ENTRY) == TRUE)
{
if (!_wcsicmp(ENTRY.szModule, ModuleName))
{
DWORD HMODULE = (DWORD)ENTRY.modBaseAddr;
return HMODULE;
}
else
{
while (Module32Next(HSNAP, &ENTRY) == TRUE)
{
if (!_wcsicmp(ENTRY.szModule, ModuleName))
{
DWORD HMODULE = (DWORD)ENTRY.modBaseAddr;
return HMODULE;
}
}
return 0;
}
}
CloseHandle(HSNAP);
}
//get process handle
//NOTICE: THIS FUNCTION USES TCHAR, IF _UNICODE IS UNDEFINED, IT WILL NOT WORK. MAKE SURE YOUR APPLICATION IS SET TO USE UNICODE.
HANDLE ProcessFunctions::GetProcessHandleByName(wchar_t* ProcessName)
{
PROCESSENTRY32 ENTRY;
ENTRY.dwSize = sizeof(PROCESSENTRY32);
HANDLE HSNAP = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if (Process32First(HSNAP, &ENTRY) == TRUE)
{
if (!_wcsicmp(ENTRY.szExeFile, ProcessName))
{
HANDLE HPROC = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ENTRY.th32ProcessID);
return HPROC;
}
else
{
while (Process32Next(HSNAP, &ENTRY) == TRUE)
{
if (!_wcsicmp(ENTRY.szExeFile, ProcessName))
{
HANDLE HPROC = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ENTRY.th32ProcessID);
return HPROC;
}
}
return 0;
}
}
CloseHandle(HSNAP);
}
//read settings file
bool ProcessFunctions::ReadSettingsFile(string* data)
{
ifstream read;
if (ifstream(Settingspath))
{
read.open(Settingspath);
string linedata;
int currentline = 1;
while (!read.eof())
{
getline(read, linedata);
data[currentline] = linedata;
currentline++;
}
read.close();
return true;
}
else
{
return false;
}
}
//convert and set settings
void ProcessFunctions::ParseSettings(string* data)
{
data[1] = data[1].substr(data[1].find("=") + 1); //Viewmatrix
data[2] = data[2].substr(data[2].find("=") + 1); //Entitylist
data[3] = data[3].substr(data[3].find("=") + 1); //Localplayer
DwVm = strtol(data[1].c_str(), 0, 0);
DwEntityList = strtol(data[2].c_str(), 0, 0);
DwLocalPlayer = strtol(data[3].c_str(), 0, 0);
}
//read settings file and parse settings
bool ProcessFunctions::ReadSettings()
{
string settings[16];
if (ReadSettingsFile(settings))
{
ParseSettings(settings);
return true;
}
else
{
MessageBox(0, L"No settings file found!", L"Error", MB_ICONERROR | MB_OK);
return false;
}
}
#pragma endregion
#pragma region MemoryFunctions
//RPM wrapper
template <typename ReadType> ReadType MemoryFunctions::Read(DWORD Address)
{
ReadType Data;
if (ReadProcessMemory(TargetProcess, (LPVOID)(Address), &Data, sizeof(ReadType), 0))
{
return Data;
}
}
#pragma endregion
#pragma region PlayerFunctions
//read address of local player
DWORD PlayerFunctions::GetPlayerBase()
{
if (DwClient)
{
return MemoryToolbox.Read<DWORD>(DwClient + DwLocalPlayer);
}
else
{
return 0;
}
}
//read game coords of local player
Vec3_t PlayerFunctions::GetPosition(DWORD PlayerBase)
{
if (PlayerBase)
{
return MemoryToolbox.Read<Vec3_t>(PlayerBase + DwVecOrigin);
}
else
{
return{0};
}
}
//read team id of local player
int PlayerFunctions::GetTeam(DWORD PlayerBase)
{
if (PlayerBase)
{
return MemoryToolbox.Read<int>(PlayerBase + DwTeamNumber);
}
else
{
return 0;
}
}
Vec3_t PlayerFunctions::GetPunchAngs(DWORD PlayerBase)
{
if (PlayerBase)
{
return MemoryToolbox.Read<Vec3_t>(PlayerBase + DwVecPunch);
}
else
{
return{ 0 };
}
}
//read and store all local player info
Player_t PlayerFunctions::GetLocalPlayer()
{
Player_t Player;
Player.Valid = true;
Player.PlayerBase = PlayerToolbox.GetPlayerBase();
if (Player.PlayerBase)
{
Player.Team = PlayerToolbox.GetTeam(Player.PlayerBase);
Player.VecOrigin = PlayerToolbox.GetPosition(Player.PlayerBase);
Player.PunchAngs = PlayerToolbox.GetPunchAngs(Player.PlayerBase);
}
else
{
Player.Valid = false;
}
return Player;
}
#pragma endregion
#pragma region EntityFunctions
//read entity base address
DWORD EntityFunctions::GetBaseEntity(int PlayerNumber)
{
if (DwClient)
{
return MemoryToolbox.Read<DWORD>(DwClient + DwEntityList + (DwEntitySize * PlayerNumber));
}
else
{
return 0;
}
}
//ghetto check for valid bones. if the origin is more than 45 units away from the right foot, the skeleton is broken
bool EntityFunctions::ValidateBones(Entity_t Ent)
{
if (MiscToolbox.get3ddist(Ent.Skeleton.Rleg.bonepos3[0], Ent.VecOrigin) > 45.f)
{
return false;
}
else
{
return true;
}
}
//check if the entity is alive
bool EntityFunctions::IsDead(DWORD BaseEntity)
{
if (BaseEntity)
{
return MemoryToolbox.Read<bool>(BaseEntity + DwLifeState);
}
else
{
return 0;
}
}
//read game coords of entity
Vec3_t EntityFunctions::GetVecOrigin(DWORD BaseEntity)
{
if (BaseEntity)
{
return MemoryToolbox.Read<Vec3_t>(BaseEntity + DwVecOrigin);
}
else
{
return{0};
}
}
//read entity team id
int EntityFunctions::GetTeam(DWORD BaseEntity)
{
if (BaseEntity)
{
return MemoryToolbox.Read<int>(BaseEntity + DwTeamNumber);
}
else
{
return 0;
}
}
int EntityFunctions::GetHealth(DWORD BaseEntity)
{
if (BaseEntity)
{
return MemoryToolbox.Read<int>(BaseEntity + DwHealth);
}
else
{
return 0;
}
}
//read address of entity's bone matrix
DWORD EntityFunctions::GetBoneMatrix(DWORD BaseEntity)
{
if (BaseEntity)
{
return MemoryToolbox.Read<DWORD>(BaseEntity + DwBoneMatrix);
}
else
{
return 0;
}
}
//read game coords of a bone
Vec3_t EntityFunctions::GetBonePos(DWORD Bmatrix, int TargetBone)////
{
if (Bmatrix)
{
Vec3_t temp;
temp.x = MemoryToolbox.Read<float>(Bmatrix + 0x30 * TargetBone + 0x0C);
temp.y = MemoryToolbox.Read<float>(Bmatrix + 0x30 * TargetBone + 0x1C);
temp.z = MemoryToolbox.Read<float>(Bmatrix + 0x30 * TargetBone + 0x2C);
return temp;
}
else
{
return{0};
}
}
//read and store all bone positions
Skeleton_t EntityFunctions::GetSkeleton(DWORD BaseEntity)
{
Skeleton_t Skeleton;
DWORD BoneMatrix = EntityToolbox.GetBoneMatrix(BaseEntity);
if (BoneMatrix)
{
Skeleton.Broken = false;
//Left leg; loop 4 times for each bone
for (int i = 0; i < 4; i++)
{
Skeleton.Lleg.bonepos3[i] = EntityToolbox.GetBonePos(BoneMatrix, Llegbones[i]);
if (!Skeleton.Lleg.bonepos3[i].x || !Skeleton.Lleg.bonepos3[i].y || !Skeleton.Lleg.bonepos3[i].z)
{
Skeleton.Broken = true;
}
}
//Right leg; loop 4 times for each bone
for (int i = 0; i < 4; i++)
{
Skeleton.Rleg.bonepos3[i] = EntityToolbox.GetBonePos(BoneMatrix, Rlegbones[i]);
if (!Skeleton.Rleg.bonepos3[i].x || !Skeleton.Rleg.bonepos3[i].y || !Skeleton.Rleg.bonepos3[i].z)
{
Skeleton.Broken = true;
}
}
//Spine; loop 7 times for each bone
for (int i = 0; i < 7; i++)
{
Skeleton.Spine.bonepos3[i] = EntityToolbox.GetBonePos(BoneMatrix, Spinebones[i]);
if (!Skeleton.Spine.bonepos3[i].x || !Skeleton.Spine.bonepos3[i].y || !Skeleton.Spine.bonepos3[i].z)
{
Skeleton.Broken = true;
}
}
//Left arm; loop 4 times for each bone
for (int i = 0; i < 4; i++)
{
Skeleton.Larm.bonepos3[i] = EntityToolbox.GetBonePos(BoneMatrix, Larmbones[i]);
if (!Skeleton.Larm.bonepos3[i].x || !Skeleton.Larm.bonepos3[i].y || !Skeleton.Larm.bonepos3[i].z)
{
Skeleton.Broken = true;
}
}
//Right arm; loop 4 times for each bone
for (int i = 0; i < 4; i++)
{
Skeleton.Rarm.bonepos3[i] = EntityToolbox.GetBonePos(BoneMatrix, Rarmbones[i]);
if (!Skeleton.Rarm.bonepos3[i].x || !Skeleton.Rarm.bonepos3[i].y || !Skeleton.Rarm.bonepos3[i].z)
{
Skeleton.Broken = true;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//w2s bones
if (!Skeleton.Broken)
{
//Left leg; loop 4 times for each bone
for (int i = 0; i < 4; i++)
{
W2Sstruct_t BoneScreenPos = MiscToolbox.w2s(Skeleton.Lleg.bonepos3[i]);
if (!BoneScreenPos.OnScreen)
{
Skeleton.Broken = true;
}
Skeleton.Lleg.bonepos2[i] = BoneScreenPos.Coords;
}
//Right leg; loop 4 times for each bone
for (int i = 0; i < 4; i++)
{
W2Sstruct_t BoneScreenPos = MiscToolbox.w2s(Skeleton.Rleg.bonepos3[i]);
if (!BoneScreenPos.OnScreen)
{
Skeleton.Broken = true;
}
Skeleton.Rleg.bonepos2[i] = BoneScreenPos.Coords;
}
//Spine; loop 7 times for each bone
for (int i = 0; i < 7; i++)
{
W2Sstruct_t BoneScreenPos = MiscToolbox.w2s(Skeleton.Spine.bonepos3[i]);
if (!BoneScreenPos.OnScreen)
{
Skeleton.Broken = true;
}
Skeleton.Spine.bonepos2[i] = BoneScreenPos.Coords;
}
//Left arm; loop 4 times for each bone
for (int i = 0; i < 4; i++)
{
W2Sstruct_t BoneScreenPos = MiscToolbox.w2s(Skeleton.Larm.bonepos3[i]);
if (!BoneScreenPos.OnScreen)
{
Skeleton.Broken = true;
}
Skeleton.Larm.bonepos2[i] = BoneScreenPos.Coords;
}
//Right arm; loop 4 times for each bone
for (int i = 0; i < 4; i++)
{
W2Sstruct_t BoneScreenPos = MiscToolbox.w2s(Skeleton.Rarm.bonepos3[i]);
if (!BoneScreenPos.OnScreen)
{
Skeleton.Broken = true;
}
Skeleton.Rarm.bonepos2[i] = BoneScreenPos.Coords;
}
}
}
else
{
Skeleton.Broken = true;
}
return Skeleton;
}
//read and store all entity info
Entity_t EntityFunctions::GetEntity(int PlayerNumber)
{
Entity_t Entity;
Entity.Skeleton.Broken = false;
Entity.Valid = true;
Entity.BaseAddr = EntityToolbox.GetBaseEntity(PlayerNumber);
if (Entity.BaseAddr)
{
Entity.IsDead = EntityToolbox.IsDead(Entity.BaseAddr);
if (!Entity.IsDead)
{
Entity.Team = EntityToolbox.GetTeam(Entity.BaseAddr);
Entity.Health = EntityToolbox.GetHealth(Entity.BaseAddr);
Entity.Skeleton = EntityToolbox.GetSkeleton(Entity.BaseAddr);
Entity.VecOrigin = EntityToolbox.GetVecOrigin(Entity.BaseAddr);
}
else
{
Entity.Skeleton.Broken = true;
}
}
else
{
Entity.Valid = false;
}
return Entity;
}
#pragma endregion
#pragma region MiscFunctions
//get game coord distance between 2 game coords
float MiscFunctions::get3ddist(Vec3_t myCoords, Vec3_t enemyCoords)
{
return sqrt(
pow(double(enemyCoords.x - myCoords.x), 2.0) +
pow(double(enemyCoords.y - myCoords.y), 2.0) +
pow(double(enemyCoords.z - myCoords.z), 2.0));
}
//read world to screem matrix
W2SMatrix_t MiscFunctions::GetW2S()
{
if (DwClient)
{
return MemoryToolbox.Read<W2SMatrix_t>(DwClient + DwVm);
}
}
//check if game coords are on screen and return w2sstruct
W2Sstruct_t MiscFunctions::w2s(Vec3_t from)
{
W2Sstruct_t W2Sstruct;
W2SMatrix_t w2sm = MiscToolbox.GetW2S();
if (w2sm.Matrixf)
{
W2Sstruc*****ords.x = w2sm.Matrixf[0][0] * from.x + w2sm.Matrixf[0][1] * from.y + w2sm.Matrixf[0][2] * from.z + w2sm.Matrixf[0][3];
W2Sstruc*****ords.y = w2sm.Matrixf[1][0] * from.x + w2sm.Matrixf[1][1] * from.y + w2sm.Matrixf[1][2] * from.z + w2sm.Matrixf[1][3];
float w = w2sm.Matrixf[3][0] * from.x + w2sm.Matrixf[3][1] * from.y + w2sm.Matrixf[3][2] * from.z + w2sm.Matrixf[3][3];
if (w > 0.01f)
{
float invw = 1.0f / w;
W2Sstruc*****ords.x *= invw;
W2Sstruc*****ords.y *= invw;
float x = SWidth / 2.f;
float y = SHeight / 2.f;
x += 0.5 * W2Sstruc*****ords.x * SWidth + 0.5;
y -= 0.5 * W2Sstruc*****ords.y * SHeight + 0.5;
W2Sstruc*****ords.x = x + ClientRect.left;
W2Sstruc*****ords.y = y + ClientRect.top;
W2Sstruct.OnScreen = true;
}
else
{
W2Sstruct.OnScreen = false;
}
}
else
{
W2Sstruct.OnScreen = false;
}
return W2Sstruct;
}
#pragma endregion
dllmain.cpp:
Code:
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
//global vars
#pragma region GlobalVars
//100 refreshes per/sec, ie. 100fps
int WRefreshRate = (1000 / 100);
//Wait inbetween memory reads
int MemorySleep = 1;
HWND GameHWND;
HWND EspHWND;
LPCWSTR WName = L"Overlay 0.0.2";
HDC MainHDC;
HGLRC MainHGLRC;
HPALETTE MainPalette;
RECT WindowRect;
RECT ClientRect;
float SWidth;
float SHeight;
HANDLE TargetProcess;
HINSTANCE CurrentInstance;
DWORD DwClient;
ProcessFunctions ProcessToolbox;
MemoryFunctions MemoryToolbox;
EntityFunctions EntityToolbox;
PlayerFunctions PlayerToolbox;
MiscFunctions MiscToolbox;
EnityInfo_t EnityList;
PlayerInfo_t PlayerInfo;
bool ALLESP = true;
bool KILLALL = false;
bool SNAPS = true;
bool BOX = true;
bool BONES = true;
bool HBAR = true;
bool CROSS = true;
#pragma endregion
//resize and reposition window
void ResizeWindow()
{
//get physical window bounds
GetWindowRect(GameHWND, &WindowRect);
//get logical client bounds
GetClientRect(GameHWND, &ClientRect);
//width and height of client rect
SWidth = ClientRect.right - ClientRect.left;
SHeight = ClientRect.bottom - ClientRect.top;
//physical screen x,y. logical width and height ie 1920x1080
SetWindowPos(EspHWND, 0, WindowRect.left, WindowRect.top, SWidth, SHeight, 0);
//physical screen x,y. logical width and length ie 1920x1080
glViewport(WindowRect.left, WindowRect.top, SWidth, SHeight);
//all logical
glOrtho(ClientRect.left, ClientRect.right, ClientRect.bottom, ClientRect.top, 0, 1);
}
//get window handle and set screen position/size; get handles to client
void Initiate()
{
ProcessToolbox.EnableDebugPriv();
if (ProcessToolbox.ReadSettings())
{
GameHWND = NULL;
while (!GameHWND)
{
GameHWND = FindWindow(0, L"Counter-Strike: Global Offensive");
Sleep(100);
}
TargetProcess = NULL;
while (!TargetProcess)
{
TargetProcess = ProcessToolbox.GetProcessHandleByName(L"csgo.exe");
Sleep(100);
}
DwClient = NULL;
while (!DwClient)
{
DwClient = ProcessToolbox.GetModuleHandleByName(L"Client.dll", GetProcessId(TargetProcess));
Sleep(100);
}
//get instance of the current process
CurrentInstance = GetModuleHandle(NULL);
ResizeWindow();
}
else
{
ExitThread(0);
}
}
//setup openGL for drawing
void SetupGL()
{
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
// PFD_SUPPORT_GDI| // Format Must Support GDI
PFD_SUPPORT_COMPOSITION | // Format Must Support Composition
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
8, // An Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
0 , // No Z-Buffer (Depth Buffer)
8, // Some Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
int PixelFormat = ChoosePixelFormat(MainHDC, &pfd);
if (!PixelFormat)
{
MessageBox(0, L"Failed to get pixel format!", L"Error", MB_ICONERROR | MB_OK);
ExitThread(0);
}
if (!SetPixelFormat(MainHDC, PixelFormat, &pfd))
{
MessageBox(0, L"Failed to set pixel format!", L"Error", MB_ICONERROR | MB_OK);
ExitThread(0);
}
if (!DescribePixelFormat(MainHDC, PixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd))
{
MessageBox(0, L"Failed to describe pixel format!", L"Error", MB_ICONERROR | MB_OK);
ExitThread(0);
}
MainHGLRC = wglCreateContext(MainHDC);
if (!MainHGLRC)
{
MessageBox(0, L"Failed to create rendering context!", L"Error", MB_ICONERROR | MB_OK);
ExitThread(0);
}
if (!wglMakeCurrent(MainHDC, MainHGLRC))
{
MessageBox(0, L"Failed to set rendering context!", L"Error", MB_ICONERROR | MB_OK);
ExitThread(0);
}
//glEnable(GL_ALPHA_TEST);
//glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
//glEnable(GL_BLEND);
glMatrixMode(GL_PROJECTION);
ResizeWindow();
//color to set when screen is cleared, black with no alpha
glClearColor(0.f, 0.f, 0.f, 0.f);
}
void DrawBox(float x, float y, float width, float height, int* RGB)
{
glLineWidth(3);
glBegin(GL_LINE_LOOP); //begin drawing outline rect
glColor4f(0, 0, 0, 1); //black, yes alpha
glVertex2f(x - (width / 2), y); // bottom left
glVertex2f(x - (width / 2), y - height); //top left
glVertex2f(x + (width / 2), y - height); //top right
glVertex2f(x + (width / 2), y); //bottom right
glEnd();
glLineWidth(1);
glBegin(GL_LINE_LOOP);//begin drawing color rect
glColor4f(RGB[0], RGB[1], RGB[2], 1);//color, yes alpha
glVertex2f(x - (width / 2), y); // bottom left
glVertex2f(x - (width / 2), y - height); //top left
glVertex2f(x + (width / 2), y - height); //top right
glVertex2f(x + (width / 2), y); //bottom right
glEnd();
}
void DrawSkeleton(Skeleton_t Skeleton, int* RGB)
{
//draw black skeleton outline
glLineWidth(3);
glColor4f(0, 0, 0, 1); //black, yes alpha
//Left leg;
glBegin(GL_LINES); //begin drawing line
glVertex2f(Skeleton.Lleg.bonepos2[0].x, Skeleton.Lleg.bonepos2[0].y);
glVertex2f(Skeleton.Lleg.bonepos2[1].x, Skeleton.Lleg.bonepos2[1].y);
glVertex2f(Skeleton.Lleg.bonepos2[1].x, Skeleton.Lleg.bonepos2[1].y);
glVertex2f(Skeleton.Lleg.bonepos2[2].x, Skeleton.Lleg.bonepos2[2].y);
glVertex2f(Skeleton.Lleg.bonepos2[2].x, Skeleton.Lleg.bonepos2[2].y);
glVertex2f(Skeleton.Lleg.bonepos2[3].x, Skeleton.Lleg.bonepos2[3].y);
glEnd();
//Right leg;
glBegin(GL_LINES); //begin drawing line
glVertex2f(Skeleton.Rleg.bonepos2[0].x, Skeleton.Rleg.bonepos2[0].y);
glVertex2f(Skeleton.Rleg.bonepos2[1].x, Skeleton.Rleg.bonepos2[1].y);
glVertex2f(Skeleton.Rleg.bonepos2[1].x, Skeleton.Rleg.bonepos2[1].y);
glVertex2f(Skeleton.Rleg.bonepos2[2].x, Skeleton.Rleg.bonepos2[2].y);
glVertex2f(Skeleton.Rleg.bonepos2[2].x, Skeleton.Rleg.bonepos2[2].y);
glVertex2f(Skeleton.Rleg.bonepos2[3].x, Skeleton.Rleg.bonepos2[3].y);
glEnd();
//Spine;
glBegin(GL_LINES); //begin drawing line
glVertex2f(Skeleton.Spine.bonepos2[0].x, Skeleton.Spine.bonepos2[0].y);
glVertex2f(Skeleton.Spine.bonepos2[1].x, Skeleton.Spine.bonepos2[1].y);
glVertex2f(Skeleton.Spine.bonepos2[1].x, Skeleton.Spine.bonepos2[1].y);
glVertex2f(Skeleton.Spine.bonepos2[2].x, Skeleton.Spine.bonepos2[2].y);
glVertex2f(Skeleton.Spine.bonepos2[2].x, Skeleton.Spine.bonepos2[2].y);
glVertex2f(Skeleton.Spine.bonepos2[3].x, Skeleton.Spine.bonepos2[3].y);
glVertex2f(Skeleton.Spine.bonepos2[3].x, Skeleton.Spine.bonepos2[3].y);
glVertex2f(Skeleton.Spine.bonepos2[4].x, Skeleton.Spine.bonepos2[4].y);
glVertex2f(Skeleton.Spine.bonepos2[4].x, Skeleton.Spine.bonepos2[4].y);
glVertex2f(Skeleton.Spine.bonepos2[5].x, Skeleton.Spine.bonepos2[5].y);
glEnd();
//Left arm;
glBegin(GL_LINES); //begin drawing line
glVertex2f(Skeleton.Larm.bonepos2[0].x, Skeleton.Larm.bonepos2[0].y);
glVertex2f(Skeleton.Larm.bonepos2[1].x, Skeleton.Larm.bonepos2[1].y);
glVertex2f(Skeleton.Larm.bonepos2[1].x, Skeleton.Larm.bonepos2[1].y);
glVertex2f(Skeleton.Larm.bonepos2[2].x, Skeleton.Larm.bonepos2[2].y);
glVertex2f(Skeleton.Larm.bonepos2[2].x, Skeleton.Larm.bonepos2[2].y);
glVertex2f(Skeleton.Larm.bonepos2[3].x, Skeleton.Larm.bonepos2[3].y);
glEnd();
//Right arm;
glBegin(GL_LINES); //begin drawing line
glVertex2f(Skeleton.Rarm.bonepos2[0].x, Skeleton.Rarm.bonepos2[0].y);
glVertex2f(Skeleton.Rarm.bonepos2[1].x, Skeleton.Rarm.bonepos2[1].y);
glVertex2f(Skeleton.Rarm.bonepos2[1].x, Skeleton.Rarm.bonepos2[1].y);
glVertex2f(Skeleton.Rarm.bonepos2[2].x, Skeleton.Rarm.bonepos2[2].y);
glVertex2f(Skeleton.Rarm.bonepos2[2].x, Skeleton.Rarm.bonepos2[2].y);
glVertex2f(Skeleton.Rarm.bonepos2[3].x, Skeleton.Rarm.bonepos2[3].y);
glEnd();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//draw color skeleton
glLineWidth(1);
glColor4f(RGB[0], RGB[1], RGB[2], 1); //color, yes alpha
//Left leg;
glBegin(GL_LINES); //begin drawing line
glVertex2f(Skeleton.Lleg.bonepos2[0].x, Skeleton.Lleg.bonepos2[0].y);
glVertex2f(Skeleton.Lleg.bonepos2[1].x, Skeleton.Lleg.bonepos2[1].y);
glVertex2f(Skeleton.Lleg.bonepos2[1].x, Skeleton.Lleg.bonepos2[1].y);
glVertex2f(Skeleton.Lleg.bonepos2[2].x, Skeleton.Lleg.bonepos2[2].y);
glVertex2f(Skeleton.Lleg.bonepos2[2].x, Skeleton.Lleg.bonepos2[2].y);
glVertex2f(Skeleton.Lleg.bonepos2[3].x, Skeleton.Lleg.bonepos2[3].y);
glEnd();
//Right leg;
glBegin(GL_LINES); //begin drawing line
glVertex2f(Skeleton.Rleg.bonepos2[0].x, Skeleton.Rleg.bonepos2[0].y);
glVertex2f(Skeleton.Rleg.bonepos2[1].x, Skeleton.Rleg.bonepos2[1].y);
glVertex2f(Skeleton.Rleg.bonepos2[1].x, Skeleton.Rleg.bonepos2[1].y);
glVertex2f(Skeleton.Rleg.bonepos2[2].x, Skeleton.Rleg.bonepos2[2].y);
glVertex2f(Skeleton.Rleg.bonepos2[2].x, Skeleton.Rleg.bonepos2[2].y);
glVertex2f(Skeleton.Rleg.bonepos2[3].x, Skeleton.Rleg.bonepos2[3].y);
glEnd();
//Spine;
glBegin(GL_LINES); //begin drawing line
glVertex2f(Skeleton.Spine.bonepos2[0].x, Skeleton.Spine.bonepos2[0].y);
glVertex2f(Skeleton.Spine.bonepos2[1].x, Skeleton.Spine.bonepos2[1].y);
glVertex2f(Skeleton.Spine.bonepos2[1].x, Skeleton.Spine.bonepos2[1].y);
glVertex2f(Skeleton.Spine.bonepos2[2].x, Skeleton.Spine.bonepos2[2].y);
glVertex2f(Skeleton.Spine.bonepos2[2].x, Skeleton.Spine.bonepos2[2].y);
glVertex2f(Skeleton.Spine.bonepos2[3].x, Skeleton.Spine.bonepos2[3].y);
glVertex2f(Skeleton.Spine.bonepos2[3].x, Skeleton.Spine.bonepos2[3].y);
glVertex2f(Skeleton.Spine.bonepos2[4].x, Skeleton.Spine.bonepos2[4].y);
glVertex2f(Skeleton.Spine.bonepos2[4].x, Skeleton.Spine.bonepos2[4].y);
glVertex2f(Skeleton.Spine.bonepos2[5].x, Skeleton.Spine.bonepos2[5].y);
glEnd();
//Left arm;
glBegin(GL_LINES); //begin drawing line
glVertex2f(Skeleton.Larm.bonepos2[0].x, Skeleton.Larm.bonepos2[0].y);
glVertex2f(Skeleton.Larm.bonepos2[1].x, Skeleton.Larm.bonepos2[1].y);
glVertex2f(Skeleton.Larm.bonepos2[1].x, Skeleton.Larm.bonepos2[1].y);
glVertex2f(Skeleton.Larm.bonepos2[2].x, Skeleton.Larm.bonepos2[2].y);
glVertex2f(Skeleton.Larm.bonepos2[2].x, Skeleton.Larm.bonepos2[2].y);
glVertex2f(Skeleton.Larm.bonepos2[3].x, Skeleton.Larm.bonepos2[3].y);
glEnd();
//Right arm;
glBegin(GL_LINES); //begin drawing line
glVertex2f(Skeleton.Rarm.bonepos2[0].x, Skeleton.Rarm.bonepos2[0].y);
glVertex2f(Skeleton.Rarm.bonepos2[1].x, Skeleton.Rarm.bonepos2[1].y);
glVertex2f(Skeleton.Rarm.bonepos2[1].x, Skeleton.Rarm.bonepos2[1].y);
glVertex2f(Skeleton.Rarm.bonepos2[2].x, Skeleton.Rarm.bonepos2[2].y);
glVertex2f(Skeleton.Rarm.bonepos2[2].x, Skeleton.Rarm.bonepos2[2].y);
glVertex2f(Skeleton.Rarm.bonepos2[3].x, Skeleton.Rarm.bonepos2[3].y);
glEnd();
}
void DrawSnaplines(float x, float y, int* RGB)
{
glLineWidth(3);
glBegin(GL_LINES); //begin drawing snapline outline
glColor4f(0, 0, 0, 1); //black, yes alpha
glVertex2f(x, y); //enemies feet
glVertex2f(SWidth / 2, SHeight); //half screen width, bottom of screen
glEnd();
glLineWidth(1);
glBegin(GL_LINES); //begin drawing color snapline
glColor4f(RGB[0], RGB[1], RGB[2], 1); //color, yes alpha
glVertex2f(x, y); //enemies feet
glVertex2f(SWidth / 2, SHeight); //half screen width, bottom of screen
glEnd();
}
//draw filled rectangle
void DrawFilledBox(float x, float y, float width, float height, int* RGB)
{
glBegin(GL_QUADS); //begin drawing filled outline rect, +1 pixel to each side to add a border
glColor4f(0, 0, 0, 1); //black, yes alpha
glVertex2f(x - (width / 2) - 1, y + 1); // bottom left
glVertex2f(x - (width / 2) - 1, y - height - 1); //top left
glVertex2f(x + (width / 2) + 1, y - height - 1); //top right
glVertex2f(x + (width / 2) + 1, y + 1); //bottom right
glEnd();
glBegin(GL_QUADS);//begin drawing filled color rect
glColor4f(RGB[0], RGB[1], RGB[2], 1);//color, yes alpha
glVertex2f(x - (width / 2), y); // bottom left
glVertex2f(x - (width / 2), y - height); //top left
glVertex2f(x + (width / 2), y - height); //top right
glVertex2f(x + (width / 2), y); //bottom right
glEnd();
}
void DrawCross(float x, float y, float width, float height, float LineWidth, int* RGB)
{
//draw black outline cross
glLineWidth(LineWidth + 2);
glBegin(GL_LINES);
glColor4f(0, 0, 0, 1); //black, yes alpha
glVertex2f(x, y + height + 1);
glVertex2f(x, y - height - 1);
glVertex2f(x + width + 1, y);
glVertex2f(x - width - 1, y);
glEnd();
//draw color cross
glLineWidth(LineWidth);
glBegin(GL_LINES);
glColor4f(RGB[0], RGB[1], RGB[2], 1); //color, yes alpha
glVertex2f(x, y + height);
glVertex2f(x, y - height);
glVertex2f(x + width, y);
glVertex2f(x - width, y);
glEnd();
}
//window message handling
LRESULT APIENTRY WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_CREATE:
{
MainHDC = GetDC(hWnd);
SetupGL();
return 0;
}
case WM_CLOSE:
{
DestroyWindow(hWnd);
}
//release resources
case WM_DESTROY:
{
wglMakeCurrent(NULL, NULL);
wglDeleteContext(MainHGLRC);
DeleteDC(MainHDC);
ReleaseDC(hWnd, MainHDC);
PostQuitMessage(0);
UnregisterClass(WName, CurrentInstance);
}
//our paint handler, invoked by invalidaterect()
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hWnd, &ps);
//redraw the background
glClear(GL_COLOR_BUFFER_BIT);
if (ALLESP)
{
//loop through all entities and draw
for (int i = 0; i < 64; i++)
{
//get entity from the entity list
Entity_t Ent = EnityList.Entity[i];
//get local player
Player_t Player = PlayerInfo.Player;
if (Ent.Valid && Player.Valid)
{
//frequently used local vars
float dist = MiscToolbox.get3ddist(Player.VecOrigin, Ent.VecOrigin);
float width = 30000.f / dist;
float height = 55000.f / dist;
float headwidth = 6000.f / dist;
float headheight = 8700.f / dist;
if (BOX)
{
if (!Ent.IsDead && Ent.Team != Player.Team)
{
//check if entity is on screen
W2Sstruct_t VecOriginScreenPos = MiscToolbox.w2s(Ent.VecOrigin);
if (VecOriginScreenPos.OnScreen)
{
//color of back of box
int BoxColor[3] = { 0, 255, 0 };
//draw box around entity
DrawBox(VecOriginScreenPos.Coords.x, VecOriginScreenPos.Coords.y, width, height, BoxColor);
}
}
}
if (BONES)
{
if (!Ent.Skeleton.Broken && !Ent.IsDead && Ent.Team != Player.Team)
{
//check for valid bones
if (EntityToolbox.ValidateBones(Ent))
{
//color of back of skeleton
int SkeletonColor[3] = { 0, 255, 0 };
//draw all bones
DrawSkeleton(Ent.Skeleton, SkeletonColor);
//draw headbox
DrawBox(Ent.Skeleton.Spine.bonepos2[6].x, Ent.Skeleton.Spine.bonepos2[5].y, headwidth, headheight, SkeletonColor);
}
}
}
if (SNAPS)
{
if (!Ent.IsDead && Ent.Team != Player.Team)
{
//check if entity is on screen
W2Sstruct_t VecOriginScreenPos = MiscToolbox.w2s(Ent.VecOrigin);
if (VecOriginScreenPos.OnScreen)
{
//color of back of snaplines
int SnapLineColor[3] = { 0, 255, 0 };
//draw snaplines to entity
DrawSnaplines(VecOriginScreenPos.Coords.x, VecOriginScreenPos.Coords.y, SnapLineColor);
}
}
}
if (HBAR)
{
if (!Ent.IsDead && Ent.Team != Player.Team)
{
//check if entity is on screen
W2Sstruct_t VecOriginScreenPos = MiscToolbox.w2s(Ent.VecOrigin);
if (VecOriginScreenPos.OnScreen)
{
//width of healthbar
float HealthBarWidth = 2000.f / dist;
//color of back of healthbar
int HealthBarBackColor[3] = { 255, 0, 0 };
//draw red, 100% height box as back of healthbar
DrawFilledBox(VecOriginScreenPos.Coords.x + (width / 2), VecOriginScreenPos.Coords.y, HealthBarWidth, height, HealthBarBackColor);
//color of front of healthbar
int HealthBarColor[3] = { 0, 255, 0 };
//draw green, health % box as front of healthbar
DrawFilledBox(VecOriginScreenPos.Coords.x + (width / 2), VecOriginScreenPos.Coords.y, HealthBarWidth, (height / 100.f) * Ent.Health, HealthBarColor);
}
}
}
if (CROSS)
{
//some of this shit gets confusing because window's screen coordinate wierd
//get center of screen x and y
float CrosshairPos2ScreenX = SWidth / 2;
float CrosshairPos2ScreenY = SHeight / 2;
//divide screenwidth by total euler angle yaw (179 * 2)
float Punch2ScreenX = (SWidth / 358.f) * (Player.PunchAngs.x * 2);
//divide screen height by total euler angle pitch (89 * 2)
float Punch2ScreenY = (SHeight / 178.f) * (Player.PunchAngs.y * 2);
//subtract cuz it works, Punch2ScreenY because it works XD
CrosshairPos2ScreenX -= Punch2ScreenY;
//add because it makes sense, Punch2ScreenX because it works XD
CrosshairPos2ScreenY += Punch2ScreenX;
//Crosshair color
int CrosshairColor[3] = { 255, 255, 0 };
//draw crosshair
DrawCross(CrosshairPos2ScreenX, CrosshairPos2ScreenY, 6, 6, 2, CrosshairColor);
}
}
}
}
//copy the backbuffer into the window
SwapBuffers(MainHDC);
//end painting
EndPaint(hWnd, &ps);
return 0;
}
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
//read user input
DWORD WINAPI KeyLoop(LPVOID PARAMS)
{
while (!KILLALL)
{
if (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_F8) < 0)
{
while (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_F8) < 0)
{
Sleep(100);
}
//close window
SendMessage(EspHWND, WM_CLOSE, 0, 0);
//kill all threads
KILLALL = true;
}
if (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(0x31) < 0)
{
while (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(0x31) < 0)
{
Sleep(100);
}
//toggle esp on/off
ALLESP = !ALLESP;
}
if (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(0x32) < 0)
{
while (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(0x32) < 0)
{
Sleep(100);
}
//toggle box on/off
BOX = !BOX;
}
if (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(0x33) < 0)
{
while (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(0x33) < 0)
{
Sleep(100);
}
//toggle snaplines on/off
SNAPS = !SNAPS;
}
if (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(0x34) < 0)
{
while (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(0x34) < 0)
{
Sleep(100);
}
//toggle bones on/off
BONES = !BONES;
}
if (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(0x35) < 0)
{
while (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(0x35) < 0)
{
Sleep(100);
}
//toggle healthbar on/off
HBAR = !HBAR;
}
if (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(0x36) < 0)
{
while (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(0x36) < 0)
{
Sleep(100);
}
//toggle healthbar on/off
CROSS = !CROSS;
}
Sleep(50);
}
ExitThread(0);
}
//constantly redraw screen
DWORD WINAPI RedrawLoop(LPVOID PARAMS)
{
CreateThread(0, 0, &KeyLoop, 0, 0, 0);
while (!KILLALL)
{
InvalidateRect(EspHWND, NULL, false);
Sleep(WRefreshRate);
}
ExitThread(0);
}
//read local player and store it
DWORD WINAPI ReadPlayer(LPVOID PARAMS)
{
CreateThread(0, 0, &RedrawLoop, 0, 0, 0);
while (!KILLALL)
{
PlayerInfo.Player = PlayerToolbox.GetLocalPlayer();
Sleep(MemorySleep);
}
ExitThread(0);
}
//read Entity and store it in the entity list
DWORD WINAPI ReadEnts(LPVOID PARAMS)
{
CreateThread(0, 0, &ReadPlayer, 0, 0, 0);
while (!KILLALL)
{
for (int i = 0; i < 64; i++)
{
EnityList.Entity[i] = EntityToolbox.GetEntity(i);
}
Sleep(MemorySleep);
}
ExitThread(0);
}
//create overlay window and loop window message dispatching
DWORD WINAPI MainWindow(LPVOID PARAMS)
{
MessageBox(0, L"Hack injected successfully!", L"NO ERROR", MB_OK);
Initiate();
WNDCLASSEX WClass;
MSG Msg;
WClass.cbSize = sizeof(WNDCLASSEX);
WClass.style = 0;
WClass.lpfnWndProc = WndProc;
WClass.cbClsExtra = 0;
WClass.cbWndExtra = 0;
WClass.hInstance = CurrentInstance;
WClass.hIcon = NULL;
WClass.hCursor = NULL;
WClass.hbrBackground = CreateSolidBrush(RGB(0, 0, 0));
WClass.lpszMenuName = NULL;
WClass.lpszClassName = WName;
WClass.hIconSm = NULL;
if (!RegisterClassEx(&WClass))
{
MessageBox(0, L"Window Registration Failed! Is another window already open? If not, kill the process and try again.", L"Error!", MB_OK);
ExitThread(0);
}
EspHWND = CreateWindowEx(
WS_EX_TRANSPARENT | WS_EX_TOPMOST | WS_EX_LAYERED,
WName,
WName,
WS_POPUP | WS_VISIBLE | WS_MAXIMIZE,
WindowRect.left,
WindowRect.top - 1,
SWidth,
SHeight + 1,
NULL, NULL, CurrentInstance, NULL);
if (EspHWND == NULL)
{
MessageBox(0, L"Window Creation Failed!", L"Error!", MB_OK);
UnregisterClass(WName, CurrentInstance);
ExitThread(0);
}
//make sure our window is layered
//NOTE: SOME WINDOWS VERSIONS DO NOT SUPPORT THIS
if (!SetLayeredWindowAttributes(EspHWND, RGB(0, 0, 0), 255, LWA_COLORKEY | LWA_ALPHA))
{
MessageBox(0, L"Failed to set layered window attributes!", L"Error", MB_ICONERROR | MB_OK);
UnregisterClass(WName, CurrentInstance);
ExitThread(0);
}
BOOL IsEnabled;
if (DwmIsCompositionEnabled(&IsEnabled) != S_OK)
{
MessageBox(0, L"Failed to check if DWM window composition is enabled! Assuming false!", L"Error", MB_ICONERROR | MB_OK);
UnregisterClass(WName, CurrentInstance);
ExitThread(0);
}
if (!IsEnabled)
{
MessageBox(0, L"DWM window composition is not enabled!", L"Error", MB_ICONERROR | MB_OK);
UnregisterClass(WName, CurrentInstance);
ExitThread(0);
}
//the region that is not blurred is rendered based off the alpha channel, therefore, we create an invalid region so that nothing is blurred but the alpha blending remains. We need this due to... who the fuck knows why layered window attributes wont work
DWM_BLURBEHIND bb = { DWM_BB_ENABLE | DWM_BB_BLURREGION, true, CreateRectRgn(0, 0, -1, -1), true };
//enable trasnparency via dwm
//NOTE: SOME WINDOWS VERSIONS DO NOT SUPPORT THIS
if (DwmEnableBlurBehindWindow(EspHWND, &bb) != S_OK)
{
MessageBox(0, L"Failed to enable DWM window blur!", L"Error", MB_ICONERROR | MB_OK);
UnregisterClass(WName, CurrentInstance);
ExitThread(0);
}
ShowWindow(EspHWND, 1);
CreateThread(0, 0, &ReadEnts, 0, 0, 0);
//message loop
while (GetMessage(&Msg, NULL, 0, 0) > 0 && !KILLALL)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
ExitThread(0);
}
//hack entry point
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
CreateThread(0, 0, &MainWindow, 0, 0, 0);
};
}
return TRUE;
}