Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "hDirectX.h"
- #include "HackProcess.h"
- IDirect3D9Ex* p_Object = 0;
- IDirect3DDevice9Ex* p_Device = 0;
- D3DPRESENT_PARAMETERS p_Params;
- ID3DXLine* p_Line;
- ID3DXFont* pFontSmall = 0;
- CHackProcess fProcess;
- //ESP VARS
- int NumOfPlayers = 32;
- const DWORD Player_Base = 0x55DB34;
- const DWORD dw_mTeamOffset = 0x98;//client
- const DWORD dw_Health = 0x90;//client
- const DWORD dw_Pos = 0x25C;//client
- const DWORD EntityPlayer_Base = 0x56B3E4;
- const DWORD EntityLoopDistance = 0x10;
- const DWORD dw_Dormant = 0x17A;
- const DWORD dw_Lifestate = 0x8F;
- const DWORD dw_vMatrix = 0x5A5730;
- 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));
- }
- struct MyPlayer_t
- {
- DWORD CLocalPlayer;
- int Team;
- int Health;
- WorldToScreenMatrix_t WorldToScreenMatrix;
- float Position[3];
- void ReadInformation()
- {
- // Reading CLocalPlayer Pointer to our "CLocalPlayer" DWORD.
- ReadProcessMemory (fProcess.__HandleProcess, (PBYTE*)(fProcess.__dwordClient + Player_Base), &CLocalPlayer, sizeof(DWORD), 0);
- // Reading out our Team to our "Team" Varible.
- ReadProcessMemory (fProcess.__HandleProcess, (PBYTE*)(CLocalPlayer + dw_mTeamOffset), &Team, sizeof(int), 0);
- // Reading out our Health to our "Health" Varible.
- ReadProcessMemory (fProcess.__HandleProcess, (PBYTE*)(CLocalPlayer + dw_Health), &Health, sizeof(int), 0);
- // Reading out our Position to our "Position" Varible.
- ReadProcessMemory (fProcess.__HandleProcess, (PBYTE*)(CLocalPlayer + dw_Pos), &Position, sizeof(float[3]), 0);
- ReadProcessMemory (fProcess.__HandleProcess, (PBYTE*)(fProcess.__dwordEngine + dw_vMatrix), &WorldToScreenMatrix, sizeof(WorldToScreenMatrix), 0);
- }
- }MyPlayer;
- struct PlayerList_t
- {
- DWORD CBaseEntity;
- int Team;
- int Health;
- int Alive;
- int Dormant;
- float Position[3];
- char Name[39];
- void ReadInformation(int Player)
- {
- // Reading CBaseEntity Pointer to our "CBaseEntity" DWORD + Current Player in the loop. 0x10 is the CBaseEntity List Size
- //"client.dll"+00545204 //0x571A5204
- ReadProcessMemory (fProcess.__HandleProcess, (PBYTE*)(fProcess.__dwordClient + EntityPlayer_Base + (Player * EntityLoopDistance)),&CBaseEntity, sizeof(DWORD), 0);
- // Reading out our Team to our "Team" Varible.
- ReadProcessMemory (fProcess.__HandleProcess, (PBYTE*)(CBaseEntity + dw_mTeamOffset), &Team, sizeof(int), 0);
- // Reading out our Health to our "Health" Varible.
- ReadProcessMemory (fProcess.__HandleProcess, (PBYTE*)(CBaseEntity + dw_Health), &Health, sizeof(int), 0);
- // Reading out our Position to our "Position" Varible.
- ReadProcessMemory (fProcess.__HandleProcess, (PBYTE*)(CBaseEntity + dw_Pos), &Position, sizeof(float[3]), 0);
- //Alive
- ReadProcessMemory (fProcess.__HandleProcess, (PBYTE*)(CBaseEntity + dw_Lifestate), &Alive, sizeof(int), 0);
- //Dormant
- ReadProcessMemory (fProcess.__HandleProcess, (PBYTE*)(CBaseEntity + dw_Dormant), &Dormant, sizeof(int), 0);
- }
- }PlayerList[32];
- 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)(tSize.right - tSize.left);
- int height = (int)(tSize.bottom - tSize.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+ tSize.left;
- to[1] = y+ tSize.top ;
- return true;
- }
- int DirectXInit(HWND hWnd)
- {
- if(FAILED(Direct3DCreate9Ex(D3D_SDK_VERSION, &p_Object)))
- exit(1);
- ZeroMemory(&p_Params, sizeof(p_Params));
- p_Params.Windowed = TRUE;
- p_Params.SwapEffect = D3DSWAPEFFECT_DISCARD;
- p_Params.hDeviceWindow = hWnd;
- p_Params.MultiSampleQuality = D3DMULTISAMPLE_NONE;
- p_Params.BackBufferFormat = D3DFMT_A8R8G8B8 ;
- p_Params.BackBufferWidth = Width;
- p_Params.BackBufferHeight = Height;
- p_Params.EnableAutoDepthStencil = TRUE;
- p_Params.AutoDepthStencilFormat = D3DFMT_D16;
- if(FAILED(p_Object->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &p_Params, 0, &p_Device)))
- exit(1);
- if(!p_Line)
- D3DXCreateLine(p_Device, &p_Line);
- D3DXCreateFont(p_Device, 18, 0, 0, 0, false, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Calibri", &pFontSmall);
- return 0;
- }
- void DrawESP(int x, int y, float distance)
- {
- int width = 15000/distance;
- int height = 50000/distance;
- DrawBox(x-(width/2), y-height-10, width, height, 1, 255, 0, 0, 255);
- }
- int Render()
- {
- p_Device->Clear(0, 0, D3DCLEAR_TARGET, 0, 1.0f, 0);
- p_Device->BeginScene();
- if(tWnd == GetForegroundWindow())
- {
- fProcess.RunProcess();
- for(int i = 0; i < NumOfPlayers; i ++)
- {
- PlayerList[i].ReadInformation(i);
- /* if(PlayerList[i].Health < 1)
- continue;
- //if(PlayerList[i].Dormant = 0)
- //continue;
- if(PlayerList[i].Alive < 1)
- continue;
- if(PlayerList[i].Team == 2)
- continue;*/
- if(PlayerList[i].Health < 2)
- continue;
- if(PlayerList[i].Team == MyPlayer.Team)
- continue;
- float EnemyXY[3];
- if(WorldToScreen(PlayerList[i].Position, EnemyXY) || PlayerList[i].Team != MyPlayer.Team)
- {
- DrawESP(EnemyXY[0] - tSize.left, EnemyXY[1] - tSize.top, Get3dDistance(MyPlayer.Position, PlayerList[i].Position));
- }
- }
- }
- p_Device->EndScene();
- p_Device->PresentEx(0, 0, 0, 0, 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement