Skip to content

Commit bfddf04

Browse files
committed
Load AddDllDirectory on demand
We had at least two people missing the KB2533623 update from 2011
1 parent f69c73d commit bfddf04

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Client/core/CSteamClient.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,24 @@ bool CSteamClient::Load()
377377
return false;
378378
}
379379

380+
static auto pAddDllDirectory = ([]() -> decltype(&AddDllDirectory) {
381+
if (const HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll"); kernel32 != nullptr)
382+
{
383+
return reinterpret_cast<decltype(&AddDllDirectory)>(static_cast<void*>(GetProcAddress(kernel32, "AddDllDirectory")));
384+
}
385+
386+
return nullptr;
387+
})();
388+
389+
if (pAddDllDirectory == nullptr)
390+
{
391+
WriteErrorEvent("Your operating system is outdated and is missing the KB2533623 update package for AddDllDirectory");
392+
return false;
393+
}
394+
380395
WriteDebugEvent(SString("Using steamclient.dll: %s", *ToUTF8(steamClientPath.value())));
381396
SetEnvironmentVariableW(L"SteamAppId", L"" STEAM_GTASA_APP_ID);
382-
AddDllDirectory(steamDirPath.c_str());
397+
pAddDllDirectory(steamDirPath.c_str());
383398
{
384399
static wchar_t pathBuffer[65536];
385400
GetEnvironmentVariableW(L"PATH", pathBuffer, sizeof(pathBuffer) / sizeof(wchar_t));
@@ -425,7 +440,7 @@ bool CSteamClient::Load()
425440

426441
releaseLibraryLock.reset();
427442

428-
Native::CreateInterface = reinterpret_cast<decltype(Native::CreateInterface)>(GetProcAddress(dll, "CreateInterface"));
443+
Native::CreateInterface = reinterpret_cast<decltype(Native::CreateInterface)>(static_cast<void*>(GetProcAddress(dll, "CreateInterface")));
429444

430445
if (!Native::CreateInterface)
431446
{

0 commit comments

Comments
 (0)