aboutsummaryrefslogtreecommitdiff
path: root/primedev/client/clientvideooverrides.cpp
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2024-08-27 22:13:35 +0100
committerGitHub <noreply@github.com>2024-08-27 23:13:35 +0200
commit3a930e481a66a50274e174f9b71135da36eacb95 (patch)
treee54344b0c9e7c5cded1c28613d21909a0781bd8a /primedev/client/clientvideooverrides.cpp
parentaec239ddd75aa37a5ca75f1006d956d65cbfc7a3 (diff)
downloadNorthstarLauncher-3a930e481a66a50274e174f9b71135da36eacb95.tar.gz
NorthstarLauncher-3a930e481a66a50274e174f9b71135da36eacb95.zip
Remove uses of Autohook from `clientvideooverrides.cpp` (#784)
Run callbacks for nested modules, and prevent running callbacks multiple times for the same module. Manually hook BinkOpen Remove AUTOHOOK_INIT and AUTOHOOK_DISPATCH
Diffstat (limited to 'primedev/client/clientvideooverrides.cpp')
-rw-r--r--primedev/client/clientvideooverrides.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/primedev/client/clientvideooverrides.cpp b/primedev/client/clientvideooverrides.cpp
index d8aa2754..54bb6469 100644
--- a/primedev/client/clientvideooverrides.cpp
+++ b/primedev/client/clientvideooverrides.cpp
@@ -1,11 +1,7 @@
#include "mods/modmanager.h"
-AUTOHOOK_INIT()
-
-// clang-format off
-AUTOHOOK_PROCADDRESS(BinkOpen, bink2w64.dll, BinkOpen,
-void*, __fastcall, (const char* path, uint32_t flags))
-// clang-format on
+static void* (*__fastcall o_pBinkOpen)(const char* path, uint32_t flags) = nullptr;
+static void* __fastcall h_BinkOpen(const char* path, uint32_t flags)
{
std::string filename(fs::path(path).filename().string());
spdlog::info("BinkOpen {}", filename);
@@ -25,16 +21,20 @@ void*, __fastcall, (const char* path, uint32_t flags))
{
// create new path
fs::path binkPath(fileOwner->m_ModDirectory / "media" / filename);
- return BinkOpen(binkPath.string().c_str(), flags);
+ return o_pBinkOpen(binkPath.string().c_str(), flags);
}
else
- return BinkOpen(path, flags);
+ return o_pBinkOpen(path, flags);
}
-ON_DLL_LOAD_CLIENT("engine.dll", BinkVideo, (CModule module))
+ON_DLL_LOAD_CLIENT("bink2w64.dll", BinkRead, (CModule module))
{
- AUTOHOOK_DISPATCH()
+ o_pBinkOpen = module.GetExportedFunction("BinkOpen").RCast<decltype(o_pBinkOpen)>();
+ HookAttach(&(PVOID&)o_pBinkOpen, (PVOID)h_BinkOpen);
+}
+ON_DLL_LOAD_CLIENT("engine.dll", BinkVideo, (CModule module))
+{
// remove engine check for whether the bik we're trying to load exists in r2/media, as this will fail for biks in mods
// note: the check in engine is actually unnecessary, so it's just useless in practice and we lose nothing by removing it
module.Offset(0x459AD).NOP(6);