[UMPNPMGR] Fix RunningOnLiveMedium according to Hermes' suggestions

Note: Running a program on a LiveCD is not the same as running it in setup mode.
This commit is contained in:
Eric Kohl
2025-10-13 17:05:43 +02:00
parent 92b8ca8eab
commit 9fa8028ae4
+23 -16
View File
@@ -204,8 +204,9 @@ GetSuppressNewUIValue(VOID)
BOOL BOOL
RunningOnLiveMedium(VOID) RunningOnLiveMedium(VOID)
{ {
WCHAR CommandLine[MAX_PATH]; WCHAR Options[MAX_PATH];
HKEY hSetupKey; PWSTR CurrentOption, NextOption;
HKEY hControlKey;
DWORD dwType; DWORD dwType;
DWORD dwSize; DWORD dwSize;
DWORD dwError; DWORD dwError;
@@ -215,36 +216,42 @@ RunningOnLiveMedium(VOID)
/* Open the Setup key */ /* Open the Setup key */
dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SYSTEM\\Setup", L"SYSTEM\\CurrentControlSet\\Control",
0, 0,
KEY_QUERY_VALUE, KEY_QUERY_VALUE,
&hSetupKey); &hControlKey);
if (dwError != ERROR_SUCCESS) if (dwError != ERROR_SUCCESS)
goto done; goto done;
/* Read the CmdLine value */ /* Read the CmdLine value */
dwSize = sizeof(CommandLine); dwSize = sizeof(Options);
dwError = RegQueryValueExW(hSetupKey, dwError = RegQueryValueExW(hControlKey,
L"CmdLine", L"SystemStartOptions",
NULL, NULL,
&dwType, &dwType,
(LPBYTE)CommandLine, (LPBYTE)Options,
&dwSize); &dwSize);
if (dwError != ERROR_SUCCESS || if ((dwError != ERROR_SUCCESS) || (dwType != REG_SZ))
(dwType != REG_SZ &&
dwType != REG_EXPAND_SZ &&
dwType != REG_MULTI_SZ))
goto done; goto done;
/* Check for the '-mini' option */ /* Check for the '-mini' option */
if (wcsstr(CommandLine, L" -mini") != NULL) CurrentOption = Options;
while (CurrentOption)
{ {
DPRINT("Running on LiveMedium\n"); NextOption = wcschr(CurrentOption, L' ');
LiveMedium = TRUE; if (NextOption)
*NextOption = L'\0';
if (_wcsicmp(CurrentOption, L"MININT") == 0)
{
DPRINT("Found 'MININT' boot option\n");
LiveMedium = TRUE;
goto done;
}
CurrentOption = NextOption ? NextOption + 1 : NULL;
} }
done: done:
RegCloseKey(hSetupKey); RegCloseKey(hControlKey);
return LiveMedium; return LiveMedium;
} }