HUD Drawing

- Initialize GObjects with Config initialization
- GetDistanceToActor implementation
- pointers to both imgui context & imgui viewport
- watermark

~squish-
- watermark
- update toolset to v143
This commit is contained in:
NightFyre 2024-01-28 14:18:30 -05:00
parent 9dc8140e59
commit 77a18c7264
11 changed files with 119 additions and 43 deletions

View File

@ -43,13 +43,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>

View File

@ -25,6 +25,9 @@
<Filter Include="Resource Files\MinHook"> <Filter Include="Resource Files\MinHook">
<UniqueIdentifier>{d55590e2-04e5-427a-a959-6dcc763f2f71}</UniqueIdentifier> <UniqueIdentifier>{d55590e2-04e5-427a-a959-6dcc763f2f71}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Resource Files\SDK">
<UniqueIdentifier>{26987ebc-44ae-4b58-be8f-b68ad7efa763}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="pch.h"> <ClInclude Include="pch.h">
@ -108,9 +111,6 @@
<ClInclude Include="config.h"> <ClInclude Include="config.h">
<Filter>Header Files\Class</Filter> <Filter>Header Files\Class</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="SDK.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="libs\utils\memory.h"> <ClInclude Include="libs\utils\memory.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -120,6 +120,9 @@
<ClInclude Include="database.h"> <ClInclude Include="database.h">
<Filter>Header Files\Class</Filter> <Filter>Header Files\Class</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="SDK.hpp">
<Filter>Resource Files\SDK</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="dllmain.cpp"> <ClCompile Include="dllmain.cpp">
@ -185,12 +188,6 @@
<ClCompile Include="config.cpp"> <ClCompile Include="config.cpp">
<Filter>Source Files\Class</Filter> <Filter>Source Files\Class</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="SDK\Basic.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SDK\CoreUObject_functions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="libs\utils\memory.cpp"> <ClCompile Include="libs\utils\memory.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -198,10 +195,16 @@
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="SDK\Pal_functions.cpp"> <ClCompile Include="SDK\Pal_functions.cpp">
<Filter>Source Files</Filter> <Filter>Resource Files\SDK</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="SDK\Engine_functions.cpp"> <ClCompile Include="SDK\Engine_functions.cpp">
<Filter>Source Files</Filter> <Filter>Resource Files\SDK</Filter>
</ClCompile>
<ClCompile Include="SDK\CoreUObject_functions.cpp">
<Filter>Resource Files\SDK</Filter>
</ClCompile>
<ClCompile Include="SDK\Basic.cpp">
<Filter>Resource Files\SDK</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -201,10 +201,12 @@ void config::Init()
//register hook //register hook
Config.ClientBase = (DWORD64)GetModuleHandleA("PalWorld-Win64-Shipping.exe"); Config.ClientBase = (DWORD64)GetModuleHandleA("PalWorld-Win64-Shipping.exe");
TickFunc = (Tick)(Config.ClientBase + Config.offset_Tick); SDK::InitGObjects();
Config.gWorld = Config.GetUWorld(); Config.gWorld = Config.GetUWorld();
TickFunc = (Tick)(Config.ClientBase + Config.offset_Tick);
MH_CreateHook(TickFunc, DetourTick, reinterpret_cast<void**>(&OldTickFunc)); MH_CreateHook(TickFunc, DetourTick, reinterpret_cast<void**>(&OldTickFunc));
//init database //init database

View File

