- Major code refactor! This means easier option additions and easier code navigation/readability!

- Now using precompiled headers for extremely fast compilation times :D
This commit is contained in:
EricPlayZ
2024-02-11 06:11:25 +02:00
parent e32f647357
commit 9c705ef652
132 changed files with 3957 additions and 3554 deletions

View File

@ -11,55 +11,142 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch\pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="source\config\config.cpp" />
<ClCompile Include="source\core.cpp" />
<ClCompile Include="source\dllmain.cpp" />
<ClCompile Include="source\game_classes.cpp" />
<ClCompile Include="source\hook.cpp" />
<ClCompile Include="source\ImGuiEx\Animation.cpp" />
<ClCompile Include="source\ImGuiEx\ImGuiEx.cpp" />
<ClCompile Include="source\ImGuiFileDialog\ImGuiFileDialog.cpp" />
<ClCompile Include="source\ImGuiHotkeys\Hotkey.cpp" />
<ClCompile Include="source\ImGui\backends\imgui_impl_dx11.cpp" />
<ClCompile Include="source\ImGui\backends\imgui_impl_dx12.cpp" />
<ClCompile Include="source\ImGui\backends\imgui_impl_win32.cpp" />
<ClCompile Include="source\ImGui\imgui.cpp" />
<ClCompile Include="source\ImGui\imgui_draw.cpp" />
<ClCompile Include="source\ImGui\imgui_tables.cpp" />
<ClCompile Include="source\ImGui\imgui_widgets.cpp" />
<ClCompile Include="source\game\Engine\CBaseCamera.cpp" />
<ClCompile Include="source\game\Engine\CBulletPhysicsCharacter.cpp" />
<ClCompile Include="source\game\Engine\CGame.cpp" />
<ClCompile Include="source\game\Engine\CGSObject.cpp" />
<ClCompile Include="source\game\Engine\CGSObject2.cpp" />
<ClCompile Include="source\game\Engine\CInput.cpp" />
<ClCompile Include="source\game\Engine\CLevel.cpp" />
<ClCompile Include="source\game\Engine\CLevel2.cpp" />
<ClCompile Include="source\game\Engine\CLobbySteam.cpp" />
<ClCompile Include="source\game\Engine\CoPhysicsProperty.cpp" />
<ClCompile Include="source\game\Engine\CVideoSettings.cpp" />
<ClCompile Include="source\game\Engine\engine_hooks.cpp" />
<ClCompile Include="source\game\GamePH\DayNightCycle.cpp" />
<ClCompile Include="source\game\GamePH\FreeCamera.cpp" />
<ClCompile Include="source\game\GamePH\GameDI_PH.cpp" />
<ClCompile Include="source\game\GamePH\GameDI_PH2.cpp" />
<ClCompile Include="source\game\GamePH\gen_TPPModel.cpp" />
<ClCompile Include="source\game\GamePH\game_hooks.cpp" />
<ClCompile Include="source\game\GamePH\LevelDI.cpp" />
<ClCompile Include="source\game\GamePH\LocalClientDI.cpp" />
<ClCompile Include="source\game\GamePH\LogicalPlayer.cpp" />
<ClCompile Include="source\game\GamePH\Other.cpp" />
<ClCompile Include="source\game\GamePH\PlayerHealthModule.cpp" />
<ClCompile Include="source\game\GamePH\PlayerObjProperties.cpp" />
<ClCompile Include="source\game\GamePH\PlayerState.cpp" />
<ClCompile Include="source\game\GamePH\PlayerVariables.cpp" />
<ClCompile Include="source\game\GamePH\SessionCooperativeDI.cpp" />
<ClCompile Include="source\game\GamePH\TimeWeather\CSystem.cpp" />
<ClCompile Include="source\game\GamePH\TPPCameraDI.cpp" />
<ClCompile Include="source\game\Vector3.cpp" />
<ClCompile Include="source\ImGui\backends\imgui_impl_dx11.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="source\ImGui\backends\imgui_impl_dx12.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="source\ImGui\backends\imgui_impl_win32.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="source\ImGui\imgui.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="source\ImGui\imguiex.cpp" />
<ClCompile Include="source\ImGui\imguiex_animation.cpp" />
<ClCompile Include="source\ImGui\ImGuiFileDialog\ImGuiFileDialog.cpp" />
<ClCompile Include="source\ImGui\imgui_draw.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="source\ImGui\imgui_hotkey.cpp" />
<ClCompile Include="source\ImGui\imgui_tables.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="source\ImGui\imgui_widgets.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="source\ImGui\impl\d3d11_impl.cpp" />
<ClCompile Include="source\ImGui\impl\d3d12_impl.cpp" />
<ClCompile Include="source\ImGui\impl\win32_impl.cpp" />
<ClCompile Include="source\kiero.cpp" />
<ClCompile Include="source\memory.cpp" />
<ClCompile Include="source\menu\camera.cpp" />
<ClCompile Include="source\menu\menu.cpp" />
<ClCompile Include="source\menu\misc.cpp" />
<ClCompile Include="source\menu\player.cpp" />
<ClCompile Include="source\menu\world.cpp" />
<ClCompile Include="source\sigscan\sigscan.cpp" />
<ClCompile Include="source\utils.cpp" />
<ClCompile Include="source\utils\files.cpp" />
<ClCompile Include="source\utils\hook.cpp" />
<ClCompile Include="source\utils\memory.cpp" />
<ClCompile Include="source\utils\sigscan.cpp" />
<ClCompile Include="source\utils\time.cpp" />
<ClCompile Include="source\utils\values.cpp" />
<ClCompile Include="source\utils\windows.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Use</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch\pch.h" />
<ClInclude Include="source\config\config.h" />
<ClInclude Include="source\config\ini.h" />
<ClInclude Include="source\config\time_tools.h" />
<ClInclude Include="source\core.h" />
<ClInclude Include="source\game_classes.h" />
<ClInclude Include="source\hook.h" />
<ClInclude Include="source\ImGuiEx\Animation.h" />
<ClInclude Include="source\ImGuiEx\ImGuiEx.h" />
<ClInclude Include="source\ImGuiFileDialog\dirent\dirent.h" />
<ClInclude Include="source\ImGuiFileDialog\ImGuiFileDialog.h" />
<ClInclude Include="source\ImGuiFileDialog\ImGuiFileDialogConfig.h" />
<ClInclude Include="source\ImGuiFileDialog\stb\stb_image.h" />
<ClInclude Include="source\ImGuiFileDialog\stb\stb_image_resize.h" />
<ClInclude Include="source\ImGuiHotkeys\Hotkey.h" />
<ClInclude Include="source\game\buffer.h" />
<ClInclude Include="source\game\Engine\CBaseCamera.h" />
<ClInclude Include="source\game\Engine\CBulletPhysicsCharacter.h" />
<ClInclude Include="source\game\Engine\CGame.h" />
<ClInclude Include="source\game\Engine\CGSObject.h" />
<ClInclude Include="source\game\Engine\CGSObject2.h" />
<ClInclude Include="source\game\Engine\CInput.h" />
<ClInclude Include="source\game\Engine\CLevel.h" />
<ClInclude Include="source\game\Engine\CLevel2.h" />
<ClInclude Include="source\game\Engine\CLobbySteam.h" />
<ClInclude Include="source\game\Engine\CoPhysicsProperty.h" />
<ClInclude Include="source\game\Engine\CVideoSettings.h" />
<ClInclude Include="source\game\GamePH\CoBaseCameraProxy.h" />
<ClInclude Include="source\game\GamePH\DayNightCycle.h" />
<ClInclude Include="source\game\GamePH\FreeCamera.h" />
<ClInclude Include="source\game\GamePH\GameDI_PH.h" />
<ClInclude Include="source\game\GamePH\GameDI_PH2.h" />
<ClInclude Include="source\game\GamePH\gen_TPPModel.h" />
<ClInclude Include="source\game\GamePH\game_hooks.h" />
<ClInclude Include="source\game\GamePH\LevelDI.h" />
<ClInclude Include="source\game\GamePH\LocalClientDI.h" />
<ClInclude Include="source\game\GamePH\LogicalPlayer.h" />
<ClInclude Include="source\game\GamePH\Other.h" />
<ClInclude Include="source\game\GamePH\PlayerHealthModule.h" />
<ClInclude Include="source\game\GamePH\PlayerObjProperties.h" />
<ClInclude Include="source\game\GamePH\PlayerState.h" />
<ClInclude Include="source\game\GamePH\PlayerVariables.h" />
<ClInclude Include="source\game\GamePH\SessionCooperativeDI.h" />
<ClInclude Include="source\game\GamePH\TimeWeather\CSystem.h" />
<ClInclude Include="source\game\GamePH\TimeWeather\EWeather.h" />
<ClInclude Include="source\game\GamePH\TPPCameraDI.h" />
<ClInclude Include="source\game\Vector3.h" />
<ClInclude Include="source\ImGui\backends\imgui_impl_dx11.h" />
<ClInclude Include="source\ImGui\backends\imgui_impl_dx12.h" />
<ClInclude Include="source\ImGui\backends\imgui_impl_win32.h" />
<ClInclude Include="source\ImGui\imconfig.h" />
<ClInclude Include="source\ImGui\imgui.h" />
<ClInclude Include="source\ImGui\imguiex.h" />
<ClInclude Include="source\ImGui\imguiex_animation.h" />
<ClInclude Include="source\ImGui\ImGuiFileDialog\ImGuiFileDialog.h" />
<ClInclude Include="source\ImGui\ImGuiFileDialog\ImGuiFileDialogConfig.h" />
<ClInclude Include="source\ImGui\imgui_hotkey.h" />
<ClInclude Include="source\ImGui\imgui_internal.h" />
<ClInclude Include="source\ImGui\impl\d3d11_impl.h" />
<ClInclude Include="source\ImGui\impl\d3d12_impl.h" />
@ -68,17 +155,21 @@
<ClInclude Include="source\ImGui\imstb_textedit.h" />
<ClInclude Include="source\ImGui\imstb_truetype.h" />
<ClInclude Include="source\kiero.h" />
<ClInclude Include="source\memory.h" />
<ClInclude Include="source\menu\camera.h" />
<ClInclude Include="source\menu\menu.h" />
<ClInclude Include="source\menu\misc.h" />
<ClInclude Include="source\menu\player.h" />
<ClInclude Include="source\menu\world.h" />
<ClInclude Include="source\MinHook\include\MinHook.h" />
<ClInclude Include="source\print.h" />
<ClInclude Include="source\sigscan\offsets.h" />
<ClInclude Include="source\sigscan\sigscan.h" />
<ClInclude Include="source\utils.h" />
<ClInclude Include="source\MinHook\MinHook.h" />
<ClInclude Include="source\offsets.h" />
<ClInclude Include="source\utils\files.h" />
<ClInclude Include="source\utils\hook.h" />
<ClInclude Include="source\utils\memory.h" />
<ClInclude Include="source\utils\print.h" />
<ClInclude Include="source\utils\sigscan.h" />
<ClInclude Include="source\utils\time.h" />
<ClInclude Include="source\utils\values.h" />
<ClInclude Include="source\utils\windows.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
@ -142,7 +233,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;DL2GameOverhaulScript_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpplatest</LanguageStandard>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@ -150,7 +241,8 @@
</Optimization>
<IntrinsicFunctions>
</IntrinsicFunctions>
<AdditionalIncludeDirectories>source\ImGuiEx;source\ImGuiHotkeys;source\ImGui;source\ImGuiFileDialog;source\MinHook\include;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>pch;source\ImGui;source\MinHook;</AdditionalIncludeDirectories>
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName)_$(PlatformTarget).pch</PrecompiledHeaderOutputFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -176,12 +268,13 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpplatest</LanguageStandard>
<AdditionalIncludeDirectories>source\ImGuiEx;source\ImGuiHotkeys;source\ImGui;source\ImGuiFileDialog;source\MinHook\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>pch;source\ImGui;source\MinHook;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>None</DebugInformationFormat>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName)_$(PlatformTarget).pch</PrecompiledHeaderOutputFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="source\memory.cpp" />
<ClCompile Include="source\core.cpp" />
<ClCompile Include="source\dllmain.cpp" />
<ClCompile Include="source\kiero.cpp" />
@ -38,15 +37,6 @@
<ClCompile Include="source\menu\menu.cpp">
<Filter>menu</Filter>
</ClCompile>
<ClCompile Include="source\game_classes.cpp" />
<ClCompile Include="source\hook.cpp" />
<ClCompile Include="source\utils.cpp" />
<ClCompile Include="source\sigscan\sigscan.cpp">
<Filter>sigscan</Filter>
</ClCompile>
<ClCompile Include="source\ImGuiFileDialog\ImGuiFileDialog.cpp">
<Filter>ImGuiFileDialog</Filter>
</ClCompile>
<ClCompile Include="source\ImGui\impl\d3d12_impl.cpp">
<Filter>ImGui\impl</Filter>
</ClCompile>
@ -59,27 +49,136 @@
<ClCompile Include="source\menu\world.cpp">
<Filter>menu</Filter>
</ClCompile>
<ClCompile Include="source\ImGuiHotkeys\Hotkey.cpp">
<Filter>ImGuiHotkeys</Filter>
</ClCompile>
<ClCompile Include="source\ImGuiEx\ImGuiEx.cpp">
<Filter>ImGuiEx</Filter>
</ClCompile>
<ClCompile Include="source\menu\misc.cpp">
<Filter>menu</Filter>
</ClCompile>
<ClCompile Include="source\ImGuiEx\Animation.cpp">
<Filter>ImGuiEx</Filter>
<ClCompile Include="source\utils\files.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClCompile Include="source\utils\values.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClCompile Include="source\utils\windows.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClCompile Include="source\utils\time.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClCompile Include="source\utils\memory.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClCompile Include="source\utils\sigscan.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClCompile Include="source\utils\hook.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClCompile Include="source\ImGui\imguiex.cpp">
<Filter>ImGui</Filter>
</ClCompile>
<ClCompile Include="source\ImGui\imguiex_animation.cpp">
<Filter>ImGui</Filter>
</ClCompile>
<ClCompile Include="source\ImGui\imgui_hotkey.cpp">
<Filter>ImGui</Filter>
</ClCompile>
<ClCompile Include="source\ImGui\ImGuiFileDialog\ImGuiFileDialog.cpp">
<Filter>ImGui\ImGuiFileDialog</Filter>
</ClCompile>
<ClCompile Include="source\game\Vector3.cpp">
<Filter>game</Filter>
</ClCompile>
<ClCompile Include="source\game\Engine\CGame.cpp">
<Filter>game\Engine</Filter>
</ClCompile>
<ClCompile Include="source\game\Engine\CGSObject.cpp">
<Filter>game\Engine</Filter>
</ClCompile>
<ClCompile Include="source\game\Engine\CGSObject2.cpp">
<Filter>game\Engine</Filter>
</ClCompile>
<ClCompile Include="source\game\Engine\CInput.cpp">
<Filter>game\Engine</Filter>
</ClCompile>
<ClCompile Include="source\game\Engine\CLevel.cpp">
<Filter>game\Engine</Filter>
</ClCompile>
<ClCompile Include="source\game\Engine\CLevel2.cpp">
<Filter>game\Engine</Filter>
</ClCompile>
<ClCompile Include="source\game\Engine\CLobbySteam.cpp">
<Filter>game\Engine</Filter>
</ClCompile>
<ClCompile Include="source\game\Engine\CoPhysicsProperty.cpp">
<Filter>game\Engine</Filter>
</ClCompile>
<ClCompile Include="source\game\Engine\CVideoSettings.cpp">
<Filter>game\Engine</Filter>
</ClCompile>
<ClCompile Include="source\game\Engine\engine_hooks.cpp">
<Filter>game\Engine</Filter>
</ClCompile>
<ClCompile Include="source\game\Engine\CBaseCamera.cpp">
<Filter>game\Engine</Filter>
</ClCompile>
<ClCompile Include="source\game\Engine\CBulletPhysicsCharacter.cpp">
<Filter>game\Engine</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\FreeCamera.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\GameDI_PH.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\GameDI_PH2.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\gen_TPPModel.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\game_hooks.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\LevelDI.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\LocalClientDI.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\LogicalPlayer.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\Other.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\PlayerHealthModule.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\PlayerObjProperties.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\PlayerState.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\PlayerVariables.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\SessionCooperativeDI.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\TPPCameraDI.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\DayNightCycle.cpp">
<Filter>game\GamePH</Filter>
</ClCompile>
<ClCompile Include="source\game\GamePH\TimeWeather\CSystem.cpp">
<Filter>game\GamePH\TimeWeather</Filter>
</ClCompile>
<ClCompile Include="pch\pch.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="source\memory.h" />
<ClInclude Include="source\game_classes.h" />
<ClInclude Include="source\print.h" />
<ClInclude Include="source\kiero.h" />
<ClInclude Include="source\MinHook\include\MinHook.h">
<Filter>MinHook\include</Filter>
</ClInclude>
<ClInclude Include="source\ImGui\imconfig.h">
<Filter>ImGui</Filter>
</ClInclude>
@ -119,39 +218,13 @@
<ClInclude Include="source\menu\menu.h">
<Filter>menu</Filter>
</ClInclude>
<ClInclude Include="source\hook.h" />
<ClInclude Include="source\utils.h" />
<ClInclude Include="source\sigscan\sigscan.h">
<Filter>sigscan</Filter>
</ClInclude>
<ClInclude Include="source\sigscan\offsets.h">
<Filter>sigscan</Filter>
</ClInclude>
<ClInclude Include="source\core.h" />
<ClInclude Include="source\ImGuiFileDialog\ImGuiFileDialog.h">
<Filter>ImGuiFileDialog</Filter>
</ClInclude>
<ClInclude Include="source\ImGuiFileDialog\ImGuiFileDialogConfig.h">
<Filter>ImGuiFileDialog</Filter>
</ClInclude>
<ClInclude Include="source\ImGuiFileDialog\dirent\dirent.h">
<Filter>ImGuiFileDialog\dirent</Filter>
</ClInclude>
<ClInclude Include="source\ImGuiFileDialog\stb\stb_image.h">
<Filter>ImGuiFileDialog\stb</Filter>
</ClInclude>
<ClInclude Include="source\ImGuiFileDialog\stb\stb_image_resize.h">
<Filter>ImGuiFileDialog\stb</Filter>
</ClInclude>
<ClInclude Include="source\ImGui\impl\d3d12_impl.h">
<Filter>ImGui\impl</Filter>
</ClInclude>
<ClInclude Include="source\config\ini.h">
<Filter>config</Filter>
</ClInclude>
<ClInclude Include="source\config\time_tools.h">
<Filter>config</Filter>
</ClInclude>
<ClInclude Include="source\config\config.h">
<Filter>config</Filter>
</ClInclude>
@ -161,26 +234,154 @@
<ClInclude Include="source\menu\world.h">
<Filter>menu</Filter>
</ClInclude>
<ClInclude Include="source\ImGuiHotkeys\Hotkey.h">
<Filter>ImGuiHotkeys</Filter>
</ClInclude>
<ClInclude Include="source\ImGuiEx\ImGuiEx.h">
<Filter>ImGuiEx</Filter>
</ClInclude>
<ClInclude Include="source\menu\misc.h">
<Filter>menu</Filter>
</ClInclude>
<ClInclude Include="source\ImGuiEx\Animation.h">
<Filter>ImGuiEx</Filter>
<ClInclude Include="source\utils\files.h">
<Filter>utils</Filter>
</ClInclude>
<ClInclude Include="source\utils\values.h">
<Filter>utils</Filter>
</ClInclude>
<ClInclude Include="source\utils\windows.h">
<Filter>utils</Filter>
</ClInclude>
<ClInclude Include="source\utils\print.h">
<Filter>utils</Filter>
</ClInclude>
<ClInclude Include="source\utils\time.h">
<Filter>utils</Filter>
</ClInclude>
<ClInclude Include="source\utils\memory.h">
<Filter>utils</Filter>
</ClInclude>
<ClInclude Include="source\utils\sigscan.h">
<Filter>utils</Filter>
</ClInclude>
<ClInclude Include="source\offsets.h" />
<ClInclude Include="source\utils\hook.h">
<Filter>utils</Filter>
</ClInclude>
<ClInclude Include="source\MinHook\MinHook.h">
<Filter>MinHook</Filter>
</ClInclude>
<ClInclude Include="source\ImGui\imguiex.h">
<Filter>ImGui</Filter>
</ClInclude>
<ClInclude Include="source\ImGui\imguiex_animation.h">
<Filter>ImGui</Filter>
</ClInclude>
<ClInclude Include="source\ImGui\imgui_hotkey.h">
<Filter>ImGui</Filter>
</ClInclude>
<ClInclude Include="source\ImGui\ImGuiFileDialog\ImGuiFileDialog.h">
<Filter>ImGui\ImGuiFileDialog</Filter>
</ClInclude>
<ClInclude Include="source\ImGui\ImGuiFileDialog\ImGuiFileDialogConfig.h">
<Filter>ImGui\ImGuiFileDialog</Filter>
</ClInclude>
<ClInclude Include="source\game\buffer.h">
<Filter>game</Filter>
</ClInclude>
<ClInclude Include="source\game\Vector3.h">
<Filter>game</Filter>
</ClInclude>
<ClInclude Include="source\game\Engine\CBulletPhysicsCharacter.h">
<Filter>game\Engine</Filter>
</ClInclude>
<ClInclude Include="source\game\Engine\CGame.h">
<Filter>game\Engine</Filter>
</ClInclude>
<ClInclude Include="source\game\Engine\CGSObject.h">
<Filter>game\Engine</Filter>
</ClInclude>
<ClInclude Include="source\game\Engine\CGSObject2.h">
<Filter>game\Engine</Filter>
</ClInclude>
<ClInclude Include="source\game\Engine\CInput.h">
<Filter>game\Engine</Filter>
</ClInclude>
<ClInclude Include="source\game\Engine\CLevel.h">
<Filter>game\Engine</Filter>
</ClInclude>
<ClInclude Include="source\game\Engine\CLevel2.h">
<Filter>game\Engine</Filter>
</ClInclude>
<ClInclude Include="source\game\Engine\CLobbySteam.h">
<Filter>game\Engine</Filter>
</ClInclude>
<ClInclude Include="source\game\Engine\CoPhysicsProperty.h">
<Filter>game\Engine</Filter>
</ClInclude>
<ClInclude Include="source\game\Engine\CVideoSettings.h">
<Filter>game\Engine</Filter>
</ClInclude>
<ClInclude Include="source\game\Engine\CBaseCamera.h">
<Filter>game\Engine</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\DayNightCycle.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\FreeCamera.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\GameDI_PH.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\GameDI_PH2.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\gen_TPPModel.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\game_hooks.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\LevelDI.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\LocalClientDI.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\LogicalPlayer.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\Other.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\PlayerHealthModule.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\PlayerObjProperties.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\PlayerState.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\PlayerVariables.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\SessionCooperativeDI.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\TPPCameraDI.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\CoBaseCameraProxy.h">
<Filter>game\GamePH</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\TimeWeather\CSystem.h">
<Filter>game\GamePH\TimeWeather</Filter>
</ClInclude>
<ClInclude Include="source\game\GamePH\TimeWeather\EWeather.h">
<Filter>game\GamePH\TimeWeather</Filter>
</ClInclude>
<ClInclude Include="pch\pch.h" />
</ItemGroup>
<ItemGroup>
<Filter Include="MinHook">
<UniqueIdentifier>{794284a1-160f-4b62-bfd0-d160dbb38e40}</UniqueIdentifier>
</Filter>
<Filter Include="MinHook\include">
<UniqueIdentifier>{e697e380-6df5-4cfc-861e-e2b77ce03d39}</UniqueIdentifier>
</Filter>
<Filter Include="ImGui">
<UniqueIdentifier>{8b35dc3d-fbec-4ae6-af90-4b9cc2b758e3}</UniqueIdentifier>
</Filter>
@ -193,26 +394,26 @@
<Filter Include="menu">
<UniqueIdentifier>{775559c7-e9f6-49d5-a2d4-6458b99e8cd9}</UniqueIdentifier>
</Filter>
<Filter Include="sigscan">
<UniqueIdentifier>{525740fe-17a7-431f-b020-720a1dc32e07}</UniqueIdentifier>
</Filter>
<Filter Include="ImGuiFileDialog">
<UniqueIdentifier>{de465f41-9f72-477f-b27f-b2e79be85aee}</UniqueIdentifier>
</Filter>
<Filter Include="ImGuiFileDialog\dirent">
<UniqueIdentifier>{3200ad89-3545-4059-8b77-8dde207ba3a4}</UniqueIdentifier>
</Filter>
<Filter Include="ImGuiFileDialog\stb">
<UniqueIdentifier>{fc7f7021-7f6b-46f0-af79-efe792ae05a8}</UniqueIdentifier>
</Filter>
<Filter Include="config">
<UniqueIdentifier>{50f832bc-5ff2-45db-8d20-e8f458c78596}</UniqueIdentifier>
</Filter>
<Filter Include="ImGuiHotkeys">
<UniqueIdentifier>{1bf47e0a-f304-4b69-9662-60e65c2c3655}</UniqueIdentifier>
<Filter Include="utils">
<UniqueIdentifier>{0e7be9b3-e988-471b-95e5-51ca0c69a046}</UniqueIdentifier>
</Filter>
<Filter Include="ImGuiEx">
<UniqueIdentifier>{c4339f5a-8efb-4f84-bb49-bd25a24d04d9}</UniqueIdentifier>
<Filter Include="ImGui\ImGuiFileDialog">
<UniqueIdentifier>{bb4754c3-ee86-4349-bbf1-2cc4e298052e}</UniqueIdentifier>
</Filter>
<Filter Include="game">
<UniqueIdentifier>{8a23ad21-b2aa-444a-b20e-a87689d4f649}</UniqueIdentifier>
</Filter>
<Filter Include="game\GamePH">
<UniqueIdentifier>{9afd9b80-0702-47ac-b291-27c901911b46}</UniqueIdentifier>
</Filter>
<Filter Include="game\GamePH\TimeWeather">
<UniqueIdentifier>{383948e8-c7b5-46bc-bec6-7cfffb473f5b}</UniqueIdentifier>
</Filter>
<Filter Include="game\Engine">
<UniqueIdentifier>{06a6e99d-eb6b-4430-bd86-76f3aed2ab32}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

