Add tool library for Unreal Engine
This commit is contained in:
23
UEngine/UEngine.cpp
Normal file
23
UEngine/UEngine.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
// UEngine.cpp : Defines all Unreal Engine static tools functions
|
||||
//
|
||||
#include <Windows.h>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include "UEngine.hpp"
|
||||
|
||||
std::optional<uint32_t> UE::CalculateOffset(const std::string& exeName, uint8_t* AOBResult)
|
||||
{
|
||||
// Récupère la base du module via GetModuleHandleA
|
||||
HMODULE hModule = GetModuleHandleA(exeName.c_str());
|
||||
if (!hModule || !AOBResult)
|
||||
return std::nullopt;
|
||||
|
||||
uintptr_t baseModule = reinterpret_cast<uintptr_t>(hModule);
|
||||
uintptr_t AOBAbsoluteAdress = reinterpret_cast<uintptr_t>(AOBResult);
|
||||
|
||||
if (AOBAbsoluteAdress < baseModule)
|
||||
return std::nullopt;
|
||||
|
||||
uintptr_t relativeOffset = AOBAbsoluteAdress - baseModule;
|
||||
return static_cast<uint32_t>(relativeOffset);
|
||||
}
|
||||
Reference in New Issue
Block a user