mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-08-25 15:46:45 +00:00
Prevent circular hooks
This commit is contained in:
@@ -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,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);
|
||||
|
||||
@@ -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,6 +3,9 @@
|
||||
|
||||
class DxgiHooks
|
||||
{
|
||||
private:
|
||||
static inline std::mutex hookMutex;
|
||||
|
||||
public:
|
||||
static void Hook();
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user