View File

@ -0,0 +1 @@
#include "pch.h"

View File

@ -0,0 +1,75 @@
#pragma once
#include <Windows.h>
#include <any>
#include <filesystem>
#include <exception>
#include <ctype.h>
#include <cfloat>
#include <cstring>
#include <cstdarg>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <cerrno>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <string_view>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <thread>
#include <complex>
#include <list>
#define _USE_MATH_DEFINES
#include <cmath>
#include <assert.h>
#include <unordered_map>
#include <dxgi.h>
#include <dxgi1_4.h>
#include <d3d11.h>
#include <d3d12.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <backends\imgui_impl_dx11.h>
#include <backends\imgui_impl_dx12.h>
#include <backends\imgui_impl_win32.h>
#include <impl\d3d11_impl.h>
#include <impl\d3d12_impl.h>
#include <impl\win32_impl.h>
#include <ImGuiFileDialog\dirent\dirent.h>
#include <ImGuiFileDialog\ImGuiFileDialog.h>
#include <ImGuiFileDialog\ImGuiFileDialogConfig.h>
#include <imconfig.h>
#include <imgui_hotkey.h>
#include <imgui_internal.h>
#include <imguiex.h>
#include <imguiex_animation.h>
#include <imstb_rectpack.h>
#include <imstb_textedit.h>
#include <imstb_truetype.h>
#include <MinHook.h>
#include "..\source\config\ini.h"
#include "..\source\game\Vector3.h"
#include "..\source\game\buffer.h"
#include "..\source\utils\files.h"
#include "..\source\utils\hook.h"
#include "..\source\utils\memory.h"
#include "..\source\utils\print.h"
#include "..\source\utils\sigscan.h"
#include "..\source\utils\time.h"
#include "..\source\utils\values.h"
#include "..\source\utils\windows.h"
#include "..\source\kiero.h"

View File

