This commit is contained in:
cdozdil
2025-04-12 21:11:42 +03:00
parent e77283df63
commit 4cd9eb769f
12 changed files with 190 additions and 80 deletions
+2 -2
View File
@@ -197,9 +197,9 @@ struct AmdExtFfxApi : public IAmdExtFfxApi
if (pfnUpdateFfxApiProvider != nullptr)
{
State::DisableChecks();
State::DisableChecks(1);
auto result = pfnUpdateFfxApiProvider(pData, dataSizeInBytes);
State::EnableChecks();
State::EnableChecks(1);
return result;
}
+8 -2
View File
@@ -49,13 +49,19 @@ static bool InitializeConsole()
// Make C++ standard streams point to console as well.
std::ios::sync_with_stdio();
WaitForEnter();
return true;
}
void WaitForEnter()
{
if (Config::Instance()->DebugWait.value_or_default())
{
std::cout << "Press ENTER to continue..." << std::endl;
std::cin.get();
}
return true;
}
void PrepareLogger()
+1
View File
@@ -4,6 +4,7 @@
void PrepareLogger();
void CloseLogger();
void WaitForEnter();
#ifdef DLSS_PARAM_DUMP
+3 -3
View File
@@ -199,7 +199,7 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>libMinHook.x64.lib;WindowsApp.lib;Dbghelp.lib;dxgi.lib;d3d11.lib;d3d12.lib;vulkan-1.lib;dxguid.lib;freetype.lib;ffx_fsr2_api_x64d.lib;ffx_fsr2_api_dx11_x64d.lib;ffx_fsr2_api_dx12_x64d.lib;ffx_fsr2_api_vk_x64d.lib;ffx_fsr2_212_api_dx12_x64d.lib;ffx_fsr2_212_api_vk_x64d.lib;ffx_fsr2_212_api_x64d.lib;d3dcompiler.lib;d3dx11.lib;ffx_backend_dx11_x64d.lib;ffx_fsr3_x64d.lib;ffx_fsr3upscaler_x64d.lib;ffx_opticalflow_x64d.lib;ffx_frameinterpolation_x64d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>WindowsApp.lib;Dbghelp.lib;dxgi.lib;d3d11.lib;d3d12.lib;vulkan-1.lib;dxguid.lib;freetype.lib;ffx_fsr2_api_x64d.lib;ffx_fsr2_api_dx11_x64d.lib;ffx_fsr2_api_dx12_x64d.lib;ffx_fsr2_api_vk_x64d.lib;ffx_fsr2_212_api_dx12_x64d.lib;ffx_fsr2_212_api_vk_x64d.lib;ffx_fsr2_212_api_x64d.lib;d3dcompiler.lib;d3dx11.lib;ffx_backend_dx11_x64d.lib;ffx_fsr3_x64d.lib;ffx_fsr3upscaler_x64d.lib;ffx_opticalflow_x64d.lib;ffx_frameinterpolation_x64d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>Source.def</ModuleDefinitionFile>
<DelayLoadDLLs>vulkan-1.dll;dxgi.dll;d3d12.dll;D3DCOMPILER_47.dll;Dbghelp.dll</DelayLoadDLLs>
<StackReserveSize>
@@ -236,7 +236,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>libMinHook.x64.lib;WindowsApp.lib;Dbghelp.lib;dxgi.lib;d3d11.lib;d3d12.lib;vulkan-1.lib;dxguid.lib;freetype.lib;ffx_fsr2_api_x64.lib;ffx_fsr2_api_dx11_x64.lib;ffx_fsr2_api_dx12_x64.lib;ffx_fsr2_api_vk_x64.lib;ffx_fsr2_212_api_dx12_x64.lib;ffx_fsr2_212_api_vk_x64.lib;ffx_fsr2_212_api_x64.lib;d3dcompiler.lib;ffx_backend_dx11_x64.lib;ffx_fsr3_x64.lib;ffx_frameinterpolation_x64.lib;ffx_fsr3upscaler_x64.lib;ffx_opticalflow_x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>WindowsApp.lib;Dbghelp.lib;dxgi.lib;d3d11.lib;d3d12.lib;vulkan-1.lib;dxguid.lib;freetype.lib;ffx_fsr2_api_x64.lib;ffx_fsr2_api_dx11_x64.lib;ffx_fsr2_api_dx12_x64.lib;ffx_fsr2_api_vk_x64.lib;ffx_fsr2_212_api_dx12_x64.lib;ffx_fsr2_212_api_vk_x64.lib;ffx_fsr2_212_api_x64.lib;d3dcompiler.lib;ffx_backend_dx11_x64.lib;ffx_fsr3_x64.lib;ffx_frameinterpolation_x64.lib;ffx_fsr3upscaler_x64.lib;ffx_opticalflow_x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<ModuleDefinitionFile>Source.def</ModuleDefinitionFile>
<DelayLoadDLLs>vulkan-1.dll;dxgi.dll;d3d12.dll;D3DCOMPILER_47.dll;Dbghelp.dll</DelayLoadDLLs>
@@ -286,7 +286,7 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" /Y
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>libMinHook.x64.lib;WindowsApp.lib;Dbghelp.lib;dxgi.lib;d3d11.lib;d3d12.lib;vulkan-1.lib;dxguid.lib;freetype.lib;ffx_fsr2_api_x64.lib;ffx_fsr2_api_dx11_x64.lib;ffx_fsr2_api_dx12_x64.lib;ffx_fsr2_api_vk_x64.lib;ffx_fsr2_212_api_dx12_x64.lib;ffx_fsr2_212_api_vk_x64.lib;ffx_fsr2_212_api_x64.lib;d3dcompiler.lib;ffx_backend_dx11_x64.lib;ffx_fsr3_x64.lib;ffx_frameinterpolation_x64.lib;ffx_fsr3upscaler_x64.lib;ffx_opticalflow_x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>WindowsApp.lib;Dbghelp.lib;dxgi.lib;d3d11.lib;d3d12.lib;vulkan-1.lib;dxguid.lib;freetype.lib;ffx_fsr2_api_x64.lib;ffx_fsr2_api_dx11_x64.lib;ffx_fsr2_api_dx12_x64.lib;ffx_fsr2_api_vk_x64.lib;ffx_fsr2_212_api_dx12_x64.lib;ffx_fsr2_212_api_vk_x64.lib;ffx_fsr2_212_api_x64.lib;d3dcompiler.lib;ffx_backend_dx11_x64.lib;ffx_fsr3_x64.lib;ffx_frameinterpolation_x64.lib;ffx_fsr3upscaler_x64.lib;ffx_opticalflow_x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<ModuleDefinitionFile>Source.def</ModuleDefinitionFile>
<DelayLoadDLLs>vulkan-1.dll;dxgi.dll;d3d12.dll;D3DCOMPILER_47.dll;Dbghelp.dll</DelayLoadDLLs>
+19 -6
View File
@@ -168,16 +168,28 @@ public:
/// Enables skipping of LoadLibrary checks
/// </summary>
/// <param name="dllName">Lower case dll name without `.dll` at the end. Leave blank for skipping all dll's</param>
static void DisableChecks(std::string dllName = "")
static void DisableChecks(UINT owner, std::string dllName = "")
{
_skipChecks = true;
_skipDllName = dllName;
if (_skipOwner == 0)
{
_skipOwner = owner;
_skipChecks = true;
_skipDllName = dllName;
}
else
{
_skipDllName = ""; // Hack for multiple skip calls
}
};
static void EnableChecks()
static void EnableChecks(UINT owner)
{
_skipChecks = false;
_skipDllName = "";
if (_skipOwner == 0 || _skipOwner == owner)
{
_skipChecks = false;
_skipDllName = "";
_skipOwner = 0;
}
};
static bool SkipDllChecks() { return _skipChecks; }
@@ -187,6 +199,7 @@ public:
private:
inline static bool _skipChecks = false;
inline static std::string _skipDllName = "";
inline static UINT _skipOwner = 0;
State() = default;
};
+7 -7
View File
@@ -29,8 +29,6 @@
#include <nvapi/NvApiHooks.h>
#include <minhook/minhook.h>
#pragma warning (disable : 4996)
typedef const char* (CDECL* PFN_wine_get_version)(void);
@@ -97,10 +95,6 @@ static void CheckWorkingMode()
break;
}
// Hook kernel32 & kernelbase methods
InitFSR4Update();
KernelHooks::Hook();
// version.dll
if (lCaseFilename == "version.dll")
{
@@ -496,12 +490,13 @@ static void CheckWorkingMode()
if (!State::Instance().enablerAvailable && Config::Instance()->DxgiSpoofing.value_or_default())
HookDxgiForSpoofing();
if (Config::Instance()->OverlayMenu.value())
if (Config::Instance()->OverlayMenu.value())
HooksDx::HookDxgi();
}
}
else
{
LOG_DEBUG("dxgi.dll already in memory");
if (!State::Instance().enablerAvailable && Config::Instance()->DxgiSpoofing.value_or_default())
HookDxgiForSpoofing();
@@ -523,6 +518,7 @@ static void CheckWorkingMode()
}
else
{
LOG_DEBUG("d3d12.dll already in memory");
HooksDx::HookDx12();
}
@@ -557,6 +553,10 @@ static void CheckWorkingMode()
if (Config::Instance()->OverlayMenu.value() && vulkanModule != nullptr)
HooksVk::HookVk(vulkanModule);
// Hook kernel32 & kernelbase methods
InitFSR4Update();
KernelHooks::Hook();
// NVAPI
HMODULE nvapi64 = nullptr;
nvapi64 = KernelBaseProxy::GetModuleHandleW_()(L"nvapi64.dll");
+4 -4
View File
@@ -49,12 +49,12 @@ struct dxgi_dll
HRESULT _CreateDXGIFactory(REFIID riid, IDXGIFactory** ppFactory)
{
return DxgiProxy::CreateDxgiFactory_Hooked()(riid, ppFactory);
return DxgiProxy::CreateDxgiFactory_()(riid, ppFactory);
}
HRESULT _CreateDXGIFactory1(REFIID riid, IDXGIFactory1** ppFactory)
{
return DxgiProxy::CreateDxgiFactory1_Hooked()(riid, ppFactory);
return DxgiProxy::CreateDxgiFactory1_()(riid, ppFactory);
}
HRESULT _CreateDXGIFactory2(UINT Flags, REFIID riid, IDXGIFactory2** ppFactory)
@@ -64,12 +64,12 @@ HRESULT _CreateDXGIFactory2(UINT Flags, REFIID riid, IDXGIFactory2** ppFactory)
HRESULT _DXGIDeclareAdapterRemovalSupport()
{
return DxgiProxy::DeclareAdepterRemovalSupport_Hooked()();
return DxgiProxy::DeclareAdepterRemovalSupport_()();
}
HRESULT _DXGIGetDebugInterface1(UINT Flags, REFIID riid, void** pDebug)
{
return DxgiProxy::GetDebugInterface_Hooked()(Flags, riid, pDebug);
return DxgiProxy::GetDebugInterface_()(Flags, riid, pDebug);
}
void _ApplyCompatResolutionQuirking()
+35 -24
View File
@@ -2317,6 +2317,8 @@ static void CheckAdapter(IUnknown* unkAdapter)
static void AttachToFactory(IUnknown* unkFactory)
{
return;
PVOID* pVTable = *(PVOID**)unkFactory;
IDXGIFactory* factory;
@@ -3229,17 +3231,15 @@ static HRESULT hkCreateDXGIFactory1(REFIID riid, IDXGIFactory1** ppFactory)
oCreateSwapChain = (PFN_CreateSwapChain)pFactoryVTable[10];
// Hook CreateSwapChainForHwnd & CreateSwapChainForCoreWindow here
// Because GoW only create a IDXGIFactory1 and query it
IDXGIFactory2* factory2 = nullptr;
if (real->QueryInterface(IID_PPV_ARGS(&factory2)) == S_OK && factory2 != nullptr)
{
pFactoryVTable = *reinterpret_cast<void***>(factory2);
factory2->Release();
//IDXGIFactory2* factory2 = nullptr;
//if (real->QueryInterface(IID_PPV_ARGS(&factory2)) == S_OK && factory2 != nullptr)
//{
// pFactoryVTable = *reinterpret_cast<void***>(factory2);
// factory2->Release();
oCreateSwapChainForHwnd = (PFN_CreateSwapChainForHwnd)pFactoryVTable[15];
oCreateSwapChainForCoreWindow = (PFN_CreateSwapChainForCoreWindow)pFactoryVTable[16];
}
// oCreateSwapChainForHwnd = (PFN_CreateSwapChainForHwnd)pFactoryVTable[15];
// oCreateSwapChainForCoreWindow = (PFN_CreateSwapChainForCoreWindow)pFactoryVTable[16];
//}
if (oCreateSwapChain != nullptr)
{
@@ -3319,15 +3319,16 @@ static HRESULT hkCreateDXGIFactory2(UINT Flags, REFIID riid, IDXGIFactory2** ppF
static HRESULT hkEnumAdapterByGpuPreference(IDXGIFactory6* This, UINT Adapter, DXGI_GPU_PREFERENCE GpuPreference, REFIID riid, IUnknown** ppvAdapter)
{
LOG_FUNC();
LOG_TRACE("HooksDx Adapter: {}, GpuPreference: {}", Adapter, (UINT)GpuPreference);
State::DisableChecks("dxgi");
State::DisableChecks(2, "dxgi");
auto result = o_EnumAdapterByGpuPreference(This, Adapter, GpuPreference, riid, ppvAdapter);
State::EnableChecks();
State::EnableChecks(2);
if (result == S_OK)
CheckAdapter(*ppvAdapter);
LOG_TRACE("HooksDx result: {:X}, Adapter: {:X}", (UINT)result, (size_t)*ppvAdapter);
return result;
}
@@ -3335,9 +3336,9 @@ static HRESULT hkEnumAdapterByLuid(IDXGIFactory4* This, LUID AdapterLuid, REFIID
{
LOG_FUNC();
State::DisableChecks("dxgi");
State::DisableChecks(3, "dxgi");
auto result = o_EnumAdapterByLuid(This, AdapterLuid, riid, ppvAdapter);
State::EnableChecks();
State::EnableChecks(3);
if (result == S_OK)
CheckAdapter(*ppvAdapter);
@@ -3349,9 +3350,9 @@ static HRESULT hkEnumAdapters1(IDXGIFactory1* This, UINT Adapter, IUnknown** ppA
{
LOG_TRACE("HooksDx");
State::DisableChecks("dxgi");
State::DisableChecks(4, "dxgi");
HRESULT result = o_EnumAdapters1(This, Adapter, ppAdapter);
State::EnableChecks();
State::EnableChecks(4);
if (result == S_OK)
CheckAdapter(*ppAdapter);
@@ -3363,9 +3364,9 @@ static HRESULT hkEnumAdapters(IDXGIFactory* This, UINT Adapter, IUnknown** ppAda
{
LOG_FUNC();
State::DisableChecks("dxgi");
State::DisableChecks(5, "dxgi");
HRESULT result = o_EnumAdapters(This, Adapter, ppAdapter);
State::EnableChecks();
State::EnableChecks(5);
if (result == S_OK)
CheckAdapter(*ppAdapter);
@@ -3808,8 +3809,7 @@ static void CALLBACK D3D12DebugCallback(D3D12_MESSAGE_CATEGORY Category, D3D12_M
static HRESULT hkD3D12CreateDevice(IDXGIAdapter* pAdapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, REFIID riid, void** ppDevice)
{
LOG_FUNC();
LOG_TRACE("Adapter: {:X}, Level: {:X}", (size_t)pAdapter, (UINT)MinimumFeatureLevel);
#ifdef ENABLE_DEBUG_LAYER_DX12
LOG_WARN("Debug layers active!");
@@ -3824,11 +3824,23 @@ static HRESULT hkD3D12CreateDevice(IDXGIAdapter* pAdapter, D3D_FEATURE_LEVEL Min
}
#endif
#if _DEBUG
State::Instance().skipSpoofing = true;
DXGI_ADAPTER_DESC desc;
if (pAdapter->GetDesc(&desc) == S_OK)
{
std::wstring szName(desc.Description);
LOG_INFO("Adapter Desc: {}", wstring_to_string(szName));
}
State::Instance().skipSpoofing = false;
#endif
auto minLevel = MinimumFeatureLevel;
if (Config::Instance()->SpoofFeatureLevel.value_or_default())
minLevel = D3D_FEATURE_LEVEL_11_0;
HRESULT result = o_D3D12CreateDevice(pAdapter, minLevel, riid, ppDevice);
auto result = o_D3D12CreateDevice(pAdapter, minLevel, riid, ppDevice);
LOG_DEBUG("o_D3D12CreateDevice result: {:X}", (UINT)result);
if (result == S_OK && ppDevice != nullptr && *ppDevice != nullptr)
{
@@ -3867,8 +3879,7 @@ static HRESULT hkD3D12CreateDevice(IDXGIAdapter* pAdapter, D3D_FEATURE_LEVEL Min
#endif
}
LOG_DEBUG("result: {:X}", (UINT)result);
LOG_DEBUG("final result: {:X}", (UINT)result);
return result;
}
+40 -19
View File
@@ -59,6 +59,12 @@ private:
{
LOG_TRACE("{}", lcaseLibName);
if (lcaseLibName.rfind("driverstore") != std::string::npos)
{
LOG_DEBUG("Skip driver call: {}", lcaseLibName);
return nullptr;
}
// If Opti is not loading as nvngx.dll
if (!State::Instance().enablerAvailable && !State::Instance().isWorkingAsNvngx)
{
@@ -236,7 +242,7 @@ private:
if (module != nullptr)
{
DxgiProxy::Init(module);
if (!State::Instance().enablerAvailable && Config::Instance()->DxgiSpoofing.value_or_default())
HookDxgiForSpoofing();
@@ -341,6 +347,12 @@ private:
auto lcaseLibNameA = wstring_to_string(lcaseLibName);
LOG_TRACE("{}", lcaseLibNameA);
if (lcaseLibNameA.rfind("driverstore") != std::string::npos)
{
LOG_DEBUG("Skip driver call: {}", lcaseLibNameA);
return nullptr;
}
// If Opti is not loading as nvngx.dll
if (!State::Instance().enablerAvailable && !State::Instance().isWorkingAsNvngx)
{
@@ -725,7 +737,7 @@ private:
{
if (State::SkipDllName() == "")
{
LOG_INFO("Skip checks for: {}", lcaseLibName);
LOG_TRACE("Skip checks for: {}", lcaseLibName);
return o_KB_LoadLibraryExA(lpLibFileName, hFile, dwFlags);
}
@@ -735,7 +747,7 @@ private:
// -4 for extension `.dll`
if (pos == (lcaseLibName.length() - dllName.length()) || pos == (lcaseLibName.length() - dllName.length() - 4))
{
LOG_INFO("Skip checks for: {}", lcaseLibName);
LOG_TRACE("Skip checks for: {}", lcaseLibName);
return o_KB_LoadLibraryExA(lpLibFileName, hFile, dwFlags);
}
}
@@ -773,7 +785,7 @@ private:
{
if (State::SkipDllName() == "")
{
LOG_INFO("Skip checks for: {}", wstring_to_string(lcaseLibName));
LOG_TRACE("Skip checks for: {}", wstring_to_string(lcaseLibName));
return o_KB_LoadLibraryExW(lpLibFileName, hFile, dwFlags);
}
@@ -783,7 +795,7 @@ private:
// -4 for extension `.dll`
if (pos == (lcaseLibName.length() - dllName.length()) || pos == (lcaseLibName.length() - dllName.length() - 4))
{
LOG_INFO("Skip checks for: {}", wstring_to_string(lcaseLibName));
LOG_TRACE("Skip checks for: {}", wstring_to_string(lcaseLibName));
return o_KB_LoadLibraryExW(lpLibFileName, hFile, dwFlags);
}
}
@@ -812,8 +824,6 @@ private:
std::string libName(lpLibFileName);
std::string lcaseLibName(libName);
LOG_DEBUG("{}", lcaseLibName);
for (size_t i = 0; i < lcaseLibName.size(); i++)
lcaseLibName[i] = std::tolower(lcaseLibName[i]);
@@ -821,7 +831,7 @@ private:
{
if (State::SkipDllName() == "")
{
LOG_INFO("Skip checks for: {}", lcaseLibName);
LOG_TRACE("Skip checks for: {}", lcaseLibName);
return o_K32_LoadLibraryExA(lpLibFileName, hFile, dwFlags);
}
@@ -831,11 +841,15 @@ private:
// -4 for extension `.dll`
if (pos == (lcaseLibName.length() - dllName.length()) || pos == (lcaseLibName.length() - dllName.length() - 4))
{
LOG_INFO("Skip checks for: {}", lcaseLibName);
LOG_TRACE("Skip checks for: {}", lcaseLibName);
return o_K32_LoadLibraryExA(lpLibFileName, hFile, dwFlags);
}
}
#if _DEBUG
LOG_DEBUG("{}", lcaseLibName);
#endif
auto moduleHandle = LoadLibraryCheck(lcaseLibName, lpLibFileName);
// skip loading of dll
@@ -860,8 +874,6 @@ private:
std::wstring libName(lpLibFileName);
std::wstring lcaseLibName(libName);
LOG_DEBUG("{}", wstring_to_string(lcaseLibName));
for (size_t i = 0; i < lcaseLibName.size(); i++)
lcaseLibName[i] = std::tolower(lcaseLibName[i]);
@@ -869,7 +881,7 @@ private:
{
if (State::SkipDllName() == "")
{
LOG_INFO("Skip checks for: {}", wstring_to_string(lcaseLibName));
LOG_TRACE("Skip checks for: {}", wstring_to_string(lcaseLibName));
return o_K32_LoadLibraryExW(lpLibFileName, hFile, dwFlags);
}
@@ -879,11 +891,15 @@ private:
// -4 for extension `.dll`
if (pos == (lcaseLibName.length() - dllName.length()) || pos == (lcaseLibName.length() - dllName.length() - 4))
{
LOG_INFO("Skip checks for: {}", wstring_to_string(lcaseLibName));
LOG_TRACE("Skip checks for: {}", wstring_to_string(lcaseLibName));
return o_K32_LoadLibraryExW(lpLibFileName, hFile, dwFlags);
}
}
#if _DEBUG
LOG_DEBUG("{}", wstring_to_string(lcaseLibName));
#endif
auto moduleHandle = LoadLibraryCheckW(lcaseLibName, lpLibFileName);
// skip loading of dll
@@ -908,8 +924,6 @@ private:
std::string libName(lpLibFileName);
std::string lcaseLibName(libName);
LOG_DEBUG("{}", lcaseLibName);
for (size_t i = 0; i < lcaseLibName.size(); i++)
lcaseLibName[i] = std::tolower(lcaseLibName[i]);
@@ -917,7 +931,7 @@ private:
{
if (State::SkipDllName() == "")
{
LOG_INFO("Skip checks for: {}", lcaseLibName);
LOG_TRACE("Skip checks for: {}", lcaseLibName);
return o_K32_LoadLibraryA(lpLibFileName);
}
@@ -927,11 +941,14 @@ private:
// -4 for extension `.dll`
if (pos == (lcaseLibName.length() - dllName.length()) || pos == (lcaseLibName.length() - dllName.length() - 4))
{
LOG_INFO("Skip checks for: {}", lcaseLibName);
LOG_TRACE("Skip checks for: {}", lcaseLibName);
return o_K32_LoadLibraryA(lpLibFileName);
}
}
#if _DEBUG
LOG_DEBUG("{}", lcaseLibName);
#endif
auto moduleHandle = LoadLibraryCheck(lcaseLibName, lpLibFileName);
// skip loading of dll
@@ -962,7 +979,7 @@ private:
{
if (State::SkipDllName() == "")
{
LOG_INFO("Skip checks for: {}", wstring_to_string(lcaseLibName));
LOG_TRACE("Skip checks for: {}", wstring_to_string(lcaseLibName));
return o_K32_LoadLibraryW(lpLibFileName);
}
@@ -972,11 +989,15 @@ private:
// -4 for extension `.dll`
if (pos == (lcaseLibName.length() - dllName.length()) || pos == (lcaseLibName.length() - dllName.length() - 4))
{
LOG_INFO("Skip checks for: {}", wstring_to_string(lcaseLibName));
LOG_TRACE("Skip checks for: {}", wstring_to_string(lcaseLibName));
return o_K32_LoadLibraryW(lpLibFileName);
}
}
#if _DEBUG
LOG_DEBUG("{}", wstring_to_string(lcaseLibName));
#endif
auto moduleHandle = LoadLibraryCheckW(lcaseLibName, lpLibFileName);
// skip loading of dll
+24 -10
View File
@@ -63,66 +63,66 @@ public:
static PFN_CreateDxgiFactory Hook_CreateDxgiFactory(PVOID method)
{
auto addr = CreateDxgiFactory_Hooked();
auto addr = CreateDxgiFactory_ForHook();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)addr, method);
DetourTransactionCommit();
_CreateDxgiFactory = addr;
//_CreateDxgiFactory = addr;
return addr;
}
static PFN_CreateDxgiFactory1 Hook_CreateDxgiFactory1(PVOID method)
{
auto addr = CreateDxgiFactory1_Hooked();
auto addr = CreateDxgiFactory1_ForHook();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)addr, method);
DetourTransactionCommit();
_CreateDxgiFactory1 = addr;
//_CreateDxgiFactory1 = addr;
return addr;
}
static PFN_CreateDxgiFactory2 Hook_CreateDxgiFactory2(PVOID method)
{
auto addr = CreateDxgiFactory2_Hooked();
auto addr = CreateDxgiFactory2_ForHook();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)addr, method);
DetourTransactionCommit();
_CreateDxgiFactory2 = addr;
//_CreateDxgiFactory2 = addr;
return addr;
}
static PFN_DeclareAdepterRemovalSupport Hook_DeclareAdepterRemovalSupport(PVOID method)
{
auto addr = DeclareAdepterRemovalSupport_Hooked();
auto addr = DeclareAdepterRemovalSupport_ForHook();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)addr, method);
DetourTransactionCommit();
_DeclareAdepterRemovalSupport = addr;
//_DeclareAdepterRemovalSupport = addr;
return addr;
}
static PFN_GetDebugInterface Hook_GetDebugInterface(PVOID method)
{
auto addr = GetDebugInterface_Hooked();
auto addr = GetDebugInterface_ForHook();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)addr, method);
DetourTransactionCommit();
_GetDebugInterface = addr;
//_GetDebugInterface = addr;
return addr;
}
@@ -142,4 +142,18 @@ private:
inline static PFN_CreateDxgiFactory2 _CreateDxgiFactory2 = nullptr;
inline static PFN_DeclareAdepterRemovalSupport _DeclareAdepterRemovalSupport = nullptr;
inline static PFN_GetDebugInterface _GetDebugInterface = nullptr;
inline static HMODULE HookModule()
{
if (State::Instance().isDxgiMode)
return dllModule;
return _dll;
}
static PFN_CreateDxgiFactory CreateDxgiFactory_ForHook() { return (PFN_CreateDxgiFactory)KernelBaseProxy::GetProcAddress_()(HookModule(), "CreateDXGIFactory"); }
static PFN_CreateDxgiFactory1 CreateDxgiFactory1_ForHook() { return (PFN_CreateDxgiFactory1)KernelBaseProxy::GetProcAddress_()(HookModule(), "CreateDXGIFactory1"); }
static PFN_CreateDxgiFactory2 CreateDxgiFactory2_ForHook() { return (PFN_CreateDxgiFactory2)KernelBaseProxy::GetProcAddress_()(HookModule(), "CreateDXGIFactory2"); }
static PFN_DeclareAdepterRemovalSupport DeclareAdepterRemovalSupport_ForHook() { return (PFN_DeclareAdepterRemovalSupport)KernelBaseProxy::GetProcAddress_()(HookModule(), "DXGIDeclareAdepterRemovalSupport"); }
static PFN_GetDebugInterface GetDebugInterface_ForHook() { return (PFN_GetDebugInterface)KernelBaseProxy::GetProcAddress_()(HookModule(), "DXGIGetDebugInterface1"); }
};
+2 -2
View File
@@ -150,7 +150,7 @@ static void hookStreamline(HMODULE slInterposer) {
// Looks like when reading DLL version load methods are called
// To prevent loops disabling checks for sl.interposer.dll
State::DisableChecks("sl.interposer");
State::DisableChecks(7, "sl.interposer");
if (o_slSetTag || o_slInit || o_slInit_sl1)
unhookStreamline();
@@ -192,6 +192,6 @@ static void hookStreamline(HMODULE slInterposer) {
}
}
State::EnableChecks();
State::EnableChecks(7);
}
+45 -1
View File
@@ -158,6 +158,11 @@ inline static bool SkipSpoofing()
inline static HRESULT detGetDesc3(IDXGIAdapter4 * This, DXGI_ADAPTER_DESC3 * pDesc)
{
auto result = o_GetDesc3(This, pDesc);
#if _DEBUG
LOG_TRACE("result: {:X}", (UINT)result);
#endif
if (result == S_OK)
{
if (pDesc->VendorId != 0x1414 && !State::Instance().adapterDescs.contains(pDesc->AdapterLuid.HighPart | pDesc->AdapterLuid.LowPart))
@@ -194,6 +199,11 @@ inline static HRESULT detGetDesc3(IDXGIAdapter4 * This, DXGI_ADAPTER_DESC3 * pDe
inline static HRESULT detGetDesc2(IDXGIAdapter2 * This, DXGI_ADAPTER_DESC2 * pDesc)
{
auto result = o_GetDesc2(This, pDesc);
#if _DEBUG
LOG_TRACE("result: {:X}", (UINT)result);
#endif
if (result == S_OK)
{
if (pDesc->VendorId != 0x1414 && !State::Instance().adapterDescs.contains(pDesc->AdapterLuid.HighPart | pDesc->AdapterLuid.LowPart))
@@ -230,6 +240,11 @@ inline static HRESULT detGetDesc2(IDXGIAdapter2 * This, DXGI_ADAPTER_DESC2 * pDe
inline static HRESULT detGetDesc1(IDXGIAdapter1 * This, DXGI_ADAPTER_DESC1 * pDesc)
{
auto result = o_GetDesc1(This, pDesc);
#if _DEBUG
LOG_TRACE("result: {:X}", (UINT)result);
#endif
if (result == S_OK)
{
if (pDesc->VendorId != 0x1414 && !State::Instance().adapterDescs.contains(pDesc->AdapterLuid.HighPart | pDesc->AdapterLuid.LowPart))
@@ -266,6 +281,11 @@ inline static HRESULT detGetDesc1(IDXGIAdapter1 * This, DXGI_ADAPTER_DESC1 * pDe
inline static HRESULT detGetDesc(IDXGIAdapter * This, DXGI_ADAPTER_DESC * pDesc)
{
auto result = o_GetDesc(This, pDesc);
#if _DEBUG
LOG_TRACE("result: {:X}", (UINT)result);
#endif
if (result == S_OK)
{
if (pDesc->VendorId != 0x1414 && !State::Instance().adapterDescs.contains(pDesc->AdapterLuid.HighPart | pDesc->AdapterLuid.LowPart))
@@ -314,6 +334,10 @@ inline static HRESULT detEnumAdapterByGpuPreference(IDXGIFactory6 * This, UINT A
if (result == S_OK)
AttachToAdapter(*ppvAdapter);
#if _DEBUG
LOG_TRACE("result: {:X}, Adapter: {}, pAdapter: {:X}", (UINT)result, Adapter, (size_t)*ppvAdapter);
#endif
return result;
}
@@ -328,6 +352,10 @@ inline static HRESULT detEnumAdapterByLuid(IDXGIFactory4 * This, LUID AdapterLui
if (result == S_OK)
AttachToAdapter(*ppvAdapter);
#if _DEBUG
LOG_TRACE("result: {:X}, pAdapter: {:X}", (UINT)result, (size_t)*ppvAdapter);
#endif
return result;
}
@@ -341,6 +369,8 @@ inline static HRESULT detEnumAdapters1(IDXGIFactory1 * This, UINT Adapter, IDXGI
if (!skipHighPerfCheck && Config::Instance()->PreferDedicatedGpu.value_or_default())
{
LOG_WARN("High perf GPU selection");
if (Config::Instance()->PreferFirstDedicatedGpu.value_or_default() && Adapter > 0)
{
LOG_DEBUG("{}, returning not found", Adapter);
@@ -399,6 +429,10 @@ inline static HRESULT detEnumAdapters1(IDXGIFactory1 * This, UINT Adapter, IDXGI
if (result == S_OK)
AttachToAdapter(*ppAdapter);
#if _DEBUG
LOG_TRACE("result: {:X}, Adapter: {}, pAdapter: {:X}", (UINT)result, Adapter, (size_t)*ppAdapter);
#endif
return result;
}
@@ -468,6 +502,10 @@ inline static HRESULT detEnumAdapters(IDXGIFactory * This, UINT Adapter, IDXGIAd
if (result == S_OK)
AttachToAdapter(*ppAdapter);
#if _DEBUG
LOG_TRACE("result: {:X}, Adapter: {}, pAdapter: {:X}", (UINT)result, Adapter, (size_t)*ppAdapter);
#endif
return result;
}
@@ -511,6 +549,9 @@ inline static HRESULT hkCreateDXGIFactory2(UINT Flags, REFIID riid, IDXGIFactory
inline static void AttachToAdapter(IUnknown * unkAdapter)
{
if (o_GetDesc != nullptr && o_GetDesc1 != nullptr && o_GetDesc2 != nullptr && o_GetDesc3 != nullptr)
return;
const GUID guid = { 0x907bf281,0xea3c,0x43b4,{0xa8,0xe4,0x9f,0x23,0x11,0x07,0xb4,0xff} };
PVOID* pVTable = *(PVOID**)unkAdapter;
@@ -608,6 +649,9 @@ inline static void AttachToAdapter(IUnknown * unkAdapter)
inline static void AttachToFactory(IUnknown * unkFactory)
{
if (o_EnumAdapters != nullptr && o_EnumAdapters1 != nullptr && o_EnumAdapterByLuid != nullptr && o_EnumAdapterByGpuPreference != nullptr)
return;
PVOID* pVTable = *(PVOID**)unkFactory;
IDXGIFactory* factory;
@@ -667,7 +711,7 @@ inline static void AttachToFactory(IUnknown * unkFactory)
DetourTransactionCommit();
factory6->Release();
factory6->Release();
}
}