Add a fallback to retrieve game base module

This commit is contained in:
2025-10-10 14:34:32 +02:00
parent 384379ead4
commit cf03aab0bc

View File

@@ -3,15 +3,20 @@
#include <Windows.h> #include <Windows.h>
#include <string> #include <string>
#include <optional> #include <optional>
#include <sstream>
#include <iomanip>
#include "UEngine.hpp" #include "UEngine.hpp"
std::optional<uint32_t> UE::CalculateOffset(const std::string& exeName, uint8_t* AOBResult) std::optional<uint32_t> UE::CalculateOffset(const std::string& exeName, uint8_t* AOBResult)
{ {
// Récupère la base du module via GetModuleHandleA // Récupère la base du module via GetModuleHandleA
HMODULE hModule = GetModuleHandleA(exeName.c_str()); HMODULE hModule = GetModuleHandleA(exeName.c_str());
if (!hModule || !AOBResult) if (!AOBResult)
return std::nullopt; return std::nullopt;
if (!hModule)
hModule = GetModuleHandleA(nullptr);
uintptr_t baseModule = reinterpret_cast<uintptr_t>(hModule); uintptr_t baseModule = reinterpret_cast<uintptr_t>(hModule);
uintptr_t AOBAbsoluteAdress = reinterpret_cast<uintptr_t>(AOBResult); uintptr_t AOBAbsoluteAdress = reinterpret_cast<uintptr_t>(AOBResult);