@ -0,0 +1,57 @@
#include <pch.h>
#include "..\core.h"
namespace ImGui {
bool isAnyHotkeyBtnPressed = false;
Utils::Time::Timer timeSinceHotkeyBtnPressed{ 250 };
void Hotkey(const std::string_view& label, KeyBindOption* key) {
ImGuiContext& g = *GImGui;
bool wasDisabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0;
if (wasDisabled)
EndDisabled();
const ImGuiID id = GetID(label.data());
PushID(label.data());
ImGuiWindow* window = GetCurrentWindow();
if (!label.contains("##") && !window->SkipItems) {
const ImGuiStyle& style = (*GImGui).Style;
const ImVec2 label_size = CalcTextSize(label.data(), nullptr, true);
const ImVec2 pos = window->DC.CursorPos;
const ImRect total_bb(pos, pos + ImVec2((label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f));
ItemSize(total_bb, style.FramePadding.y);
if (ItemAdd(total_bb, window->GetID(label.data()))) {
const ImVec2 label_pos = ImVec2(pos.x + style.ItemInnerSpacing.x, pos.y + style.FramePadding.y);
if (label_size.x > 0.0f)
RenderText(label_pos, label.data());
}
}
SameLine(0.0f);
if (GetActiveID() == id) {
PushStyleColor(ImGuiCol_Button, GetColorU32(ImGuiCol_ButtonActive));
Button("...", ImVec2(0.0f, 0.0f));
PopStyleColor();
GetCurrentContext()->ActiveIdAllowOverlap = true;
if ((!IsItemHovered() && GetIO().MouseClicked[0]) || key->SetToPressedKey()) {
timeSinceHotkeyBtnPressed = Utils::Time::Timer(250);
isAnyHotkeyBtnPressed = false;
ClearActiveID();
} else
SetActiveID(id, GetCurrentWindow());
} else if (Button(key->ToString(), ImVec2(0.0f, 0.0f))) {
isAnyHotkeyBtnPressed = true;
SetActiveID(id, GetCurrentWindow());
}
PopID();
if (wasDisabled)
BeginDisabled(wasDisabled);
}
}

View File

@ -1,11 +1,10 @@
#pragma once
#include <imgui.h>
#include "..\..\core.h"
#include "..\utils.h"
#include "..\core.h"
#include "..\utils\time.h"
namespace ImGui {
extern bool isAnyHotkeyBtnPressed;
extern Utils::Timer timeSinceHotkeyBtnPressed;
extern Utils::Time::Timer timeSinceHotkeyBtnPressed;
void Hotkey(const std::string_view& label, KeyBindOption* key);
}

View File

@ -1,11 +1,10 @@
#define IMGUI_DEFINE_MATH_OPERATORS
#include <Hotkey.h>
#include <imgui_internal.h>
#include <pch.h>
#include "..\core.h"
namespace ImGui {
static ImGuiStyle defStyle{};
void StyleScaleAllSizes(ImGuiStyle* style, float scale_factor) {
void StyleScaleAllSizes(ImGuiStyle* style, const float scale_factor) {
style->WindowPadding = ImFloor(defStyle.WindowPadding * scale_factor);
style->WindowRounding = ImFloor(defStyle.WindowRounding * scale_factor);
style->WindowMinSize = ImFloor(defStyle.WindowMinSize * scale_factor);
@ -86,7 +85,7 @@ namespace ImGui {
ImGui::Hotkey(std::string(label + std::string("##ToggleKey")), v);
return checkbox;
}
static const float CalculateIndentation(const float& window_width, const float& text_width, const float& min_indentation) {
static const float CalculateIndentation(const float window_width, const float text_width, const float min_indentation) {
const float indentation = (window_width - text_width) * 0.5f;
return indentation > min_indentation ? indentation : min_indentation;
}
@ -118,7 +117,7 @@ namespace ImGui {
ImGui::NewLine();
}
}
void TextCenteredColored(const char* text, const ImU32& col) {
void TextCenteredColored(const char* text, const ImU32 col) {
const float min_indentation = 20.0f;
const float window_width = ImGui::GetWindowSize().x - ImGui::GetStyle().ScrollbarSize - min_indentation;
const float wrap_pos = window_width - min_indentation;
@ -150,7 +149,7 @@ namespace ImGui {
ImGui::NewLine();
}
}
bool ButtonCentered(const char* label, const ImVec2& size) {
bool ButtonCentered(const char* label, const ImVec2 size) {
ImGuiStyle& style = ImGui::GetStyle();
const float window_width = ImGui::GetContentRegionAvail().x;
const float button_width = ImGui::CalcTextSize(label).x + style.FramePadding.x * 2.0f;
@ -164,12 +163,12 @@ namespace ImGui {
return ImGui::Button(label, size);
ImGui::NewLine();
}
void SeparatorTextColored(const char* label, const ImU32& col) {
void SeparatorTextColored(const char* label, const ImU32 col) {
ImGui::PushStyleColor(ImGuiCol_Text, col);
ImGui::SeparatorText(label);
ImGui::PopStyleColor();
}
void Spacing(const ImVec2& size, const bool& customPosOffset) {
void Spacing(const ImVec2 size, const bool customPosOffset) {
ImGuiWindow* window = ImGui::GetCurrentWindow();
if (window->SkipItems)
return;

View File

@ -0,0 +1,13 @@
#pragma once
#include "..\core.h"
namespace ImGui {
extern void StyleScaleAllSizes(ImGuiStyle* style, const float scale_factor);
extern bool Checkbox(const char* label, Option* v);
extern bool CheckboxHotkey(const char* label, KeyBindOption* v);
extern void TextCentered(const char* text);
extern void TextCenteredColored(const char* text, const ImU32 col);
extern bool ButtonCentered(const char* label, const ImVec2 size = ImVec2(0.0f, 0.0f));
extern void SeparatorTextColored(const char* text, const ImU32 col);
extern void Spacing(const ImVec2 size, const bool customPosOffset = false);
}

View File

@ -1,8 +1,4 @@
#define _USE_MATH_DEFINES
#include <cmath>
#include <imgui_internal.h>
#include <string_view>
#include <unordered_map>
#include <pch.h>
namespace ImGui {
std::unordered_map<std::string_view, float> AnimValueStack{};

View File

@ -1,59 +1,54 @@
#include <assert.h>
#include <backends\imgui_impl_dx11.h>
#include <backends\imgui_impl_win32.h>
#include <d3d11.h>
#include <imgui.h>
#include <thread>
#include "..\..\kiero.h"
#include "..\..\menu\menu.h"
#include "d3d11_impl.h"
#include "win32_impl.h"
#include <pch.h>
#include "..\menu\menu.h"
HRESULT(__stdcall* oPresent)(IDXGISwapChain*, UINT, UINT);
HRESULT __stdcall hkPresent11(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags) {
static bool init = false;
namespace impl {
namespace d3d11 {
HRESULT(__stdcall* oPresent)(IDXGISwapChain*, UINT, UINT);
HRESULT __stdcall hkPresent11(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags) {
static bool init = false;
if (!init)
{
DXGI_SWAP_CHAIN_DESC desc{};
pSwapChain->GetDesc(&desc);
if (!init) {
DXGI_SWAP_CHAIN_DESC desc{};
pSwapChain->GetDesc(&desc);
ID3D11Device* device = nullptr;
pSwapChain->GetDevice(__uuidof(ID3D11Device), (void**)&device);
ID3D11Device* device = nullptr;
pSwapChain->GetDevice(__uuidof(ID3D11Device), (void**)&device);
ID3D11DeviceContext* context = nullptr;
device->GetImmediateContext(&context);
ID3D11DeviceContext* context = nullptr;
device->GetImmediateContext(&context);
#ifndef LLMH_IMPL_DISABLE_DEBUG
std::thread([&desc]() { impl::win32::init(desc.OutputWindow); }).detach();
std::thread([&desc]() { impl::win32::init(desc.OutputWindow); }).detach();
#else
impl::win32::init(desc.OutputWindow);
impl::win32::init(desc.OutputWindow);
#endif
ImGui::CreateContext();
ImGui::GetIO().IniFilename = nullptr;
ImGui::CreateContext();
ImGui::GetIO().IniFilename = nullptr;
ImGui_ImplWin32_Init(desc.OutputWindow);
ImGui_ImplDX11_Init(device, context);
ImGui_ImplWin32_Init(desc.OutputWindow);
ImGui_ImplDX11_Init(device, context);
init = true;
init = true;
}
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
Menu::FirstTimeRunning();
if (Menu::menuToggle.GetValue())
Menu::Render();
ImGui::EndFrame();
ImGui::Render();
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
return oPresent(pSwapChain, SyncInterval, Flags);
}
void init() {
assert(kiero::bind(8, (LPVOID*)&oPresent, hkPresent11) == kiero::Status::Success);
}
}
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
Menu::FirstTimeRunning();
if (Menu::menuToggle.GetValue())
Menu::Render();
ImGui::EndFrame();
ImGui::Render();
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
return oPresent(pSwapChain, SyncInterval, Flags);
}
void impl::d3d11::init() {
assert(kiero::bind(8, (LPVOID*)&oPresent, hkPresent11) == kiero::Status::Success);
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace impl {
namespace d3d11 {
void init();
extern void init();
}
}

View File

@ -1,199 +1,194 @@
#include <assert.h>
#include <backends\imgui_impl_dx12.h>
#include <backends\imgui_impl_win32.h>
#include <d3d12.h>
#include <dxgi1_4.h>
#include <imgui.h>
#include <thread>
#include "..\..\kiero.h"
#include "..\..\menu\menu.h"
#include "d3d12_impl.h"
#include "win32_impl.h"
#include <pch.h>
#include "..\menu\menu.h"
struct FrameContext {
ID3D12CommandAllocator* commandAllocator = nullptr;
ID3D12Resource* main_render_target_resource = nullptr;
D3D12_CPU_DESCRIPTOR_HANDLE main_render_target_descriptor{};
};
namespace impl {
namespace d3d12 {
struct FrameContext {
ID3D12CommandAllocator* commandAllocator = nullptr;
ID3D12Resource* main_render_target_resource = nullptr;
D3D12_CPU_DESCRIPTOR_HANDLE main_render_target_descriptor{};
};
static UINT buffersCounts = -1;
static FrameContext* frameContext = nullptr;
static UINT buffersCounts = -1;
static FrameContext* frameContext = nullptr;
static ID3D12Device* device = nullptr;
static ID3D12DescriptorHeap* d3d12DescriptorHeapBackBuffers = nullptr;
static ID3D12DescriptorHeap* d3d12DescriptorHeapImGuiRender = nullptr;
static ID3D12GraphicsCommandList* d3d12CommandList = nullptr;
static ID3D12CommandQueue* d3d12CommandQueue = nullptr;
static ID3D12Device* device = nullptr;
static ID3D12DescriptorHeap* d3d12DescriptorHeapBackBuffers = nullptr;
static ID3D12DescriptorHeap* d3d12DescriptorHeapImGuiRender = nullptr;
static ID3D12GraphicsCommandList* d3d12CommandList = nullptr;
static ID3D12CommandQueue* d3d12CommandQueue = nullptr;
static void CreateRenderTarget(IDXGISwapChain* pSwapChain) {
for (UINT i = 0; i < buffersCounts; i++) {
ID3D12Resource* pBackBuffer = nullptr;
pSwapChain->GetBuffer(i, IID_PPV_ARGS(&pBackBuffer));
if (pBackBuffer) {
D3D12_RENDER_TARGET_VIEW_DESC descTarget{};
descTarget.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
descTarget.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
static void CreateRenderTarget(IDXGISwapChain* pSwapChain) {
for (UINT i = 0; i < buffersCounts; i++) {
ID3D12Resource* pBackBuffer = nullptr;
pSwapChain->GetBuffer(i, IID_PPV_ARGS(&pBackBuffer));
if (pBackBuffer) {
D3D12_RENDER_TARGET_VIEW_DESC descTarget{};
descTarget.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
descTarget.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
device->CreateRenderTargetView(pBackBuffer, &descTarget, frameContext[i].main_render_target_descriptor);
frameContext[i].main_render_target_resource = pBackBuffer;
}
}
}
static void RenderImGui_DX12(IDXGISwapChain3* pSwapChain) {
static bool init = false;
if (!init) {
DXGI_SWAP_CHAIN_DESC desc{};
pSwapChain->GetDesc(&desc);
pSwapChain->GetDevice(__uuidof(ID3D12Device), (void**)&device);
buffersCounts = desc.BufferCount;
frameContext = new FrameContext[buffersCounts];
D3D12_DESCRIPTOR_HEAP_DESC descriptorBackBuffers{};
descriptorBackBuffers.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
descriptorBackBuffers.NumDescriptors = buffersCounts;
descriptorBackBuffers.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
descriptorBackBuffers.NodeMask = 1;
if (device->CreateDescriptorHeap(&descriptorBackBuffers, IID_PPV_ARGS(&d3d12DescriptorHeapBackBuffers)) != S_OK)
return;
SIZE_T rtvDescriptorSize = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = d3d12DescriptorHeapBackBuffers->GetCPUDescriptorHandleForHeapStart();
for (UINT i = 0; i < buffersCounts; ++i) {
frameContext[i].main_render_target_descriptor = rtvHandle;
rtvHandle.ptr += rtvDescriptorSize;
device->CreateRenderTargetView(pBackBuffer, &descTarget, frameContext[i].main_render_target_descriptor);
frameContext[i].main_render_target_resource = pBackBuffer;
}
}
}
D3D12_DESCRIPTOR_HEAP_DESC descriptorImGuiRender{};
descriptorImGuiRender.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
descriptorImGuiRender.NumDescriptors = 1;
descriptorImGuiRender.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
if (device->CreateDescriptorHeap(&descriptorImGuiRender, IID_PPV_ARGS(&d3d12DescriptorHeapImGuiRender)) != S_OK)
return;
static void RenderImGui_DX12(IDXGISwapChain3* pSwapChain) {
static bool init = false;
for (size_t i = 0; i < buffersCounts; i++) {
ID3D12CommandAllocator* allocator = nullptr;
if (device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator)) != S_OK)
return;
if (!init) {
DXGI_SWAP_CHAIN_DESC desc{};
pSwapChain->GetDesc(&desc);
pSwapChain->GetDevice(__uuidof(ID3D12Device), (void**)&device);
frameContext[i].commandAllocator = allocator;
}
buffersCounts = desc.BufferCount;
frameContext = new FrameContext[buffersCounts];
if (device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, frameContext[0].commandAllocator, NULL, IID_PPV_ARGS(&d3d12CommandList)) != S_OK || d3d12CommandList->Close() != S_OK)
return;
D3D12_DESCRIPTOR_HEAP_DESC descriptorBackBuffers{};
descriptorBackBuffers.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
descriptorBackBuffers.NumDescriptors = buffersCounts;
descriptorBackBuffers.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
descriptorBackBuffers.NodeMask = 1;
if (device->CreateDescriptorHeap(&descriptorBackBuffers, IID_PPV_ARGS(&d3d12DescriptorHeapBackBuffers)) != S_OK)
return;
SIZE_T rtvDescriptorSize = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = d3d12DescriptorHeapBackBuffers->GetCPUDescriptorHandleForHeapStart();
for (UINT i = 0; i < buffersCounts; ++i) {
frameContext[i].main_render_target_descriptor = rtvHandle;
rtvHandle.ptr += rtvDescriptorSize;
}
D3D12_DESCRIPTOR_HEAP_DESC descriptorImGuiRender{};
descriptorImGuiRender.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
descriptorImGuiRender.NumDescriptors = 1;
descriptorImGuiRender.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
if (device->CreateDescriptorHeap(&descriptorImGuiRender, IID_PPV_ARGS(&d3d12DescriptorHeapImGuiRender)) != S_OK)
return;
for (size_t i = 0; i < buffersCounts; i++) {
ID3D12CommandAllocator* allocator = nullptr;
if (device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator)) != S_OK)
return;
frameContext[i].commandAllocator = allocator;
}
if (device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, frameContext[0].commandAllocator, NULL, IID_PPV_ARGS(&d3d12CommandList)) != S_OK || d3d12CommandList->Close() != S_OK)
return;
#ifndef LLMH_IMPL_DISABLE_DEBUG
std::thread([&desc]() { impl::win32::init(desc.OutputWindow); }).detach();
std::thread([&desc]() { impl::win32::init(desc.OutputWindow); }).detach();
#else
impl::win32::init(desc.OutputWindow);
impl::win32::init(desc.OutputWindow);
#endif
ImGui::CreateContext();
ImGui::GetIO().IniFilename = nullptr;
ImGui::CreateContext();
ImGui::GetIO().IniFilename = nullptr;
ImGui_ImplWin32_Init(desc.OutputWindow);
ImGui_ImplDX12_Init(device, buffersCounts, DXGI_FORMAT_R8G8B8A8_UNORM, d3d12DescriptorHeapImGuiRender, d3d12DescriptorHeapImGuiRender->GetCPUDescriptorHandleForHeapStart(), d3d12DescriptorHeapImGuiRender->GetGPUDescriptorHandleForHeapStart());
ImGui_ImplDX12_CreateDeviceObjects();
ImGui_ImplWin32_Init(desc.OutputWindow);
ImGui_ImplDX12_Init(device, buffersCounts, DXGI_FORMAT_R8G8B8A8_UNORM, d3d12DescriptorHeapImGuiRender, d3d12DescriptorHeapImGuiRender->GetCPUDescriptorHandleForHeapStart(), d3d12DescriptorHeapImGuiRender->GetGPUDescriptorHandleForHeapStart());
ImGui_ImplDX12_CreateDeviceObjects();
init = true;
}
init = true;
}
if (!frameContext[0].main_render_target_resource)
CreateRenderTarget(pSwapChain);
if (!d3d12CommandQueue || !frameContext[0].main_render_target_resource)
return;
if (!frameContext[0].main_render_target_resource)
CreateRenderTarget(pSwapChain);
if (!d3d12CommandQueue || !frameContext[0].main_render_target_resource)
return;
ImGui_ImplDX12_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
ImGui_ImplDX12_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
Menu::FirstTimeRunning();
if (Menu::menuToggle.GetValue())
Menu::Render();
Menu::FirstTimeRunning();
if (Menu::menuToggle.GetValue())
Menu::Render();
ImGui::Render();
ImGui::Render();
UINT backBufferIdx = pSwapChain->GetCurrentBackBufferIndex();
ID3D12CommandAllocator* commandAllocator = frameContext[backBufferIdx].commandAllocator;
commandAllocator->Reset();
UINT backBufferIdx = pSwapChain->GetCurrentBackBufferIndex();
ID3D12CommandAllocator* commandAllocator = frameContext[backBufferIdx].commandAllocator;
commandAllocator->Reset();
D3D12_RESOURCE_BARRIER barrier{};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
barrier.Transition.pResource = frameContext[backBufferIdx].main_render_target_resource;
barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
d3d12CommandList->Reset(commandAllocator, NULL);
d3d12CommandList->ResourceBarrier(1, &barrier);
D3D12_RESOURCE_BARRIER barrier{};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
barrier.Transition.pResource = frameContext[backBufferIdx].main_render_target_resource;
barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
d3d12CommandList->Reset(commandAllocator, NULL);
d3d12CommandList->ResourceBarrier(1, &barrier);
d3d12CommandList->OMSetRenderTargets(1, &frameContext[backBufferIdx].main_render_target_descriptor, FALSE, NULL);
d3d12CommandList->SetDescriptorHeaps(1, &d3d12DescriptorHeapImGuiRender);
d3d12CommandList->OMSetRenderTargets(1, &frameContext[backBufferIdx].main_render_target_descriptor, FALSE, NULL);
d3d12CommandList->SetDescriptorHeaps(1, &d3d12DescriptorHeapImGuiRender);
ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData(), d3d12CommandList);
ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData(), d3d12CommandList);
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
d3d12CommandList->ResourceBarrier(1, &barrier);
d3d12CommandList->Close();
d3d12CommandList->ResourceBarrier(1, &barrier);
d3d12CommandList->Close();
d3d12CommandQueue->ExecuteCommandLists(1, reinterpret_cast<ID3D12CommandList* const*>(&d3d12CommandList));
}
d3d12CommandQueue->ExecuteCommandLists(1, reinterpret_cast<ID3D12CommandList* const*>(&d3d12CommandList));
}
HRESULT(__stdcall* oPresent)(IDXGISwapChain3*, UINT, UINT);
HRESULT __stdcall hkPresent12(IDXGISwapChain3* pSwapChain, UINT SyncInterval, UINT Flags) {
RenderImGui_DX12(pSwapChain);
HRESULT(__stdcall* oPresent)(IDXGISwapChain3*, UINT, UINT);
HRESULT __stdcall hkPresent12(IDXGISwapChain3* pSwapChain, UINT SyncInterval, UINT Flags) {
RenderImGui_DX12(pSwapChain);
return oPresent(pSwapChain, SyncInterval, Flags);
}
return oPresent(pSwapChain, SyncInterval, Flags);
}
HRESULT(__stdcall* oPresent1)(IDXGISwapChain3*, UINT, UINT, const DXGI_PRESENT_PARAMETERS* pPresentParameters);
HRESULT __stdcall hkPresent112(IDXGISwapChain3* pSwapChain, UINT SyncInterval, UINT PresentFlags, const DXGI_PRESENT_PARAMETERS* pPresentParameters) {
RenderImGui_DX12(pSwapChain);
HRESULT(__stdcall* oPresent1)(IDXGISwapChain3*, UINT, UINT, const DXGI_PRESENT_PARAMETERS* pPresentParameters);
HRESULT __stdcall hkPresent112(IDXGISwapChain3* pSwapChain, UINT SyncInterval, UINT PresentFlags, const DXGI_PRESENT_PARAMETERS* pPresentParameters) {
RenderImGui_DX12(pSwapChain);
return oPresent1(pSwapChain, SyncInterval, PresentFlags, pPresentParameters);
}
return oPresent1(pSwapChain, SyncInterval, PresentFlags, pPresentParameters);
}
static void CleanupRenderTarget() {
for (UINT i = 0; i < buffersCounts; ++i) {
if (frameContext[i].main_render_target_resource) {
frameContext[i].main_render_target_resource->Release();
frameContext[i].main_render_target_resource = NULL;
static void CleanupRenderTarget() {
for (UINT i = 0; i < buffersCounts; ++i) {
if (frameContext[i].main_render_target_resource) {
frameContext[i].main_render_target_resource->Release();
frameContext[i].main_render_target_resource = NULL;
}
}
}
HRESULT(__stdcall* oResizeBuffers)(IDXGISwapChain*, UINT, UINT, UINT, DXGI_FORMAT, UINT);
HRESULT hookResizeBuffers12(IDXGISwapChain* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) {
CleanupRenderTarget();
return oResizeBuffers(pSwapChain, BufferCount, Width, Height, NewFormat, SwapChainFlags);
}
HRESULT(__stdcall* oResizeBuffers1)(IDXGISwapChain3*, UINT, UINT, UINT, DXGI_FORMAT, UINT, const UINT*, IUnknown* const*);
HRESULT hookResizeBuffers112(IDXGISwapChain3* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags, const UINT* pCreationNodeMask, IUnknown* const* ppPresentQueue) {
CleanupRenderTarget();
return oResizeBuffers1(pSwapChain, BufferCount, Width, Height, NewFormat, SwapChainFlags, pCreationNodeMask, ppPresentQueue);
}
void(__stdcall* oExecuteCommandLists)(ID3D12CommandQueue*, UINT, ID3D12CommandList* const*);
void hookExecuteCommandLists12(ID3D12CommandQueue* queue, UINT NumCommandLists, ID3D12CommandList* const* ppCommandLists) {
if (!d3d12CommandQueue)
d3d12CommandQueue = queue;
oExecuteCommandLists(queue, NumCommandLists, ppCommandLists);
}
void init() {
assert(kiero::bind(140, (LPVOID*)&oPresent, hkPresent12) == kiero::Status::Success);
assert(kiero::bind(154, (LPVOID*)&oPresent1, hkPresent112) == kiero::Status::Success);
assert(kiero::bind(145, (LPVOID*)&oResizeBuffers, hookResizeBuffers12) == kiero::Status::Success);
assert(kiero::bind(171, (LPVOID*)&oResizeBuffers1, hookResizeBuffers112) == kiero::Status::Success);
assert(kiero::bind(54, (LPVOID*)&oExecuteCommandLists, hookExecuteCommandLists12) == kiero::Status::Success);
}
}
}
HRESULT(__stdcall* oResizeBuffers)(IDXGISwapChain*, UINT, UINT, UINT, DXGI_FORMAT, UINT);
HRESULT hookResizeBuffers12(IDXGISwapChain* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) {
CleanupRenderTarget();
return oResizeBuffers(pSwapChain, BufferCount, Width, Height, NewFormat, SwapChainFlags);
}
HRESULT(__stdcall* oResizeBuffers1)(IDXGISwapChain3*, UINT, UINT, UINT, DXGI_FORMAT, UINT, const UINT*, IUnknown* const*);
HRESULT hookResizeBuffers112(IDXGISwapChain3* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags, const UINT* pCreationNodeMask, IUnknown* const* ppPresentQueue) {
CleanupRenderTarget();
return oResizeBuffers1(pSwapChain, BufferCount, Width, Height, NewFormat, SwapChainFlags, pCreationNodeMask, ppPresentQueue);
}
void(__stdcall* oExecuteCommandLists)(ID3D12CommandQueue*, UINT, ID3D12CommandList* const*);
void hookExecuteCommandLists12(ID3D12CommandQueue* queue, UINT NumCommandLists, ID3D12CommandList* const *ppCommandLists) {
if (!d3d12CommandQueue)
d3d12CommandQueue = queue;
oExecuteCommandLists(queue, NumCommandLists, ppCommandLists);
}
void impl::d3d12::init() {
assert(kiero::bind(140, (LPVOID*)&oPresent, hkPresent12) == kiero::Status::Success);
assert(kiero::bind(154, (LPVOID*)&oPresent1, hkPresent112) == kiero::Status::Success);
assert(kiero::bind(145, (LPVOID*)&oResizeBuffers, hookResizeBuffers12) == kiero::Status::Success);
assert(kiero::bind(171, (LPVOID*)&oResizeBuffers1, hookResizeBuffers112) == kiero::Status::Success);
assert(kiero::bind(54, (LPVOID*)&oExecuteCommandLists, hookExecuteCommandLists12) == kiero::Status::Success);
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace impl {
namespace d3d12 {
void init();
extern void init();
}
}

View File

@ -1,125 +1,122 @@
#include <Hotkey.h>
#include <Windows.h>
#include <backends\imgui_impl_win32.h>
#include <imgui.h>
#include <thread>
#include "..\..\core.h"
#include "..\..\game_classes.h"
#include "..\..\kiero.h"
#include "..\..\menu\menu.h"
#include "..\..\print.h"
#include "..\..\sigscan\offsets.h"
#include "..\config\config.h"
#include "win32_impl.h"
#include <pch.h>
#include "..\core.h"
#include "..\game\Engine\CInput.h"
#include "..\menu\menu.h"
static HWND gHwnd = nullptr;
static WNDPROC oWndProc = nullptr;
static HHOOK oMouseProc = nullptr;
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
static LRESULT __stdcall hkWindowProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam) {
switch (uMsg) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
if (Menu::firstTimeRunning.GetValue() || ImGui::isAnyHotkeyBtnPressed || !ImGui::timeSinceHotkeyBtnPressed.DidTimePass() || KeyBindOption::wasAnyKeyPressed)
break;
namespace impl {
namespace win32 {
static HWND gHwnd = nullptr;
static WNDPROC oWndProc = nullptr;
static HHOOK oMouseProc = nullptr;
for (auto& option : *KeyBindOption::GetInstances()) {
if (option->GetChangesAreDisabled())
continue;
if (option->GetKeyBind() == VK_NONE)
continue;
static LRESULT __stdcall hkWindowProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam) {
switch (uMsg) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
if (Menu::firstTimeRunning.GetValue() || ImGui::isAnyHotkeyBtnPressed || !ImGui::timeSinceHotkeyBtnPressed.DidTimePass() || KeyBindOption::wasAnyKeyPressed)
break;
if (wParam == option->GetKeyBind()) {
KeyBindOption::wasAnyKeyPressed = true;
option->Toggle();
}
}
break;
case WM_KEYUP:
case WM_SYSKEYUP:
if (!KeyBindOption::wasAnyKeyPressed)
break;
for (auto& option : *KeyBindOption::GetInstances()) {
if (option->GetChangesAreDisabled())
continue;
if (option->GetKeyBind() == VK_NONE)
continue;
for (auto& option : *KeyBindOption::GetInstances()) {
if (wParam == option->GetKeyBind())
KeyBindOption::wasAnyKeyPressed = false;
}
break;
}
Engine::CInput* pCInput = Engine::CInput::Get();
if (!pCInput)
return CallWindowProc(oWndProc, hwnd, uMsg, wParam, lParam);
ImGui::GetIO().MouseDrawCursor = Menu::firstTimeRunning.GetValue() || Menu::menuToggle.GetValue();
ImGui_ImplWin32_WndProcHandler(hwnd, uMsg, wParam, lParam);
if (Menu::firstTimeRunning.GetValue() || Menu::menuToggle.GetValue()) {
pCInput->BlockGameInput();
if (Menu::menuToggle.GetValue())
Menu::menuToggle.SetPrevValue(true);
} else if (Menu::firstTimeRunning.GetPrevValue() || Menu::menuToggle.GetPrevValue()) {
if (Menu::firstTimeRunning.GetPrevValue())
Menu::firstTimeRunning.SetPrevValue(false);
else if (Menu::menuToggle.GetPrevValue())
Menu::menuToggle.SetPrevValue(false);
pCInput->UnlockGameInput();
}
return CallWindowProc(oWndProc, hwnd, uMsg, wParam, lParam);
}
#ifndef LLMH_IMPL_DISABLE_DEBUG
static LRESULT CALLBACK hkMouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode != HC_ACTION)
return CallNextHookEx(oMouseProc, nCode, wParam, lParam);
if (GetForegroundWindow() != gHwnd)
return CallNextHookEx(oMouseProc, nCode, wParam, lParam);
switch (wParam) {
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL: {
MSLLHOOKSTRUCT* pMouseStruct = (MSLLHOOKSTRUCT*)lParam;
if (pMouseStruct == nullptr)
break;
if (GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData)) {
if (Menu::firstTimeRunning.GetValue())
if (wParam == option->GetKeyBind()) {
KeyBindOption::wasAnyKeyPressed = true;
option->Toggle();
}
}
break;
for (auto& option : *KeyBindOption::GetInstances()) {
if (option->GetChangesAreDisabled())
continue;
case WM_KEYUP:
case WM_SYSKEYUP:
if (!KeyBindOption::wasAnyKeyPressed)
break;
if ((option->GetKeyBind() == VK_MWHEELUP && GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData) > 0) ||
(option->GetKeyBind() == VK_MWHEELDOWN && GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData) < 0))
option->Toggle();
for (auto& option : *KeyBindOption::GetInstances()) {
if (wParam == option->GetKeyBind())
KeyBindOption::wasAnyKeyPressed = false;
}
break;
}
if (GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData) > 0)
KeyBindOption::scrolledMouseWheelUp = true;
else if (GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData) < 0)
KeyBindOption::scrolledMouseWheelDown = true;
Engine::CInput* pCInput = Engine::CInput::Get();
if (!pCInput)
return CallWindowProc(oWndProc, hwnd, uMsg, wParam, lParam);
ImGui::GetIO().MouseDrawCursor = Menu::firstTimeRunning.GetValue() || Menu::menuToggle.GetValue();
ImGui_ImplWin32_WndProcHandler(hwnd, uMsg, wParam, lParam);
if (Menu::firstTimeRunning.GetValue() || Menu::menuToggle.GetValue()) {
pCInput->BlockGameInput();
if (Menu::menuToggle.GetValue())
Menu::menuToggle.SetPrevValue(true);
} else if (Menu::firstTimeRunning.GetPrevValue() || Menu::menuToggle.GetPrevValue()) {
if (Menu::firstTimeRunning.GetPrevValue())
Menu::firstTimeRunning.SetPrevValue(false);
else if (Menu::menuToggle.GetPrevValue())
Menu::menuToggle.SetPrevValue(false);
pCInput->UnlockGameInput();
}
return CallWindowProc(oWndProc, hwnd, uMsg, wParam, lParam);
}
break;
}
}
return CallNextHookEx(oMouseProc, nCode, wParam, lParam);
}
#endif
void impl::win32::init(HWND hwnd) {
gHwnd = hwnd;
oWndProc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)hkWindowProc);
#ifndef LLMH_IMPL_DISABLE_DEBUG
oMouseProc = SetWindowsHookEx(WH_MOUSE_LL, hkMouseProc, GetModuleHandle(nullptr), 0);
static LRESULT CALLBACK hkMouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode != HC_ACTION)
return CallNextHookEx(oMouseProc, nCode, wParam, lParam);
if (GetForegroundWindow() != gHwnd)
return CallNextHookEx(oMouseProc, nCode, wParam, lParam);
MSG msg;
while (oMouseProc && GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
switch (wParam) {
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
{
MSLLHOOKSTRUCT* pMouseStruct = (MSLLHOOKSTRUCT*)lParam;
if (pMouseStruct == nullptr)
break;
if (GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData)) {
if (Menu::firstTimeRunning.GetValue())
break;
for (auto& option : *KeyBindOption::GetInstances()) {
if (option->GetChangesAreDisabled())
continue;
if ((option->GetKeyBind() == VK_MWHEELUP && GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData) > 0) ||
(option->GetKeyBind() == VK_MWHEELDOWN && GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData) < 0))
option->Toggle();
}
if (GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData) > 0)
KeyBindOption::scrolledMouseWheelUp = true;
else if (GET_WHEEL_DELTA_WPARAM(pMouseStruct->mouseData) < 0)
KeyBindOption::scrolledMouseWheelDown = true;
}
break;
}
}
return CallNextHookEx(oMouseProc, nCode, wParam, lParam);
}
#endif
void init(HWND hwnd) {
gHwnd = hwnd;
oWndProc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)hkWindowProc);
#ifndef LLMH_IMPL_DISABLE_DEBUG
oMouseProc = SetWindowsHookEx(WH_MOUSE_LL, hkMouseProc, GetModuleHandle(nullptr), 0);
MSG msg;
while (oMouseProc && GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
#endif
}
}
}

