Prevent circular hooks

This commit is contained in:
cdozdil
2026-02-14 00:02:46 +03:00
parent 0c012529f7
commit 0ebebbf4d5
6 changed files with 24 additions and 0 deletions
+4
View File
@@ -963,6 +963,8 @@ static void UnhookDevice()
void D3D12Hooks::Hook()
{
std::lock_guard<std::mutex> lock(hookMutex);
if (o_D3D12CreateDevice != nullptr)
return;
@@ -976,6 +978,8 @@ void D3D12Hooks::Hook()
void D3D12Hooks::HookAgility(HMODULE module)
{
std::lock_guard<std::mutex> lock(agilityMutex);
if (module == nullptr || o_D3D12GetInterface != nullptr)
return;
+4
View File
@@ -4,6 +4,10 @@
class D3D12Hooks
{
private:
inline static std::mutex hookMutex;
inline static std::mutex agilityMutex;
public:
static void Hook();
static void HookAgility(HMODULE module);
+2
View File
@@ -300,6 +300,8 @@ inline static HRESULT hkCreateDXGIFactory2(UINT Flags, REFIID riid, IDXGIFactory
void DxgiHooks::Hook()
{
std::lock_guard<std::mutex> lock(hookMutex);
// If not spoofing and
// using no frame generation (or Nukem's) and
// not using DXGI spoofing we don't need DXGI hooks
+3
View File
@@ -3,6 +3,9 @@
class DxgiHooks
{
private:
static inline std::mutex hookMutex;
public:
static void Hook();
};
+7
View File
@@ -55,9 +55,14 @@ class KernelHooks
static HMODULE hk_KB_LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
static BOOL hk_K32_FreeLibrary(HMODULE lpLibrary);
static inline std::mutex hookMutex32;
static inline std::mutex hookMutexBase;
public:
static void Hook()
{
std::lock_guard<std::mutex> lock(hookMutex32);
if (o_K32_FreeLibrary != nullptr)
return;
@@ -81,6 +86,8 @@ class KernelHooks
static void HookBase()
{
std::lock_guard<std::mutex> lock(hookMutexBase);
if (o_KB_GetProcAddress != nullptr)
return;
+4
View File
@@ -14,6 +14,8 @@
class NtdllHooks
{
private:
inline static std::mutex hookMutex;
inline static NtdllProxy::PFN_NtLoadDll o_NtLoadDll = nullptr;
inline static NtdllProxy::PFN_LdrLoadDll o_LdrLoadDll = nullptr;
inline static NtdllProxy::PFN_LdrUnloadDll o_LdrUnloadDll = nullptr;
@@ -159,6 +161,8 @@ class NtdllHooks
public:
static void Hook()
{
std::lock_guard lock(hookMutex);
LOG_FUNC();
if (!Config::Instance()->UseNtdllHooks.value_or_default())