mirror of
https://github.com/EricPlayZ/EGameTools.git
synced 2025-09-20 05:25:57 +08:00
Update Other.cpp
This commit is contained in:
@ -4,57 +4,44 @@
|
|||||||
#include "gen_TPPModel.h"
|
#include "gen_TPPModel.h"
|
||||||
|
|
||||||
namespace GamePH {
|
namespace GamePH {
|
||||||
const std::tuple<uint16_t, uint16_t, uint16_t, uint16_t> GetCurrentGameVersion() {
|
const DWORD GetCurrentGameVersion() {
|
||||||
WCHAR inBuf[MAX_PATH] = { 0 };
|
char exePath[MAX_PATH]{};
|
||||||
GetModuleFileNameW(GetModuleHandleW(nullptr), inBuf, static_cast<DWORD>(std::size(inBuf)));
|
GetModuleFileNameA(GetModuleHandleA(nullptr), exePath, sizeof(exePath));
|
||||||
std::wstring fileStr = inBuf;
|
|
||||||
|
|
||||||
DWORD verHandle;
|
DWORD dummy{};
|
||||||
DWORD verSz = GetFileVersionInfoSizeW(fileStr.data(), &verHandle);
|
DWORD size = GetFileVersionInfoSizeA(exePath, &dummy);
|
||||||
|
if (!size)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (verSz != 0 && verHandle == 0) {
|
std::vector<BYTE> data(size);
|
||||||
|
if (!GetFileVersionInfoA(exePath, 0, size, data.data()))
|
||||||
|
return 0;
|
||||||
|
|
||||||
std::vector<uint8_t> verData(verSz);
|
VS_FIXEDFILEINFO* fileInfo = nullptr;
|
||||||
|
UINT fileInfoSize = 0;
|
||||||
|
if (!VerQueryValueA(data.data(), "\\", reinterpret_cast<void**>(&fileInfo), &fileInfoSize))
|
||||||
|
return 0;
|
||||||
|
if (fileInfo == nullptr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (GetFileVersionInfoW(fileStr.data(), verHandle, verSz, verData.data())) {
|
const DWORD major = HIWORD(fileInfo->dwFileVersionMS);
|
||||||
|
const DWORD minor = LOWORD(fileInfo->dwFileVersionMS);
|
||||||
|
const DWORD patch = HIWORD(fileInfo->dwFileVersionLS);
|
||||||
|
|
||||||
LPVOID buffer;
|
return major * 10000 + minor * 100 + patch;
|
||||||
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 };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
const std::string GameVerToStr(DWORD version) {
|
||||||
|
DWORD major = version / 10000;
|
||||||
|
DWORD minor = (version / 100) % 100;
|
||||||
|
DWORD patch = version % 100;
|
||||||
|
|
||||||
return { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF };
|
return std::string(std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(patch));
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string GetCurrentGameVersionStr() {
|
const std::string GetCurrentGameVersionStr() {
|
||||||
auto [major, minor, build, revision] = GetCurrentGameVersion();
|
if (!GetCurrentGameVersion())
|
||||||
|
|
||||||
if (major == 0xFFFF || minor == 0xFFFF || build == 0xFFFF || revision == 0xFFFF)
|
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
|
|
||||||
return std::string(std::to_string(major) + std::to_string(minor) + std::to_string(build) + std::to_string(revision));
|
return GameVerToStr(GetCurrentGameVersion());
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
||||||
|
Reference in New Issue
Block a user