Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdio.h>
- #include <tlhelp32.h>
- #include <dwmapi.h>
- #include <math.h>
- #pragma comment(lib, "dwmapi.lib")
- #define OFFSET_WORKSPACE 0x150
- #define OFFSET_CHILDREN 0x70
- #define OFFSET_POSITION 0x140
- #define OFFSET_HUMANOID 0x850
- #define OFFSET_STATE_ID 0x20
- #define OFFSET_VIEWMATRIX 0x4D0
- struct Vector3 {
- float x, y, z;
- };
- // World-to-screen transformation using the view matrix
- bool WorldToScreen(Vector3 pos, Vector3 *screen, float matrix[16], int width, int height) {
- float clipX = pos.x * matrix[0] + pos.y * matrix[4] + pos.z * matrix[8] + matrix[12];
- float clipY = pos.x * matrix[1] + pos.y * matrix[5] + pos.z * matrix[9] + matrix[13];
- float clipW = pos.x * matrix[3] + pos.y * matrix[7] + pos.z * matrix[11] + matrix[15];
- if (clipW < 0.1f) return false; // Behind camera
- screen->x = (width / 2) * (1.0f + clipX / clipW);
- screen->y = (height / 2) * (1.0f - clipY / clipW);
- return true;
- }
- // Get the base address of Roblox
- uintptr_t GetModuleBaseAddress(DWORD processID, const char *moduleName) {
- uintptr_t baseAddress = 0;
- HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, processID);
- if (snapshot != INVALID_HANDLE_VALUE) {
- MODULEENTRY32 moduleEntry;
- moduleEntry.dwSize = sizeof(moduleEntry);
- if (Module32First(snapshot, &moduleEntry)) {
- do {
- if (strcmp(moduleEntry.szModule, moduleName) == 0) {
- baseAddress = (uintptr_t)moduleEntry.modBaseAddr;
- break;
- }
- } while (Module32Next(snapshot, &moduleEntry));
- }
- CloseHandle(snapshot);
- }
- return baseAddress;
- }
- // Draw a rectangle on screen
- void DrawESP(HDC hdc, int x, int y, int width, int height) {
- HBRUSH brush = CreateSolidBrush(RGB(255, 0, 0)); // Red box
- RECT rect = { x - width / 2, y - height / 2, x + width / 2, y + height / 2 };
- FillRect(hdc, &rect, brush);
- DeleteObject(brush);
- }
- int main() {
- DWORD processID = 0;
- HWND hwnd = FindWindow(NULL, "Roblox");
- if (!hwnd) {
- printf("Roblox is not running.\n");
- return 1;
- }
- GetWindowThreadProcessId(hwnd, &processID);
- HANDLE hProcess = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, processID);
- if (!hProcess) {
- printf("Failed to open Roblox process. Run as Administrator.\n");
- return 1;
- }
- uintptr_t baseAddress = GetModuleBaseAddress(processID, "RobloxPlayerBeta.exe");
- if (!baseAddress) {
- printf("Failed to find base address.\n");
- CloseHandle(hProcess);
- return 1;
- }
- // Get ViewMatrix
- float viewMatrix[16] = {0};
- ReadProcessMemory(hProcess, (LPCVOID)(baseAddress + OFFSET_VIEWMATRIX), &viewMatrix, sizeof(viewMatrix), NULL);
- // Get Workspace Address
- uintptr_t workspaceAddress = 0;
- ReadProcessMemory(hProcess, (LPCVOID)(baseAddress + OFFSET_WORKSPACE), &workspaceAddress, sizeof(workspaceAddress), NULL);
- // Get Children (List of Players)
- uintptr_t childrenAddress = 0;
- ReadProcessMemory(hProcess, (LPCVOID)(workspaceAddress + OFFSET_CHILDREN), &childrenAddress, sizeof(childrenAddress), NULL);
- // Get screen size
- RECT screen;
- GetClientRect(hwnd, &screen);
- int screenWidth = screen.right;
- int screenHeight = screen.bottom;
- // Get device context for drawing
- HDC hdc = GetDC(hwnd);
- // Loop through 50 objects
- for (int i = 0; i < 50; i++) {
- uintptr_t objectAddress = 0;
- ReadProcessMemory(hProcess, (LPCVOID)(childrenAddress + (i * sizeof(uintptr_t))), &objectAddress, sizeof(objectAddress), NULL);
- if (!objectAddress) continue;
- // Check if Object has a Humanoid
- uintptr_t humanoidAddress = 0;
- ReadProcessMemory(hProcess, (LPCVOID)(objectAddress + OFFSET_HUMANOID), &humanoidAddress, sizeof(humanoidAddress), NULL);
- if (!humanoidAddress) continue;
- // Check Humanoid State
- int stateId = 0;
- ReadProcessMemory(hProcess, (LPCVOID)(humanoidAddress + OFFSET_STATE_ID), &stateId, sizeof(stateId), NULL);
- // Read Position
- Vector3 position = {0};
- ReadProcessMemory(hProcess, (LPCVOID)(objectAddress + OFFSET_POSITION), &position, sizeof(position), NULL);
- // Calculate dynamic box size based on distance
- float distance = position.z;
- int boxSize = (int)(2000 / distance); // Adjust scaling factor (2000 is arbitrary)
- // Prevent boxes from getting too small or too big
- if (boxSize < 10) boxSize = 10; // Minimum size
- if (boxSize > 100) boxSize = 100; // Maximum size
- // Convert 3D position to screen coordinates
- Vector3 screenPos;
- if (WorldToScreen(position, &screenPos, viewMatrix, screenWidth, screenHeight)) {
- DrawESP(hdc, (int)screenPos.x, (int)screenPos.y, boxSize, boxSize);
- }
- }
- ReleaseDC(hwnd, hdc);
- CloseHandle(hProcess);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement