Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit 16c1a63

Browse files
committed
Force fail EOS overlay dll load. Exports aren't enough.
1 parent 69f10cd commit 16c1a63

File tree

2 files changed

+31
-60
lines changed

2 files changed

+31
-60
lines changed

source/wrapper_generic/EOSOverlay.cpp

Lines changed: 0 additions & 43 deletions
This file was deleted.

source/wrapper_generic/dllmain.cpp

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
// _nvngx.dll loads nvngx_dlssg.dll <- intercept this stage
77
//
88
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";
109
constinit const wchar_t *TargetImplementationDll = L"nvngx_dlssg.dll";
1110
constinit const wchar_t *RelplacementImplementationDll = L"dlssg_to_fsr3_amd_is_better.dll";
1211

12+
constinit const wchar_t *TargetEGSServicesDll = L"EOSSDK-Win64-Shipping.dll";
13+
constinit const wchar_t *TargetEGSOverlayDll = L"EOSOVH-Win64-Shipping.dll";
14+
1315
bool EnableAggressiveHooking;
1416

1517
bool TryInterceptNvAPIFunction(void *ModuleHandle, const void *FunctionName, void **FunctionPointer);
16-
bool TryInterceptEOSFunction(void *ModuleHandle, const void *FunctionName, void **FunctionPointer);
1718
bool PatchImportsForModule(const wchar_t *Path, HMODULE ModuleHandle);
1819

1920
void *LoadImplementationDll()
@@ -57,19 +58,35 @@ void *LoadImplementationDll()
5758
return mod;
5859
}
5960

60-
HMODULE RedirectModule(const wchar_t *Path)
61+
bool RedirectModule(const wchar_t *Path, HMODULE *ModuleHandle)
6162
{
62-
if (Path && std::wstring_view(Path).ends_with(TargetImplementationDll))
63-
return static_cast<HMODULE>(LoadImplementationDll());
63+
if (Path)
64+
{
65+
if (std::wstring_view(Path).ends_with(TargetImplementationDll))
66+
{
67+
*ModuleHandle = static_cast<HMODULE>(LoadImplementationDll());
68+
return true;
69+
}
70+
71+
if (std::wstring_view(Path).ends_with(TargetEGSOverlayDll))
72+
{
73+
SetLastError(ERROR_MOD_NOT_FOUND);
74+
*ModuleHandle = nullptr;
6475

65-
return nullptr;
76+
return true;
77+
}
78+
}
79+
80+
return false;
6681
}
6782

6883
HMODULE WINAPI HookedLoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
6984
{
70-
auto libraryHandle = RedirectModule(lpLibFileName);
85+
HMODULE libraryHandle = nullptr;
7186

72-
if (!libraryHandle)
87+
if (RedirectModule(lpLibFileName, &libraryHandle))
88+
return libraryHandle;
89+
else
7390
libraryHandle = LoadLibraryExW(lpLibFileName, hFile, dwFlags);
7491

7592
PatchImportsForModule(lpLibFileName, libraryHandle);
@@ -78,9 +95,11 @@ HMODULE WINAPI HookedLoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD d
7895

7996
HMODULE WINAPI HookedLoadLibraryW(LPCWSTR lpLibFileName)
8097
{
81-
auto libraryHandle = RedirectModule(lpLibFileName);
98+
HMODULE libraryHandle = nullptr;
8299

83-
if (!libraryHandle)
100+
if (RedirectModule(lpLibFileName, &libraryHandle))
101+
return libraryHandle;
102+
else
84103
libraryHandle = LoadLibraryW(lpLibFileName);
85104

86105
PatchImportsForModule(lpLibFileName, libraryHandle);
@@ -90,9 +109,7 @@ HMODULE WINAPI HookedLoadLibraryW(LPCWSTR lpLibFileName)
90109
FARPROC WINAPI HookedGetProcAddress(HMODULE hModule, LPCSTR lpProcName)
91110
{
92111
auto proc = GetProcAddress(hModule, lpProcName);
93-
94112
TryInterceptNvAPIFunction(hModule, lpProcName, reinterpret_cast<void **>(&proc));
95-
TryInterceptEOSFunction(hModule, lpProcName, reinterpret_cast<void **>(&proc));
96113

97114
return proc;
98115
}
@@ -125,10 +142,7 @@ bool PatchImportsForModule(const wchar_t *Path, HMODULE ModuleHandle)
125142
return libFileName.ends_with(Target);
126143
});
127144

128-
if (!isMatch)
129-
return false;
130-
131-
if (!ModuleRequiresPatching(ModuleHandle))
145+
if (!isMatch || !ModuleRequiresPatching(ModuleHandle))
132146
return false;
133147

134148
OutputDebugStringW(L"Patching imports for a new module: ");
@@ -162,7 +176,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
162176
TargetLibrariesToHook.end(),
163177
[](const wchar_t *Target)
164178
{
165-
return PatchImportsForModule(Target, GetModuleHandleW(Target)) && _wcsicmp(Target, TargetEGSOverlayDll) != 0;
179+
return PatchImportsForModule(Target, GetModuleHandleW(Target)) && _wcsicmp(Target, TargetEGSServicesDll) != 0;
166180
}) > 0;
167181

168182
// If zero Streamline dlls were loaded we'll have to hook the game's LoadLibrary calls and wait

0 commit comments

Comments
 (0)