Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //no compiled headers & use Multi Byte
- #include <Windows.h>
- DWORD gameModule;
- DWORD localPlayer;
- DWORD localPlayerAddy = 0xCF1A4C;
- DWORD vectorOrigin = 0x138;
- DWORD entityList = 0x4D03AA4;
- DWORD viewMatrix = 0x4CF54D4;
- DWORD boneMatrix = 0x26A8;
- DWORD dormat = 0xED;
- DWORD team = 0xF4;
- DWORD healthOffset = 0x100;
- HWND hwndCSGO;
- HBRUSH Brush;
- HDC hdcCSGO;
- float Matrix[16];
- //defining our vectors
- struct Vec3
- {
- float x, y, z;
- };
- struct Vec4
- {
- float x, y, z, w;
- };
- struct Vec2
- {
- float x, y;
- };
- //These two function are from a old fleep post, i was able to use them to create the box style however this was just to save time :) Thx Fleep
- void DrawFilledRect(int x, int y, int w, int h)
- {
- RECT rect = { x, y, x + w, y + h };
- FillRect(hdcCSGO, &rect, Brush);
- }
- 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);
- }
- //this is the world to screen function for directX
- bool WorldToScreen(Vec3 pos, Vec2 &screen, float matrix[16], int windowWidth, int windowHeight)
- {
- Vec4 clipCoords;
- clipCoords.x = pos.x*matrix[0] + pos.y*matrix[1] + pos.z*matrix[2] + matrix[3];
- clipCoords.y = pos.x*matrix[4] + pos.y*matrix[5] + pos.z*matrix[6] + matrix[7];
- clipCoords.z = pos.x*matrix[8] + pos.y*matrix[9] + pos.z*matrix[10] + matrix[11];
- clipCoords.w = pos.x*matrix[12] + pos.y*matrix[13] + pos.z*matrix[14] + matrix[15];
- if (clipCoords.w < 0.1f)
- return false;
- Vec3 NDC;
- NDC.x = clipCoords.x / clipCoords.w;
- NDC.y = clipCoords.y / clipCoords.w;
- NDC.z = clipCoords.z / clipCoords.w;
- screen.x = (windowWidth / 2 * NDC.x) + (NDC.x + windowWidth / 2);
- screen.y = -(windowHeight / 2 * NDC.y) + (NDC.y + windowHeight / 2);
- return true;
- }
- int mainThread()
- {
- gameModule = (DWORD)GetModuleHandle("client.dll");//creates the game module
- hwndCSGO = FindWindow(0, ("Counter-Strike: Global Offensive"));//Gets Window
- while (true)
- {
- //Base of player
- Vec2 vScreen;
- //Head of player
- Vec2 vHead;
- memcpy(&Matrix, (PBYTE*)(gameModule + viewMatrix), sizeof(Matrix));
- localPlayer = *(DWORD*)(gameModule + localPlayerAddy);//Creates your local player
- if (localPlayer == NULL)//checks if your local player is existant
- {
- while (localPlayer == NULL)
- {
- localPlayer = *(DWORD*)(gameModule + localPlayerAddy);
- }
- }
- hdcCSGO = GetDC(hwndCSGO);
- int myTeam = *(int*)(localPlayer + team);
- //our entity list loop
- for (short int i = 0; i < 64; i++)
- {
- //each entity is 0x10 apart in memory
- DWORD entity = *(DWORD*)(gameModule + entityList + i * 0x10);
- if (entity != NULL)
- {
- if (entity != localPlayer)//Makes sure we dont draw on our own player
- {
- int entityTeam = *(int*)(entity + team);
- Vec3 entityLocation = *(Vec3*)(entity + vectorOrigin);
- DWORD dwBoneMatrix = *(DWORD*)(entity + boneMatrix);
- DWORD health = *(DWORD*)(entity + healthOffset);
- int isDormat = *(int*)(entity + dormat);
- if (isDormat == 0)//Checks if the entity is culled
- {
- if (health > 0)
- {
- if (WorldToScreen(entityLocation, vScreen, Matrix, 1920, 1080))
- {
- //this gets the x,y,z of the head bone
- float enemyHeadX = *(float*)(dwBoneMatrix + 0x30 * 9 + 0x0C);
- float enemyHeadY = *(float*)(dwBoneMatrix + 0x30 * 9 + 0x1C);
- float enemyHeadZ = *(float*)(dwBoneMatrix + 0x30 * 9 + 0x2C);
- //turns the head bone floats into a Vec3
- Vec3 enemyHeadPos = { enemyHeadX, enemyHeadY, enemyHeadZ };
- //this takes the entitys cords and the players view matrix turning them into screen cords
- if (WorldToScreen(enemyHeadPos, vHead, Matrix, 1920, 1080))
- {
- float head = vHead.y - vScreen.y;
- float width = head / 2;
- float center = width / -2;
- if (myTeam == entityTeam)
- {
- Brush = CreateSolidBrush(RGB(000, 000, 255));//Any color you want
- DrawBorderBox(vScreen.x + center, vScreen.y, width, head - 5, 2);//Draws the boxes
- DeleteObject(Brush);
- }
- else
- {
- Brush = CreateSolidBrush(RGB(255, 000, 000));
- DrawBorderBox(vScreen.x + center, vScreen.y, width, head - 5, 2);
- DeleteObject(Brush);
- }
- }
- }
- }
- }
- }
- }
- }
- //This prevents a fat memory leak
- Sleep(1);
- DeleteObject(hdcCSGO);
- }
- }
- BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
- {
- if (dwReason == DLL_PROCESS_ATTACH) {
- DisableThreadLibraryCalls(hModule);
- CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)mainThread, NULL, NULL, NULL);
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement