From bfa0c0fdd8d586ad9cfe4a74e0fa2f69a5fa6f88 Mon Sep 17 00:00:00 2001 From: mwilsnd Date: Sun, 30 Oct 2022 01:08:06 -0500 Subject: [PATCH] Fix menu vtable offsets for different game versions --- SmoothCam/include/offset_ids.h | 2 ++ SmoothCam/source/hooks.cpp | 8 ++++---- SmoothCam/source/offset_ids.cpp | 6 ++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/SmoothCam/include/offset_ids.h b/SmoothCam/include/offset_ids.h index 073d7a9..bc1b12d 100644 --- a/SmoothCam/include/offset_ids.h +++ b/SmoothCam/include/offset_ids.h @@ -222,4 +222,6 @@ class Offsets { uintptr_t UpdateGPUCameraData = 0; uintptr_t CBuffer12 = 0; uintptr_t GBuffer = 0; + + uintptr_t menuHookOffset = 0; }; \ No newline at end of file diff --git a/SmoothCam/source/hooks.cpp b/SmoothCam/source/hooks.cpp index 18edab6..b81eade 100644 --- a/SmoothCam/source/hooks.cpp +++ b/SmoothCam/source/hooks.cpp @@ -154,7 +154,7 @@ typedef RE::BSEventNotifyControl(__thiscall* MenuOpenCloseHandler)(uintptr_t pTh static RE::BSEventNotifyControl mMenuOpenCloseHandler(uintptr_t pThis, RE::MenuOpenCloseEvent* ev, RE::BSTEventSource* dispatcher) { - const auto menuOpenCloseHandler = reinterpret_cast(RE::PlayerCharacter::GetSingleton()) + 0x2B0; + const auto menuOpenCloseHandler = reinterpret_cast(RE::PlayerCharacter::GetSingleton()) + g_Offsets->menuHookOffset; if (pThis == menuOpenCloseHandler) { const auto mdmp = Debug::MiniDumpScope(); @@ -191,7 +191,7 @@ typedef RE::BSEventNotifyControl(__thiscall* MenuModeChangeHandler)(uintptr_t pT static RE::BSEventNotifyControl mMenuModeChangeHandler(uintptr_t pThis, MenuModeChangeEvent* ev, RE::BSTEventSource* dispatcher) { - const auto menuModeChangeHandler = reinterpret_cast(RE::PlayerCharacter::GetSingleton()) + 0x2B8; + const auto menuModeChangeHandler = reinterpret_cast(RE::PlayerCharacter::GetSingleton()) + g_Offsets->menuHookOffset + 8; if (pThis == menuModeChangeHandler) { const auto mdmp = Debug::MiniDumpScope(); if (!ev->name.empty()) @@ -360,7 +360,7 @@ bool Hooks::DeferredAttach() { menuOpenCloseHook = eastl::make_unique>( reinterpret_cast( - reinterpret_cast(RE::PlayerCharacter::GetSingleton()) + 0x2B8 + reinterpret_cast(RE::PlayerCharacter::GetSingleton()) + g_Offsets->menuHookOffset ) ); menuOpenCloseHook->Add(1, mMenuOpenCloseHandler); @@ -369,7 +369,7 @@ bool Hooks::DeferredAttach() { menuModeChangeHook = eastl::make_unique>( reinterpret_cast( - reinterpret_cast(RE::PlayerCharacter::GetSingleton()) + 0x2C0 + reinterpret_cast(RE::PlayerCharacter::GetSingleton()) + g_Offsets->menuHookOffset + 8 ) ); menuModeChangeHook->Add(1, mMenuModeChangeHandler); diff --git a/SmoothCam/source/offset_ids.cpp b/SmoothCam/source/offset_ids.cpp index 8869688..2053fe9 100644 --- a/SmoothCam/source/offset_ids.cpp +++ b/SmoothCam/source/offset_ids.cpp @@ -6,6 +6,12 @@ Offsets::Offsets() noexcept { #else populateSE(); #endif + +#if defined(SKYRIM_SUPPORT_AE) && !defined(SKYRIM_IS_PRE629) + menuHookOffset = 0x2B8; +#else + menuHookOffset = 0x2B0; +#endif } #ifdef SKYRIM_SUPPORT_AE