Skip to content

Commit 0b9e6be

Browse files
committed
Add environment variable to disable network hook
1 parent 91e3d7c commit 0b9e6be

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

source/dll_main.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,21 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID)
239239
// Register modules to hook
240240
{
241241
reshade::hooks::register_module(L"user32.dll");
242+
242243
#if RESHADE_ADDON_LITE
243-
reshade::hooks::register_module(L"ws2_32.dll");
244+
// Disable network hooks when requested through an environment variable and always disable add-ons in that case
245+
if (WCHAR buf[8];
246+
GetEnvironmentVariableW(L"RESHADE_DISABLE_NETWORK_HOOK", buf, ARRAYSIZE(buf)) && buf[0] != L'\0')
247+
{
248+
extern volatile long g_network_traffic;
249+
// Special value to indicate that add-ons should never be enabled
250+
g_network_traffic = std::numeric_limits<long>::max();
251+
reshade::addon_enabled = false;
252+
}
253+
else
254+
{
255+
reshade::hooks::register_module(L"ws2_32.dll");
256+
}
244257
#endif
245258

246259
const std::filesystem::path module_name = g_reshade_dll_path.stem();

source/runtime.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,8 @@ void reshade::runtime::on_present()
682682
#endif
683683
}
684684

685-
g_network_traffic = 0;
685+
if (std::numeric_limits<long>::max() != g_network_traffic)
686+
g_network_traffic = 0;
686687
#endif
687688
}
688689

0 commit comments

Comments
 (0)