|
5 | 5 | // sl.common.dll loads _nvngx.dll <- we are here |
6 | 6 | // _nvngx.dll loads nvngx_dlssg.dll <- intercept this stage |
7 | 7 | // |
8 | | -constinit const wchar_t *TargetLibrariesToHook[] = { L"sl.interposer.dll", L"sl.common.dll", L"sl.dlss_g.dll", L"_nvngx.dll", L"EOSSDK-Win64-Shipping.dll" }; |
| 8 | +std::vector<const wchar_t *> TargetLibrariesToHook = { L"sl.interposer.dll", L"sl.common.dll", L"sl.dlss_g.dll", L"_nvngx.dll" }; |
| 9 | +constinit const wchar_t *TargetEGSOverlayDll = L"EOSSDK-Win64-Shipping.dll"; |
9 | 10 | constinit const wchar_t *TargetImplementationDll = L"nvngx_dlssg.dll"; |
10 | 11 | constinit const wchar_t *RelplacementImplementationDll = L"dlssg_to_fsr3_amd_is_better.dll"; |
11 | 12 |
|
12 | 13 | bool EnableAggressiveHooking; |
13 | 14 |
|
14 | | -void TryInterceptNvAPIFunction(void *ModuleHandle, const void *FunctionName, void **FunctionPointer); |
15 | | -void TryInterceptEOSFunction(void *ModuleHandle, const void *FunctionName, void **FunctionPointer); |
| 15 | +bool TryInterceptNvAPIFunction(void *ModuleHandle, const void *FunctionName, void **FunctionPointer); |
| 16 | +bool TryInterceptEOSFunction(void *ModuleHandle, const void *FunctionName, void **FunctionPointer); |
16 | 17 | bool PatchImportsForModule(const wchar_t *Path, HMODULE ModuleHandle); |
17 | 18 |
|
18 | 19 | void *LoadImplementationDll() |
@@ -117,8 +118,8 @@ bool PatchImportsForModule(const wchar_t *Path, HMODULE ModuleHandle) |
117 | 118 | std::wstring_view libFileName(Path); |
118 | 119 |
|
119 | 120 | const bool isMatch = std::any_of( |
120 | | - std::begin(TargetLibrariesToHook), |
121 | | - std::end(TargetLibrariesToHook), |
| 121 | + TargetLibrariesToHook.begin(), |
| 122 | + TargetLibrariesToHook.end(), |
122 | 123 | [&](const wchar_t *Target) |
123 | 124 | { |
124 | 125 | return libFileName.ends_with(Target); |
@@ -150,19 +151,22 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) |
150 | 151 | OutputDebugStringW(L"DEBUG: Shim built with commit ID " BUILD_GIT_COMMIT_HASH "\n"); |
151 | 152 |
|
152 | 153 | if (EnableAggressiveHooking) |
| 154 | + { |
| 155 | + TargetLibrariesToHook.push_back(TargetEGSOverlayDll); |
153 | 156 | LoadLibraryW(L"sl.interposer.dll"); |
| 157 | + } |
154 | 158 |
|
155 | 159 | // We probably loaded after sl.interposer.dll and sl.common.dll. Try patching them up front. |
156 | 160 | bool anyPatched = std::count_if( |
157 | | - std::begin(TargetLibrariesToHook), |
158 | | - std::end(TargetLibrariesToHook), |
| 161 | + TargetLibrariesToHook.begin(), |
| 162 | + TargetLibrariesToHook.end(), |
159 | 163 | [](const wchar_t *Target) |
160 | 164 | { |
161 | | - return PatchImportsForModule(Target, GetModuleHandleW(Target)); |
| 165 | + return PatchImportsForModule(Target, GetModuleHandleW(Target)) && _wcsicmp(Target, TargetEGSOverlayDll) != 0; |
162 | 166 | }) > 0; |
163 | 167 |
|
164 | 168 | // If zero Streamline dlls were loaded we'll have to hook the game's LoadLibrary calls and wait |
165 | | - if (!anyPatched) |
| 169 | + if (!anyPatched && EnableAggressiveHooking) |
166 | 170 | anyPatched = PatchImportsForModule(TargetLibrariesToHook[0], GetModuleHandleW(nullptr)); |
167 | 171 |
|
168 | 172 | // Hooks can't be removed once they're in place. Pin this DLL in memory. |
|
0 commit comments