Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Code/immersive_launcher/Launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "Utils/FileVersion.inl"

#include "oobe/PathSelection.h"
#include "SystemDllPreload.h"
#include "oobe/PathArgument.h"
#include "oobe/SupportChecks.h"
#include "steam/SteamLoader.h"
Expand Down Expand Up @@ -70,6 +71,7 @@ void SetMaxstdio()

int StartUp(int argc, char** argv)
{
PreloadSystemDlls();
bool askSelect = (GetAsyncKeyState(VK_SPACE) & 0x8000);
if (!HandleArguments(argc, argv, askSelect))
return -1;
Expand Down
28 changes: 28 additions & 0 deletions Code/immersive_launcher/SystemDllPreload.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

// Pre-binds System32 copies of DLLs that could otherwise be shadowed by the
// extra DLL directories STR registers (the Steam folder, see
// steam/SteamLoader.cpp). Windows reuses an already-loaded module for
// same-name imports, so a later import of dwmapi.dll gets this one.
// Call at the very start of launcher::StartUp().
//
// Deliberately NOT listed: d3d11/dxgi/d3d9/dinput8/version, which ENB,
// ReShade etc. intentionally proxy from the game folder.

#include <Windows.h>

namespace launcher
{
inline void PreloadSystemDlls()
{
static const wchar_t* const kSystemOnly[] = {
L"dwmapi.dll",
};

for (const wchar_t* name : kSystemOnly)
{
// Searches System32 only. Never freed, so it stays resident.
LoadLibraryExW(name, nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
}
}
} // namespace launcher