@ -3,16 +3,15 @@
#include "initialize.hpp" #include "initialize.hpp"
using namespace SDK; using namespace SDK;
using namespace DX11_Base;
extern DWORD WINAPI MainThread_Initialize(); extern DWORD WINAPI MainThread_Initialize();
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwCallReason, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwCallReason, LPVOID lpReserved)
{ {
using namespace DX11_Base;
g_hModule = hModule; g_hModule = hModule;
switch (dwCallReason) { switch (dwCallReason) {
case (DLL_PROCESS_ATTACH): { case (DLL_PROCESS_ATTACH): {
InitGObjects();
DisableThreadLibraryCalls(hModule); DisableThreadLibraryCalls(hModule);
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)MainThread_Initialize, g_hModule, NULL, NULL); CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)MainThread_Initialize, g_hModule, NULL, NULL);
break; break;

View File

@ -52,8 +52,8 @@ void ESP_DEBUG(float mDist, ImVec4 color, UClass* mEntType)
{ {
FVector actorLocation = actor->K2_GetActorLocation(); FVector actorLocation = actor->K2_GetActorLocation();
FVector localPlayerLocation = pLocalPlayer->K2_GetActorLocation(); FVector localPlayerLocation = pLocalPlayer->K2_GetActorLocation();
float distantTo = pLocalPlayer->GetDistanceTo(actor); float distanceTo = GetDistanceToActor(pLocalPlayer, actor);
if (distantTo > mDist) if (distanceTo > mDist)
continue; continue;
FVector2D outScreen; FVector2D outScreen;
@ -61,13 +61,13 @@ void ESP_DEBUG(float mDist, ImVec4 color, UClass* mEntType)
continue; continue;
char data[0x256]; char data[0x256];
const char* StringData = "OBJECT: [%s]\nCLASS: [%s]\nINDEX: [%d]\nPOSITION: { %0.0f, %0.0f, %0.0f }\nDISTANCE: [%.0fm]"; const char* StringData = "OBJECT: [%s]\nCLASS: [%s]\nPOSITION: { %0.0f, %0.0f, %0.0f }\nDISTANCE: [%.0fm]";
if (distantTo >= 1000.f) if (distanceTo >= 1000.f)
{ {
distantTo /= 1000.f; distanceTo /= 1000.f;
StringData = "OBJECT: [%s]\nCLASS: [%s]\nINDEX: [%d]\nPOSITION: { %0.0f, %0.0f, %0.0f }\nDISTANCE: [%.0fkm]"; StringData = "OBJECT: [%s]\nCLASS: [%s]\nPOSITION: { %0.0f, %0.0f, %0.0f }\nDISTANCE: [%.0fkm]";
} }
sprintf_s(data, StringData, actor->GetName().c_str(), actor->Class->GetFullName().c_str(), actorLocation.X, actorLocation.Y, actorLocation.Z, distantTo); sprintf_s(data, StringData, actor->GetName().c_str(), actor->Class->GetFullName().c_str(), actorLocation.X, actorLocation.Y, actorLocation.Z, distanceTo);
ImVec2 screen = ImVec2(static_cast<float>(outScreen.X), static_cast<float>(outScreen.Y)); ImVec2 screen = ImVec2(static_cast<float>(outScreen.X), static_cast<float>(outScreen.Y));
draw->AddText(screen, ImColor(color), data); draw->AddText(screen, ImColor(color), data);
@ -242,11 +242,17 @@ void SpeedHack(float mSpeed)
if (!pWorld) if (!pWorld)
return; return;
AWorldSettings* pWorldSettings = pWorld->K2_GetWorldSettings(); ULevel* pLevel = pWorld->PersistentLevel;
if (!pLevel)
return;
AWorldSettings* pWorldSettings = pLevel->WorldSettings;
if (!pWorldSettings) if (!pWorldSettings)
return; return;
pWorldSettings->TimeDilation = mSpeed; pWorld->PersistentLevel->WorldSettings->TimeDilation = mSpeed;
// pWorldSettings->TimeDilation = mSpeed;
} }
// //
@ -451,6 +457,17 @@ void RemoveAncientTechPoint(__int32 mPoints)
pTechData->bossTechnologyPoint -= mPoints; pTechData->bossTechnologyPoint -= mPoints;
} }
float GetDistanceToActor(AActor* pLocal, AActor* pTarget)
{
if (!pLocal || !pTarget)
return -1.f;
FVector pLocation = pLocal->K2_GetActorLocation();
FVector pTargetLocation = pTarget->K2_GetActorLocation();
double distance = sqrt(pow(pTargetLocation.X - pLocation.X, 2.0) + pow(pTargetLocation.Y - pLocation.Y, 2.0) + pow(pTargetLocation.Z - pLocation.Z, 2.0));
return distance / 100.0f;
}
/// OLDER METHODS /// OLDER METHODS
//SDK::FPalDebugOtomoPalInfo palinfo = SDK::FPalDebugOtomoPalInfo(); //SDK::FPalDebugOtomoPalInfo palinfo = SDK::FPalDebugOtomoPalInfo();

View File

@ -47,4 +47,6 @@ void AddAncientTechPoints(__int32 mPoints);
void RemoveTechPoints(__int32 mPoints); void RemoveTechPoints(__int32 mPoints);
void RemoveAncientTechPoint(__int32 mPoints); void RemoveAncientTechPoint(__int32 mPoints);
float GetDistanceToActor(SDK::AActor* pLocal, SDK::AActor* pTarget);

