Skip to content

Commit b1bd421

Browse files
committed
[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 8fabb29 and 9fa8028.
1 parent 8dce285 commit b1bd421

3 files changed

Lines changed: 22 additions & 56 deletions

File tree

‎base/services/umpnpmgr/precomp.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ extern HKEY hEnumKey;
105105
extern HKEY hClassKey;
106106
extern BOOL g_IsUISuppressed;
107107
extern BOOL g_ShuttingDown;
108-
extern BOOL g_IsLiveMedium;
108+
extern BOOL g_IsMiniNT;
109109

110110
BOOL
111111
GetSuppressNewUIValue(VOID);

‎base/services/umpnpmgr/rpcserver.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ PNP_ReportLogOn(
791791
hBinding, Admin, ProcessId);
792792

793793
/* Fail, if the caller is not an interactive user */
794-
if ((g_IsLiveMedium == FALSE) && (IsCallerInteractive(hBinding) == FALSE))
794+
if ((g_IsMiniNT == FALSE) && (IsCallerInteractive(hBinding) == FALSE))
795795
goto cleanup;
796796

797797
/* Get the users token */

‎base/services/umpnpmgr/umpnpmgr.c‎

Lines changed: 20 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ HKEY hEnumKey = NULL;
4545
HKEY hClassKey = NULL;
4646
BOOL g_IsUISuppressed = FALSE;
4747
BOOL g_ShuttingDown = FALSE;
48-
BOOL g_IsLiveMedium = FALSE;
48+
BOOL g_IsMiniNT = FALSE;
4949

5050
/* FUNCTIONS *****************************************************************/
5151

@@ -201,59 +201,25 @@ GetSuppressNewUIValue(VOID)
201201
return bSuppressNewHWUI;
202202
}
203203

204-
BOOL
205-
RunningOnLiveMedium(VOID)
204+
/**
205+
* @brief Check whether we are running in MiniNT mode (e.g. live medium).
206+
**/
207+
static BOOL
208+
IsMiniNT(VOID)
206209
{
207-
WCHAR Options[MAX_PATH];
208-
PWSTR CurrentOption, NextOption;
209-
HKEY hControlKey;
210-
DWORD dwType;
211-
DWORD dwSize;
212-
DWORD dwError;
213-
BOOL LiveMedium = FALSE;
214-
215-
DPRINT("RunningOnLiveMedium()\n");
216-
217-
/* Open the Setup key */
218-
dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
219-
L"SYSTEM\\CurrentControlSet\\Control",
220-
0,
221-
KEY_QUERY_VALUE,
222-
&hControlKey);
223-
if (dwError != ERROR_SUCCESS)
224-
goto done;
225-
226-
/* Read the CmdLine value */
227-
dwSize = sizeof(Options);
228-
dwError = RegQueryValueExW(hControlKey,
229-
L"SystemStartOptions",
230-
NULL,
231-
&dwType,
232-
(LPBYTE)Options,
233-
&dwSize);
234-
if ((dwError != ERROR_SUCCESS) || (dwType != REG_SZ))
235-
goto done;
236-
237-
/* Check for the '-mini' option */
238-
CurrentOption = Options;
239-
while (CurrentOption)
240-
{
241-
NextOption = wcschr(CurrentOption, L' ');
242-
if (NextOption)
243-
*NextOption = L'\0';
244-
if (_wcsicmp(CurrentOption, L"MININT") == 0)
245-
{
246-
DPRINT("Found 'MININT' boot option\n");
247-
LiveMedium = TRUE;
248-
goto done;
249-
}
250-
CurrentOption = NextOption ? NextOption + 1 : NULL;
251-
}
252-
253-
done:
254-
RegCloseKey(hControlKey);
255-
256-
return LiveMedium;
210+
HKEY hKey;
211+
LONG rc;
212+
213+
/* Check for the presence of the "MiniNT" registry key */
214+
rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
215+
L"SYSTEM\\CurrentControlSet\\Control\\MiniNT",
216+
0,
217+
KEY_QUERY_VALUE,
218+
&hKey);
219+
if (rc == ERROR_SUCCESS)
220+
RegCloseKey(hKey);
221+
222+
return (rc == ERROR_SUCCESS);
257223
}
258224

259225
VOID WINAPI
@@ -267,7 +233,7 @@ ServiceMain(DWORD argc, LPTSTR *argv)
267233

268234
DPRINT("ServiceMain() called\n");
269235

270-
g_IsLiveMedium = RunningOnLiveMedium();
236+
g_IsMiniNT = IsMiniNT();
271237

272238
ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
273239
ServiceControlHandler,

0 commit comments

Comments
 (0)