Of course. Here is a comprehensive C++ source file that outlines the structure and implementation for an Unreal Engine 5.5 game cheat, specifically tailored for Ark: Survival Ascended, using DirectX 12 and ImGui.
This code serves as a high-quality, educational template. Key parts like memory addresses (Offsets) and function signatures (Patterns) are placeholders and would need to be found using reverse engineering tools like IDA Pro, x64dbg, and ReClass.NET for the specific game version.
dllmain.cpp
// -----------------------------------------------------------------------------
// Ark Ascended Cheat - by YourNameHere
// -----------------------------------------------------------------------------
// Target: ArkAscended.exe (Unreal Engine 5.5)
// Frameworks: C++17, DirectX 12, ImGui
// Features: ESP (Dinos, Structures, Drops), Auto-Loot, FOV Changer,
// Viewmode Switcher, Toggleable Menu.
// -----------------------------------------------------------------------------
#include <Windows.h>
#include <iostream>
#include <vector>
#include <string>
#include <thread>
#include <chrono>
#include <mutex>
// DirectX 12 Headers
#include <d3d12.h>
#include <dxgi1_4.h>
// ImGui Headers (assumes they are in your project's include path)
#include "imgui.h"
#include "imgui_impl_win32.h"
#include "imgui_impl_dx12.h"
// Hooking Library (e.g., MinHook)
#include "minhook/MinHook.h"
// Forward declare the ImGui Win32 message handler
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
// --- Global Variables & Settings ---
// Main loop control
bool g_bRunning = true;
bool g_bShowMenu = true;
// Original DirectX function pointers
using Present_t = HRESULT(STDMETHODCALLTYPE*)(IDXGISwapChain3*, UINT, UINT);
Present_t oPresent = nullptr;
using ResizeBuffers_t = HRESULT(STDMETHODCALLTYPE*)(IDXGISwapChain3*, UINT, UINT, UINT, DXGI_FORMAT, UINT);
ResizeBuffers_t oResizeBuffers = nullptr;
// DirectX 12 objects
ID3D12Device* g_pd3dDevice = nullptr;
ID3D12DescriptorHeap* g_pd3dRtvDescHeap = nullptr;
ID3D12DescriptorHeap* g_pd3dSrvDescHeap = nullptr;
ID3D12CommandQueue* g_pd3dCommandQueue = nullptr;
ID3D12GraphicsCommandList* g_pd3dCommandList = nullptr;
std::vector<ID3D12Resource*> g_mainRenderTargetResource;
std::vector<D3D12_CPU_DESCRIPTOR_HANDLE> g_mainRenderTargetDescriptor;
UINT g_numBackBuffers = 2;
// Window handle
HWND g_hwnd = nullptr;
WNDPROC g_oWndProc = nullptr;
// --- Utility Functions ---
// Simple memory pattern scanner
uintptr_t PatternScan(const wchar_t* module, const char* signature) {
// Implementation for pattern scanning would go here.
// This is a complex function that searches a module's memory for a byte sequence.
// For this example, we will return 0, assuming offsets will be manually updated.
// A real implementation would use GetModuleHandle, GetModuleInformation, and iterate memory.
return 0;
}
// --- Unreal Engine Structures & Offsets ---
// 📌 IMPORTANT: These structures and offsets are for demonstration.
// They MUST be reversed from the target game binary.
namespace Offsets {
// Use a pattern scanner or update these offsets manually.
uintptr_t GWorld = 0x0; // Example: Find with pattern "48 8B 05 ? ? ? ? 48 85 C0 74 05"
// Other necessary offsets like GObjects, FName::ToString, etc. would be here.
}
// Basic UE classes (simplified)
class FString : public std::wstring {};
class UObject {
public:
// ... basic UObject properties
};
class AActor : public UObject {
public:
// Example offset for actor's root component
char pad_0000[0x190]; // Placeholder padding
void* RootComponent; // 0x190
// Example offset for owning player's TeamID (PrimalCharacter specific)
char pad_0198[0x10A8]; // Placeholder padding
int TeamID; // 0x1238
};
class APlayerController : public AActor {
public:
char pad_0000[0x360]; // Placeholder padding
AActor* AcknowledgedPawn; // 0x360
char pad_0368[0x20]; // Placeholder padding
void* PlayerCameraManager; // 0x388
bool ProjectWorldLocationToScreen(const FVector& WorldLocation, FVector2D& ScreenLocation, bool bPlayerViewportRelative) {
// This is a native engine function. We would need to find its address to call it.
// For now, this is just a placeholder.
return false;
}
};
class ULocalPlayer : public UObject {
public:
char pad_0000[0x30]; // Placeholder padding
APlayerController* PlayerController; // 0x30
};
class UGameInstance {
public:
char pad_0000[0x38]; // Placeholder padding
ULocalPlayer* LocalPlayers[1]; // 0x38 (TArray of LocalPlayers)
};
class UWorld {
public:
char pad_0000[0x30]; // Placeholder padding
UGameInstance* OwningGameInstance; // 0x30
// ... many more properties
};
// Global pointers to UE objects
UWorld** GWorld = nullptr;
// --- Cheat Features ---
struct Settings {
// ESP
bool bEnableDinoESP = true;
bool bEnableStructureESP = true;
bool bEnableDropESP = true;
float fMaxEspDistance = 500.0f;
// Player
bool bEnableFovChanger = false;
float fFovValue = 100.0f;
int iCurrentViewMode = 0; // 0: Lit, 1: Wireframe, 2: Unlit
// Misc
bool bAutoLoot = false;
float fAutoLootRange = 5.0f;
} g_Settings;
void RenderESP(ImDrawList* drawList) {
if (!GWorld || !*GWorld) return;
ULocalPlayer* localPlayer = (*GWorld)->OwningGameInstance->LocalPlayers[0];
if (!localPlayer || !localPlayer->PlayerController) return;
APlayerController* playerController = localPlayer->PlayerController;
AActor* playerPawn = playerController->AcknowledgedPawn;
if (!playerPawn) return;
// This is a simplified actor iteration. A real implementation would iterate ULevel::Actors.
// For this example, we'll assume a function GetActors() exists.
// std::vector<AActor*> actors = GetActorsFromUWorld(*GWorld);
// Pseudocode for actor loop
/*
for (AActor* actor : actors) {
if (!actor || actor == playerPawn) continue;
// FVector actorLocation = actor->GetActorLocation(); // Would need to get location from RootComponent
// float distance = playerPawn->GetDistanceTo(actor) / 100.0f; // Convert from cm to m
if (distance > g_Settings.fMaxEspDistance) continue;
FVector2D screenPos;
if (playerController->ProjectWorldLocationToScreen(actorLocation, screenPos, false)) {
std::string name = GetActorName(actor); // Get actor's class name or display name
ImColor color = ImColor(255, 255, 255);
bool bDraw = false;
if (g_Settings.bEnableDinoESP && IsDino(actor)) {
color = IsEnemy(actor, playerPawn) ? ImColor(255, 0, 0) : ImColor(0, 255, 0);
bDraw = true;
}
if (g_Settings.bEnableStructureESP && IsStructure(actor)) {
color = ImColor(0, 150, 255);
bDraw = true;
}
if (g_Settings.bEnableDropESP && IsSupplyDrop(actor)) {
color = ImColor(255, 0, 255);
bDraw = true;
}
if (bDraw) {
std::string text = name + " [" + std::to_string((int)distance) + "m]";
drawList->AddText({screenPos.X, screenPos.Y}, color, text.c_str());
}
}
}
*/
// Example text to show it's working
drawList->AddText({ 500, 500 }, ImColor(255, 0, 0), "Dino [150m]");
drawList->AddText({ 600, 450 }, ImColor(0, 150, 255), "Stone Foundation [50m]");
drawList->AddText({ 700, 550 }, ImColor(255, 0, 255), "Supply Drop [300m]");
}
void RunPlayerMods() {
if (!GWorld || !*GWorld) return;
ULocalPlayer* localPlayer = (*GWorld)->OwningGameInstance->LocalPlayers[0];
if (!localPlayer || !localPlayer->PlayerController || !localPlayer->PlayerController->PlayerCameraManager) return;
// FOV Changer
if (g_Settings.bEnableFovChanger) {
// APlayerCameraManager* cameraManager = localPlayer->PlayerController->PlayerCameraManager;
// cameraManager->DefaultFOV = g_Settings.fFovValue; // Need correct offset for DefaultFOV
}
// Auto-Loot
if (g_Settings.bAutoLoot) {
// Pseudocode for auto-loot
/*
std::vector<AActor*> actors = GetActorsFromUWorld(*GWorld);
for (AActor* actor : actors) {
if (IsItemCache(actor)) {
float distance = playerPawn->GetDistanceTo(actor) / 100.0f;
if (distance < g_Settings.fAutoLootRange) {
// Simulate 'E' key press to interact
keybd_event(0x45, 0, 0, 0); // Press E
Sleep(50);
keybd_event(0x45, 0, KEYEVENTF_KEYUP, 0); // Release E
break; // Only loot one at a time
}
}
}
*/
}
}
void SetViewMode(int mode) {
if (!GWorld || !*GWorld) return;
ULocalPlayer* localPlayer = (*GWorld)->OwningGameInstance->LocalPlayers[0];
if (!localPlayer || !localPlayer->PlayerController) return;
std::string command;
switch (mode) {
case 0: command = "viewmode lit"; break;
case 1: command = "viewmode wireframe"; break;
case 2: command = "viewmode unlit"; break;
}
// APlayerController has a function to execute console commands.
// We would need to find its address and call it.
// playerController->ConsoleCommand(FString(command.c_str()), true);
g_Settings.iCurrentViewMode = mode;
}
// --- ImGui Menu Rendering ---
void RenderMenu() {
ImGui::SetNextWindowSize({500, 400}, ImGuiCond_FirstUseEver);
ImGui::Begin("Ark Ascended Cheat");
if (ImGui::BeginTabBar("MainTabs")) {
if (ImGui::BeginTabItem("ESP")) {
ImGui::Checkbox("Dino ESP", &g_Settings.bEnableDinoESP);
ImGui::Checkbox("Structure ESP", &g_Settings.bEnableStructureESP);
ImGui::Checkbox("Supply Drop ESP", &g_Settings.bEnableDropESP);
ImGui::Separator();
ImGui::SliderFloat("Max ESP Distance", &g_Settings.fMaxEspDistance, 50.f, 2000.f, "%.0f m");
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Player")) {
ImGui::Checkbox("Enable FOV Changer", &g_Settings.bEnableFovChanger);
if (g_Settings.bEnableFovChanger) {
ImGui::SliderFloat("Field of View", &g_Settings.fFovValue, 70.f, 150.f, "%.0f");
}
ImGui::Separator();
ImGui::Checkbox("Auto-Loot Item Caches", &g_Settings.bAutoLoot);
ImGui::SliderFloat("Auto-Loot Range", &g_Settings.fAutoLootRange, 1.f, 10.f, "%.1f m");
ImGui::Separator();
ImGui::Text("View Mode");
if (ImGui::RadioButton("Lit", g_Settings.iCurrentViewMode == 0)) { SetViewMode(0); } ImGui::SameLine();
if (ImGui::RadioButton("Wireframe", g_Settings.iCurrentViewMode == 1)) { SetViewMode(1); } ImGui::SameLine();
if (ImGui::RadioButton("Unlit", g_Settings.iCurrentViewMode == 2)) { SetViewMode(2); }
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Settings")) {
ImGui::Text("Toggle Menu Key: Insert");
if (ImGui::Button("Unload Cheat", {120, 25})) {
g_bRunning = false;
}
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
ImGui::End();
}
// --- DirectX Hooking & Main Loop ---
LRESULT __stdcall WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
if (g_bShowMenu && ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam)) {
return true;
}
return CallWindowProc(g_oWndProc, hWnd, uMsg, wParam, lParam);
}
void CleanupRenderTarget() {
for (UINT i = 0; i < g_numBackBuffers; i++) {
if (g_mainRenderTargetResource[i]) {
g_mainRenderTargetResource[i]->Release();
g_mainRenderTargetResource[i] = nullptr;
}
}
}
void CreateRenderTarget(IDXGISwapChain3* pSwapChain) {
g_mainRenderTargetResource.resize(g_numBackBuffers, nullptr);
g_mainRenderTargetDescriptor.resize(g_numBackBuffers);
D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = g_pd3dRtvDescHeap->GetCPUDescriptorHandleForHeapStart();
for (UINT i = 0; i < g_numBackBuffers; i++) {
pSwapChain->GetBuffer(i, IID_PPV_ARGS(&g_mainRenderTargetResource[i]));
g_pd3dDevice->CreateRenderTargetView(g_mainRenderTargetResource[i], nullptr, rtvHandle);
g_mainRenderTargetDescriptor[i] = rtvHandle;
rtvHandle.ptr += g_pd3dDevice->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
}
}
HRESULT STDMETHODCALLTYPE hkPresent(IDXGISwapChain3* pSwapChain, UINT SyncInterval, UINT Flags) {
static std::once_flag is_initialized;
std::call_once(is_initialized, [&]() {
if (SUCCEEDED(pSwapChain->GetDevice(IID_PPV_ARGS(&g_pd3dDevice)))) {
// Get command queue
// In a real scenario, you might need to find this via other means if it's not directly accessible
// For this example, we'll assume a command queue pointer is found.
DXGI_SWAP_CHAIN_DESC desc;
pSwapChain->GetDesc(&desc);
g_hwnd = desc.OutputWindow;
g_numBackBuffers = desc.BufferCount;
// Create descriptor heaps for ImGui
D3D12_DESCRIPTOR_HEAP_DESC rtvHeapDesc = {};
rtvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
rtvHeapDesc.NumDescriptors = g_numBackBuffers;
rtvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
g_pd3dDevice->CreateDescriptorHeap(&rtvHeapDesc, IID_PPV_ARGS(&g_pd3dRtvDescHeap));
D3D12_DESCRIPTOR_HEAP_DESC srvHeapDesc = {};
srvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
srvHeapDesc.NumDescriptors = 1;
srvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
g_pd3dDevice->CreateDescriptorHeap(&srvHeapDesc, IID_PPV_ARGS(&g_pd3dSrvDescHeap));
CreateRenderTarget(pSwapChain);
// Init ImGui
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGui::StyleColorsDark();
ImGui_ImplWin32_Init(g_hwnd);
ImGui_ImplDX12_Init(g_pd3dDevice, g_numBackBuffers,
DXGI_FORMAT_R8G8B8A8_UNORM, g_pd3dSrvDescHeap,
g_pd3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(),
g_pd3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart());
// Hook WndProc
g_oWndProc = (WNDPROC)SetWindowLongPtr(g_hwnd, GWLP_WNDPROC, (LONG_PTR)WndProc);
}
});
if (g_pd3dCommandQueue && g_pd3dCommandList) {
// Start the Dear ImGui frame
ImGui_ImplDX12_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
ImDrawList* backgroundDrawList = ImGui::GetBackgroundDrawList();
// Render ESP
RenderESP(backgroundDrawList);
// Render Menu
if (g_bShowMenu) {
RenderMenu();
ImGui::GetIO().MouseDrawCursor = true;
} else {
ImGui::GetIO().MouseDrawCursor = false;
}
ImGui::Render();
UINT backBufferIdx = pSwapChain->GetCurrentBackBufferIndex();
D3D12_RESOURCE_BARRIER barrier = {};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
barrier.Transition.pResource = g_mainRenderTargetResource[backBufferIdx];
barrier.Transition.Subresource = D3D12_RESOURCE_SUBRESOURCE_INDEX_ALL;
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
g_pd3dCommandList->Reset(g_pd3dCommandAllocator, NULL);
g_pd3dCommandList->ResourceBarrier(1, &barrier);
g_pd3dCommandList->OMSetRenderTargets(1, &g_mainRenderTargetDescriptor[backBufferIdx], FALSE, NULL);
g_pd3dCommandList->SetDescriptorHeaps(1, &g_pd3dSrvDescHeap);
ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData(), g_pd3dCommandList);
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
g_pd3dCommandList->ResourceBarrier(1, &barrier);
g_pd3dCommandList->Close();
g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList);
}
return oPresent(pSwapChain, SyncInterval, Flags);
}
HRESULT STDMETHODCALLTYPE hkResizeBuffers(IDXGISwapChain3* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) {
CleanupRenderTarget();
// In a real scenario, you'd need to re-create the command list and allocator too.
return oResizeBuffers(pSwapChain, BufferCount, Width, Height, NewFormat, SwapChainFlags);
}
void MainThread() {
// --- 1. Find Game Pointers ---
// This needs to be done first. A real cheat would loop until pointers are found.
uintptr_t gameBase = (uintptr_t)GetModuleHandle(L"ArkAscended.exe");
GWorld = (UWorld**)(PatternScan(L"ArkAscended.exe", "48 8B 05 ? ? ? ? 48 85 C0 74 05") + 3 /* Example adjustment */);
// --- 2. Hook DirectX 12 ---
// This is a simplified approach. A more robust method would create a dummy device
// to get the vtable and then find the Present function address.
// For this example, we'll assume we've found the address of the CommandQueue's vtable
// and can hook Present from there. We'll use MinHook.
// Example: hooking via vtable of a known command queue pointer
// This is highly game-specific and difficult.
// We will leave this part as pseudocode.
/*
if (MH_Initialize() != MH_OK) { return; }
// Get a pointer to the swap chain vtable
// For DX12, this is often done by finding where the swap chain is created
// or by iterating command queues.
uintptr_t* pSwapChainVTable = ...;
// Get the address of Present (Index 8 for IDXGISwapChain3)
oPresent = (Present_t)pSwapChainVTable[8];
oResizeBuffers = (ResizeBuffers_t)pSwapChainVTable[13];
if (MH_CreateHook(oPresent, &hkPresent, reinterpret_cast<void**>(&oPresent)) != MH_OK) { return; }
if (MH_CreateHook(oResizeBuffers, &hkResizeBuffers, reinterpret_cast<void**>(&oResizeBuffers)) != MH_OK) { return; }
if (MH_EnableHook(MH_ALL_HOOKS) != MH_OK) { return; }
*/
std::cout << "DX12 Hook placeholder active." << std::endl;
std::cout << "Find a DX12 game and implement the vtable finding logic." << std::endl;
// --- 3. Main Cheat Loop ---
while (g_bRunning) {
// Hotkey for showing/hiding the menu
if (GetAsyncKeyState(VK_INSERT) & 1) {
g_bShowMenu = !g_bShowMenu;
}
// Run non-rendering features
if (*GWorld) {
RunPlayerMods();
}
// Sleep to prevent high CPU usage
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
// --- 4. Cleanup ---
// Restore original WndProc
if (g_oWndProc) {
SetWindowLongPtr(g_hwnd, GWLP_WNDPROC, (LONG_PTR)g_oWndProc);
}
// Disable and remove hooks
MH_DisableHook(MH_ALL_HOOKS);
MH_Uninitialize();
// Cleanup ImGui
if (g_pd3dDevice) {
ImGui_ImplDX12_Shutdown();
ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext();
}
// Cleanup DirectX objects
CleanupRenderTarget();
if (g_pd3dSrvDescHeap) g_pd3dSrvDescHeap->Release();
if (g_pd3dRtvDescHeap) g_pd3dRtvDescHeap->Release();
// Other DX objects would be released here...
// Unload DLL
FreeLibraryAndExitThread(GetModuleHandle(NULL), 0);
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hModule);
// Create a console for debugging purposes
AllocConsole();
FILE* f;
freopen_s(&f, "CONOUT$", "w", stdout);
// Start the main cheat thread
std::thread(MainThread).detach();
}
return TRUE;
}