View File

@ -26,6 +26,8 @@ namespace DX11_Base {
bool m_Init{}; bool m_Init{};
bool b_ImGui_Initialized{}; bool b_ImGui_Initialized{};
WNDPROC m_OldWndProc{}; WNDPROC m_OldWndProc{};
ImGuiContext* pImGui;
ImGuiViewport* pViewport;
// Forward Dx11 Hook Declarations // Forward Dx11 Hook Declarations
bool Init(IDXGISwapChain* swapChain); bool Init(IDXGISwapChain* swapChain);

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#define DEBUG 0 #define DEBUG 1
// External Libraries // External Libraries
#include "../libs/ImGui/imgui.h" #include "../libs/ImGui/imgui.h"

View File

@ -11,7 +11,7 @@ void ClientBGThread()
{ {
while (g_Running) { while (g_Running) {
g_Menu->Loops(); g_Menu->Loops();
std::this_thread::sleep_for(0ms); std::this_thread::sleep_for(1ms);
std::this_thread::yield(); std::this_thread::yield();
} }
} }
@ -42,7 +42,12 @@ DWORD WINAPI MainThread_Initialize()
g_Running = TRUE; g_Running = TRUE;
while (g_Running) while (g_Running)
{ {
if (GetAsyncKeyState(VK_INSERT) & 1) g_GameVariables->m_ShowMenu = !g_GameVariables->m_ShowMenu; if (GetAsyncKeyState(VK_INSERT) & 1)
{
g_GameVariables->m_ShowMenu = !g_GameVariables->m_ShowMenu;
g_GameVariables->m_ShowHud = !g_GameVariables->m_ShowMenu;
}
} }
/// EXIT /// EXIT

View File

@ -208,6 +208,8 @@ namespace DX11_Base {
ImGui::GetIO().ImeWindowHandle = g_GameVariables->g_GameWindow; ImGui::GetIO().ImeWindowHandle = g_GameVariables->g_GameWindow;
m_OldWndProc = (WNDPROC)SetWindowLongPtr(g_GameVariables->g_GameWindow, GWLP_WNDPROC, (__int3264)(LONG_PTR)WndProc); m_OldWndProc = (WNDPROC)SetWindowLongPtr(g_GameVariables->g_GameWindow, GWLP_WNDPROC, (__int3264)(LONG_PTR)WndProc);
b_ImGui_Initialized = TRUE; b_ImGui_Initialized = TRUE;
pImGui = GImGui;
pViewport = pImGui->Viewports[0];
#if DEBUG #if DEBUG
g_Console->printdbg("D3D11Window::Swapchain Initialized\n", Console::Colors::pink); g_Console->printdbg("D3D11Window::Swapchain Initialized\n", Console::Colors::pink);
#endif #endif

View File

@ -271,15 +271,21 @@ namespace DX11_Base
void TABDebug() void TABDebug()
{ {
ImGui::Checkbox("DEBUG ESP", &Config.isDebugESP);
if (Config.isDebugESP)
{
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
ImGui::SliderFloat("##DISTANCE", &Config.mDebugESPDistance, 1.0f, 100.f, "%.0f", ImGuiSliderFlags_AlwaysClamp);
}
// @TODO: print additional debug information // @TODO: print additional debug information
if (ImGui::Button("PrintPlayerAddr", ImVec2(ImGui::GetContentRegionAvail().x - 3, 20))) if (ImGui::Button("PrintPlayerAddr", ImVec2(ImGui::GetContentRegionAvail().x - 3, 20)))
{ {
SDK::APalPlayerCharacter* p_appc = Config.GetPalPlayerCharacter(); SDK::APalPlayerCharacter* p_appc = Config.GetPalPlayerCharacter();
if (p_appc != NULL) if (p_appc)
{ g_Console->printdbg("\n\n[+] APalPlayerCharacter: 0x%llX\n", Console::Colors::green, p_appc);
g_Console->printdbg("\n\n[+] APalPlayerCharacter: %x [+]\n\n", Console::Colors::green, p_appc);
}
} }
ImGui::InputTextWithHint("##INPUT", "INPUT GOBJECT fn NAME", inputBuffer_getFnAddr, 100); ImGui::InputTextWithHint("##INPUT", "INPUT GOBJECT fn NAME", inputBuffer_getFnAddr, 100);
@ -293,9 +299,11 @@ namespace DX11_Base
static __int64 dwHandle = reinterpret_cast<__int64>(GetModuleHandle(0)); static __int64 dwHandle = reinterpret_cast<__int64>(GetModuleHandle(0));
void* fnAddr = object->ExecFunction; void* fnAddr = object->ExecFunction;
unsigned __int64 fnOffset = (reinterpret_cast<__int64>(fnAddr) - dwHandle); unsigned __int64 fnOffset = (reinterpret_cast<__int64>(fnAddr) - dwHandle);
g_Console->printdbg("[+] Found %s @ 0x%llX\n", Console::Colors::yellow, input.c_str(), fnOffset); g_Console->printdbg("[+] Found [%s] -> 0x%llX\n", Console::Colors::yellow, input.c_str(), fnOffset);
} }
else
g_Console->printdbg("[!] OBJECT [%s] NOT FOUND!\n", Console::Colors::red, input.c_str());
memset(inputBuffer_getFnAddr, 0, 100);
} }
} }
@ -303,23 +311,15 @@ namespace DX11_Base
void Menu::Draw() void Menu::Draw()
{ {
if (Config.IsESP)
ESP();
if (g_GameVariables->m_ShowMenu) if (g_GameVariables->m_ShowMenu)
MainMenu(); MainMenu();
if (Config.bisOpenManager && g_GameVariables->m_ShowMenu)
ManagerMenu();
if (g_GameVariables->m_ShowHud) if (g_GameVariables->m_ShowHud)
HUD(&g_GameVariables->m_ShowHud); HUD(&g_GameVariables->m_ShowHud);
if (g_GameVariables->m_ShowDemo) if (g_GameVariables->m_ShowDemo)
ImGui::ShowDemoWindow(); ImGui::ShowDemoWindow();
if (Config.isDebugESP)
ESP_DEBUG(Config.mDebugESPDistance, ImVec4(0,1,0,1));
} }
void Menu::ManagerMenu() void Menu::ManagerMenu()
@ -468,6 +468,8 @@ namespace DX11_Base
ImGui::PopStyleColor(); ImGui::PopStyleColor();
} }
ImGuiContext* pImGui = GImGui;
// Display Menu Content // Display Menu Content
//Tabs::TABMain(); //Tabs::TABMain();
@ -495,6 +497,13 @@ namespace DX11_Base
Tabs::TABConfig(); Tabs::TABConfig();
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
#if DEBUG
if (ImGui::BeginTabItem("DEBUG"))
{
Tabs::TABDebug();
ImGui::EndTabItem();
}
#endif
if (Config.IsQuick && ImGui::BeginTabItem("Quick")) if (Config.IsQuick && ImGui::BeginTabItem("Quick"))
{ {
Tabs::TABQuick(); Tabs::TABQuick();
@ -508,10 +517,45 @@ namespace DX11_Base
ImGui::EndTabBar(); ImGui::EndTabBar();
} }
ImGui::End(); ImGui::End();
if (Config.bisOpenManager)
ManagerMenu();
} }
void Menu::HUD(bool* p_open) void Menu::HUD(bool* p_open)
{ {
ImGui::SetNextWindowPos(g_D3D11Window->pViewport->WorkPos);
ImGui::SetNextWindowSize(g_D3D11Window->pViewport->WorkSize);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, NULL);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.00f, 0.00f, 0.00f, 0.00f));
if (!ImGui::Begin("##HUDWINDOW", (bool*)true, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs))
{
ImGui::PopStyleColor();
ImGui::PopStyleVar();
ImGui::End();
return;
}
ImGui::PopStyleColor();
ImGui::PopStyleVar();
auto ImDraw = ImGui::GetWindowDrawList();
auto draw_size = g_D3D11Window->pViewport->WorkSize;
auto center = ImVec2({ draw_size.x * .5f, draw_size.y * .5f });
auto top_center = ImVec2({ draw_size.x * .5f, draw_size.y * 0.0f });
// Watermark
ImDraw->AddText(top_center, g_Menu->dbg_RAINBOW, "PalWorld-NetCrack");
if (Config.IsESP)
ESP();
if (Config.isDebugESP)
ESP_DEBUG(Config.mDebugESPDistance, ImVec4(0, 1, 0, 1));
ImGui::End();
} }
void Menu::Loops() void Menu::Loops()