mirror of
https://github.com/EricPlayZ/EGameTools.git
synced 2025-09-20 13:35:58 +08:00
dynamically fetch game version instead of using a pattern for it
- use win api for getting game version & remove memory scanning dependency for it - could be useful for maintaining compatibility across different game versions
This commit is contained in:
@ -262,7 +262,7 @@
|
|||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableUAC>false</EnableUAC>
|
<EnableUAC>false</EnableUAC>
|
||||||
<AdditionalDependencies>DbgHelp.lib;spdlog-mtd.lib;freetype-mtd.lib;libMinHook-x64-v141-mtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>DbgHelp.lib;Version.lib;spdlog-mtd.lib;freetype-mtd.lib;libMinHook-x64-v141-mtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<OptimizeReferences>
|
<OptimizeReferences>
|
||||||
</OptimizeReferences>
|
</OptimizeReferences>
|
||||||
<EnableCOMDATFolding>
|
<EnableCOMDATFolding>
|
||||||
@ -298,7 +298,7 @@
|
|||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
<EnableUAC>false</EnableUAC>
|
<EnableUAC>false</EnableUAC>
|
||||||
<AdditionalLibraryDirectories>source\spdlog\lib;source\ImGui\freetype\lib;source\MinHook\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>source\spdlog\lib;source\ImGui\freetype\lib;source\MinHook\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>DbgHelp.lib;spdlog-mt.lib;freetype-mt.lib;libMinHook-x64-v141-mtd.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>DbgHelp.lib;Version.lib;spdlog-mt.lib;freetype-mt.lib;libMinHook-x64-v141-mtd.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<ImportLibrary />
|
<ImportLibrary />
|
||||||
<AdditionalOptions>/NOIMPLIB /NOEXP %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/NOIMPLIB /NOEXP %(AdditionalOptions)</AdditionalOptions>
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -159,14 +159,23 @@ namespace Core {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD64 gameVer = 0;
|
uint16_t gameVer = 0;
|
||||||
static void LoopGetGameVer() {
|
static void LoopGetGameVer() {
|
||||||
|
|
||||||
|
auto str = GamePH::GetCurrentGameVersionStr();
|
||||||
|
auto end = str.c_str() + std::char_traits<char>::length(str.c_str());
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (exiting)
|
if (exiting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gameVer = GamePH::GetCurrentGameVersion();
|
uint16_t value;
|
||||||
if (!gameVer)
|
std::from_chars(str.c_str(), end, value);
|
||||||
|
|
||||||
|
if(value!=0)
|
||||||
|
gameVer = value;
|
||||||
|
|
||||||
|
if (gameVer == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
#define VK_MWHEELUP 0x101
|
#define VK_MWHEELUP 0x101
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
constexpr auto MOD_VERSION_STR = "v1.1.3";
|
constexpr auto MOD_VERSION_STR = "v1.1.2";
|
||||||
constexpr auto MOD_VERSION = 10103;
|
constexpr auto MOD_VERSION = 10102;
|
||||||
constexpr auto GAME_VER_COMPAT = 11504;
|
constexpr uint16_t GAME_VER_COMPAT = 11530;
|
||||||
|
|
||||||
struct Key {
|
struct Key {
|
||||||
constexpr Key(std::string_view name, int code, ImGuiKey imGuiCode) : name(name), code(code), imGuiCode(imGuiCode) {}
|
constexpr Key(std::string_view name, int code, ImGuiKey imGuiCode) : name(name), code(code), imGuiCode(imGuiCode) {}
|
||||||
@ -227,6 +227,6 @@ namespace Core {
|
|||||||
extern bool exiting;
|
extern bool exiting;
|
||||||
|
|
||||||
extern int rendererAPI;
|
extern int rendererAPI;
|
||||||
extern DWORD64 gameVer;
|
extern uint16_t gameVer;
|
||||||
extern void OnPostUpdate();
|
extern void OnPostUpdate();
|
||||||
}
|
}
|
@ -4,25 +4,57 @@
|
|||||||
#include "gen_TPPModel.h"
|
#include "gen_TPPModel.h"
|
||||||
|
|
||||||
namespace GamePH {
|
namespace GamePH {
|
||||||
const DWORD64 GetCurrentGameVersion() {
|
const std::tuple<uint16_t, uint16_t, uint16_t, uint16_t> GetCurrentGameVersion() {
|
||||||
DWORD64(*pGetCurrentGameVersion)() = (decltype(pGetCurrentGameVersion))Offsets::Get_GetCurrentGameVersion();
|
WCHAR inBuf[MAX_PATH] = { 0 };
|
||||||
if (!pGetCurrentGameVersion)
|
GetModuleFileNameW(GetModuleHandleW(nullptr), inBuf, static_cast<DWORD>(std::size(inBuf)));
|
||||||
return 0;
|
std::wstring fileStr = inBuf;
|
||||||
|
|
||||||
return pGetCurrentGameVersion();
|
DWORD verHandle;
|
||||||
}
|
DWORD verSz = GetFileVersionInfoSizeW(fileStr.data(), &verHandle);
|
||||||
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));
|
if (verSz != 0 && verHandle == 0) {
|
||||||
|
|
||||||
|
std::vector<uint8_t> verData(verSz);
|
||||||
|
|
||||||
|
if (GetFileVersionInfoW(fileStr.data(), verHandle, verSz, verData.data())) {
|
||||||
|
|
||||||
|
LPVOID buffer;
|
||||||
|
UINT bufferLength;
|
||||||
|
|
||||||
|
if (VerQueryValueW(verData.data(), L"\\", &buffer, &bufferLength) && bufferLength != 0) {
|
||||||
|
|
||||||
|
VS_FIXEDFILEINFO* verInfo = reinterpret_cast<VS_FIXEDFILEINFO*>(buffer);
|
||||||
|
|
||||||
|
if (verInfo->dwSignature == 0xFEEF04BD) {
|
||||||
|
const auto major = (verInfo->dwFileVersionMS >> 16) & 0xFFFF;
|
||||||
|
const auto minor = verInfo->dwFileVersionMS & 0xFFFF;
|
||||||
|
const auto build = (verInfo->dwFileVersionLS >> 16) & 0xFFFF;
|
||||||
|
const auto revision = verInfo->dwFileVersionLS & 0xFFFF;
|
||||||
|
return { major, minor, build, revision };
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF };
|
||||||
|
}
|
||||||
|
|
||||||
const std::string GetCurrentGameVersionStr() {
|
const std::string GetCurrentGameVersionStr() {
|
||||||
if (!GetCurrentGameVersion())
|
auto [major, minor, build, revision] = GetCurrentGameVersion();
|
||||||
|
|
||||||
|
if (major == 0xFFFF || minor == 0xFFFF || build == 0xFFFF || revision == 0xFFFF)
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
|
|
||||||
return GameVerToStr(GetCurrentGameVersion());
|
return std::string(std::to_string(major) + std::to_string(minor) + std::to_string(build) + std::to_string(revision));
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string GameVerToStr(uint16_t version) {
|
||||||
|
uint16_t major = version / 10000;
|
||||||
|
uint16_t minor = (version / 100) % 100;
|
||||||
|
uint16_t build = (version / 10) % 10;
|
||||||
|
uint16_t revision = version % 10;
|
||||||
|
|
||||||
|
return std::string(std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(build) + "." + std::to_string(revision));
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD64 ShowTPPModelFunc2(GameDI_PH* pGameDI_PH) {
|
static DWORD64 ShowTPPModelFunc2(GameDI_PH* pGameDI_PH) {
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
#include <basetsd.h>
|
#include <basetsd.h>
|
||||||
|
|
||||||
namespace GamePH {
|
namespace GamePH {
|
||||||
extern const DWORD64 GetCurrentGameVersion();
|
extern const std::tuple<uint16_t, uint16_t, uint16_t, uint16_t> GetCurrentGameVersion();
|
||||||
extern const std::string GameVerToStr(DWORD64 version);
|
|
||||||
extern const std::string GetCurrentGameVersionStr();
|
extern const std::string GetCurrentGameVersionStr();
|
||||||
|
extern const std::string GameVerToStr(uint16_t version);
|
||||||
extern void ShowTPPModel(bool showTPPModel);
|
extern void ShowTPPModel(bool showTPPModel);
|
||||||
extern bool ReloadJumps();
|
extern bool ReloadJumps();
|
||||||
}
|
}
|
@ -50,7 +50,6 @@ struct Offsets {
|
|||||||
// Functions
|
// Functions
|
||||||
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(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(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(GetCurrentGameVersion, "gamedll_ph_x64_rwdi.dll", "B8 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC CC CC 48 83 79", 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(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(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(GetViewCamera, "engine_x64_rwdi.dll", "E8 [?? ?? ?? ?? 48 85 C0 74 28 48 8B C8", PatternType::RelativePointer, LPVOID)
|
||||||
|
Reference in New Issue
Block a user