Advertisement
fasdfasdfw

Untitled

Feb 8th, 2025
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.03 KB | None | 0 0
  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <tlhelp32.h>
  4. #include <dwmapi.h>
  5. #include <math.h>
  6.  
  7. #pragma comment(lib, "dwmapi.lib")
  8.  
  9. #define OFFSET_WORKSPACE  0x150
  10. #define OFFSET_CHILDREN   0x70
  11. #define OFFSET_POSITION   0x140
  12. #define OFFSET_HUMANOID   0x850
  13. #define OFFSET_STATE_ID   0x20
  14. #define OFFSET_VIEWMATRIX 0x4D0
  15.  
  16. struct Vector3 {
  17.     float x, y, z;
  18. };
  19.  
  20. // World-to-screen transformation using the view matrix
  21. bool WorldToScreen(Vector3 pos, Vector3 *screen, float matrix[16], int width, int height) {
  22.     float clipX = pos.x * matrix[0] + pos.y * matrix[4] + pos.z * matrix[8]  + matrix[12];
  23.     float clipY = pos.x * matrix[1] + pos.y * matrix[5] + pos.z * matrix[9]  + matrix[13];
  24.     float clipW = pos.x * matrix[3] + pos.y * matrix[7] + pos.z * matrix[11] + matrix[15];
  25.  
  26.     if (clipW < 0.1f) return false;  // Behind camera
  27.  
  28.     screen->x = (width / 2) * (1.0f + clipX / clipW);
  29.     screen->y = (height / 2) * (1.0f - clipY / clipW);
  30.     return true;
  31. }
  32.  
  33. // Get the base address of Roblox
  34. uintptr_t GetModuleBaseAddress(DWORD processID, const char *moduleName) {
  35.     uintptr_t baseAddress = 0;
  36.     HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, processID);
  37.     if (snapshot != INVALID_HANDLE_VALUE) {
  38.         MODULEENTRY32 moduleEntry;
  39.         moduleEntry.dwSize = sizeof(moduleEntry);
  40.         if (Module32First(snapshot, &moduleEntry)) {
  41.             do {
  42.                 if (strcmp(moduleEntry.szModule, moduleName) == 0) {
  43.                     baseAddress = (uintptr_t)moduleEntry.modBaseAddr;
  44.                     break;
  45.                 }
  46.             } while (Module32Next(snapshot, &moduleEntry));
  47.         }
  48.         CloseHandle(snapshot);
  49.     }
  50.     return baseAddress;
  51. }
  52.  
  53. // Draw a rectangle on screen
  54. void DrawESP(HDC hdc, int x, int y, int width, int height) {
  55.     HBRUSH brush = CreateSolidBrush(RGB(255, 0, 0));  // Red box
  56.     RECT rect = { x - width / 2, y - height / 2, x + width / 2, y + height / 2 };
  57.     FillRect(hdc, &rect, brush);
  58.     DeleteObject(brush);
  59. }
  60.  
  61. int main() {
  62.     DWORD processID = 0;
  63.     HWND hwnd = FindWindow(NULL, "Roblox");
  64.     if (!hwnd) {
  65.         printf("Roblox is not running.\n");
  66.         return 1;
  67.     }
  68.     GetWindowThreadProcessId(hwnd, &processID);
  69.  
  70.     HANDLE hProcess = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, processID);
  71.     if (!hProcess) {
  72.         printf("Failed to open Roblox process. Run as Administrator.\n");
  73.         return 1;
  74.     }
  75.  
  76.     uintptr_t baseAddress = GetModuleBaseAddress(processID, "RobloxPlayerBeta.exe");
  77.     if (!baseAddress) {
  78.         printf("Failed to find base address.\n");
  79.         CloseHandle(hProcess);
  80.         return 1;
  81.     }
  82.  
  83.     // Get ViewMatrix
  84.     float viewMatrix[16] = {0};
  85.     ReadProcessMemory(hProcess, (LPCVOID)(baseAddress + OFFSET_VIEWMATRIX), &viewMatrix, sizeof(viewMatrix), NULL);
  86.  
  87.     // Get Workspace Address
  88.     uintptr_t workspaceAddress = 0;
  89.     ReadProcessMemory(hProcess, (LPCVOID)(baseAddress + OFFSET_WORKSPACE), &workspaceAddress, sizeof(workspaceAddress), NULL);
  90.  
  91.     // Get Children (List of Players)
  92.     uintptr_t childrenAddress = 0;
  93.     ReadProcessMemory(hProcess, (LPCVOID)(workspaceAddress + OFFSET_CHILDREN), &childrenAddress, sizeof(childrenAddress), NULL);
  94.  
  95.     // Get screen size
  96.     RECT screen;
  97.     GetClientRect(hwnd, &screen);
  98.     int screenWidth = screen.right;
  99.     int screenHeight = screen.bottom;
  100.  
  101.     // Get device context for drawing
  102.     HDC hdc = GetDC(hwnd);
  103.  
  104.     // Loop through 50 objects
  105.     for (int i = 0; i < 50; i++) {
  106.         uintptr_t objectAddress = 0;
  107.         ReadProcessMemory(hProcess, (LPCVOID)(childrenAddress + (i * sizeof(uintptr_t))), &objectAddress, sizeof(objectAddress), NULL);
  108.         if (!objectAddress) continue;
  109.  
  110.         // Check if Object has a Humanoid
  111.         uintptr_t humanoidAddress = 0;
  112.         ReadProcessMemory(hProcess, (LPCVOID)(objectAddress + OFFSET_HUMANOID), &humanoidAddress, sizeof(humanoidAddress), NULL);
  113.         if (!humanoidAddress) continue;
  114.  
  115.         // Check Humanoid State
  116.         int stateId = 0;
  117.         ReadProcessMemory(hProcess, (LPCVOID)(humanoidAddress + OFFSET_STATE_ID), &stateId, sizeof(stateId), NULL);
  118.  
  119.         // Read Position
  120.         Vector3 position = {0};
  121.         ReadProcessMemory(hProcess, (LPCVOID)(objectAddress + OFFSET_POSITION), &position, sizeof(position), NULL);
  122.  
  123.         // Calculate dynamic box size based on distance
  124.         float distance = position.z;  
  125.         int boxSize = (int)(2000 / distance);  // Adjust scaling factor (2000 is arbitrary)
  126.  
  127.         // Prevent boxes from getting too small or too big
  128.         if (boxSize < 10) boxSize = 10;   // Minimum size
  129.         if (boxSize > 100) boxSize = 100; // Maximum size
  130.  
  131.         // Convert 3D position to screen coordinates
  132.         Vector3 screenPos;
  133.         if (WorldToScreen(position, &screenPos, viewMatrix, screenWidth, screenHeight)) {
  134.             DrawESP(hdc, (int)screenPos.x, (int)screenPos.y, boxSize, boxSize);
  135.         }
  136.     }
  137.  
  138.     ReleaseDC(hwnd, hdc);
  139.     CloseHandle(hProcess);
  140.     return 0;
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement