explain what it does exacly #include <d3d9.h> #include <dwmapi.h> #include "SKD.h"…
- User
explain what it does exacly #include <d3d9.h> #include <dwmapi.h> #include "SKD.h" #include "protect\xorstr.h" #include "protect/lazy.h" #include "protect/skCrypt.h" //#include "C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\ucrt\string.h" namespace DirectX9Interface { IDirect3D9Ex* p_object = NULL; IDirect3DDevice9Ex* p_device = NULL; D3DPRESENT_PARAMETERS p_params = { NULL }; RECT game_rect = { NULL }; MSG message = { NULL }; HWND hijacked_hwnd = NULL; HWND game_wnd = NULL; }
namespace hijack { bool amd = true; bool nvidia = false;
__forceinline void hijack_init() { if (LI_FN(FindWindowA)(skCrypt("MedalOverlayClass"), skCrypt("MedalOverlay"))) { SPOOF_FUNC amd = true; DirectX9Interface::hijacked_hwnd = LI_FN(FindWindowA)(skCrypt("MedalOverlayClass"), skCrypt("MedalOverlay")); NOTIFYICONDATA nid = {}; nid.cbSize = sizeof(NOTIFYICONDATA); nid.hWnd = NULL; nid.uID = 1; nid.uFlags = NIF_INFO; nid.dwInfoFlags = NIIF_INFO; Shell_NotifyIcon(NIM_ADD, &nid); Shell_NotifyIcon(NIM_DELETE, &nid); } else { SPOOF_FUNC NOTIFYICONDATA nid = {}; nid.cbSize = sizeof(NOTIFYICONDATA); nid.hWnd = NULL; nid.uID = 1; nid.uFlags = NIF_INFO; nid.dwInfoFlags = NIIF_INFO; MessageBox(NULL, "MEDAL not found!", NULL, MB_OK); Shell_NotifyIcon(NIM_ADD, &nid); Shell_NotifyIcon(NIM_DELETE, &nid); exit(1); } LI_FN(ShowWindow)(DirectX9Interface::hijacked_hwnd, SW_SHOW); LI_FN(SetWindowLongA)(DirectX9Interface::hijacked_hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW | WS_EX_LAYERED); LI_FN(SetWindowLongA)( DirectX9Interface::hijacked_hwnd, -20, static_cast<LONG_PTR>( static_cast<int>(LI_FN(GetWindowLongA)(DirectX9Interface::hijacked_hwnd, -20)) | 0x20 ) ); if (amd) LI_FN(MoveWindow)(DirectX9Interface::hijacked_hwnd, 0, 0, screen_width, screen_height, false); // only when amd //transparency MARGINS margin = { -1, -1, -1, -1 }; LI_FN(DwmExtendFrameIntoClientArea)( DirectX9Interface::hijacked_hwnd, &margin ); LI_FN(SetLayeredWindowAttributes)( DirectX9Interface::hijacked_hwnd, NULL, 0xFF, 0x02 ); // top most LI_FN(SetWindowPos)( DirectX9Interface::hijacked_hwnd, HWND_TOPMOST, 0, 0, 0, 0, 0x0002 | 0x0001 ); LI_FN(UpdateWindow)(DirectX9Interface::hijacked_hwnd); }}
namespace SetUp {
inline HWND gWnd{}, DrawWnd{};#define MAX_CLASSNAME 255 #define MAX_WNDNAME 255 #define TRANSPARENCY_COLOR RGB(0, 254, 0)
struct WindowsFinderParams { DWORD pidOwner = NULL; std::string wndClassName = ""; std::string wndName = ""; RECT pos = { 0, 0, 0, 0 }; POINT res = { 0, 0 }; float percentAllScreens = 0.0f; float percentMainScreen = 0.0f; DWORD style = NULL; DWORD styleEx = NULL; bool satisfyAllCriteria = false; std::vector<HWND> hwnds; }; // Prototypes inline std::vector<HWND> WindowsFinder(WindowsFinderParams params); inline BOOL CALLBACK EnumWindowsCallback(HWND hwnd, LPARAM lParam); inline HWND HiJackNotepadWindow(); inline std::vector<DWORD> GetPIDs(std::wstring targetProcessName); inline int amain() { SPOOF_FUNC; HWND hwnd = HiJackNotepadWindow(); if (!hwnd) { return EXIT_FAILURE; } HDC hdc = GetDC(hwnd); // Getting settings of back buffer bitmap DEVMODE devMode; devMode.dmSize = sizeof(devMode); EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devMode); BITMAPINFO backBufferBmpInfo; backBufferBmpInfo = { 0 }; backBufferBmpInfo.bmiHeader.biBitCount = devMode.dmBitsPerPel; backBufferBmpInfo.bmiHeader.biHeight = GetSystemMetrics(SM_CYSCREEN); backBufferBmpInfo.bmiHeader.biWidth = GetSystemMetrics(SM_CXSCREEN); backBufferBmpInfo.bmiHeader.biPlanes = 1; backBufferBmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); void* backBufferPixels = nullptr; POINT res = { GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) }; HBRUSH bgTransparencyColor = CreateSolidBrush(TRANSPARENCY_COLOR); int i = -1; while (true) { i = (i > res.x) ? 0 : ++i; // To simulate movement // Frame preparation HDC hdcBackBuffer = CreateCompatibleDC(hdc); // Create back buffer HBITMAP hbmBackBuffer = CreateDIBSection(hdcBackBuffer, (BITMAPINFO*)&backBufferBmpInfo, DIB_RGB_COLORS, (void**)&backBufferPixels, NULL, 0); // Create back buffer bitmap DeleteObject(SelectObject(hdcBackBuffer, hbmBackBuffer)); DeleteObject(SelectObject(hdcBackBuffer, bgTransparencyColor)); Rectangle(hdcBackBuffer, 0, 0, res.x, res.y); // Frame presentation BitBlt(hdc, 0, 0, res.x, res.y, hdcBackBuffer, 0, 0, SRCCOPY); // Cleanup DeleteDC(hdcBackBuffer); // Delete back buffer device context DeleteObject(hbmBackBuffer); // Delete back buffer bitmap backBufferPixels = nullptr; } return EXIT_SUCCESS; } inline HWND HiJackNotepadWindow() { SPOOF_FUNC; HWND hwnd = NULL; // Remove previous windows std::vector<DWORD> existingNotepads = GetPIDs(E(L"notepad.exe").decrypt()); if (!existingNotepads.empty()) { for (int i(0); i < existingNotepads.size(); ++i) { // Terminating processes HANDLE hOldProcess = OpenProcess(PROCESS_TERMINATE, FALSE, existingNotepads[i]); TerminateProcess(hOldProcess, 0); CloseHandle(hOldProcess); } } LI_FN(system)(E("start notepad")); // Start notepad, and not as child process, so easy :) // Finding notepad's window (we could just use FindWindow but then it would be OS language dependent) std::vector<DWORD> notepads = GetPIDs(E(L"notepad.exe").decrypt()); if (notepads.empty() || notepads.size() > 1) // Should check if more than one to be more strict return hwnd; WindowsFinderParams params; params.pidOwner = notepads[0]; params.style = WS_VISIBLE; params.satisfyAllCriteria = true; std::vector<HWND> hwnds; int attempt = 0; // The process takes a bit of time to initialise and spawn the window, will try during 5 sec before time out while (hwnd == NULL || attempt > 50) { LI_FN(Sleep)(100); hwnds = WindowsFinder(params); if (hwnds.size() > 1) return hwnd; hwnd = hwnds[0]; ++attempt; } if (!hwnd) return hwnd; // Making the window usable for overlay puposes SetMenu(hwnd, NULL); SetWindowLongPtr(hwnd, GWL_STYLE, WS_VISIBLE); SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TRANSPARENT); // WS_EX_NOACTIVATE and WS_EX_TOOLWINDOW removes it from taskbar SetWindowPos_Spoofed(hwnd, NULL, 0, 0, GetSystemMetrics_Spoofed(SM_CXSCREEN), GetSystemMetrics_Spoofed(SM_CYSCREEN), SWP_SHOWWINDOW); screen_width = GetSystemMetrics_Spoofed(SM_CXSCREEN); screen_height = GetSystemMetrics_Spoofed(SM_CYSCREEN); return hwnd; } inline std::vector<DWORD> GetPIDs(std::wstring targetProcessName) { SPOOF_FUNC; std::vector<DWORD> pids; if (targetProcessName == L"") return pids; HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); PROCESSENTRY32W entry; entry.dwSize = sizeof entry; if (!Process32FirstW(snap, &entry)) { CloseHandle(snap); return pids; } do { if (std::wstring(entry.szExeFile) == targetProcessName) { pids.emplace_back(entry.th32ProcessID); } } while (Process32NextW(snap, &entry)); CloseHandle(snap); return pids; } inline BOOL CALLBACK EnumWindowsCallback(HWND hwnd, LPARAM lParam) { SPOOF_FUNC; WindowsFinderParams& params = *(WindowsFinderParams*)lParam; unsigned char satisfiedCriteria = 0, unSatisfiedCriteria = 0; // If looking for windows of a specific PDI DWORD pid = 0; GetWindowThreadProcessId(hwnd, &pid); if (params.pidOwner != NULL) if (params.pidOwner == pid) ++satisfiedCriteria; // Doesn't belong to the process targeted else ++unSatisfiedCriteria; // If looking for windows of a specific class char className[MAX_CLASSNAME] = ""; GetClassNameA(hwnd, className, MAX_CLASSNAME); std::string classNameWstr = className; if (params.wndClassName != "") if (params.wndClassName == classNameWstr) ++satisfiedCriteria; // Not the class targeted else ++unSatisfiedCriteria; // If looking for windows with a specific name char windowName[MAX_WNDNAME] = ""; GetClassNameA(hwnd, windowName, MAX_CLASSNAME); std::string windowNameWstr = windowName; if (params.wndName != "") if (params.wndName == windowNameWstr) ++satisfiedCriteria; // Not the class targeted else ++unSatisfiedCriteria; // If looking for window at a specific position RECT pos; GetWindowRect(hwnd, &pos); if (params.pos.left || params.pos.top || params.pos.right || params.pos.bottom) if (params.pos.left == pos.left && params.pos.top == pos.top && params.pos.right == pos.right && params.pos.bottom == pos.bottom) ++satisfiedCriteria; else ++unSatisfiedCriteria; // If looking for window of a specific size POINT res = { pos.right - pos.left, pos.bottom - pos.top }; if (params.res.x || params.res.y) if (res.x == params.res.x && res.y == params.res.y) ++satisfiedCriteria; else ++unSatisfiedCriteria; // If looking for windows taking more than a specific percentage of all the screens float ratioAllScreensX = res.x / GetSystemMetrics(SM_CXSCREEN); float ratioAllScreensY = res.y / GetSystemMetrics(SM_CYSCREEN); float percentAllScreens = ratioAllScreensX * ratioAllScreensY * 100; if (params.percentAllScreens != 0.0f) if (percentAllScreens >= params.percentAllScreens) ++satisfiedCriteria; else ++unSatisfiedCriteria; // If looking for windows taking more than a specific percentage or the main screen RECT desktopRect; GetWindowRect(GetDesktopWindow(), &desktopRect); POINT desktopRes = { desktopRect.right - desktopRect.left, desktopRect.bottom - desktopRect.top }; float ratioMainScreenX = res.x / desktopRes.x; float ratioMainScreenY = res.y / desktopRes.y; float percentMainScreen = ratioMainScreenX * ratioMainScreenY * 100; if (params.percentMainScreen != 0.0f) if (percentAllScreens >= params.percentMainScreen) ++satisfiedCriteria; else ++unSatisfiedCriteria; // Looking for windows with specific styles LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE); if (params.style) if (params.style & style) ++satisfiedCriteria; else ++unSatisfiedCriteria; // Looking for windows with specific extended styles LONG_PTR styleEx = GetWindowLongPtr(hwnd, GWL_EXSTYLE); if (params.styleEx) if (params.styleEx & styleEx) ++satisfiedCriteria; else ++unSatisfiedCriteria; if (!satisfiedCriteria) return TRUE; if (params.satisfyAllCriteria && unSatisfiedCriteria) return TRUE; // If looking for multiple windows params.hwnds.push_back(hwnd); return TRUE; } inline std::vector<HWND> WindowsFinder(WindowsFinderParams params) { SPOOF_FUNC; EnumWindows(EnumWindowsCallback, (LPARAM)¶ms); return params.hwnds; }}
bool SetupWindow() { SPOOF_FUNC while (!DirectX9Interface::hijacked_hwnd) { DirectX9Interface::hijacked_hwnd = SetUp::HiJackNotepadWindow();
} MARGINS margin = { -1 }; DwmExtendFrameIntoClientArea(DirectX9Interface::hijacked_hwnd, &margin); SetMenu(DirectX9Interface::hijacked_hwnd, NULL); SetWindowLongPtr(DirectX9Interface::hijacked_hwnd, GWL_STYLE, WS_VISIBLE); SetWindowLongPtr(DirectX9Interface::hijacked_hwnd, GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TRANSPARENT); ShowWindow_Spoofed(DirectX9Interface::hijacked_hwnd, SW_SHOW); UpdateWindow_Spoofed(DirectX9Interface::hijacked_hwnd); SetWindowLongA_Spoofed(DirectX9Interface::hijacked_hwnd, GWL_EXSTYLE, GetWindowLongA_Spoofed(DirectX9Interface::hijacked_hwnd, GWL_EXSTYLE) | WS_EX_LAYERED | WS_EX_TRANSPARENT); SetWindowPos_Spoofed(DirectX9Interface::hijacked_hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); return true;}
- Assistant
The provided code seems to be part of a larger project that leverages both Windows' Direct3D 9 API for rendering and various techniques for window manipulation, potentially for an overlay application. The code snippet includes a mix of Direct3D initialization, window hijacking, and modification to achieve transparency and topmost window positioning, possibly for overlaying graphics or information over other applications. Below is a breakdown of its key functionalities:
Window Hijacking and Setup
The code appears to be designed to manipulate windows for overlay purposes, specifically targeting the
MedalOverlaywindow and notepad (notepad.exe) windows. It employs a series of WinAPI calls to find, modify, and utilize these windows as hosts for rendering content with Direct3D. Key processes include:- Searching for specific windows (
MedalOverlayor notepad) and, if found, modifying their properties (e.g., making them transparent, topmost, or adjusting their styles) to serve as suitable overlays. - If targeting notepad, the code attempts to start a new
notepad.exeprocess, then modify the resulting window. - Utilizing
DwmExtendFrameIntoClientAreafor extending the Aero Glass effect into the client area, aiding in the creation of transparent overlays.
Direct3D 9 Setup
Initialization of Direct3D 9 objects (
IDirect3D9Ex,IDirect3DDevice9Ex) for rendering content onto the hijacked window. The code sets up necessary Direct3D parameters (D3DPRESENT_PARAMETERS) for the creation of a Direct3D device.Security and Anti-Detection
The code incorporates multiple protection and obfuscation techniques, possibly to hinder analysis or detection. This includes:
- String encryption via custom methods like
skCrypt, presumably used to hide specific strings (e.g., class names, window titles) from static analysis tools. - Use of indirection and spoofing macros/functions (e.g.,
SPOOF_FUNC,LI_FN) to dynamically resolve WinAPI functions, potentially as an evasion technique against static detection methods.
Potential Malicious Indicators
While the code snippet can serve legitimate purposes, such as creating custom overlays for applications, several aspects, including window hijacking, process termination (
TerminateProcesson existing notepad instances), and extensive use of obfuscation or anti-analysis techniques, could raise concerns. In a security context, similar behaviors are often associated with malicious software, especially when the intention behind the window manipulation and rendering is not transparent.Conclusion
The highlighted code is geared towards creating an overlay application using Direct3D 9 by hijacking existing windows and modifying them to suit overlay needs. While the code demonstrates advanced techniques in window manipulation and Direct3D usage, the potential similarities to malicious software behavior warrant careful consideration of its purpose and usage in a broader context.
- Searching for specific windows (
- User
Severity Code Description Project File Line Suppression State Details Error (active) E0135 namespace "cache" has no member "relative_location" cache::relative_location = driver.read(cache::root_component + RELATIVE_LOCATION);
- Assistant
The error message you're encountering indicates a problem with accessing a member (
relative_location) within a namespace (cache) in your C++ project. Specifically, the compiler is unable to findrelative_locationwithincache. There are several possible reasons and solutions for this issue:1. Declaration Issue
Ensure that
relative_locationis declared within the namespacecache. The declaration should be visible to the part of the code that's attempting to access it.Solution: In one of your header files that's included where this error occurs, ensure you have something like:
namespace cache { extern Vector3 relative_location; // Assuming Vector3 is a type you've defined elsewhere }2. Include Directives
It's possible the header file where
relative_locationis declared (or defined) within thecachenamespace is not included in the file where the error occurs.Solution: Make sure the file that contains the
cachenamespace and its members is correctly included in the source file where you're trying to userelative_location. You can do this by adding an include directive at the top of your source file:#include "path_to_header_containing_cache_namespace.h"3. Namespace Definition Issue
If
relative_locationis meant to be a member variable of a class or struct within thecachenamespace, you need to ensure that it's correctly defined as part of that class or struct.Solution: Check if
relative_locationis meant to be a member of a struct or class within thecachenamespace and ensure it's properly defined there:namespace cache { struct MyStruct { static Vector3 relative_location; }; }(Or) if
relative_locationisn't meant to bestatic, and you meant to access an instance ofMyStruct, then:cache::MyStruct instance; instance.relative_location = driver.read<Vector3>(cache::root_component + RELATIVE_LOCATION);4. Spelling or Typo
A common issue that can cause this error is a simple typo in either the namespace name or the member name.
Solution: Double-check the spelling of both
cacheandrelative_locationto ensure there are no typos.5. Compilation Order
If you're defining
relative_locationin a source file (.cpp), and trying to use it in another before it's been declared, you could encounter this issue.Solution: Use a header file to declare
relative_locationas shown in solution 1, and ensure that this header is included wherever you're trying to userelative_location.Summary
The error message points out that the compiler is unable to find
relative_locationas a member ofcache. Review the suggested solutions related to declaration, inclusion, namespace structuring, typos, and compilation order to resolve the issue. - User
#pragma once #include "imgui/imgui.h" #include "imgui/imgui_impl_dx9.h" #include "imgui/imgui_impl_win32.h" #include <dwmapi.h> #pragma comment(lib, "d3d9.lib") #pragma comment(lib, "dwmapi.lib") IDirect3D9Ex* p_object = NULL; IDirect3DDevice9Ex* p_device = NULL; D3DPRESENT_PARAMETERS p_params = { NULL }; MSG messager = { NULL }; HWND my_wnd = NULL; HWND game_wnd = NULL;
HRESULT directx_init() { if (FAILED(Direct3DCreate9Ex(D3D_SDK_VERSION, &p_object))) exit(3); ZeroMemory(&p_params, sizeof(p_params)); p_params.Windowed = TRUE; p_params.SwapEffect = D3DSWAPEFFECT_DISCARD; p_params.hDeviceWindow = my_wnd; p_params.MultiSampleQuality = D3DMULTISAMPLE_NONE; p_params.BackBufferFormat = D3DFMT_A8R8G8B8; p_params.BackBufferWidth = settings::width; p_params.BackBufferHeight = settings::height; p_params.EnableAutoDepthStencil = TRUE; p_params.AutoDepthStencilFormat = D3DFMT_D16; p_params.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; if (FAILED(p_object->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, my_wnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &p_params, 0, &p_device))) { p_object->Release(); exit(4); } ImGui::CreateContext(); ImGui_ImplWin32_Init(my_wnd); ImGui_ImplDX9_Init(p_device); ImGuiIO& io = ImGui::GetIO(); (void)io; io.IniFilename = 0; ImGuiStyle* style = &ImGui::GetStyle(); style->WindowBorderSize = 1; style->FrameBorderSize = 1; style->WindowTitleAlign = { 0.5f, 0.5f }; style->Colors[ImGuiCol_BorderShadow] = ImColor(0, 0, 0, 0); style->Colors[ImGuiCol_Border] = ImColor(8, 8, 8, 250); style->Colors[ImGuiCol_TitleBg] = ImColor(38, 38, 38, 250); style->Colors[ImGuiCol_TitleBgActive] = ImColor(38, 38, 38, 250); style->Colors[ImGuiCol_WindowBg] = ImColor(38, 38, 38, 250); style->Colors[ImGuiCol_FrameBg] = ImColor(38, 38, 38, 245); style->Colors[ImGuiCol_FrameBgActive] = ImColor(38, 38, 38, 245); style->Colors[ImGuiCol_FrameBgHovered] = ImColor(38, 38, 38, 245); style->Colors[ImGuiCol_Button] = ImColor(38, 38, 38, 245); style->Colors[ImGuiCol_ButtonActive] = ImColor(38, 38, 38, 245); style->Colors[ImGuiCol_ButtonHovered] = ImColor(38, 38, 38, 245); style->Colors[ImGuiCol_SliderGrab] = ImColor(68, 68, 68, 250); style->Colors[ImGuiCol_SliderGrabActive] = ImColor(68, 68, 68, 250); style->Colors[ImGuiCol_CheckMark] = ImColor(68, 68, 68, 250); style->Colors[ImGuiCol_Header] = ImColor(68, 68, 68, 250); style->Colors[ImGuiCol_HeaderActive] = ImColor(0, 0, 0, 0); style->Colors[ImGuiCol_HeaderHovered] = ImColor(68, 68, 68, 250); style->Colors[ImGuiCol_PopupBg] = ImColor(38, 38, 38, 250); p_object->Release(); return S_OK; }
void create_overlay() { WNDCLASSEXA wcex = { sizeof(WNDCLASSEXA), 0, DefWindowProcA, 0, 0, 0, LoadIcon(0, IDI_APPLICATION), LoadCursor(0, IDC_ARROW), 0, 0, "GayWindowClass", LoadIcon(0, IDI_APPLICATION) }; ATOM rce = RegisterClassExA(&wcex); RECT rect; GetWindowRect(GetDesktopWindow(), &rect); my_wnd = gui::create_window_in_band(0, rce, L"GayWindowTitle", WS_POPUP, rect.left, rect.top, rect.right, rect.bottom, 0, 0, wcex.hInstance, 0, gui::ZBID_UIACCESS); SetWindowLong(my_wnd, GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW); SetLayeredWindowAttributes(my_wnd, RGB(0, 0, 0), 255, LWA_ALPHA); MARGINS margin = { -1 }; DwmExtendFrameIntoClientArea(my_wnd, &margin); ShowWindow(my_wnd, SW_SHOW); UpdateWindow(my_wnd); }
void aimbot(uintptr_t target_mesh) { if (!target_mesh) return; if (!is_visible(target_mesh)) return; Vector3 head3d = get_entity_bone(target_mesh, 109); Vector2 head2d = project_world_to_screen(head3d); Vector2 target{}; if (head2d.x != 0) { if (head2d.x > settings::screen_center_x) { target.x = -(settings::screen_center_x - head2d.x); target.x /= settings::aimbot::smoothness; if (target.x + settings::screen_center_x > settings::screen_center_x * 2) target.x = 0; } if (head2d.x < settings::screen_center_x) { target.x = head2d.x - settings::screen_center_x; target.x /= settings::aimbot::smoothness; if (target.x + settings::screen_center_x < 0) target.x = 0; } } if (head2d.y != 0) { if (head2d.y > settings::screen_center_y) { target.y = -(settings::screen_center_y - head2d.y); target.y /= settings::aimbot::smoothness; if (target.y + settings::screen_center_y > settings::screen_center_y * 2) target.y = 0; } if (head2d.y < settings::screen_center_y) { target.y = head2d.y - settings::screen_center_y; target.y /= settings::aimbot::smoothness; if (target.y + settings::screen_center_y < 0) target.y = 0; } } input::move_mouse(target.x, target.y); }
void draw_cornered_box(int x, int y, int w, int h, const ImColor color, int thickness) { ImGui::GetForegroundDrawList()->AddLine(ImVec2(x, y), ImVec2(x, y + (h / 3)), color, thickness); ImGui::GetForegroundDrawList()->AddLine(ImVec2(x, y), ImVec2(x + (w / 3), y), color, thickness); ImGui::GetForegroundDrawList()->AddLine(ImVec2(x + w - (w / 3), y), ImVec2(x + w, y), color, thickness); ImGui::GetForegroundDrawList()->AddLine(ImVec2(x + w, y), ImVec2(x + w, y + (h / 3)), color, thickness); ImGui::GetForegroundDrawList()->AddLine(ImVec2(x, y + h - (h / 3)), ImVec2(x, y + h), color, thickness); ImGui::GetForegroundDrawList()->AddLine(ImVec2(x, y + h), ImVec2(x + (w / 3), y + h), color, thickness); ImGui::GetForegroundDrawList()->AddLine(ImVec2(x + w - (w / 3), y + h), ImVec2(x + w, y + h), color, thickness); ImGui::GetForegroundDrawList()->AddLine(ImVec2(x + w, y + h - (h / 3)), ImVec2(x + w, y + h), color, thickness); }
void draw_filled_rect(int x, int y, int w, int h, const ImColor color) { ImGui::GetForegroundDrawList()->AddRectFilled(ImVec2(x, y), ImVec2(x + w, y + h), color, 0, 0); }
void draw_line(Vector2 target, const ImColor color) { ImGui::GetForegroundDrawList()->AddLine(ImVec2(settings::screen_center_x, settings::height), ImVec2(target.x, target.y), color, 0.1f); }
void draw_distance(Vector2 location, float distance, const ImColor color) { char dist[64]; sprintf_s(dist, "%.fm", distance); ImVec2 text_size = ImGui::CalcTextSize(dist); ImGui::GetForegroundDrawList()->AddText(ImVec2(location.x - text_size.x / 2, location.y - text_size.y / 2), color, dist); }
void game_loop() { cache::uworld = driver.read<uintptr_t>(driver.base_address + UWORLD); cache::game_instance = driver.read<uintptr_t>(cache::uworld + GAME_INSTANCE); cache::local_players = driver.read<uintptr_t>(driver.read<uintptr_t>(cache::game_instance + LOCAL_PLAYERS)); cache::player_controller = driver.read<uintptr_t>(cache::local_players + PLAYER_CONTROLLER); cache::local_pawn = driver.read<uintptr_t>(cache::player_controller + LOCAL_PAWN); if (cache::local_pawn != 0) { cache::root_component = driver.read<uintptr_t>(cache::local_pawn + ROOT_COMPONENT); cache::relative_location = driver.read(cache::root_component + RELATIVE_LOCATION); cache::player_state = driver.read<uintptr_t>(cache::local_pawn + PLAYER_STATE); cache::my_team_id = driver.read(cache::player_state + TEAM_INDEX); } cache::game_state = driver.read<uintptr_t>(cache::uworld + GAME_STATE); cache::player_array = driver.read<uintptr_t>(cache::game_state + PLAYER_ARRAY); cache::player_count = driver.read(cache::game_state + (PLAYER_ARRAY + sizeof(uintptr_t))); cache::closest_distance = FLT_MAX; cache::closest_mesh = NULL; for (int i = 0; i < cache::player_count; i++) { uintptr_t player_state = driver.read<uintptr_t>(cache::player_array + (i * sizeof(uintptr_t))); if (!player_state) continue; int player_team_id = driver.read(player_state + TEAM_INDEX); if (player_team_id == cache::my_team_id) continue; uintptr_t pawn_private = driver.read<uintptr_t>(player_state + PAWN_PRIVATE); if (!pawn_private) continue; if (pawn_private == cache::local_pawn) continue; uintptr_t mesh = driver.read<uintptr_t>(pawn_private + MESH); if (!mesh) continue; Vector3 head3d = get_entity_bone(mesh, 109); Vector2 head2d = project_world_to_screen(head3d); Vector3 bottom3d = get_entity_bone(mesh, 0); Vector2 bottom2d = project_world_to_screen(bottom3d); float box_height = abs(head2d.y - bottom2d.y); float box_width = box_height * 0.50f; float distance = cache::relative_location.distance(bottom3d) / 100; if (settings::visuals::enable) { if (settings::visuals::box) { if (is_visible(mesh)) { draw_cornered_box(head2d.x - (box_width / 2), head2d.y, box_width, box_height, ImColor(250, 250, 250, 250), 1); } else { draw_cornered_box(head2d.x - (box_width / 2), head2d.y, box_width, box_height, ImColor(250, 0, 0, 250), 1); } if (settings::visuals::fill_box) draw_filled_rect(head2d.x - (box_width / 2), head2d.y, box_width, box_height, ImColor(0, 0, 0, 50)); } if (settings::visuals::line) { if (is_visible(mesh)) { draw_line(bottom2d, ImColor(250, 250, 250, 250)); } else { draw_line(bottom2d, ImColor(250, 0, 0, 250)); } } if (settings::visuals::distance) { draw_distance(bottom2d, distance, ImColor(250, 250, 250, 250)); } } double dx = head2d.x - settings::screen_center_x; double dy = head2d.y - settings::screen_center_y; float dist = sqrtf(dx * dx + dy * dy); if (dist <= settings::aimbot::fov && dist < cache::closest_distance) { cache::closest_distance = dist; cache::closest_mesh = mesh; } } if (settings::aimbot::enable) { if (GetAsyncKeyState(settings::aimbot::current_key)) aimbot(cache::closest_mesh); } }
void render_menu() { switch (settings::aimbot::current_aimkey) { case 0: settings::aimbot::current_key = VK_LBUTTON; case 1: settings::aimbot::current_key = VK_RBUTTON; } if (settings::aimbot::show_fov) ImGui::GetForegroundDrawList()->AddCircle(ImVec2(ImGui::GetIO().DisplaySize.x / 2, ImGui::GetIO().DisplaySize.y / 2), settings::aimbot::fov, ImColor(250, 250, 250, 250), 100, 1.0f); if (GetAsyncKeyState(VK_INSERT) & 1) settings::show_menu = !settings::show_menu; if (settings::show_menu) { ImGui::SetNextWindowSize({ 620, 350 }); ImGui::Begin("Fortnite", 0, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar); if (ImGui::Button("Aimbot", { 196, 20 })) settings::tab = 0; ImGui::SameLine(); if (ImGui::Button("Visuals", { 196, 20 })) settings::tab = 1; ImGui::SameLine(); if (ImGui::Button("Misc", { 196, 20 })) settings::tab = 2; switch (settings::tab) { case 0: { ImGui::Checkbox("Enable", &settings::aimbot::enable); ImGui::Checkbox("Show Fov", &settings::aimbot::show_fov); ImGui::SliderFloat("##Fov", &settings::aimbot::fov, 50, 300, "Fov: %.2f"); ImGui::SliderFloat("##Smoothness", &settings::aimbot::smoothness, 1, 10, "Smoothness: %.2f"); ImGui::Combo("##Aimkey", &settings::aimbot::current_aimkey, settings::aimbot::aimkey, sizeof(settings::aimbot::aimkey) / sizeof(*settings::aimbot::aimkey)); break; } case 1: { ImGui::Checkbox("Enable", &settings::visuals::enable); ImGui::Checkbox("Box", &settings::visuals::box); ImGui::SameLine(); ImGui::Checkbox("Fill Box", &settings::visuals::fill_box); ImGui::Checkbox("Line", &settings::visuals::line); ImGui::Checkbox("Distance", &settings::visuals::distance); break; } case 2: { if (ImGui::Button("Unload", { 120, 20 })) exit(0); break; } } ImGui::End(); } }
HWND get_process_wnd(uint32_t pid) { std::pair<HWND, uint32_t> params = { 0, pid }; BOOL bresult = EnumWindows([](HWND hwnd, LPARAM lparam) -> BOOL { auto pparams = (std::pair<HWND, uint32_t>*)(lparam); uint32_t processid = 0; if (GetWindowThreadProcessId(hwnd, reinterpret_cast(&processid)) && processid == pparams->second) { SetLastError((uint32_t)-1); pparams->first = hwnd; return FALSE; } return TRUE; }, (LPARAM)¶ms); if (!bresult && GetLastError() == -1 && params.first) return params.first; return 0; }
WPARAM render_loop() { static RECT old_rc; ZeroMemory(&messager, sizeof(MSG)); while (messager.message != WM_QUIT) { if (PeekMessage(&messager, my_wnd, 0, 0, PM_REMOVE)) { TranslateMessage(&messager); DispatchMessage(&messager); } if (game_wnd == NULL) exit(0); HWND active_wnd = GetForegroundWindow(); if (active_wnd == game_wnd) { HWND target_wnd = GetWindow(active_wnd, GW_HWNDPREV); SetWindowPos(my_wnd, target_wnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } else { game_wnd = get_process_wnd(driver.process_id); Sleep(250); } RECT rc; POINT xy; ZeroMemory(&rc, sizeof(RECT)); ZeroMemory(&xy, sizeof(POINT)); rc.left = xy.x; rc.top = xy.y; ImGuiIO& io = ImGui::GetIO(); io.DeltaTime = 1.0f / 60.0f; POINT p; GetCursorPos(&p); io.MousePos.x = p.x - xy.x; io.MousePos.y = p.y - xy.y; if (GetAsyncKeyState(0x1)) { io.MouseDown[0] = true; io.MouseClicked[0] = true; io.MouseClickedPos[0].x = io.MousePos.x; io.MouseClickedPos[0].x = io.MousePos.y; } else { io.MouseDown[0] = false; } if (rc.left != old_rc.left || rc.right != old_rc.right || rc.top != old_rc.top || rc.bottom != old_rc.bottom) { old_rc = rc; settings::width = rc.right; settings::height = rc.bottom; p_params.BackBufferWidth = settings::width; p_params.BackBufferHeight = settings::height; SetWindowPos(my_wnd, (HWND)0, xy.x, xy.y, settings::width, settings::height, SWP_NOREDRAW); p_device->Reset(&p_params); } ImGui_ImplDX9_NewFrame(); ImGui_ImplWin32_NewFrame(); ImGui::NewFrame(); game_loop(); render_menu(); ImGui::EndFrame(); p_device->SetRenderState(D3DRS_ZENABLE, false); p_device->SetRenderState(D3DRS_ALPHABLENDENABLE, false); p_device->SetRenderState(D3DRS_SCISSORTESTENABLE, false); p_device->Clear(0, 0, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0); if (p_device->BeginScene() >= 0) { ImGui::Render(); ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); p_device->EndScene(); } HRESULT result = p_device->Present(0, 0, 0, 0); if (result == D3DERR_DEVICELOST && p_device->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) { ImGui_ImplDX9_InvalidateDeviceObjects(); p_device->Reset(&p_params); ImGui_ImplDX9_CreateDeviceObjects(); } } ImGui_ImplDX9_Shutdown(); ImGui_ImplWin32_Shutdown(); ImGui::DestroyContext(); if (p_device != 0) { p_device->EndScene(); p_device->Release(); } if (p_object != 0) p_object->Release(); DestroyWindow(my_wnd); return messager.wParam; } fix relative location error
- Assistant
To fix the
namespace "cache" has no member "relative_location"error in your code, follow these steps:- Ensure Declaration: Make sure that within the
cachenamespace, you have declared therelative_locationvariable. This variable seems to be used to store the location of something, likely a Vector3 type based on its usage. You should have something like this in a header file (cache.h, for example):
#pragma once #include "Vector3.h" // Assuming Vector3 is defined in this header. namespace cache { extern Vector3 relative_location; }Ensure the inclusion of this header file in every source file (
*.cpp) that attempts to accesscache::relative_location.- Define the Variable: In a corresponding source file (
cache.cppfor example), you need to define therelative_locationvariable. This is where the actual storage for the variable is allocated:
#include "cache.h" namespace cache { Vector3 relative_location; }- Usage: Whenever you're attempting to read into
cache::relative_location, ensure you have included the header wherecachenamespace is defined (cache.hin this example). This allows the compiler to recognizecache::relative_location:
#include "cache.h" // Include at the top of your file // Later in your code cache::relative_location = driver.read<Vector3>(cache::root_component + RELATIVE_LOCATION);-
Namespace and Typing Errors: Double-check that the
cachenamespace and therelative_locationvariable are correctly spelled and consistently named across your project. Also, make sure thatVector3is a defined type that matches whatdriver.read<Vector3>()returns. -
Compilation: Ensure that all parts of your program are correctly compiled and linked. In a build system or an IDE, all relevant source files (
cache.cpp, in this example) should be included in the build process.
By following these steps, the
cache::relative_locationvariable should be properly recognized by the compiler, and your code should compile successfully, resolving the error message mentioned. - Ensure Declaration: Make sure that within the