From: lx-s Date: Wed, 8 Jul 2026 07:35:00 +0000 (+0200) Subject: Hardened program loading. X-Git-Tag: 2.6.0.0~95 X-Git-Url: https://repos.lx-s.de/gitweb/?a=commitdiff_plain;h=fff63491b849f8ad143d59bbadc580d759ff361c;p=winmute.git Hardened program loading. --- diff --git a/WinMute/WinMain.cpp b/WinMute/WinMain.cpp index 6602781..a3051e9 100644 --- a/WinMute/WinMain.cpp +++ b/WinMute/WinMain.cpp @@ -93,6 +93,10 @@ int WINAPI wWinMain( _In_ PWSTR, _In_ int) { + // Harden the DLL search path against binary planting before anything + // is loaded dynamically. + SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32); + hglobInstance = hInstance; WMSettings settings; WMi18n& i18n = WMi18n::GetInstance(); @@ -152,7 +156,14 @@ int WINAPI wWinMain( MSG msg = { nullptr }; WinMute program(settings); if (program.Init()) { - while (GetMessage(&msg, nullptr, 0, 0)) { + for (;;) { + const BOOL msgResult = GetMessage(&msg, nullptr, 0, 0); + if (msgResult == 0) { // WM_QUIT + break; + } else if (msgResult == -1) { + WMLog::GetInstance().LogWinError(L"GetMessage", GetLastError()); + break; + } HWND hwnd = GetForegroundWindow(); if (!IsWindow(hwnd) || !IsDialogMessage(hwnd, &msg)) { TranslateMessage(&msg);