From 8fabb29ed91d1ff50ce451823f37caaea3504c6b Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Tue, 7 Oct 2025 21:32:46 +0200 Subject: [PATCH] [UMPNPMGR] Fix the LiveCD check --- base/services/umpnpmgr/umpnpmgr.c | 46 +++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/base/services/umpnpmgr/umpnpmgr.c b/base/services/umpnpmgr/umpnpmgr.c index 4bfc3dfdf46..636d237581f 100644 --- a/base/services/umpnpmgr/umpnpmgr.c +++ b/base/services/umpnpmgr/umpnpmgr.c @@ -204,13 +204,49 @@ GetSuppressNewUIValue(VOID) BOOL RunningOnLiveMedium(VOID) { - WCHAR LogPath[MAX_PATH]; + WCHAR CommandLine[MAX_PATH]; + HKEY hSetupKey; + DWORD dwType; + DWORD dwSize; + DWORD dwError; + BOOL LiveMedium = FALSE; - GetSystemWindowsDirectoryW(LogPath, ARRAYSIZE(LogPath)); - if (GetDriveTypeW(LogPath) == DRIVE_FIXED) - return FALSE; + DPRINT("RunningOnLiveMedium()\n"); - return TRUE; + /* Open the Setup key */ + dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SYSTEM\\Setup", + 0, + KEY_QUERY_VALUE, + &hSetupKey); + if (dwError != ERROR_SUCCESS) + goto done; + + /* Read the CmdLine value */ + dwSize = sizeof(CommandLine); + dwError = RegQueryValueExW(hSetupKey, + L"CmdLine", + NULL, + &dwType, + (LPBYTE)CommandLine, + &dwSize); + if (dwError != ERROR_SUCCESS || + (dwType != REG_SZ && + dwType != REG_EXPAND_SZ && + dwType != REG_MULTI_SZ)) + goto done; + + /* Check for the '-mini' option */ + if (wcsstr(CommandLine, L" -mini") != NULL) + { + DPRINT("Running on LiveMedium\n"); + LiveMedium = TRUE; + } + +done: + RegCloseKey(hSetupKey); + + return LiveMedium; } VOID WINAPI