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">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View File

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

View File

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

View File

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

View File

@ -52,8 +52,8 @@ void ESP_DEBUG(float mDist, ImVec4 color, UClass* mEntType)
{
FVector actorLocation = actor->K2_GetActorLocation();
FVector localPlayerLocation = pLocalPlayer->K2_GetActorLocation();
float distantTo = pLocalPlayer->GetDistanceTo(actor);
if (distantTo > mDist)
float distanceTo = GetDistanceToActor(pLocalPlayer, actor);
if (distanceTo > mDist)
continue;
FVector2D outScreen;
@ -61,13 +61,13 @@ void ESP_DEBUG(float mDist, ImVec4 color, UClass* mEntType)
continue;
char data[0x256];
const char* StringData = "OBJECT: [%s]\nCLASS: [%s]\nINDEX: [%d]\nPOSITION: { %0.0f, %0.0f, %0.0f }\nDISTANCE: [%.0fm]";
if (distantTo >= 1000.f)
const char* StringData = "OBJECT: [%s]\nCLASS: [%s]\nPOSITION: { %0.0f, %0.0f, %0.0f }\nDISTANCE: [%.0fm]";
if (distanceTo >= 1000.f)
{
distantTo /= 1000.f;
StringData = "OBJECT: [%s]\nCLASS: [%s]\nINDEX: [%d]\nPOSITION: { %0.0f, %0.0f, %0.0f }\nDISTANCE: [%.0fkm]";
distanceTo /= 1000.f;
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));
draw->AddText(screen, ImColor(color), data);
@ -242,11 +242,17 @@ void SpeedHack(float mSpeed)
if (!pWorld)
return;
AWorldSettings* pWorldSettings = pWorld->K2_GetWorldSettings();
ULevel* pLevel = pWorld->PersistentLevel;
if (!pLevel)
return;
AWorldSettings* pWorldSettings = pLevel->WorldSettings;
if (!pWorldSettings)
return;
pWorldSettings->TimeDilation = mSpeed;
pWorld->PersistentLevel->WorldSettings->TimeDilation = mSpeed;
// pWorldSettings->TimeDilation = mSpeed;
}
//
@ -451,6 +457,17 @@ void RemoveAncientTechPoint(__int32 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
//SDK::FPalDebugOtomoPalInfo palinfo = SDK::FPalDebugOtomoPalInfo();

View File

@ -48,3 +48,5 @@ void AddAncientTechPoints(__int32 mPoints);
void RemoveTechPoints(__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 b_ImGui_Initialized{};
WNDPROC m_OldWndProc{};
ImGuiContext* pImGui;
ImGuiViewport* pViewport;
// Forward Dx11 Hook Declarations
bool Init(IDXGISwapChain* swapChain);

View File

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

View File

@ -11,7 +11,7 @@ void ClientBGThread()
{
while (g_Running) {
g_Menu->Loops();
std::this_thread::sleep_for(0ms);
std::this_thread::sleep_for(1ms);
std::this_thread::yield();
}
}
@ -42,7 +42,12 @@ DWORD WINAPI MainThread_Initialize()
g_Running = TRUE;
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

View File

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

View File

@ -271,15 +271,21 @@ namespace DX11_Base
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
if (ImGui::Button("PrintPlayerAddr", ImVec2(ImGui::GetContentRegionAvail().x - 3, 20)))
{
SDK::APalPlayerCharacter* p_appc = Config.GetPalPlayerCharacter();
if (p_appc != NULL)
{
g_Console->printdbg("\n\n[+] APalPlayerCharacter: %x [+]\n\n", Console::Colors::green, p_appc);
}
if (p_appc)
g_Console->printdbg("\n\n[+] APalPlayerCharacter: 0x%llX\n", Console::Colors::green, p_appc);
}
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));
void* fnAddr = object->ExecFunction;
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()
{
if (Config.IsESP)
ESP();
if (g_GameVariables->m_ShowMenu)
MainMenu();
if (Config.bisOpenManager && g_GameVariables->m_ShowMenu)
ManagerMenu();
if (g_GameVariables->m_ShowHud)
HUD(&g_GameVariables->m_ShowHud);
if (g_GameVariables->m_ShowDemo)
ImGui::ShowDemoWindow();
if (Config.isDebugESP)
ESP_DEBUG(Config.mDebugESPDistance, ImVec4(0,1,0,1));
}
void Menu::ManagerMenu()
@ -468,6 +468,8 @@ namespace DX11_Base
ImGui::PopStyleColor();
}
ImGuiContext* pImGui = GImGui;
// Display Menu Content
//Tabs::TABMain();
@ -495,6 +497,13 @@ namespace DX11_Base
Tabs::TABConfig();
ImGui::EndTabItem();
}
#if DEBUG
if (ImGui::BeginTabItem("DEBUG"))
{
Tabs::TABDebug();
ImGui::EndTabItem();
}
#endif
if (Config.IsQuick && ImGui::BeginTabItem("Quick"))
{
Tabs::TABQuick();
@ -508,10 +517,45 @@ namespace DX11_Base
ImGui::EndTabBar();
}
ImGui::End();
if (Config.bisOpenManager)
ManagerMenu();
}
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()