Unnecessary hook removal. Update offset for console enabling
This commit is contained in:
@@ -21,6 +21,7 @@ std::shared_ptr<spdlog::logger> logger;
|
|||||||
|
|
||||||
// Plugin states
|
// Plugin states
|
||||||
static bool AOBScanDone = false;
|
static bool AOBScanDone = false;
|
||||||
|
static bool g_Console = false;
|
||||||
static bool g_fix_enabled = false;
|
static bool g_fix_enabled = false;
|
||||||
static bool g_fov_fix_enabled = false;
|
static bool g_fov_fix_enabled = false;
|
||||||
static bool g_ultrawide_fix_enabled = false;
|
static bool g_ultrawide_fix_enabled = false;
|
||||||
@@ -39,7 +40,6 @@ static bool g_Console_Enabled = false;
|
|||||||
|
|
||||||
// AOB Unreal Engine offsets addresses
|
// AOB Unreal Engine offsets addresses
|
||||||
static uint8_t* GObjectsaddress = nullptr;
|
static uint8_t* GObjectsaddress = nullptr;
|
||||||
static uint8_t* GNamesaddress = nullptr;
|
|
||||||
static uint8_t* AppendStringaddress = nullptr;
|
static uint8_t* AppendStringaddress = nullptr;
|
||||||
static uint8_t* ProcessEventaddress = nullptr;
|
static uint8_t* ProcessEventaddress = nullptr;
|
||||||
|
|
||||||
@@ -57,9 +57,7 @@ static uint8_t* AspectRatioAxisConstraintaddress = nullptr;
|
|||||||
|
|
||||||
// Hooking
|
// Hooking
|
||||||
static SafetyHookMid FOVHook{};
|
static SafetyHookMid FOVHook{};
|
||||||
static SafetyHookMid CameraHook{};
|
|
||||||
static SafetyHookMid FogHook{};
|
static SafetyHookMid FogHook{};
|
||||||
static SafetyHookMid ProcessEventHook{};
|
|
||||||
|
|
||||||
// Prototypes
|
// Prototypes
|
||||||
static void FOVFixEnabled();
|
static void FOVFixEnabled();
|
||||||
@@ -157,14 +155,14 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
|||||||
AOBScanDone = true;
|
AOBScanDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GObjectsaddress || !GNamesaddress || !AppendStringaddress || !ProcessEventaddress) {
|
if (!GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
|
||||||
logger->info("------------ UEngine offsets search ------------");
|
logger->info("------------ UEngine offsets search ------------");
|
||||||
uint8_t* baseModule = reinterpret_cast<uint8_t*>(GetModuleHandleA(nullptr)); // Get game base address
|
uint8_t* baseModule = reinterpret_cast<uint8_t*>(GetModuleHandleA(nullptr)); // Get game base address
|
||||||
|
|
||||||
constexpr auto GObjetcsStringObfuscated = make_obfuscated<0x4A>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33");
|
constexpr auto GObjetcsStringObfuscated = make_obfuscated<0x4A>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33");
|
||||||
GObjectsaddress = Memory::AOBScan("", GObjetcsStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
GObjectsaddress = Memory::AOBScan("", GObjetcsStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||||
constexpr auto GNamesStringObfuscated = make_obfuscated<0x4A>("48 8D ?? ?? ?? ?? ?? EB ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? C6 05 ?? ?? ?? ?? ?? 0F ?? ?? 4C");
|
constexpr auto AppendStringStringObfuscated = make_obfuscated<0x4A>("48 89 ?? ?? ?? 48 89 ?? ?? ?? 57 48 83 ?? ?? 80 3D ?? ?? ?? ?? ?? 48 ?? F2 8B ?? 48 ?? ?? 74 ?? 4C 8D ?? ?? ?? ?? ?? EB ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? 4C");
|
||||||
GNamesaddress = Memory::AOBScan("", GNamesStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
AppendStringaddress = Memory::AOBScan("", AppendStringStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||||
constexpr auto ProcessEventStringObfuscated = make_obfuscated<0x4A>("40 ?? 56 57 41 ?? 41 ?? 41 ?? 41 ?? 48 81 ?? ?? ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 ?? ?? 48 89 ?? ?? ?? ?? ?? 4D 8B");
|
constexpr auto ProcessEventStringObfuscated = make_obfuscated<0x4A>("40 ?? 56 57 41 ?? 41 ?? 41 ?? 41 ?? 48 81 ?? ?? ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 ?? ?? 48 89 ?? ?? ?? ?? ?? 4D 8B");
|
||||||
ProcessEventaddress = Memory::AOBScan("", ProcessEventStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
ProcessEventaddress = Memory::AOBScan("", ProcessEventStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||||
|
|
||||||
@@ -176,12 +174,13 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
|||||||
Offsets::GObjects = static_cast<UC::uint32>(gObjectsOffset); // Update GObjects offset
|
Offsets::GObjects = static_cast<UC::uint32>(gObjectsOffset); // Update GObjects offset
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GNamesaddress)
|
if (!AppendStringaddress)
|
||||||
logger->warn("GNames signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
logger->warn("AppendString signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
||||||
else {
|
else {
|
||||||
uint32_t gNamesOffset = static_cast<uint32_t>(Memory::GetOffsetFromOpcode(GNamesaddress + 0x3) - baseModule);
|
std::optional<uint32_t> gAppendStringOffsetOpt = UE::CalculateOffset("", AppendStringaddress);
|
||||||
logger->info("GNames offset is: 0x{:X}.", gNamesOffset);
|
uint32_t gAppendStringOffset = *gAppendStringOffsetOpt;
|
||||||
Offsets::GNames = static_cast<UC::uint32>(gNamesOffset); // Update GNames offset
|
logger->info("AppendString offset is: 0x{:X}.", gAppendStringOffset);
|
||||||
|
Offsets::AppendString = static_cast<UC::uint32>(gAppendStringOffset);// Update AppendString
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ProcessEventaddress)
|
if (!ProcessEventaddress)
|
||||||
@@ -208,7 +207,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
|||||||
// Setters for Reshade addon call
|
// Setters for Reshade addon call
|
||||||
extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enabled)
|
extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enabled)
|
||||||
{ // Set each fix individually
|
{ // Set each fix individually
|
||||||
if (fix == GameFixes::DevConsole) EnableConsole();
|
if (fix == GameFixes::DevConsole) { g_Console = enabled; EnableConsole(); }
|
||||||
if (fix == GameFixes::FOV) { g_fov_fix_enabled = enabled; FOVFixEnabled(); }
|
if (fix == GameFixes::FOV) { g_fov_fix_enabled = enabled; FOVFixEnabled(); }
|
||||||
if (fix == GameFixes::UltraWide) { g_ultrawide_fix_enabled = enabled; UltraWideFixEnabled(); }
|
if (fix == GameFixes::UltraWide) { g_ultrawide_fix_enabled = enabled; UltraWideFixEnabled(); }
|
||||||
if (fix == GameFixes::DOF) { g_DOF_fix_enabled = enabled; DOFFixEnabled(); }
|
if (fix == GameFixes::DOF) { g_DOF_fix_enabled = enabled; DOFFixEnabled(); }
|
||||||
@@ -330,8 +329,13 @@ static void VolumetricFogFixEnabled() {
|
|||||||
// UE Console creation
|
// UE Console creation
|
||||||
static void EnableConsole()
|
static void EnableConsole()
|
||||||
{
|
{
|
||||||
|
if (!g_Console) {
|
||||||
|
logger->info("------------------ User inputs ------------------");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
logger->info("-------------- Console re-enabling --------------");
|
logger->info("-------------- Console re-enabling --------------");
|
||||||
if (!GObjectsaddress || !GNamesaddress || !ProcessEventaddress) {
|
if (!GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
|
||||||
logger->warn("Could not re-enable console");
|
logger->warn("Could not re-enable console");
|
||||||
logger->info("------------------ User inputs ------------------");
|
logger->info("------------------ User inputs ------------------");
|
||||||
return;
|
return;
|
||||||
@@ -370,14 +374,13 @@ static void EnableConsole()
|
|||||||
UInputSettings::GetDefaultObj()->ConsoleKeys[i].KeyName = UKismetStringLibrary::Conv_StringToName(L"F2");
|
UInputSettings::GetDefaultObj()->ConsoleKeys[i].KeyName = UKismetStringLibrary::Conv_StringToName(L"F2");
|
||||||
}
|
}
|
||||||
logger->info("Console fully reactivated in {:.3f}s and bound to key F2", elapsed.count());
|
logger->info("Console fully reactivated in {:.3f}s and bound to key F2", elapsed.count());
|
||||||
logger->info("------------------ User inputs ------------------");
|
|
||||||
|
|
||||||
g_Console_Enabled = true;
|
g_Console_Enabled = true;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
logger->error("Could not spawn console object");
|
logger->error("Could not spawn console object");
|
||||||
}
|
|
||||||
}).detach();
|
logger->info("------------------ User inputs ------------------");
|
||||||
|
}).detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InitializeLogger()
|
static void InitializeLogger()
|
||||||
|
|||||||
Reference in New Issue
Block a user