View File

@ -1,6 +1,8 @@
#pragma once
#include <wtypes.h>
namespace impl {
namespace win32 {
void init(HWND hwnd);
extern void init(HWND hwnd);
}
}

View File

@ -1,14 +0,0 @@
#pragma once
#include "..\core.h"
#include "Animation.h"
namespace ImGui {
extern void StyleScaleAllSizes(ImGuiStyle* style, float scale_factor);
extern bool Checkbox(const char* label, Option* v);
extern bool CheckboxHotkey(const char* label, KeyBindOption* v);
extern void TextCentered(const char* text);
extern void TextCenteredColored(const char* text, const ImU32& col);
extern bool ButtonCentered(const char* label, const ImVec2& size = ImVec2(0.0f, 0.0f));
extern void SeparatorTextColored(const char* text, const ImU32& col);
extern void Spacing(const ImVec2& size, const bool& customPosOffset = false);
}

View File

@ -1,58 +0,0 @@
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui_internal.h>
#include "Hotkey.h"
bool ImGui::isAnyHotkeyBtnPressed = false;
Utils::Timer ImGui::timeSinceHotkeyBtnPressed{ 250 };
void ImGui::Hotkey(const std::string_view& label, KeyBindOption* key) {
ImGuiContext& g = *GImGui;
bool wasDisabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0;
if (wasDisabled)
ImGui::EndDisabled();
const ImGuiID id = ImGui::GetID(label.data());
ImGui::PushID(label.data());
ImGuiWindow* window = GetCurrentWindow();
if (!label.contains("##") && !window->SkipItems) {
const ImGuiStyle& style = (*GImGui).Style;
const ImVec2 label_size = CalcTextSize(label.data(), nullptr, true);
const ImVec2 pos = window->DC.CursorPos;
const ImRect total_bb(pos, pos + ImVec2((label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f));
ItemSize(total_bb, style.FramePadding.y);
if (ItemAdd(total_bb, window->GetID(label.data()))) {
const ImVec2 label_pos = ImVec2(pos.x + style.ItemInnerSpacing.x, pos.y + style.FramePadding.y);
if (label_size.x > 0.0f)
RenderText(label_pos, label.data());
}
}
ImGui::SameLine(0.0f);
if (ImGui::GetActiveID() == id) {
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetColorU32(ImGuiCol_ButtonActive));
ImGui::Button("...", ImVec2(0.0f, 0.0f));
ImGui::PopStyleColor();
ImGui::GetCurrentContext()->ActiveIdAllowOverlap = true;
if ((!ImGui::IsItemHovered() && ImGui::GetIO().MouseClicked[0]) || key->SetToPressedKey()) {
timeSinceHotkeyBtnPressed = Utils::Timer(250);
isAnyHotkeyBtnPressed = false;
ImGui::ClearActiveID();
}
else
ImGui::SetActiveID(id, ImGui::GetCurrentWindow());
}
else if (ImGui::Button(key->ToString(), ImVec2(0.0f, 0.0f))) {
isAnyHotkeyBtnPressed = true;
ImGui::SetActiveID(id, ImGui::GetCurrentWindow());
}
ImGui::PopID();
if (wasDisabled)
ImGui::BeginDisabled(wasDisabled);
}

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2022 xvorost
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,18 +1,18 @@
#include <any>
#include <array>
#include <filesystem>
#include <functional>
#include <pch.h>
#include "..\menu\camera.h"
#include "..\menu\menu.h"
#include "..\menu\misc.h"
#include "..\menu\player.h"
#include "..\menu\world.h"
#include "..\print.h"
#include "..\utils.h"
#include "config.h"
#include "ini.h"
namespace Config {
enum ValueType {
OPTION,
Float,
String
};
struct VKey {
constexpr VKey(std::string_view name, int code) : name(name), code(code) {}
@ -4089,7 +4089,7 @@ namespace Config {
static void LoadDefaultConfig() {
reader = inih::INIReader();
const std::filesystem::path desktopPath = Utils::GetDesktopDir();
const std::filesystem::path desktopPath = Utils::Files::GetDesktopDir();
std::string desktopPathStr = desktopPath.string();
if (!desktopPath.empty() && !(std::filesystem::is_directory(desktopPath.parent_path()) && std::filesystem::is_directory(desktopPath)))
desktopPathStr = {};
@ -4130,14 +4130,14 @@ namespace Config {
inih::INIWriter writer{};
writer.write(configFileName, reader);
} catch (const std::runtime_error& e) {
configError = PrintError("Error writing file %s: %s", configFileName, e.what());
configError = Utils::PrintError("Error writing file %s: %s", configFileName, e.what());
}
}
static bool ConfigExists() {
return std::filesystem::exists(configFileName);
}
static void CreateConfig() {
configStatus = PrintWarning("%s does not exist (will create now); using default config values", configFileName);
configStatus = Utils::PrintWarning("%s does not exist (will create now); using default config values", configFileName);
LoadAndWriteDefaultConfig();
}
@ -4145,7 +4145,7 @@ namespace Config {
try {
reader = inih::INIReader(configFileName);
const std::filesystem::path desktopPath = Utils::GetDesktopDir();
const std::filesystem::path desktopPath = Utils::Files::GetDesktopDir();
std::string desktopPathStr = desktopPath.string();
if (!desktopPath.empty() && !(std::filesystem::is_directory(desktopPath.parent_path()) && std::filesystem::is_directory(desktopPath)))
desktopPathStr = {};
@ -4198,9 +4198,9 @@ namespace Config {
}
}
configStatus = PrintSuccess(configUpdate ? "Successfully read updated config!" : "Successfully read config!");
configStatus = Utils::PrintSuccess(configUpdate ? "Successfully read updated config!" : "Successfully read config!");
} catch (const std::runtime_error& e) {
configError = PrintSuccess("Error writing file %s; using default config values: %s", configFileName, e.what());
configError = Utils::PrintSuccess("Error writing file %s; using default config values: %s", configFileName, e.what());
LoadDefaultConfig();
}
@ -4237,7 +4237,7 @@ namespace Config {
savedConfig = true;
} catch (const std::runtime_error& e) {
configError = PrintError("Error saving to file %s: %s", configFileName, e.what());
configError = Utils::PrintError("Error saving to file %s: %s", configFileName, e.what());
}
}
void InitConfig() {

View File

@ -1,14 +1,6 @@
#pragma once
#include <windows.h>
namespace Config {
extern const char playerVars[];
enum ValueType {
OPTION,
Float,
String
};
extern void SaveConfig();
extern void InitConfig();

View File

@ -1,19 +0,0 @@
#pragma once
#include <chrono>
#include <iomanip>
template <class result_t = std::chrono::milliseconds, class clock_t = std::chrono::steady_clock, class duration_t = std::chrono::milliseconds> auto since(std::chrono::time_point<clock_t, duration_t> const& start) {
return std::chrono::duration_cast<result_t>(clock_t::now() - start);
}
inline std::ostringstream GetTimestamp() {
time_t timeInstance = time(0);
tm timestamp{};
localtime_s(&timestamp, &timeInstance);
std::ostringstream oss{};
oss << "[" << std::setw(2) << std::setfill('0') << timestamp.tm_hour << "h:"
<< std::setw(2) << std::setfill('0') << timestamp.tm_min << "m:"
<< std::setw(2) << std::setfill('0') << timestamp.tm_sec << "s] ";
return oss;
}

View File

@ -1,17 +1,8 @@
#include <MinHook.h>
#include <Windows.h>
#include <filesystem>
#include <iostream>
#include <thread>
#include "ImGui\impl\d3d11_impl.h"
#include "ImGui\impl\d3d12_impl.h"
#include <pch.h>
#include "config\config.h"
#include "game_classes.h"
#include "hook.h"
#include "kiero.h"
#include "core.h"
#include "game\GamePH\PlayerVariables.h"
#include "menu\menu.h"
#include "print.h"
#include "sigscan\offsets.h"
#pragma region KeyBindOption
bool KeyBindOption::wasAnyKeyPressed = false;
@ -46,7 +37,7 @@ namespace Core {
bool exiting = false;
static bool createdConfigThread = false;
static std::string_view rendererAPI{};
int rendererAPI = 0;
static void LoopHookRenderer() {
while (true) {
if (exiting)
@ -54,9 +45,9 @@ namespace Core {
Sleep(1000);
if (rendererAPI.empty())
if (!rendererAPI)
continue;
if (kiero::init(rendererAPI == "d3d11" ? kiero::RenderType::D3D11 : kiero::RenderType::D3D12) != kiero::Status::Success)
if (kiero::init(rendererAPI == 11 ? kiero::RenderType::D3D11 : kiero::RenderType::D3D12) != kiero::Status::Success)
continue;
switch (kiero::getRenderType()) {
@ -74,21 +65,18 @@ namespace Core {
}
}
#pragma region ReadVideoSettings
// forward decl
static bool detourReadVideoSettings(LPVOID instance, LPVOID file, bool flag1);
static Hook::MHook<LPVOID, bool(*)(LPVOID, LPVOID, bool)> ReadVideoSettingsHook{ "ReadVideoSettings", &Offsets::Get_ReadVideoSettings, &detourReadVideoSettings};
static void CreateSymlinkForLoadingFiles() {
std::filesystem::create_directories("EGameTools\\FilesToLoad");
static bool detourReadVideoSettings(LPVOID instance, LPVOID file, bool flag1) {
if (!rendererAPI.empty())
return ReadVideoSettingsHook.pOriginal(instance, file, flag1);
DWORD renderer = *reinterpret_cast<PDWORD>(reinterpret_cast<DWORD64>(instance) + 0x7C);
rendererAPI = !renderer ? "d3d11" : "d3d12";
return ReadVideoSettingsHook.pOriginal(instance, file, flag1);
for (const auto& entry : std::filesystem::directory_iterator("..\\..\\data")) {
if (entry.path().filename().string() == "EGameTools" && is_symlink(entry.symlink_status())) {
if (std::filesystem::equivalent("..\\..\\data\\EGameTools", "EGameTools"))
return;
std::filesystem::remove(entry.path());
}
}
std::filesystem::create_directory_symlink(Utils::Files::GetCurrentProcDirectory() + "\\EGameTools", "..\\..\\data\\EGameTools");
}
#pragma endregion
void OnPostUpdate() {
if (!createdConfigThread) {
@ -104,41 +92,27 @@ namespace Core {
for (auto& menuTab : *Menu::MenuTab::GetInstances())
menuTab.second->Update();
}
static void CreateSymlinkForLoadingFiles() {
std::filesystem::create_directories("EGameTools\\FilesToLoad");
for (const auto& entry : std::filesystem::directory_iterator("..\\..\\data")) {
if (entry.path().filename().string() == "EGameTools" && is_symlink(entry.symlink_status())) {
if (std::filesystem::equivalent("..\\..\\data\\EGameTools", "EGameTools"))
return;
std::filesystem::remove(entry.path());
}
}
std::filesystem::create_directory_symlink(Utils::GetCurrentProcDirectory() + "\\EGameTools", "..\\..\\data\\EGameTools");
}
DWORD64 WINAPI MainThread(HMODULE hModule) {
EnableConsole();
PrintInfo("Initializing config");
Utils::PrintInfo("Initializing config");
Config::InitConfig();
PrintInfo("Creating \"EGameTools\\FilesToLoad\"");
Utils::PrintInfo("Creating \"EGameTools\\FilesToLoad\"");
CreateSymlinkForLoadingFiles();
PrintInfo("Sorting Player Variables");
Utils::PrintInfo("Sorting Player Variables");
GamePH::PlayerVariables::SortPlayerVars();
PrintInfo("Initializing MinHook");
Utils::PrintInfo("Initializing MinHook");
MH_Initialize();
PrintInfo("Hooking DX11/DX12 renderer");
Utils::PrintInfo("Hooking DX11/DX12 renderer");
std::thread([]() {
LoopHookRenderer();
PrintSuccess("Hooked DX11/DX12 renderer!");
Utils::PrintSuccess("Hooked DX11/DX12 renderer!");
}).detach();
for (auto& hook : *Hook::HookBase::GetInstances()) {
PrintInfo("Hooking %s", hook->name.data());
for (auto& hook : *Utils::Hook::HookBase::GetInstances()) {
Utils::PrintInfo("Hooking %s", hook->name.data());
std::thread([hook]() { hook->HookLoop(); }).detach();
}
@ -151,11 +125,11 @@ namespace Core {
void Cleanup() {
exiting = true;
PrintInfo("Game request exit, running cleanup");
PrintInfo("Saving config to file");
Utils::PrintInfo("Game request exit, running cleanup");
Utils::PrintInfo("Saving config to file");
Config::SaveConfig();
PrintInfo("Unhooking everything");
Utils::PrintInfo("Unhooking everything");
MH_DisableHook(MH_ALL_HOOKS);
MH_Uninitialize();
}

View File

@ -1,12 +1,15 @@
#pragma once
#include <Windows.h>
#include <array>
#include <ShlObj.h>
#include <imgui.h>
#include <ranges>
#include <set>
#include <string_view>
#include "utils.h"
#include "..\utils\values.h"
#ifndef VK_NONE
#ifdef _DEBUG
#define LLMH_IMPL_DISABLE_DEBUG // this is for disabling low-level mouse hook in case ure trying to debug and u dont want ur pc to die lol
#endif
#define MOD_VERSION_STR "v1.1.0"
#define GAME_VER_COMPAT_STR ">= v1.14.0"
@ -70,7 +73,7 @@ public:
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
ChangeKeyBind(VK_NONE);
return true;
} else if (!Utils::are_same(ImGui::GetIO().MouseWheel, 0.0f)) {
} else if (!Utils::Values::are_samef(ImGui::GetIO().MouseWheel, 0.0f)) {
ChangeKeyBind(ImGui::GetIO().MouseWheel < 0.0f ? VK_MWHEELDOWN : VK_MWHEELUP);
return true;
} else if (GetKeyState(VK_LSHIFT) & 0x8000) {
@ -221,10 +224,8 @@ private:
};
namespace Core {
extern void DisableConsole();
extern bool exiting;
extern DWORD64 WINAPI MainThread(HMODULE hModule);
extern void Cleanup();
extern int rendererAPI;
extern void OnPostUpdate();
}

View File

@ -1,4 +1,11 @@
#include "core.h"
#include <pch.h>
namespace Core {
extern void DisableConsole();
extern DWORD64 WINAPI MainThread(HMODULE hModule);
extern void Cleanup();
}
static HANDLE hMainThread{};

View File

@ -0,0 +1,49 @@
#include <pch.h>
#include "CBaseCamera.h"
namespace Engine {
Vector3* CBaseCamera::GetForwardVector(Vector3* outForwardVec) {
__try {
Vector3*(*pGetForwardVector)(LPVOID pCBaseCamera, Vector3* outForwardVec) = (decltype(pGetForwardVector))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?GetForwardVector@IBaseCamera@@QEBA?BVvec3@@XZ");
if (!pGetForwardVector)
return nullptr;
return pGetForwardVector(this, outForwardVec);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
Vector3* CBaseCamera::GetUpVector(Vector3* outUpVec) {
__try {
Vector3*(*pGetUpVector)(LPVOID pCBaseCamera, Vector3* outUpVec) = (decltype(pGetUpVector))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?GetUpVector@IBaseCamera@@QEBA?BVvec3@@XZ");
if (!pGetUpVector)
return nullptr;
return pGetUpVector(this, outUpVec);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
Vector3* CBaseCamera::GetLeftVector(Vector3* outLeftVec) {
__try {
Vector3*(*pGetLeftVector)(LPVOID pCBaseCamera, Vector3* outLeftVec) = (decltype(pGetLeftVector))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?GetLeftVector@IBaseCamera@@QEBA?BVvec3@@XZ");
if (!pGetLeftVector)
return nullptr;
return pGetLeftVector(this, outLeftVec);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
Vector3* CBaseCamera::GetPosition(Vector3* outPos) {
__try {
Vector3*(*pGetPosition)(LPVOID pCBaseCamera, Vector3* outPos) = (decltype(pGetPosition))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?GetPosition@IBaseCamera@@UEBA?BVvec3@@XZ");
if (!pGetPosition)
return nullptr;
return pGetPosition(this, outPos);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,19 @@
#pragma once
#include "..\Vector3.h"
namespace Engine {
class CBaseCamera {
public:
/*union {
buffer<0x48, float> yaw;
buffer<0x4C, float> X;
buffer<0x58, float> pitch;
buffer<0x5C, float> Y;
buffer<0x6C, float> Z;
};*/
Vector3* GetForwardVector(Vector3* outForwardVec);
Vector3* GetUpVector(Vector3* outUpVec);
Vector3* GetLeftVector(Vector3* outLeftVec);
Vector3* GetPosition(Vector3* outPos);
};
}

View File

@ -0,0 +1,32 @@
#include <pch.h>
#include "CBulletPhysicsCharacter.h"
#include "CoPhysicsProperty.h"
namespace Engine {
Vector3 CBulletPhysicsCharacter::posBeforeFreeze{};
void CBulletPhysicsCharacter::FreezeCharacter() {
MoveCharacter(posBeforeFreeze);
}
void CBulletPhysicsCharacter::MoveCharacter(const Vector3& pos) {
playerDownwardVelocity = 0.0f;
playerPos = pos;
playerPos2 = pos;
}
CBulletPhysicsCharacter* CBulletPhysicsCharacter::Get() {
__try {
CoPhysicsProperty* pCoPhysicsProperty = CoPhysicsProperty::Get();
if (!pCoPhysicsProperty)
return nullptr;
CBulletPhysicsCharacter* ptr = pCoPhysicsProperty->pCBulletPhysicsCharacter;
if (!Utils::Memory::IsValidPtrMod(ptr, "engine_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,21 @@
#pragma once
#include "..\Vector3.h"
#include "..\buffer.h"
namespace Engine {
class CBulletPhysicsCharacter {
public:
union {
buffer<0x8A0, Vector3> playerPos2;
buffer<0x8B8, Vector3> playerPos;
buffer<0xC38, float> playerDownwardVelocity;
};
static Vector3 posBeforeFreeze;
void FreezeCharacter();
void MoveCharacter(const Vector3& pos);
static CBulletPhysicsCharacter* Get();
};
}

View File

@ -0,0 +1,21 @@
#include <pch.h>
#include "CGSObject.h"
#include "CLevel.h"
namespace Engine {
CGSObject* CGSObject::Get() {
__try {
CLevel* pCLevel = CLevel::Get();
if (!pCLevel)
return nullptr;
CGSObject* ptr = pCLevel->pCGSObject;
if (!Utils::Memory::IsValidPtrMod(ptr, "engine_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,15 @@
#pragma once
#include "..\buffer.h"
namespace Engine {
class CLevel2;
class CGSObject {
public:
union {
buffer<0x48, CLevel2*> pCLevel2;
};
static CGSObject* Get();
};
}

View File

@ -0,0 +1,21 @@
#include <pch.h>
#include "CGSObject2.h"
#include "CLevel2.h"
namespace Engine {
CGSObject2* CGSObject2::Get() {
__try {
CLevel2* pCLevel2 = CLevel2::Get();
if (!pCLevel2)
return nullptr;
CGSObject2* ptr = pCLevel2->pCGSObject2;
if (!Utils::Memory::IsValidPtrMod(ptr, "engine_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "..\buffer.h"
namespace GamePH {
class LogicalPlayer;
}
namespace Engine {
class CGSObject2 {
public:
union {
buffer<0x20, GamePH::LogicalPlayer*> pLogicalPlayer;
};
static CGSObject2* Get();
};
}

View File

@ -0,0 +1,21 @@
#include <pch.h>
#include "CGame.h"
#include "CLobbySteam.h"
namespace Engine {
CGame* CGame::Get() {
__try {
CLobbySteam* pCLobbySteam = CLobbySteam::Get();
if (!pCLobbySteam)
return nullptr;
CGame* ptr = pCLobbySteam->pCGame;
if (!Utils::Memory::IsValidPtrMod(ptr, "engine_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,22 @@
#pragma once
#include "..\buffer.h"
namespace GamePH {
class GameDI_PH;
}
namespace Engine {
class CVideoSettings;
class CLevel;
class CGame {
public:
union {
buffer<0x8, GamePH::GameDI_PH*> pGameDI_PH;
buffer<0x28, CVideoSettings*> pCVideoSettings;
buffer<0x380, CLevel*> pCLevel;
};
static CGame* Get();
};
}

View File

@ -0,0 +1,27 @@
#include <pch.h>
#include "..\offsets.h"
#include "CInput.h"
namespace Engine {
DWORD64 CInput::BlockGameInput() {
return Utils::Memory::CallVT<2, DWORD64>(this);
}
void CInput::UnlockGameInput() {
Utils::Memory::CallVT<1>(this);
}
CInput* CInput::Get() {
__try {
if (!Offsets::Get_g_CInput())
return nullptr;
CInput* ptr = *reinterpret_cast<CInput**>(Offsets::Get_g_CInput());
if (!Utils::Memory::IsValidPtrMod(ptr, "engine_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,12 @@
#pragma once
#include <basetsd.h>
namespace Engine {
class CInput {
public:
DWORD64 BlockGameInput();
void UnlockGameInput();
static CInput* Get();
};
}

View File

@ -0,0 +1,21 @@
#include <pch.h>
#include "CGame.h"
#include "CLevel.h"
namespace Engine {
CLevel* CLevel::Get() {
__try {
CGame* pCGame = CGame::Get();
if (!pCGame)
return nullptr;
CLevel* ptr = pCGame->pCLevel;
if (!Utils::Memory::IsValidPtrMod(ptr, "engine_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,20 @@
#pragma once
#include "..\buffer.h"
namespace GamePH {
class LevelDI;
}
namespace Engine {
class CGSObject;
class CLevel {
public:
union {
buffer<0x20, GamePH::LevelDI*> pLevelDI;
buffer<0x30, CGSObject*> pCGSObject;
};
static CLevel* Get();
};
}

View File

@ -0,0 +1,21 @@
#include <pch.h>
#include "CGSObject.h"
#include "CLevel2.h"
namespace Engine {
CLevel2* CLevel2::Get() {
__try {
CGSObject* pCGSObject = CGSObject::Get();
if (!pCGSObject)
return nullptr;
CLevel2* ptr = pCGSObject->pCLevel2;
if (!Utils::Memory::IsValidPtrMod(ptr, "engine_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,15 @@
#pragma once
#include "..\buffer.h"
namespace Engine {
class CGSObject2;
class CLevel2 {
public:
union {
buffer<0x28, CGSObject2*> pCGSObject2;
};
static CLevel2* Get();
};
}

View File

@ -0,0 +1,20 @@
#include <pch.h>
#include "..\offsets.h"
#include "CLobbySteam.h"
namespace Engine {
CLobbySteam* CLobbySteam::Get() {
__try {
if (!Offsets::Get_CLobbySteam())
return nullptr;
CLobbySteam* ptr = *reinterpret_cast<CLobbySteam**>(Offsets::Get_CLobbySteam());
if (!Utils::Memory::IsValidPtrMod(ptr, "engine_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,15 @@
#pragma once
#include "..\buffer.h"
namespace Engine {
class CGame;
class CLobbySteam {
public:
union {
buffer<0xF8, CGame*> pCGame;
};
static CLobbySteam* Get();
};
}

View File

@ -0,0 +1,21 @@
#include <pch.h>
#include "CGame.h"
#include "CVideoSettings.h"
namespace Engine {
CVideoSettings* CVideoSettings::Get() {
__try {
CGame* pCGame = CGame::Get();
if (!pCGame)
return nullptr;
CVideoSettings* ptr = pCGame->pCVideoSettings;
if (!Utils::Memory::IsValidPtrMod(ptr, "engine_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,13 @@
#pragma once
#include "..\buffer.h"
namespace Engine {
class CVideoSettings {
public:
union {
buffer<0x7C, float> extraFOV;
};
static CVideoSettings* Get();
};
}

View File

@ -0,0 +1,21 @@
#include <pch.h>
#include "..\GamePH\PlayerObjProperties.h"
#include "CoPhysicsProperty.h"
namespace Engine {
CoPhysicsProperty* CoPhysicsProperty::Get() {
__try {
GamePH::PlayerObjProperties* pPlayerObjProperties = GamePH::PlayerObjProperties::Get();
if (!pPlayerObjProperties)
return nullptr;
CoPhysicsProperty* ptr = pPlayerObjProperties->pCoPhysicsProperty;
if (!Utils::Memory::IsValidPtrMod(ptr, "engine_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,15 @@
#pragma once
#include "..\buffer.h"
namespace Engine {
class CBulletPhysicsCharacter;
class CoPhysicsProperty {
public:
union {
buffer<0x20, CBulletPhysicsCharacter*> pCBulletPhysicsCharacter;
};
static CoPhysicsProperty* Get();
};
}

View File

@ -0,0 +1,152 @@
#include <pch.h>
#include "..\GamePH\GameDI_PH.h"
#include "..\GamePH\LevelDI.h"
#include "..\GamePH\Other.h"
#include "..\GamePH\game_hooks.h"
#include "..\GamePH\gen_TPPModel.h"
#include "..\core.h"
#include "..\menu\camera.h"
#include "..\offsets.h"
#include "CBaseCamera.h"
namespace Engine {
namespace Hooks {
#pragma region ReadVideoSettings
static bool detourReadVideoSettings(LPVOID instance, LPVOID file, bool flag1);
static Utils::Hook::MHook<LPVOID, bool(*)(LPVOID, LPVOID, bool)> ReadVideoSettingsHook{ "ReadVideoSettings", &Offsets::Get_ReadVideoSettings, &detourReadVideoSettings };
static bool detourReadVideoSettings(LPVOID instance, LPVOID file, bool flag1) {
if (Core::rendererAPI)
return ReadVideoSettingsHook.pOriginal(instance, file, flag1);
DWORD renderer = *reinterpret_cast<PDWORD>(reinterpret_cast<DWORD64>(instance) + 0x7C);
Core::rendererAPI = !renderer ? 11 : 12;
return ReadVideoSettingsHook.pOriginal(instance, file, flag1);
}
#pragma endregion
#pragma region MoveCameraFromForwardUpPos
static void detourMoveCameraFromForwardUpPos(LPVOID pCBaseCamera, float* a3, float* a4, Vector3* pos);
static Utils::Hook::MHook<LPVOID, void(*)(LPVOID, float*, float*, Vector3*)> MoveCameraFromForwardUpPosHook{ "MoveCameraFromForwardUpPos", &Offsets::Get_MoveCameraFromForwardUpPos, &detourMoveCameraFromForwardUpPos };
static void detourMoveCameraFromForwardUpPos(LPVOID pCBaseCamera, float* a3, float* a4, Vector3* pos) {
GamePH::LevelDI* iLevel = GamePH::LevelDI::Get();
if (!iLevel || !iLevel->IsLoaded())
return MoveCameraFromForwardUpPosHook.pOriginal(pCBaseCamera, a3, a4, pos);
GamePH::gen_TPPModel* pgen_TPPModel = GamePH::gen_TPPModel::Get();
if (pgen_TPPModel) {
if (GamePH::Hooks::wannaUseTPPModel.GetValue()) {
GamePH::Hooks::wannaUseTPPModel.SetPrevValue(true);
if (Menu::Camera::thirdPersonCamera.GetValue() && Menu::Camera::tpUseTPPModel.GetValue()) {
pgen_TPPModel->enableTPPModel2 = false;
pgen_TPPModel->enableTPPModel1 = false;
}
}
if (Menu::Camera::photoMode.HasChangedTo(false) && !GamePH::Hooks::wannaUseTPPModel.GetValue()) {
if (!Menu::Camera::freeCam.GetValue() && !Menu::Camera::tpUseTPPModel.GetValue()) {
Menu::Camera::photoMode.SetPrevValue(false);
GamePH::ShowTPPModel(false);
} else if (Menu::Camera::freeCam.GetValue() || (Menu::Camera::tpUseTPPModel.GetValue() && Menu::Camera::thirdPersonCamera.GetValue())) {
Menu::Camera::photoMode.SetPrevValue(true);
GamePH::ShowTPPModel(true);
}
} else if (Menu::Camera::photoMode.HasChangedTo(true)) {
Menu::Camera::photoMode.SetPrevValue(true);
GamePH::ShowTPPModel(true);
} else if (Menu::Camera::freeCam.HasChangedTo(false)) {
if (!Menu::Camera::photoMode.GetValue() && !Menu::Camera::thirdPersonCamera.GetValue()) {
Menu::Camera::freeCam.SetPrevValue(false);
GamePH::ShowTPPModel(false);
} else if (Menu::Camera::photoMode.GetValue() || (Menu::Camera::tpUseTPPModel.GetValue() && Menu::Camera::thirdPersonCamera.GetValue())) {
Menu::Camera::freeCam.SetPrevValue(true);
GamePH::ShowTPPModel(true);
}
} else if (Menu::Camera::freeCam.HasChangedTo(true)) {
Menu::Camera::freeCam.SetPrevValue(true);
GamePH::ShowTPPModel(true);
} else if (Menu::Camera::thirdPersonCamera.HasChangedTo(false)) {
if (!Menu::Camera::freeCam.GetValue() && !Menu::Camera::photoMode.GetValue()) {
Menu::Camera::thirdPersonCamera.SetPrevValue(false);
GamePH::ShowTPPModel(false);
} else if (Menu::Camera::freeCam.GetValue() || Menu::Camera::photoMode.GetValue()) {
Menu::Camera::thirdPersonCamera.SetPrevValue(true);
GamePH::ShowTPPModel(true);
}
} else if (Menu::Camera::thirdPersonCamera.HasChangedTo(true) && Menu::Camera::tpUseTPPModel.GetValue()) {
Menu::Camera::thirdPersonCamera.SetPrevValue(true);
GamePH::ShowTPPModel(true);
} else if (Menu::Camera::tpUseTPPModel.HasChangedTo(false)) {
if (!Menu::Camera::freeCam.GetValue() && !Menu::Camera::photoMode.GetValue()) {
Menu::Camera::tpUseTPPModel.SetPrevValue(false);
GamePH::ShowTPPModel(false);
} else if (Menu::Camera::freeCam.GetValue() || Menu::Camera::photoMode.GetValue()) {
Menu::Camera::tpUseTPPModel.SetPrevValue(true);
GamePH::ShowTPPModel(true);
}
} else if (Menu::Camera::tpUseTPPModel.HasChangedTo(true) && Menu::Camera::thirdPersonCamera.GetValue()) {
Menu::Camera::tpUseTPPModel.SetPrevValue(true);
GamePH::ShowTPPModel(true);
}
}
if (!Menu::Camera::thirdPersonCamera.GetValue() || Menu::Camera::photoMode.GetValue() || Menu::Camera::freeCam.GetValue() || !pos)
return MoveCameraFromForwardUpPosHook.pOriginal(pCBaseCamera, a3, a4, pos);
CBaseCamera* viewCam = static_cast<CBaseCamera*>(iLevel->GetViewCamera());
if (!viewCam)
return MoveCameraFromForwardUpPosHook.pOriginal(pCBaseCamera, a3, a4, pos);
Vector3 forwardVec{};
viewCam->GetForwardVector(&forwardVec);
const Vector3 normForwardVec = forwardVec.normalize();
Vector3 leftVec{};
viewCam->GetLeftVector(&leftVec);
const Vector3 normLeftVec = leftVec.normalize();
Vector3 newCamPos = *pos - normForwardVec * -Menu::Camera::tpDistanceBehindPlayer;
newCamPos.Y += Menu::Camera::tpHeightAbovePlayer - 1.5f;
newCamPos -= normLeftVec * Menu::Camera::tpHorizontalDistanceFromPlayer;
*pos = newCamPos;
MoveCameraFromForwardUpPosHook.pOriginal(pCBaseCamera, a3, a4, pos);
}
#pragma endregion
#pragma region fs::open
static LPVOID GetFsOpen() {
return Utils::Memory::GetProcAddr("filesystem_x64_rwdi.dll", "?open@fs@@YAPEAUSFsFile@@V?$string_const@D@ttl@@W4TYPE@EFSMode@@W45FFSOpenFlags@@@Z");
}
static DWORD64 detourFsOpen(DWORD64 file, DWORD a2, DWORD a3);
static Utils::Hook::MHook<LPVOID, DWORD64(*)(DWORD64, DWORD, DWORD)> FsOpenHook{ "fs::open", &GetFsOpen, &detourFsOpen };
static DWORD64 detourFsOpen(DWORD64 file, DWORD a2, DWORD a3) {
const DWORD64 firstByte = (file >> 56) & 0xFF; // get first byte of addr
const char* filePath = reinterpret_cast<const char*>(file & 0x1FFFFFFFFFFFFFFF); // remove first byte of addr in case it exists
const std::string fileName = std::filesystem::path(filePath).filename().string();
if (fileName.empty())
return FsOpenHook.pOriginal(file, a2, a3);
for (const auto& entry : std::filesystem::recursive_directory_iterator("EGameTools\\FilesToLoad")) {
const std::filesystem::path pathToFile = entry.path();
if (!std::filesystem::is_regular_file(pathToFile))
continue;
const std::filesystem::path pathToFilename = pathToFile.filename();
if (!pathToFilename.string().contains(fileName))
continue;
const std::string finalPath = pathToFile.string();
const char* filePath2 = finalPath.c_str();
return FsOpenHook.pOriginal(firstByte != 0x0 ? (reinterpret_cast<DWORD64>(filePath2) | (firstByte << 56)) : reinterpret_cast<DWORD64>(filePath2), a2, a3); // restores first byte of addr if first byte was not 0
}
return FsOpenHook.pOriginal(file, a2, a3);
}
#pragma endregion
}
}

View File

@ -0,0 +1,13 @@
#pragma once
#include "..\buffer.h"
namespace GamePH {
class TPPCameraDI;
class CoBaseCameraProxy {
public:
union {
buffer<0xD0, TPPCameraDI*> pTPPCameraDI;
};
};
}

View File

@ -0,0 +1,27 @@
#include <pch.h>
#include "..\offsets.h"
#include "DayNightCycle.h"
namespace GamePH {
void DayNightCycle::SetDaytime(float time) {
time /= 24;
time1 = time;
time2 = time;
time3 = time;
}
DayNightCycle* DayNightCycle::Get() {
__try {
if (!Offsets::Get_g_DayNightCycle())
return nullptr;
DayNightCycle* ptr = *reinterpret_cast<DayNightCycle**>(Offsets::Get_g_DayNightCycle());
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "..\buffer.h"
namespace GamePH {
class DayNightCycle {
public:
union {
buffer<0x10, float> time1;
buffer<0x20, float> time2;
buffer<0x5C, float> time3;
};
void SetDaytime(float time);
static DayNightCycle* Get();
};
}

View File

@ -0,0 +1,25 @@
#include <pch.h>
#include "..\offsets.h"
#include "FreeCamera.h"
namespace GamePH {
void FreeCamera::AllowCameraMovement(int mode) {
Utils::Memory::CallVT<187>(this, mode);
}
FreeCamera* FreeCamera::Get() {
__try {
PDWORD64 pg_FreeCamera = Offsets::Get_g_FreeCamera();
if (!pg_FreeCamera)
return nullptr;
FreeCamera* ptr = reinterpret_cast<FreeCamera*>(*pg_FreeCamera);
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,22 @@
#pragma once
#include "..\Engine\CBaseCamera.h"
#include "..\buffer.h"
namespace GamePH {
class CoBaseCameraProxy;
class FreeCamera : public Engine::CBaseCamera {
public:
union {
buffer<0x18, CoBaseCameraProxy*> pCoBaseCameraProxy;
buffer<0x38, Engine::CBaseCamera*> pCBaseCamera;
buffer<0x42, bool> enableSpeedMultiplier1;
buffer<0x43, bool> enableSpeedMultiplier2;
buffer<0x1CC, float> speedMultiplier;
};
void AllowCameraMovement(int mode = 2);
static FreeCamera* Get();
};
}

View File

@ -0,0 +1,39 @@
#include <pch.h>
#include "..\Engine\CGame.h"
#include "GameDI_PH.h"
namespace GamePH {
float GameDI_PH::GetGameTimeDelta() {
__try {
float(*pGetGameTimeDelta)(LPVOID pGameDI_PH) = (decltype(pGetGameTimeDelta))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?GetGameTimeDelta@IGame@@QEBAMXZ");
if (!pGetGameTimeDelta)
return -1.0f;
return pGetGameTimeDelta(this);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return -1.0f;
}
}
DWORD64 GameDI_PH::GetCurrentGameVersion() {
return Utils::Memory::CallVT<225, DWORD64>(this);
}
void GameDI_PH::TogglePhotoMode(bool doNothing, bool setAsOptionalCamera) {
Utils::Memory::CallVT<258>(this, doNothing, setAsOptionalCamera);
}
GameDI_PH* GameDI_PH::Get() {
__try {
Engine::CGame* pCGame = Engine::CGame::Get();
if (!pCGame)
return nullptr;
GameDI_PH* ptr = pCGame->pGameDI_PH;
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,21 @@
#pragma once
#include <basetsd.h>
#include "..\buffer.h"
namespace GamePH {
class SessionCooperativeDI;
class GameDI_PH {
public:
union {
buffer<0xF0, SessionCooperativeDI*> pSessionCooperativeDI;
buffer<0x830, bool> blockPauseGameOnPlayerAfk;
};
float GetGameTimeDelta();
DWORD64 GetCurrentGameVersion();
void TogglePhotoMode(bool doNothing = false, bool setAsOptionalCamera = false);
static GameDI_PH* Get();
};
}

View File

@ -0,0 +1,22 @@
#include <pch.h>
#include "..\offsets.h"
#include "GameDI_PH.h"
#include "GameDI_PH2.h"
namespace GamePH {
GameDI_PH2* GameDI_PH2::Get() {
__try {
GameDI_PH* pGameDI_PH = GameDI_PH::Get();
if (!pGameDI_PH)
return nullptr;
GameDI_PH2* ptr = reinterpret_cast<GameDI_PH2*>(reinterpret_cast<DWORD64>(pGameDI_PH) + Offsets::Get_gameDI_PH2_offset());
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,7 @@
#pragma once
namespace GamePH {
class GameDI_PH2 {
public:
static GameDI_PH2* Get();
};
}

View File

@ -0,0 +1,111 @@
#include <pch.h>
#include "..\Engine\CLevel.h"
#include "LevelDI.h"
#include "PlayerObjProperties.h"
namespace GamePH {
bool LevelDI::IsLoading() {
__try {
bool(*pIsLoading)(LPVOID iLevel) = (decltype(pIsLoading))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?IsLoading@ILevel@@QEBA_NXZ");
if (!pIsLoading)
return true;
return pIsLoading(this);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return true;
}
}
bool LevelDI::IsLoaded() {
static float loadDeltaTime = 0.0f;
if (IsLoading() || !GamePH::PlayerObjProperties::Get()) {
loadDeltaTime = 0.0f;
return false;
}
loadDeltaTime += GetTimeDelta();
if (loadDeltaTime > 3.0f)
return true;
return false;
}
LPVOID LevelDI::GetViewCamera() {
__try {
LPVOID(*pGetViewCamera)(LPVOID iLevel) = (decltype(pGetViewCamera))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?GetViewCamera@ILevel@@QEBAPEAVIBaseCamera@@XZ");
if (!pGetViewCamera)
return nullptr;
return pGetViewCamera(this);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
float LevelDI::GetTimeDelta() {
return Utils::Memory::CallVT<176, float>(this);
}
void LevelDI::SetViewCamera(LPVOID viewCam) {
Utils::Memory::CallVT<289, void>(this, viewCam);
}
float LevelDI::GetTimePlayed() {
return Utils::Memory::CallVT<317, float>(this);
}
void LevelDI::ShowUIManager(bool enabled) {
__try {
void(*pShowUIManager)(LPVOID iLevel, bool enabled) = (decltype(pShowUIManager))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?ShowUIManager@ILevel@@QEAAX_N@Z");
if (!pShowUIManager)
return;
pShowUIManager(this, enabled);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return;
}
}
float LevelDI::TimerGetSpeedUp() {
__try {
float(*pTimerGetSpeedUp)(LPVOID iLevel) = (decltype(pTimerGetSpeedUp))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?TimerGetSpeedUp@ILevel@@QEBAMXZ");
if (!pTimerGetSpeedUp)
return -1.0f;
return pTimerGetSpeedUp(this);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return -1.0f;
}
}
void LevelDI::TimerSetSpeedUp(float timeScale) {
__try {
void(*pTimerSetSpeedUp)(LPVOID iLevel, float timeScale) = (decltype(pTimerSetSpeedUp))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?TimerSetSpeedUp@ILevel@@QEAAXM@Z");
if (!pTimerSetSpeedUp)
return;
pTimerSetSpeedUp(this, timeScale);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return;
}
}
TimeWeather::CSystem* LevelDI::GetTimeWeatherSystem() {
__try {
TimeWeather::CSystem* (*pGetTimeWeatherSystem)(LevelDI * iLevel) = (decltype(pGetTimeWeatherSystem))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?GetTimeWeatherSystem@ILevel@@QEBAPEAVCSystem@TimeWeather@@XZ");
if (!pGetTimeWeatherSystem)
return nullptr;
return pGetTimeWeatherSystem(this);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
LevelDI* LevelDI::Get() {
__try {
Engine::CLevel* pCLevel = Engine::CLevel::Get();
if (!pCLevel)
return nullptr;
LevelDI* ptr = pCLevel->pLevelDI;
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,24 @@
#pragma once
#include <WTypesbase.h>
namespace GamePH {
namespace TimeWeather {
class CSystem;
}
class LevelDI {
public:
bool IsLoading();
bool IsLoaded();
LPVOID GetViewCamera();
float GetTimeDelta();
void SetViewCamera(LPVOID viewCam);
float GetTimePlayed();
void ShowUIManager(bool enabled);
float TimerGetSpeedUp();
void TimerSetSpeedUp(float timeScale);
TimeWeather::CSystem* GetTimeWeatherSystem();
static LevelDI* Get();
};
}

View File

@ -0,0 +1,21 @@
#include <pch.h>
#include "LocalClientDI.h"
#include "SessionCooperativeDI.h"
namespace GamePH {
LocalClientDI* LocalClientDI::Get() {
__try {
SessionCooperativeDI* pSessionCooperativeDI = SessionCooperativeDI::Get();
if (!pSessionCooperativeDI)
return nullptr;
LocalClientDI* ptr = pSessionCooperativeDI->pLocalClientDI;
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,15 @@
#pragma once
#include "..\buffer.h"
namespace GamePH {
class gen_TPPModel;
class LocalClientDI {
public:
union {
buffer<0x90, gen_TPPModel*> pgen_TPPModel;
};
static LocalClientDI* Get();
};
}

View File

@ -0,0 +1,21 @@
#include <pch.h>
#include "..\Engine\CGSObject2.h"
#include "LogicalPlayer.h"
namespace GamePH {
LogicalPlayer* LogicalPlayer::Get() {
__try {
Engine::CGSObject2* pCGSObject2 = Engine::CGSObject2::Get();
if (!pCGSObject2)
return nullptr;
LogicalPlayer* ptr = pCGSObject2->pLogicalPlayer;
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,7 @@
#pragma once
namespace GamePH {
class LogicalPlayer {
public:
static LogicalPlayer* Get();
};
}

View File

@ -0,0 +1,64 @@
#include <pch.h>
#include "..\offsets.h"
#include "GameDI_PH.h"
#include "gen_TPPModel.h"
namespace GamePH {
const DWORD64 GetCurrentGameVersion() {
DWORD64(*pGetCurrentGameVersion)() = (decltype(pGetCurrentGameVersion))Offsets::Get_GetCurrentGameVersion();
if (!pGetCurrentGameVersion)
return 0;
return pGetCurrentGameVersion();
}
const std::string GameVerToStr(DWORD64 version) {
DWORD64 major = version / 10000;
DWORD64 minor = (version / 100) % 100;
DWORD64 patch = version % 100;
return std::string(std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(patch));
}
const std::string GetCurrentGameVersionStr() {
if (!GetCurrentGameVersion())
return {};
DWORD64 version = GetCurrentGameVersion();
DWORD64 major = version / 10000;
DWORD64 minor = (version / 100) % 100;
DWORD64 patch = version % 100;
return std::string(std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(patch));
}
static DWORD64 ShowTPPModelFunc2(GameDI_PH* pGameDI_PH) {
DWORD64(*pShowTPPModelFunc2)(LPVOID pGameDI_PH) = (decltype(pShowTPPModelFunc2))Offsets::Get_ShowTPPModelFunc2();
if (!pShowTPPModelFunc2)
return 0;
return pShowTPPModelFunc2(pGameDI_PH);
}
void ShowTPPModel(bool showTPPModel) {
GameDI_PH* pGameDI_PH = GameDI_PH::Get();
if (!pGameDI_PH)
return;
DWORD64 tppFunc2Addr = ShowTPPModelFunc2(pGameDI_PH);
if (!tppFunc2Addr)
return;
void(*pShowTPPModelFunc3)(DWORD64 tppFunc2Addr, bool showTPPModel) = (decltype(pShowTPPModelFunc3))Offsets::Get_ShowTPPModelFunc3();
if (!pShowTPPModelFunc3)
return;
gen_TPPModel* pgen_TPPModel = gen_TPPModel::Get();
if (!pgen_TPPModel)
return;
pShowTPPModelFunc3(tppFunc2Addr, showTPPModel);
}
bool ReloadJumps() {
bool(*pReloadJumps)() = (decltype(pReloadJumps))Offsets::Get_ReloadJumps();
if (!pReloadJumps)
return false;
return pReloadJumps();
}
}

View File

@ -0,0 +1,11 @@
#pragma once
#include <string>
#include <basetsd.h>
namespace GamePH {
extern const DWORD64 GetCurrentGameVersion();
extern const std::string GameVerToStr(DWORD64 version);
extern const std::string GetCurrentGameVersionStr();
extern void ShowTPPModel(bool showTPPModel);
extern bool ReloadJumps();
}

View File

@ -0,0 +1,19 @@
#include <pch.h>
#include "PlayerHealthModule.h"
namespace GamePH {
PlayerHealthModule* PlayerHealthModule::pPlayerHealthModule = nullptr;
PlayerHealthModule* PlayerHealthModule::Get() {
__try {
if (!pPlayerHealthModule)
return nullptr;
if (!*reinterpret_cast<LPVOID*>(pPlayerHealthModule))
return nullptr;
return pPlayerHealthModule;
} __except (EXCEPTION_EXECUTE_HANDLER) {
pPlayerHealthModule = nullptr;
return nullptr;
}
}
}

View File

@ -0,0 +1,15 @@
#pragma once
#include "..\buffer.h"
namespace GamePH {
class PlayerHealthModule {
public:
union {
buffer<0x2C, float> health;
buffer<0x3C, float> maxHealth;
};
static PlayerHealthModule* pPlayerHealthModule;
static PlayerHealthModule* Get();
};
}

View File

@ -0,0 +1,20 @@
#include <pch.h>
#include "..\offsets.h"
#include "PlayerObjProperties.h"
namespace GamePH {
PlayerObjProperties* PlayerObjProperties::Get() {
__try {
if (!Offsets::Get_g_PlayerObjProperties())
return nullptr;
PlayerObjProperties* ptr = *reinterpret_cast<PlayerObjProperties**>(Offsets::Get_g_PlayerObjProperties());
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,19 @@
#pragma once
#include "..\buffer.h"
namespace Engine {
class CoPhysicsProperty;
}
namespace GamePH {
class PlayerObjProperties {
public:
union {
buffer<0xF0, Engine::CoPhysicsProperty*> pCoPhysicsProperty;
buffer<0x2E80, bool> isOutOfBounds;
buffer<0x2E84, float> outOfBoundsTimer;
};
static PlayerObjProperties* Get();
};
}

View File

@ -0,0 +1,20 @@
#include <pch.h>
#include "..\offsets.h"
#include "PlayerState.h"
namespace GamePH {
PlayerState* PlayerState::Get() {
__try {
if (!Offsets::Get_PlayerState())
return nullptr;
PlayerState* ptr = *reinterpret_cast<PlayerState**>(Offsets::Get_PlayerState());
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,15 @@
#pragma once
#include "..\buffer.h"
namespace GamePH {
class PlayerVariables;
class PlayerState {
public:
union {
buffer<0x290, PlayerVariables*> playerVars;
};
static PlayerState* Get();
};
}

View File

@ -0,0 +1,144 @@
#include <pch.h>
#include "..\config\config.h"
#include "..\offsets.h"
#include "PlayerState.h"
#include "PlayerVariables.h"
namespace GamePH {
static const int FLOAT_VAR_OFFSET = 3;
static const int BOOL_VAR_OFFSET = 2;
static const int VAR_LOC_OFFSET = 1;
std::vector<std::pair<std::string, std::pair<LPVOID, std::string>>> PlayerVariables::playerVars;
std::vector<std::pair<std::string, std::pair<std::any, std::string>>> PlayerVariables::playerVarsDefault;
std::vector<std::pair<std::string, std::pair<std::any, std::string>>> PlayerVariables::playerCustomVarsDefault;
bool PlayerVariables::gotPlayerVars = false;
static PDWORD64 getFloatPlayerVariableVT() {
if (!Offsets::Get_InitializePlayerVariables())
return nullptr;
const DWORD64 offsetToInstr = Offsets::Get_InitializePlayerVariables() + Offsets::Get_initPlayerFloatVarsInstr_offset() + 0x3; // 0x3 is instruction size
const DWORD floatPlayerVariableVTOffset = *reinterpret_cast<DWORD*>(offsetToInstr);
return reinterpret_cast<PDWORD64>(offsetToInstr + sizeof(DWORD) + floatPlayerVariableVTOffset);
}
static PDWORD64 getBoolPlayerVariableVT() {
if (!Offsets::Get_InitializePlayerVariables())
return nullptr;
const DWORD64 offsetToInstr = Offsets::Get_InitializePlayerVariables() + Offsets::Get_initPlayerBoolVarsInstr_offset() + 0x3; // 0x3 is instruction size
const DWORD boolPlayerVariableVTOffset = *reinterpret_cast<DWORD*>(offsetToInstr);
return reinterpret_cast<PDWORD64>(offsetToInstr + sizeof(DWORD) + boolPlayerVariableVTOffset);
}
template <typename T>
static void updateDefaultVar(std::vector<std::pair<std::string, std::pair<std::any, std::string>>>& defaultVars, const std::string& varName, T varValue) {
static_assert(std::is_same<T, float>::value || std::is_same<T, bool>::value, "Invalid type: value must be float or bool");
auto it = std::find_if(defaultVars.begin(), defaultVars.end(), [&varName](const auto& pair) {
return pair.first == varName;
});
if (it == defaultVars.end())
return;
it->second.first.template emplace<T>(varValue);
}
static void processPlayerVar(PDWORD64*& playerVarsMem, std::pair<std::string, std::pair<LPVOID, std::string>>& var) {
while (true) {
const bool isFloatPlayerVar = *playerVarsMem == getFloatPlayerVariableVT();
const bool isBoolPlayerVar = *playerVarsMem == getBoolPlayerVariableVT();
if (isFloatPlayerVar || isBoolPlayerVar) {
var.second.first = playerVarsMem + VAR_LOC_OFFSET;
const std::string& varName = var.first;
if (isFloatPlayerVar) {
float* varValue = reinterpret_cast<float*>(var.second.first);
updateDefaultVar(GamePH::PlayerVariables::playerVarsDefault, varName, *varValue);
updateDefaultVar(GamePH::PlayerVariables::playerCustomVarsDefault, varName, *varValue);
playerVarsMem += FLOAT_VAR_OFFSET;
} else {
bool* varValue = reinterpret_cast<bool*>(var.second.first);
updateDefaultVar(GamePH::PlayerVariables::playerVarsDefault, varName, *varValue);
updateDefaultVar(GamePH::PlayerVariables::playerCustomVarsDefault, varName, *varValue);
playerVarsMem += BOOL_VAR_OFFSET;
}
break;
} else
playerVarsMem += 1;
}
}
void PlayerVariables::GetPlayerVars() {
if (gotPlayerVars)
return;
if (!Get())
return;
if (playerVars.empty())
return;
if (!getFloatPlayerVariableVT())
return;
if (!getBoolPlayerVariableVT())
return;
PDWORD64* playerVarsMem = reinterpret_cast<PDWORD64*>(Get());
for (auto& var : playerVars)
processPlayerVar(playerVarsMem, var);
gotPlayerVars = true;
}
void PlayerVariables::SortPlayerVars() {
if (!playerVars.empty())
return;
std::stringstream ss(Config::playerVars);
while (ss.good()) {
// separate the string by the , character to get each variable
std::string pVar{};
getline(ss, pVar, ',');
std::stringstream ssPVar(pVar);
std::string varName{};
std::string varType{};
while (ssPVar.good()) {
// seperate the string by the : character to get name and type of variable
std::string subStr{};
getline(ssPVar, subStr, ':');
if (subStr != "float" && subStr != "bool")
varName = subStr;
else
varType = subStr;
}
PlayerVariables::playerVars.emplace_back(varName, std::make_pair(nullptr, varType));
PlayerVariables::playerVarsDefault.emplace_back(varName, std::make_pair(varType == "float" ? 0.0f : false, varType));
PlayerVariables::playerCustomVarsDefault.emplace_back(varName, std::make_pair(varType == "float" ? 0.0f : false, varType));
}
}
PlayerVariables* PlayerVariables::Get() {
__try {
PlayerState* pPlayerState = PlayerState::Get();
if (!pPlayerState)
return nullptr;
PlayerVariables* ptr = pPlayerState->playerVars;
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,93 @@
#pragma once
#include <WTypesbase.h>
#include <any>
#include <vector>
#include "..\buffer.h"
#include "..\core.h"
#include "..\utils\values.h"
namespace GamePH {
class PlayerVariables {
public:
static std::vector<std::pair<std::string, std::pair<LPVOID, std::string>>> playerVars;
static std::vector<std::pair<std::string, std::pair<std::any, std::string>>> playerVarsDefault;
static std::vector<std::pair<std::string, std::pair<std::any, std::string>>> playerCustomVarsDefault;
static bool gotPlayerVars;
static void GetPlayerVars();
static void SortPlayerVars();
template <typename T> static T GetPlayerVar(const std::string& playerVar) {
static_assert(std::is_same<T, bool>::value || std::is_same<T, float>::value || std::is_same<T, std::string>::value, "Invalid type: value must be bool, float or string");
auto it = std::find_if(PlayerVariables::playerVars.begin(), PlayerVariables::playerVars.end(), [&playerVar](const auto& pair) {
return pair.first == playerVar;
});
if (it == PlayerVariables::playerVars.end()) {
if (std::is_same<T, std::string>::value)
return {};
else if (std::is_same<T, float>::value)
return -404.0f;
else
return false;
}
return *reinterpret_cast<T*>(it->second.first);
}
template <typename T> static void ChangePlayerVar(const std::string& playerVar, const T value) {
static_assert(std::is_same<T, bool>::value || std::is_same<T, float>::value || std::is_same<T, std::string>::value, "Invalid type: value must be bool, float or string");
if (!gotPlayerVars)
return;
auto it = std::find_if(PlayerVariables::playerVars.begin(), PlayerVariables::playerVars.end(), [&playerVar](const auto& pair) {
return pair.first == playerVar;
});
if (it == PlayerVariables::playerVars.end())
return;
if (std::is_same<T, std::string>::value) {
std::string valueStr = Utils::Values::to_string(value);
if (it->second.second == "float") {
float* const varValue = reinterpret_cast<float*>(it->second.first);
const float actualValue = std::stof(valueStr);
*varValue = actualValue;
*(varValue + 1) = actualValue;
} else {
bool* const varValue = reinterpret_cast<bool*>(it->second.first);
const bool actualValue = valueStr == "true";
*varValue = actualValue;
*(varValue + 1) = actualValue;
}
} else {
T* const varValue = reinterpret_cast<T*>(it->second.first);
*varValue = value;
*(varValue + 1) = value;
}
}
template <typename T> static void ManagePlayerVarOption(const std::string& playerVar, const T valueIfTrue, const T valueIfFalse, Option* option, const bool& usePreviousVal = true) {
if (!gotPlayerVars)
return;
static T previousPlayerVarValue = GamePH::PlayerVariables::GetPlayerVar<T>(playerVar);
if (option->GetValue()) {
if (!option->GetPrevValue())
previousPlayerVarValue = GamePH::PlayerVariables::GetPlayerVar<T>(playerVar);
GamePH::PlayerVariables::ChangePlayerVar(playerVar, valueIfTrue);
option->SetPrevValue(true);
} else if (option->GetPrevValue()) {
option->SetPrevValue(false);
GamePH::PlayerVariables::ChangePlayerVar(playerVar, usePreviousVal ? previousPlayerVarValue : valueIfFalse);
}
}
static PlayerVariables* Get();
};
}

View File

@ -0,0 +1,21 @@
#include <pch.h>
#include "GameDI_PH.h"
#include "SessionCooperativeDI.h"
namespace GamePH {
SessionCooperativeDI* SessionCooperativeDI::Get() {
__try {
GameDI_PH* pGameDI_PH = GameDI_PH::Get();
if (!pGameDI_PH)
return nullptr;
SessionCooperativeDI* ptr = pGameDI_PH->pSessionCooperativeDI;
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,15 @@
#pragma once
#include "..\buffer.h"
namespace GamePH {
class LocalClientDI;
class SessionCooperativeDI {
public:
union {
buffer<0xE08, LocalClientDI*> pLocalClientDI;
};
static SessionCooperativeDI* Get();
};
}

View File

@ -0,0 +1,26 @@
#include <pch.h>
#include "CoBaseCameraProxy.h"
#include "FreeCamera.h"
#include "TPPCameraDI.h"
namespace GamePH {
TPPCameraDI* TPPCameraDI::Get() {
__try {
FreeCamera* pFreeCam = FreeCamera::Get();
if (!pFreeCam)
return nullptr;
CoBaseCameraProxy* pCoBaseCameraProxy = pFreeCam->pCoBaseCameraProxy;
if (!pCoBaseCameraProxy)
return nullptr;
TPPCameraDI* ptr = pCoBaseCameraProxy->pTPPCameraDI;
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,9 @@
#pragma once
#include "..\Engine\CBaseCamera.h"
namespace GamePH {
class TPPCameraDI : public Engine::CBaseCamera {
public:
static TPPCameraDI* Get();
};
}

View File

@ -0,0 +1,47 @@
#include <pch.h>
#include "..\LevelDI.h"
#include "CSystem.h"
#include "EWeather.h"
namespace GamePH {
namespace TimeWeather {
void CSystem::SetForcedWeather(int weather) {
__try {
void(*pSetForcedWeather)(LPVOID timeWeatherSystem, int weather) = (decltype(pSetForcedWeather))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?SetForcedWeather@CSystem@TimeWeather@@QEAAXW4TYPE@EWeather@@VApiDebugAccess@2@@Z");
if (!pSetForcedWeather)
return;
pSetForcedWeather(this, weather);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return;
}
}
int CSystem::GetCurrentWeather() {
__try {
int(*pGetCurrentWeather)(LPVOID timeWeatherSystem) = (decltype(pGetCurrentWeather))Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?GetCurrentWeather@CSystem@TimeWeather@@QEBA?AW4TYPE@EWeather@@XZ");
if (!pGetCurrentWeather)
return EWeather::TYPE::Default;
return pGetCurrentWeather(this);
} __except (EXCEPTION_EXECUTE_HANDLER) {
return EWeather::TYPE::Default;
}
}
CSystem* CSystem::Get() {
__try {
LevelDI* pLevelDI = LevelDI::Get();
if (!pLevelDI)
return nullptr;
CSystem* ptr = pLevelDI->GetTimeWeatherSystem();
if (!Utils::Memory::IsValidPtr(ptr))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}
}

View File

@ -0,0 +1,12 @@
#pragma once
namespace GamePH {
namespace TimeWeather {
class CSystem {
public:
void SetForcedWeather(int weather);
int GetCurrentWeather();
static CSystem* Get();
};
}
}

View File

@ -0,0 +1,16 @@
#pragma once
namespace GamePH {
namespace TimeWeather {
namespace EWeather {
enum TYPE {
Default = 0,
Foggy = 1,
Clear = 2,
Overcast = 3,
Cloudy = 4,
Rainy = 5,
Stormy = 6
};
}
}
}

View File

@ -0,0 +1,157 @@
#include <pch.h>
#include "..\menu\camera.h"
#include "..\menu\misc.h"
#include "..\menu\player.h"
#include "..\menu\world.h"
#include "..\offsets.h"
#include "FreeCamera.h"
#include "GameDI_PH.h"
#include "GameDI_PH2.h"
#include "LevelDI.h"
#include "PlayerHealthModule.h"
#include "gen_TPPModel.h"
namespace GamePH {
namespace Hooks {
#pragma region CreatePlayerHealthModule
static DWORD64 detourCreatePlayerHealthModule(DWORD64 playerHealthModule);
static Utils::Hook::MHook<LPVOID, DWORD64(*)(DWORD64)> CreatePlayerHealthModuleHook{ "CreatePlayerHealthModule", &Offsets::Get_CreatePlayerHealthModule, &detourCreatePlayerHealthModule };
static DWORD64 detourCreatePlayerHealthModule(DWORD64 playerHealthModule) {
PlayerHealthModule::pPlayerHealthModule = reinterpret_cast<PlayerHealthModule*>(playerHealthModule);
return CreatePlayerHealthModuleHook.pOriginal(playerHealthModule);
}
#pragma endregion
#pragma region LifeSetHealth
static void detourLifeSetHealth(float* pLifeHealth, float health);
static Utils::Hook::MHook<LPVOID, void(*)(float*, float)> LifeSetHealthHook{ "LifeSetHealth", &Offsets::Get_LifeSetHealth, &detourLifeSetHealth };
static void detourLifeSetHealth(float* pLifeHealth, float health) {
if (!Menu::Player::godMode.GetValue() && !Menu::Camera::freeCam.GetValue())
return LifeSetHealthHook.pOriginal(pLifeHealth, health);
PlayerHealthModule* playerHealthModule = PlayerHealthModule::Get();
if (!playerHealthModule)
return LifeSetHealthHook.pOriginal(pLifeHealth, health);
LevelDI* iLevel = LevelDI::Get();
if (!iLevel || !iLevel->IsLoaded())
return LifeSetHealthHook.pOriginal(pLifeHealth, health);
if (std::abs(reinterpret_cast<LONG64>(playerHealthModule) - reinterpret_cast<LONG64>(pLifeHealth)) < 0x100 && playerHealthModule->health > 0.0f)
return;
LifeSetHealthHook.pOriginal(pLifeHealth, health);
}
static bool detourIsNotOutOfBounds(LPVOID pInstance, DWORD64 a2);
static Utils::Hook::MHook<LPVOID, bool(*)(LPVOID, DWORD64)> IsNotOutOfBoundsHook{ "IsNotOutOfBounds", &Offsets::Get_IsNotOutOfBounds, &detourIsNotOutOfBounds };
static bool detourIsNotOutOfBounds(LPVOID pInstance, DWORD64 a2) {
if (Menu::Player::disableOutOfBoundsTimer.GetValue())
return true;
return IsNotOutOfBoundsHook.pOriginal(pInstance, a2);
}
#pragma endregion
#pragma region ShowUIManager
static void detourShowUIManager(LPVOID pLevelDI, bool enabled);
static LPVOID GetShowUIManager() {
return Utils::Memory::GetProcAddr("engine_x64_rwdi.dll", "?ShowUIManager@ILevel@@QEAAX_N@Z");
}
static Utils::Hook::MHook<LPVOID, void(*)(LPVOID, bool)> ShowUIManagerHook{ "ShowUIManager", &GetShowUIManager, &detourShowUIManager };
static void detourShowUIManager(LPVOID pLevelDI, bool enabled) {
if (Menu::Misc::disableHUD.GetValue())
enabled = false;
ShowUIManagerHook.pOriginal(pLevelDI, enabled);
}
#pragma endregion
#pragma region OnPostUpdate
static void detourOnPostUpdate(LPVOID pGameDI_PH2);
static Utils::Hook::VTHook<GamePH::GameDI_PH2*, void(*)(LPVOID)> OnPostUpdateHook{ "OnPostUpdate", &GamePH::GameDI_PH2::Get, &detourOnPostUpdate, 0x3A8 };
static void detourOnPostUpdate(LPVOID pGameDI_PH2) {
OnPostUpdateHook.pOriginal(pGameDI_PH2);
Core::OnPostUpdate();
}
#pragma endregion
#pragma region TogglePhotoMode
static void detourTogglePhotoMode(LPVOID guiPhotoModeData, bool enabled);
static Utils::Hook::MHook<LPVOID, void(*)(LPVOID, bool)> TogglePhotoModeHook{ "TogglePhotoMode", &Offsets::Get_TogglePhotoMode, &detourTogglePhotoMode };
static void detourTogglePhotoMode(LPVOID guiPhotoModeData, bool enabled) {
Menu::Camera::photoMode.Set(enabled);
if (!Menu::Camera::freeCam.GetValue())
return TogglePhotoModeHook.pOriginal(guiPhotoModeData, enabled);
GameDI_PH* pGameDI_PH = GameDI_PH::Get();
if (!pGameDI_PH)
return TogglePhotoModeHook.pOriginal(guiPhotoModeData, enabled);
FreeCamera* pFreeCam = FreeCamera::Get();
if (!pFreeCam)
return TogglePhotoModeHook.pOriginal(guiPhotoModeData, enabled);
if (enabled) {
pGameDI_PH->TogglePhotoMode();
pFreeCam->AllowCameraMovement(0);
}
TogglePhotoModeHook.pOriginal(guiPhotoModeData, enabled);
}
#pragma endregion
#pragma region ShowTPPModelFunc3
Option wannaUseTPPModel{};
static void detourShowTPPModelFunc3(DWORD64 tppFunc2Addr, bool showTPPModel);
static Utils::Hook::MHook<LPVOID, void(*)(DWORD64, bool)> ShowTPPModelFunc3Hook{ "ShowTPPModelFunc3", &Offsets::Get_ShowTPPModelFunc3, &detourShowTPPModelFunc3 };
static void detourShowTPPModelFunc3(DWORD64 tppFunc2Addr, bool showTPPModel) {
wannaUseTPPModel.Set(showTPPModel);
gen_TPPModel* pgen_TPPModel = gen_TPPModel::Get();
if (!pgen_TPPModel) {
ShowTPPModelFunc3Hook.pOriginal(tppFunc2Addr, showTPPModel);
return;
}
if (wannaUseTPPModel.HasChangedTo(false)) {
wannaUseTPPModel.SetPrevValue(false);
pgen_TPPModel->enableTPPModel2 = true;
pgen_TPPModel->enableTPPModel1 = true;
}
ShowTPPModelFunc3Hook.pOriginal(tppFunc2Addr, showTPPModel);
}
#pragma endregion
#pragma region CalculateFreeCamCollision
static DWORD64 detourCalculateFreeCamCollision(LPVOID pFreeCamera, float* finalPos);
static Utils::Hook::MHook<LPVOID, DWORD64(*)(LPVOID, float*)> CalculateFreeCamCollisionHook{ "CalculateFreeCamCollision", &Offsets::Get_CalculateFreeCamCollision, &detourCalculateFreeCamCollision };
static DWORD64 detourCalculateFreeCamCollision(LPVOID pFreeCamera, float* finalPos) {
if (Menu::Camera::disablePhotoModeLimits.GetValue() || Menu::Camera::freeCam.GetValue())
return 0;
return CalculateFreeCamCollisionHook.pOriginal(pFreeCamera, finalPos);
}
#pragma endregion
#pragma region PlaySoundEvent
static DWORD64 detourPlaySoundEvent(LPVOID pCoAudioEventControl, DWORD64 name, DWORD64 a3);
static Utils::Hook::MHook<LPVOID, DWORD64(*)(LPVOID, DWORD64, DWORD64)> PlaySoundEventHook{ "PlaySoundEvent", &Offsets::Get_PlaySoundEvent, &detourPlaySoundEvent };
static DWORD64 detourPlaySoundEvent(LPVOID pCoAudioEventControl, DWORD64 name, DWORD64 a3) {
const char* soundName = reinterpret_cast<const char*>(name & 0x1FFFFFFFFFFFFFFF); // remove first byte of addr in case it exists
if (Menu::World::freezeTime.GetValue() && soundName &&
(!strcmp(soundName, "set_gp_infection_start") || !strcmp(soundName, "set_gp_infection_immune"))) {
return 0;
}
return PlaySoundEventHook.pOriginal(pCoAudioEventControl, name, a3);
}
#pragma endregion
}
}

View File

@ -0,0 +1,8 @@
#pragma once
#include "..\core.h"
namespace GamePH {
namespace Hooks {
extern Option wannaUseTPPModel;
}
}

View File

@ -0,0 +1,21 @@
#include <pch.h>
#include "LocalClientDI.h"
#include "gen_TPPModel.h"
namespace GamePH {
gen_TPPModel* gen_TPPModel::Get() {
__try {
LocalClientDI* pLocalClientDI = LocalClientDI::Get();
if (!pLocalClientDI)
return nullptr;
gen_TPPModel* ptr = pLocalClientDI->pgen_TPPModel;
if (!Utils::Memory::IsValidPtrMod(ptr, "gamedll_ph_x64_rwdi.dll"))
return nullptr;
return ptr;
} __except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
}

View File

@ -0,0 +1,14 @@
#pragma once
#include "..\buffer.h"
namespace GamePH {
class gen_TPPModel {
public:
union {
buffer<0x2CF9, bool> enableTPPModel1;
buffer<0x2CFA, bool> enableTPPModel2;
};
static gen_TPPModel* Get();
};
}

View File

@ -0,0 +1,45 @@
#include <pch.h>
bool Vector3::operator==(const Vector3& v) const {
return Utils::Values::are_samef(X, v.X) && Utils::Values::are_samef(Y, v.Y) && Utils::Values::are_samef(Z, v.Z);
}
Vector3& Vector3::operator+=(const Vector3& v) {
X += v.X;
Y += v.Y;
Z += v.Z;
return *this;
}
Vector3& Vector3::operator-=(const Vector3& v) {
X -= v.X;
Y -= v.Y;
Z -= v.Z;
return *this;
}
Vector3 Vector3::operator+(const Vector3& v) const {
return { X + v.X, Y + v.Y, Z + v.Z };
}
Vector3 Vector3::operator-(const Vector3& v) const {
return { X - v.X, Y - v.Y, Z - v.Z };
}
Vector3 Vector3::operator*(float scalar) const {
return { X * scalar, Y * scalar, Z * scalar };
}
Vector3 Vector3::operator/(float scalar) const {
return { X / scalar, Y / scalar, Z / scalar };
}
Vector3 Vector3::normalize() {
float length = std::sqrt(X * X + Y * Y + Z * Z);
return { X / length, Y / length, Z / length };
}
Vector3 Vector3::cross(const Vector3& v) const {
return {
Y * v.Z - Z * v.Y,
Z * v.X - X * v.Z,
X * v.Y - Y * v.X
};
}
bool Vector3::isDefault() const {
return Utils::Values::are_samef(X, 0.0f) && Utils::Values::are_samef(Y, 0.0f) && Utils::Values::are_samef(Z, 0.0f);
}

View File

@ -0,0 +1,17 @@
#pragma once
struct Vector3 {
float X, Y, Z;
bool operator==(const Vector3& v) const;
Vector3& operator+=(const Vector3& v);
Vector3& operator-=(const Vector3& v);
Vector3 operator+(const Vector3& v) const;
Vector3 operator-(const Vector3& v) const;
Vector3 operator*(float scalar) const;
Vector3 operator/(float scalar) const;
Vector3 normalize();
Vector3 cross(const Vector3& v) const;
bool isDefault() const;
};

View File

@ -0,0 +1,17 @@
#pragma once
template<size_t size, typename T> class buffer {
char buffer[size];
T data;
public:
operator T() { return data; }
T operator->() { return data; }
T& operator=(const T& other) { data = other; return data; }
T& operator*=(const T& other) { data *= other; return data; }
T operator*(const T& other) const { return data * other; }
T& operator/=(const T& other) { data /= other; return data; }
T operator/(const T& other) const { return data / other; }
T& operator+=(const T& other) { data += other; return data; }
T operator+(const T& other) const { return data + other; }
T& operator-=(const T& other) { data -= other; return data; }
T operator-(const T& other) const { return data - other; }
};

File diff suppressed because it is too large Load Diff

View File

@ -1,480 +0,0 @@
#pragma once
#include <Windows.h>
#include <any>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "core.h"
#include "hook.h"
#include "utils.h"
#define STR_MERGE_IMPL(a, b) a##b
#define STR_MERGE(a, b) STR_MERGE_IMPL(a, b)
#define MAKE_PAD(size) STR_MERGE(_pad, __COUNTER__)[size]
#define DEFINE_MEMBER_N(type, name, offset) struct {unsigned char MAKE_PAD(offset); type name;}
#define DEFINE_MEMBER_0(type, name) struct {type name;}
// Game structs
struct Vector3 {
float X, Y, Z;
bool operator==(const Vector3& v) const {
return Utils::are_same(X, v.X) && Utils::are_same(Y, v.Y) && Utils::are_same(Z, v.Z);
}
Vector3& operator+=(const Vector3& v) {
X += v.X;
Y += v.Y;
Z += v.Z;
return *this;
}
Vector3& operator-=(const Vector3& v) {
X -= v.X;
Y -= v.Y;
Z -= v.Z;
return *this;
}
Vector3 operator+(const Vector3& v) const {
return { X + v.X, Y + v.Y, Z + v.Z };
}
Vector3 operator-(const Vector3& v) const {
return { X - v.X, Y - v.Y, Z - v.Z };
}
Vector3 operator*(float scalar) const {
return { X * scalar, Y * scalar, Z * scalar };
}
Vector3 operator/(float scalar) const {
return { X / scalar, Y / scalar, Z / scalar };
}
Vector3 normalize() {
float length = std::sqrt(X * X + Y * Y + Z * Z);
return { X / length, Y / length, Z / length };
}
Vector3 cross(const Vector3& v) const {
return {
Y * v.Z - Z * v.Y,
Z * v.X - X * v.Z,
X * v.Y - Y * v.X
};
}
bool isDefault() const {
return Utils::are_same(X, 0.0f) && Utils::are_same(Y, 0.0f) && Utils::are_same(Z, 0.0f);
}
};
namespace EWeather {
enum TYPE {
Default = 0,
Foggy = 1,
Clear = 2,
Overcast = 3,
Cloudy = 4,
Rainy = 5,
Stormy = 6
};
}
// Forward decl
namespace Engine {
class CBaseCamera {
public:
/*union {
DEFINE_MEMBER_N(float, yaw, 0x48);
DEFINE_MEMBER_N(float, X, 0x4C);
DEFINE_MEMBER_N(float, pitch, 0x58);
DEFINE_MEMBER_N(float, Y, 0x5C);
DEFINE_MEMBER_N(float, Z, 0x6C);
};*/
Vector3* GetForwardVector(Vector3* outForwardVec);
Vector3* GetUpVector(Vector3* outUpVec);
Vector3* GetLeftVector(Vector3* outLeftVec);
Vector3* GetPosition(Vector3* outPos);
};
class CoPhysicsProperty;
class CRTTI;
class CRTTIObject;
// Inheritance classes
class CRTTIField {
public:
DWORD64 Get_vec3(CRTTIObject* crtti, Vector3& out);
};
class CRTTI {
public:
CRTTIField* FindField(char const* name);
};
class CRTTIObject {
public:
CRTTIField* FindField(char const* name);
};
class CRTTIManager {
public:
CRTTIManager* Get();
};
}
namespace GamePH {
extern const std::string GameVerToStr(DWORD64 version);
extern const std::string GetCurrentGameVersionStr();
extern const DWORD64 GetCurrentGameVersion();
extern void ShowTPPModel(bool showTPPModel);
extern bool ReloadJumps();
class PlayerVariables {
public:
static std::vector<std::pair<std::string, std::pair<LPVOID, std::string>>> playerVars;
static std::vector<std::pair<std::string, std::pair<std::any, std::string>>> playerVarsDefault;
static std::vector<std::pair<std::string, std::pair<std::any, std::string>>> playerCustomVarsDefault;
static bool gotPlayerVars;
static void GetPlayerVars();
static void SortPlayerVars();
template <typename T>
static T GetPlayerVar(const std::string& playerVar) {
static_assert(std::is_same<T, bool>::value || std::is_same<T, float>::value || std::is_same<T, std::string>::value, "Invalid type: value must be bool, float or string");
auto it = std::find_if(PlayerVariables::playerVars.begin(), PlayerVariables::playerVars.end(), [&playerVar](const auto& pair) {
return pair.first == playerVar;
});
if (it == PlayerVariables::playerVars.end()) {
if (std::is_same<T, std::string>::value)
return {};
else if (std::is_same<T, float>::value)
return -404.0f;
else
return false;
}
return *reinterpret_cast<T*>(it->second.first);
}
template <typename T>
static void ChangePlayerVar(const std::string& playerVar, const T value) {
static_assert(std::is_same<T, bool>::value || std::is_same<T, float>::value || std::is_same<T, std::string>::value, "Invalid type: value must be bool, float or string");
if (!gotPlayerVars)
return;
auto it = std::find_if(PlayerVariables::playerVars.begin(), PlayerVariables::playerVars.end(), [&playerVar](const auto& pair) {
return pair.first == playerVar;
});
if (it == PlayerVariables::playerVars.end())
return;
if (std::is_same<T, std::string>::value) {
std::string valueStr = Utils::to_string(value);
if (it->second.second == "float") {
float* const varValue = reinterpret_cast<float*>(it->second.first);
const float actualValue = std::stof(valueStr);
*varValue = actualValue;
*(varValue + 1) = actualValue;
}
else {
bool* const varValue = reinterpret_cast<bool*>(it->second.first);
const bool actualValue = valueStr == "true";
*varValue = actualValue;
*(varValue + 1) = actualValue;
}
}
else {
T* const varValue = reinterpret_cast<T*>(it->second.first);
*varValue = value;
*(varValue + 1) = value;
}
}
template <typename T>
static void ManagePlayerVarOption(const std::string& playerVar, const T valueIfTrue, const T valueIfFalse, Option* option, const bool& usePreviousVal = true) {
if (!gotPlayerVars)
return;
static T previousPlayerVarValue = GamePH::PlayerVariables::GetPlayerVar<T>(playerVar);
if (option->GetValue()) {
if (!option->GetPrevValue())
previousPlayerVarValue = GamePH::PlayerVariables::GetPlayerVar<T>(playerVar);
GamePH::PlayerVariables::ChangePlayerVar(playerVar, valueIfTrue);
option->SetPrevValue(true);
} else if (option->GetPrevValue()) {
option->SetPrevValue(false);
GamePH::PlayerVariables::ChangePlayerVar(playerVar, usePreviousVal ? previousPlayerVarValue : valueIfFalse);
}
}
static PlayerVariables* Get();
};
class PlayerState {
public:
union {
DEFINE_MEMBER_N(PlayerVariables*, playerVars, 0x290);
};
static PlayerState* Get();
};
class PlayerHealthModule {
public:
union {
DEFINE_MEMBER_N(float, health, 0x2C);
DEFINE_MEMBER_N(float, maxHealth, 0x3C);
};
static PlayerHealthModule* pPlayerHealthModule;
static PlayerHealthModule* Get();
};
class TPPCameraDI : public Engine::CBaseCamera {
public:
static TPPCameraDI* Get();
};
class CameraFPPDI : public Engine::CBaseCamera {
public:
union {
DEFINE_MEMBER_N(Engine::CBaseCamera*, pCBaseCamera, 0x38);
};
//static CameraFPPDI* Get();
};
class CoBaseCameraProxy {
public:
union {
DEFINE_MEMBER_N(TPPCameraDI*, pTPPCameraDI, 0xD0);
};
};
class FreeCamera : public Engine::CBaseCamera {
public:
union {
DEFINE_MEMBER_N(CoBaseCameraProxy*, pCoBaseCameraProxy, 0x18);
DEFINE_MEMBER_N(Engine::CBaseCamera*, pCBaseCamera, 0x38);
DEFINE_MEMBER_N(bool, enableSpeedMultiplier1, 0x42);
DEFINE_MEMBER_N(bool, enableSpeedMultiplier2, 0x43);
DEFINE_MEMBER_N(float, speedMultiplier, 0x1CC);
};
void AllowCameraMovement(int mode = 2);
static FreeCamera* Get();
};
class DayNightCycle {
public:
union {
DEFINE_MEMBER_N(float, time1, 0x10);
DEFINE_MEMBER_N(float, time2, 0x20);
DEFINE_MEMBER_N(float, time3, 0x5C);
};
void SetDaytime(float time);
static DayNightCycle* Get();
};
namespace TimeWeather {
class CSystem {
public:
void SetForcedWeather(int weather);
int GetCurrentWeather();
static CSystem* Get();
};
}
class LevelDI {
public:
bool IsLoading();
bool IsLoaded();
LPVOID GetViewCamera();
float GetTimeDelta();
void SetViewCamera(LPVOID viewCam);
float GetTimePlayed();
void ShowUIManager(bool enabled);
float TimerGetSpeedUp();
void TimerSetSpeedUp(float timeScale);
TimeWeather::CSystem* GetTimeWeatherSystem();
static LevelDI* Get();
};
class gen_TPPModel {
public:
union {
DEFINE_MEMBER_N(bool, enableTPPModel1, 0x2CF9);
DEFINE_MEMBER_N(bool, enableTPPModel2, 0x2CFA);
};
static gen_TPPModel* Get();
};
class LocalClientDI {
public:
union {
DEFINE_MEMBER_N(gen_TPPModel*, pgen_TPPModel, 0x90);
};
static LocalClientDI* Get();
};
class SessionCooperativeDI {
public:
union {
DEFINE_MEMBER_N(LocalClientDI*, pLocalClientDI, 0xE08);
};
static SessionCooperativeDI* Get();
};
class GameDI_PH2 {
public:
static GameDI_PH2* Get();
};
class GameDI_PH {
public:
union {
DEFINE_MEMBER_N(SessionCooperativeDI*, pSessionCooperativeDI, 0xF0);
DEFINE_MEMBER_N(bool, blockPauseGameOnPlayerAfk, 0x830);
};
float GetGameTimeDelta();
DWORD64 GetCurrentGameVersion();
void TogglePhotoMode(bool doNothing = false, bool setAsOptionalCamera = false);
static GameDI_PH* Get();
};
class PlayerObjProperties {
public:
union {
DEFINE_MEMBER_N(Engine::CoPhysicsProperty*, pCoPhysicsProperty, 0xF0);
DEFINE_MEMBER_N(bool, isOutOfBounds, 0x2E80);
DEFINE_MEMBER_N(float, outOfBoundsTimer, 0x2E84);
};
static PlayerObjProperties* Get();
};
class LogicalPlayer : public Engine::CRTTIObject {
public:
static LogicalPlayer* Get();
};
}
namespace Engine {
class CVideoSettings {
public:
union {
DEFINE_MEMBER_N(float, extraFOV, 0x7C);
};
static CVideoSettings* Get();
};
class CGSObject2 {
public:
union {
DEFINE_MEMBER_N(GamePH::LogicalPlayer*, pLogicalPlayer, 0x20);
};
static CGSObject2* Get();
};
class CLevel2 {
public:
union {
DEFINE_MEMBER_N(CGSObject2*, pCGSObject2, 0x28);
};
static CLevel2* Get();
};
class CGSObject {
public:
union {
DEFINE_MEMBER_N(CLevel2*, pCLevel2, 0x48);
};
static CGSObject* Get();
};
class CLevel {
public:
union {
DEFINE_MEMBER_N(GamePH::LevelDI*, pLevelDI, 0x20);
DEFINE_MEMBER_N(CGSObject*, pCGSObject, 0x30);
};
static CLevel* Get();
};
class CGame {
public:
union {
DEFINE_MEMBER_N(GamePH::GameDI_PH*, pGameDI_PH, 0x8);
DEFINE_MEMBER_N(CVideoSettings*, pCVideoSettings, 0x28);
DEFINE_MEMBER_N(CLevel*, pCLevel, 0x380);
};
static CGame* Get();
};
class CLobbySteam {
public:
union {
DEFINE_MEMBER_N(CGame*, pCGame, 0xF8);
};
static CLobbySteam* Get();
};
class CInput {
public:
DWORD64 BlockGameInput();
void UnlockGameInput();
static CInput* Get();
};
class CBulletPhysicsCharacter {
public:
union {
DEFINE_MEMBER_N(Vector3, playerPos2, 0x8A0);
DEFINE_MEMBER_N(Vector3, playerPos, 0x8B8);
DEFINE_MEMBER_N(float, playerDownwardVelocity, 0xC38);
};
static Vector3 posBeforeFreeze;
void FreezeCharacter();
void MoveCharacter(const Vector3& pos);
static CBulletPhysicsCharacter* Get();
};
class CoPhysicsProperty {
public:
union {
DEFINE_MEMBER_N(CBulletPhysicsCharacter*, pCBulletPhysicsCharacter, 0x20);
};
static CoPhysicsProperty* Get();
};
}
#undef DEFINE_MEMBER_0
#undef DEFINE_MEMBER_N
#undef MAKE_PAD
#undef STR_MERGE
#undef STR_MERGE_IMPL

View File

@ -1,137 +0,0 @@
#include <cstdint>
#include <iostream>
#include "hook.h"
#include "sigscan\offsets.h"
namespace Hook {
// VTable hooking
static int VTHookUnprotect(LPCVOID region) {
MEMORY_BASIC_INFORMATION mbi{};
VirtualQuery(region, &mbi, sizeof(mbi));
VirtualProtect(mbi.BaseAddress, mbi.RegionSize, PAGE_READWRITE, &mbi.Protect);
return mbi.Protect;
}
static void VTHookProtect(LPCVOID region, int protection) {
MEMORY_BASIC_INFORMATION mbi{};
VirtualQuery(region, &mbi, sizeof(mbi));
VirtualProtect(mbi.BaseAddress, mbi.RegionSize, protection, &mbi.Protect);
}
void HookVT(LPVOID instance, LPVOID pDetour, LPVOID* ppOriginal, const DWORD offset) {
PDWORD64* entry = reinterpret_cast<PDWORD64*>(*reinterpret_cast<DWORD64*>(instance) + offset);
*ppOriginal = *entry;
const int original_protection = VTHookUnprotect(entry);
*entry = reinterpret_cast<PDWORD64>(pDetour);
VTHookProtect(entry, original_protection);
}
// Trampoline hooking
DETOUR_INFO MidFuncHook(LPVOID pTarget, LPVOID pHookedFunc, const size_t nops, const size_t bytesToSkip) {
DWORD dwOldProtect, dwBkup{};
const size_t finalHookSize = 13 + nops;
DETOUR_INFO detour{ pTarget, pHookedFunc };
detour.oBytes.resize(finalHookSize);
detour.patchedBytes.resize(finalHookSize);
VirtualProtect(pTarget, finalHookSize, PAGE_EXECUTE_READWRITE, &dwOldProtect);
BYTE* temp_target = reinterpret_cast<BYTE*>(pTarget);
std::copy(temp_target, temp_target + finalHookSize, detour.oBytes.begin());
// push rax
*temp_target = 0x50;
temp_target++;
// mov rax, hookedFuncAddr
*temp_target = 0x48;
*(temp_target + 1) = 0xB8;
*reinterpret_cast<PDWORD64>(temp_target + 2) = reinterpret_cast<DWORD64>(pHookedFunc) + bytesToSkip;
temp_target += 2 + sizeof(DWORD64);
// jmp rax
*temp_target = 0xFF;
*(temp_target + 1) = 0xE0;
temp_target += 2;
// nop
if (nops != 0) {
for (int i = 0; i < nops; i++) {
*temp_target = 0x90;
temp_target++;
}
}
detour.jmpBack = reinterpret_cast<PDWORD64>(temp_target);
temp_target = reinterpret_cast<BYTE*>(pTarget);
std::copy(temp_target, temp_target + finalHookSize, detour.patchedBytes.begin());
VirtualProtect(pTarget, finalHookSize, dwOldProtect, &dwBkup);
return detour;
}
// Breakpoint hooking
static std::vector<BreakpointHook*> s_hookList;
BreakpointHook::BreakpointHook(PDWORD64 addr, std::function<void(PEXCEPTION_POINTERS)> handler) {
m_addr = addr;
m_handler = handler;
m_originalBytes = *reinterpret_cast<BYTE*>(m_addr);
AddVectoredExceptionHandler(true, (PVECTORED_EXCEPTION_HANDLER)OnException);
s_hookList.push_back(this);
Enable();
}
void BreakpointHook::Enable() {
DWORD oldProtection = 0;
VirtualProtect(m_addr, 1, PAGE_EXECUTE_READWRITE, &m_originalProtection);
*reinterpret_cast<BYTE*>(m_addr) = 0xCC;
VirtualProtect(m_addr, 1, m_originalProtection, &oldProtection);
}
void BreakpointHook::Disable() {
DWORD oldProtection = 0;
VirtualProtect(m_addr, 1, PAGE_EXECUTE_READWRITE, &oldProtection);
*reinterpret_cast<BYTE*>(m_addr) = m_originalBytes;
VirtualProtect(m_addr, 1, m_originalProtection, &oldProtection);
}
BreakpointHook::~BreakpointHook() {
Disable();
auto it = std::find(s_hookList.begin(), s_hookList.end(), this);
if (it != s_hookList.end())
s_hookList.erase(it);
}
static PDWORD64 lastBpAddress = nullptr;
long WINAPI BreakpointHook::OnException(PEXCEPTION_POINTERS info) {
for (auto it = s_hookList.begin(); it != s_hookList.end(); it++) {
BreakpointHook* bp = *it;
if (bp->m_addr == info->ExceptionRecord->ExceptionAddress) {
bp->Disable();
lastBpAddress = bp->m_addr;
info->ContextRecord->EFlags |= 0x100; // Set EFLAGS to single step
return EXCEPTION_CONTINUE_EXECUTION;
} else if (info->ExceptionRecord->ExceptionCode == STATUS_SINGLE_STEP && bp->m_addr == lastBpAddress) {
bp->Enable();
info->ContextRecord->EFlags &= ~0x00000100; // Remove TRACE from EFLAGS
bp->m_handler(info);
return EXCEPTION_CONTINUE_EXECUTION;
}
}
return EXCEPTION_CONTINUE_SEARCH;
}
}

Some files were not shown because too many files have changed in this diff Show More