mirror of
https://github.com/EricPlayZ/EGameTools.git
synced 2025-07-18 17:37:53 +08:00
merge dev into master
This commit is contained in:
@ -44,6 +44,11 @@ So e.g. 5 months from now, I'd want the latest mod version to support the latest
|
||||
Unfortunately, I haven't found a way to do this yet, so I will be setting this aside for some other time. For now, I'll release this compatibility patch!
|
||||
|
||||
You should also expect less updates in the future, as I'm going to be pretty busy this year, with my final exam, driving school, and so many other things!
|
||||
Thank you everyone for the support <3)" }
|
||||
Thank you everyone for the support <3)" },
|
||||
{ "v1.1.3",
|
||||
R"(- Added compatibility with v1.16.0 "Nightmare Mode" update
|
||||
- Fixed really fast player speed when executing a slow motion kill, dodging or ground pounding at 1.00x game speed (will still happen at any other game speed unfortunately)
|
||||
- Added function hooking timeout for easier debugging
|
||||
- Fetch game version using Windows' API instead of using the game's function)" }
|
||||
};
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,15 @@
|
||||
|
||||
namespace GamePH {
|
||||
void FreeCamera::AllowCameraMovement(int mode) {
|
||||
Utils::Memory::CallVT<187>(this, mode);
|
||||
__try {
|
||||
void(*pAllowCameraMovement)(LPVOID pGameDI_PH, int mode) = (decltype(pAllowCameraMovement))Offsets::Get_AllowCameraMovement();
|
||||
if (!pAllowCameraMovement)
|
||||
return;
|
||||
|
||||
pAllowCameraMovement(this, mode);
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FreeCamera* FreeCamera::Get() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <pch.h>
|
||||
#include "..\Engine\CGame.h"
|
||||
#include "GameDI_PH.h"
|
||||
#include "..\offsets.h"
|
||||
|
||||
namespace GamePH {
|
||||
float GameDI_PH::GetGameTimeDelta() {
|
||||
@ -14,11 +15,16 @@ namespace GamePH {
|
||||
return -1.0f;
|
||||
}
|
||||
}
|
||||
DWORD64 GameDI_PH::GetCurrentGameVersion() {
|
||||
return Utils::Memory::CallVT<228, DWORD64>(this);
|
||||
}
|
||||
void GameDI_PH::TogglePhotoMode(bool doNothing, bool setAsOptionalCamera) {
|
||||
Utils::Memory::CallVT<260>(this, doNothing, setAsOptionalCamera);
|
||||
__try {
|
||||
void(*pTogglePhotoMode)(LPVOID pGameDI_PH, bool doNothing, bool setAsOptionalCamera) = (decltype(pTogglePhotoMode))Offsets::Get_TogglePhotoMode2();
|
||||
if (!pTogglePhotoMode)
|
||||
return;
|
||||
|
||||
pTogglePhotoMode(this, doNothing, setAsOptionalCamera);
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
GameDI_PH* GameDI_PH::Get() {
|
||||
|
@ -9,7 +9,7 @@ namespace GamePH {
|
||||
GetModuleFileNameA(GetModuleHandleA(nullptr), exePath, sizeof(exePath));
|
||||
|
||||
DWORD dummy{};
|
||||
DWORD size = GetFileVersionInfoSizeA(exePath, &dummy);
|
||||
const DWORD size = GetFileVersionInfoSizeA(exePath, &dummy);
|
||||
if (!size)
|
||||
return 0;
|
||||
|
||||
@ -19,9 +19,7 @@ namespace GamePH {
|
||||
|
||||
VS_FIXEDFILEINFO* fileInfo = nullptr;
|
||||
UINT fileInfoSize = 0;
|
||||
if (!VerQueryValueA(data.data(), "\\", reinterpret_cast<void**>(&fileInfo), &fileInfoSize))
|
||||
return 0;
|
||||
if (fileInfo == nullptr)
|
||||
if (!VerQueryValueA(data.data(), "\\", reinterpret_cast<LPVOID*>(&fileInfo), &fileInfoSize) || !fileInfo)
|
||||
return 0;
|
||||
|
||||
const DWORD major = HIWORD(fileInfo->dwFileVersionMS);
|
||||
|
@ -43,7 +43,9 @@ namespace GamePH {
|
||||
|
||||
LifeSetHealthHook.pOriginal(pLifeHealth, health);
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region IsNotOutOfBounds
|
||||
static bool detourIsNotOutOfBounds(LPVOID pInstance, DWORD64 a2);
|
||||
static Utils::Hook::MHook<LPVOID, bool(*)(LPVOID, DWORD64)> IsNotOutOfBoundsHook{ "IsNotOutOfBounds", &Offsets::Get_IsNotOutOfBounds, &detourIsNotOutOfBounds };
|
||||
|
||||
@ -81,30 +83,30 @@ namespace GamePH {
|
||||
#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 detourTogglePhotoMode1(LPVOID guiPhotoModeData, bool enabled);
|
||||
static Utils::Hook::MHook<LPVOID, void(*)(LPVOID, bool)> TogglePhotoMode1Hook{ "TogglePhotoMode1", &Offsets::Get_TogglePhotoMode1, &detourTogglePhotoMode1 };
|
||||
|
||||
static void detourTogglePhotoMode(LPVOID guiPhotoModeData, bool enabled) {
|
||||
static void detourTogglePhotoMode1(LPVOID guiPhotoModeData, bool enabled) {
|
||||
Menu::Camera::photoMode.Set(enabled);
|
||||
|
||||
if (!Menu::Camera::freeCam.GetValue())
|
||||
return TogglePhotoModeHook.pOriginal(guiPhotoModeData, enabled);
|
||||
return TogglePhotoMode1Hook.pOriginal(guiPhotoModeData, enabled);
|
||||
LevelDI* iLevel = LevelDI::Get();
|
||||
if (!iLevel || iLevel->IsTimerFrozen())
|
||||
return TogglePhotoModeHook.pOriginal(guiPhotoModeData, enabled);
|
||||
return TogglePhotoMode1Hook.pOriginal(guiPhotoModeData, enabled);
|
||||
GameDI_PH* pGameDI_PH = GameDI_PH::Get();
|
||||
if (!pGameDI_PH)
|
||||
return TogglePhotoModeHook.pOriginal(guiPhotoModeData, enabled);
|
||||
return TogglePhotoMode1Hook.pOriginal(guiPhotoModeData, enabled);
|
||||
FreeCamera* pFreeCam = FreeCamera::Get();
|
||||
if (!pFreeCam)
|
||||
return TogglePhotoModeHook.pOriginal(guiPhotoModeData, enabled);
|
||||
return TogglePhotoMode1Hook.pOriginal(guiPhotoModeData, enabled);
|
||||
|
||||
if (enabled) {
|
||||
pGameDI_PH->TogglePhotoMode();
|
||||
pFreeCam->AllowCameraMovement(0);
|
||||
}
|
||||
|
||||
TogglePhotoModeHook.pOriginal(guiPhotoModeData, enabled);
|
||||
TogglePhotoMode1Hook.pOriginal(guiPhotoModeData, enabled);
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
@ -62,7 +62,7 @@ namespace Menu {
|
||||
ImGui::SliderFloat("Menu Scale", &scale, 1.0f, 2.5f, "%.1f%%", ImGuiSliderFlags_AlwaysClamp);
|
||||
if (Core::gameVer != GAME_VER_COMPAT) {
|
||||
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(IM_COL32(200, 0, 0, 255)), "Incompatible game version detected!");
|
||||
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(IM_COL32(200, 0, 0, 255)), Core::gameVer > GAME_VER_COMPAT ? "Please wait for a new mod update." : "Upgrade your game version to one that the mod supports.");
|
||||
ImGui::TextColored(ImGui::ColorConvertU32ToFloat4(IM_COL32(200, 0, 0, 255)), "Compatible game version: v%s", GamePH::GameVerToStr(GAME_VER_COMPAT));
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
@ -6096,8 +6096,9 @@ namespace Menu {
|
||||
if (*varAddr != *(varAddr + 1) && *(varAddr + 1) != std::any_cast<bool>(valDef.second.first))
|
||||
*varAddr = *(varAddr + 1);
|
||||
}
|
||||
} catch (std::out_of_range& e) {
|
||||
} catch (std::exception& e) {
|
||||
UNREFERENCED_PARAMETER(e);
|
||||
spdlog::error("PlayerVarsUpdate() threw an exception! If this error message appears, please open a bug report.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace Menu {
|
||||
namespace World {
|
||||
float time = 0.0f;
|
||||
static float timeBeforeFreeze = 0.0f;
|
||||
float worldSpeed = 1.0f;
|
||||
float gameSpeed = 1.0f;
|
||||
static float gameSpeedBeforeSlowMo = gameSpeed;
|
||||
KeyBindOption freezeTime{ VK_NONE };
|
||||
@ -88,7 +89,7 @@ namespace Menu {
|
||||
if (freezeTime.GetValue() && !Utils::Values::are_samef(time, timeBeforeFreeze, 0.009999f))
|
||||
dayNightCycle->SetDaytime(timeBeforeFreeze);
|
||||
|
||||
if (!slowMotion.GetValue() && !slowMotion.HasChanged())
|
||||
if (!slowMotion.GetValue() && !slowMotion.HasChanged() && !Utils::Values::are_samef(gameSpeed, 1.0f))
|
||||
iLevel->TimerSetSpeedUp(gameSpeed);
|
||||
gameSpeed = iLevel->TimerGetSpeedUp();
|
||||
}
|
||||
@ -116,7 +117,7 @@ namespace Menu {
|
||||
if (ImGui::SliderFloat("Game Speed", &gameSpeed, 0.0f, 2.0f, "%.2fx"))
|
||||
iLevel->TimerSetSpeedUp(gameSpeed);
|
||||
else if (iLevel && iLevel->IsLoaded()) {
|
||||
if (!slowMotion.GetValue() && !slowMotion.HasChanged())
|
||||
if (!slowMotion.GetValue() && !slowMotion.HasChanged() && !Utils::Values::are_samef(gameSpeed, 1.0f))
|
||||
iLevel->TimerSetSpeedUp(gameSpeed);
|
||||
gameSpeed = iLevel->TimerGetSpeedUp();
|
||||
}
|
||||
|
@ -51,17 +51,19 @@ struct Offsets {
|
||||
AddOffset(ReadVideoSettings, "engine_x64_rwdi.dll", "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC ?? 48 8B FA 48 8B D9 45 84 C0", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
AddOffset(MoveCameraFromForwardUpPos, "engine_x64_rwdi.dll", "48 89 5C 24 ?? 57 48 83 EC ?? 49 8B C1 48 8B F9", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
AddOffset(CalculateFreeCamCollision, "gamedll_ph_x64_rwdi.dll", "48 8B C4 55 53 56 57 48 8D A8 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 83 B9", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
AddOffset(AllowCameraMovement, "gamedll_ph_x64_rwdi.dll", "89 91 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC CC 48 8B C4 55 56", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
//AddOffset(GetViewCamera, "engine_x64_rwdi.dll", "E8 [?? ?? ?? ?? 48 85 C0 74 28 48 8B C8", PatternType::RelativePointer, LPVOID)
|
||||
AddOffset(CreatePlayerHealthModule, "gamedll_ph_x64_rwdi.dll", "48 89 5C 24 ?? 55 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 4C 8B F1 E8 ?? ?? ?? ?? 48 8D 05", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
AddOffset(LifeSetHealth, "gamedll_ph_x64_rwdi.dll", "F3 0F 11 49 ?? F3 0F 11 49 ?? F3 0F 11 49 ?? C3", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
AddOffset(TogglePhotoMode, "gamedll_ph_x64_rwdi.dll", "48 83 EC ?? 38 91 ?? ?? ?? ?? 0F 84", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
AddOffset(TogglePhotoMode1, "gamedll_ph_x64_rwdi.dll", "48 83 EC ?? 38 91 ?? ?? ?? ?? 0F 84", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
AddOffset(TogglePhotoMode2, "gamedll_ph_x64_rwdi.dll", "48 89 5C 24 ?? 57 48 83 EC ?? 48 8B D9 41 0F B6 F8 48 8B 0D", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
//AddOffset(OnUpdate_ChangeMap, "gamedll_ph_x64_rwdi.dll", "E8 [?? ?? ?? ?? 88 44 24 20 48 8B 84 24 ?? ?? ?? ?? 48 83 78 ?? ??", PatternType::RelativePointer, LPVOID)
|
||||
AddOffset(ShowTPPModelFunc2, "gamedll_ph_x64_rwdi.dll", "40 53 48 83 EC ?? 48 8B 01 48 8B D9 FF 90 ?? ?? ?? ?? 84 C0 74 ?? 48 8B 83 ?? ?? ?? ?? 48 8B 88 ?? ?? ?? ?? 48 85 C9 74 ?? 48 83 B9 ?? ?? ?? ?? ?? 74 ?? 48 8B 81", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
AddOffset(ShowTPPModelFunc3, "gamedll_ph_x64_rwdi.dll", "48 83 EC ?? 38 91 ?? ?? ?? ?? 74 ?? 88 91", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
//AddOffset(CalculateOutOfBoundsTimer, "gamedll_ph_x64_rwdi.dll", "48 89 5C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 0F B6 99", PatternType::Address, LPVOID)
|
||||
AddOffset(IsNotOutOfBounds, "gamedll_ph_x64_rwdi.dll", "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 56 41 57 48 83 EC ?? 4C 8B F9 48 85 D2", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
AddOffset(ReloadJumps, "gamedll_ph_x64_rwdi.dll", "48 83 EC ?? E8 ?? ?? ?? ?? 48 8D 15", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
AddOffset(PlaySoundEvent, "gamedll_ph_x64_rwdi.dll", "4C 8B DC 49 89 5B ?? 49 89 73 ?? 57 48 81 EC ?? ?? ?? ?? 4C 8B 4C 24 ?? 48 8B F9 4D 8B D0 66 C7 84 24 ?? ?? ?? ?? ?? ?? 49 8B C1 66 C7 84 24", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
AddOffset(PlaySoundEvent, "gamedll_ph_x64_rwdi.dll", "4C 8B DC 49 89 5B ?? 49 89 73 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B 44 24 ?? 48 8B F9 48 8B DA", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
AddOffset(CalculateFallHeight, "gamedll_ph_x64_rwdi.dll", "40 55 56 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 44 0F 29 9C 24", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
//AddOffset(HandleFallHeight, "gamedll_ph_x64_rwdi.dll", "48 89 5C 24 ?? 57 48 83 EC ?? 0F B6 FA 48 8B D9 0F B6 91", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
//AddOffset(HandlePlayerFall, "gamedll_ph_x64_rwdi.dll", "48 89 5C 24 ?? 57 48 83 EC ?? 0F 29 74 24 ?? 48 8B FA 0F 28 F2", Utils::SigScan::PatternType::Address, LPVOID)
|
||||
|
@ -38,7 +38,13 @@ namespace Utils {
|
||||
MHook(const std::string_view& name, GetTargetOffsetRetType(*pGetOffsetFunc)(), OrigType pDetour) : HookBase(name), pGetOffsetFunc(pGetOffsetFunc), pDetour(pDetour) {}
|
||||
|
||||
void HookLoop() override {
|
||||
timeSpentHooking = Utils::Time::Timer(60000);
|
||||
|
||||
while (true) {
|
||||
if (timeSpentHooking.DidTimePass()) {
|
||||
spdlog::error("Failed hooking function \"{}\" after 60 seconds", name);
|
||||
break;
|
||||
}
|
||||
if (!pGetOffsetFunc)
|
||||
continue;
|
||||
|
||||
@ -56,6 +62,8 @@ namespace Utils {
|
||||
private:
|
||||
GetTargetOffsetRetType(*pGetOffsetFunc)() = nullptr;
|
||||
OrigType pDetour = nullptr;
|
||||
|
||||
Utils::Time::Timer timeSpentHooking{ 60000 };
|
||||
};
|
||||
template <typename GetTargetOffsetRetType, typename OrigType>
|
||||
class VTHook : HookBase {
|
||||
@ -63,7 +71,13 @@ namespace Utils {
|
||||
VTHook(const std::string_view& name, GetTargetOffsetRetType(*pGetOffsetFunc)(), OrigType pDetour, DWORD offset) : HookBase(name), pGetOffsetFunc(pGetOffsetFunc), pDetour(pDetour), offset(offset) {}
|
||||
|
||||
void HookLoop() override {
|
||||
timeSpentHooking = Utils::Time::Timer(60000);
|
||||
|
||||
while (true) {
|
||||
if (timeSpentHooking.DidTimePass()) {
|
||||
spdlog::error("Failed hooking function \"{}\" after 60 seconds", name);
|
||||
break;
|
||||
}
|
||||
if (!pGetOffsetFunc)
|
||||
continue;
|
||||
|
||||
@ -82,6 +96,8 @@ namespace Utils {
|
||||
LPVOID pInstance = nullptr;
|
||||
OrigType pDetour = nullptr;
|
||||
|
||||
Utils::Time::Timer timeSpentHooking{ 60000 };
|
||||
|
||||
DWORD offset = 0x0;
|
||||
};
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user