[UMPNPMGR] Simplify the LiveMedium check

Use the standard way of checking for the existence of
the `HKLM\SYSTEM\CurrentControlSet\Control\MiniNT` key.
Addendum to commits 8fabb29ed9 and 9fa8028ae4.
This commit is contained in:
Hermès Bélusca-Maïto
2026-07-27 19:32:27 +02:00
parent 8dce28564a
commit b1bd421163
3 changed files with 20 additions and 54 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ extern HKEY hEnumKey;
extern HKEY hClassKey;
extern BOOL g_IsUISuppressed;
extern BOOL g_ShuttingDown;
extern BOOL g_IsLiveMedium;
extern BOOL g_IsMiniNT;
BOOL
GetSuppressNewUIValue(VOID);
+1 -1
View File
@@ -791,7 +791,7 @@ PNP_ReportLogOn(
hBinding, Admin, ProcessId);
/* Fail, if the caller is not an interactive user */
if ((g_IsLiveMedium == FALSE) && (IsCallerInteractive(hBinding) == FALSE))
if ((g_IsMiniNT == FALSE) && (IsCallerInteractive(hBinding) == FALSE))
goto cleanup;
/* Get the users token */
+18 -52
View File
@@ -45,7 +45,7 @@ HKEY hEnumKey = NULL;
HKEY hClassKey = NULL;
BOOL g_IsUISuppressed = FALSE;
BOOL g_ShuttingDown = FALSE;
BOOL g_IsLiveMedium = FALSE;
BOOL g_IsMiniNT = FALSE;
/* FUNCTIONS *****************************************************************/
@@ -201,59 +201,25 @@ GetSuppressNewUIValue(VOID)
return bSuppressNewHWUI;
}
BOOL
RunningOnLiveMedium(VOID)
/**
* @brief Check whether we are running in MiniNT mode (e.g. live medium).
**/
static BOOL
IsMiniNT(VOID)
{
WCHAR Options[MAX_PATH];
PWSTR CurrentOption, NextOption;
HKEY hControlKey;
DWORD dwType;
DWORD dwSize;
DWORD dwError;
BOOL LiveMedium = FALSE;
HKEY hKey;
LONG rc;
DPRINT("RunningOnLiveMedium()\n");
/* Check for the presence of the "MiniNT" registry key */
rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Control\\MiniNT",
0,
KEY_QUERY_VALUE,
&hKey);
if (rc == ERROR_SUCCESS)
RegCloseKey(hKey);
/* Open the Setup key */
dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Control",
0,
KEY_QUERY_VALUE,
&hControlKey);
if (dwError != ERROR_SUCCESS)
goto done;
/* Read the CmdLine value */
dwSize = sizeof(Options);
dwError = RegQueryValueExW(hControlKey,
L"SystemStartOptions",
NULL,
&dwType,
(LPBYTE)Options,
&dwSize);
if ((dwError != ERROR_SUCCESS) || (dwType != REG_SZ))
goto done;
/* Check for the '-mini' option */
CurrentOption = Options;
while (CurrentOption)
{
NextOption = wcschr(CurrentOption, L' ');
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:
RegCloseKey(hControlKey);
return LiveMedium;
return (rc == ERROR_SUCCESS);
}
VOID WINAPI
@@ -267,7 +233,7 @@ ServiceMain(DWORD argc, LPTSTR *argv)
DPRINT("ServiceMain() called\n");
g_IsLiveMedium = RunningOnLiveMedium();
g_IsMiniNT = IsMiniNT();
ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
ServiceControlHandler,