Skip to content

Commit d524789

Browse files
committed
[USERINIT] Simplify the LiveMedium check
Use the standard way of checking for the existence of the `HKLM\SYSTEM\CurrentControlSet\Control\MiniNT` key. Addendum to commit 8c9a41d (r70607).
1 parent b1bd421 commit d524789

3 files changed

Lines changed: 13 additions & 45 deletions

File tree

‎base/system/userinit/livecd.c‎

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -101,57 +101,25 @@ InitLogo(PIMGINFO pImgInfo, HWND hwndDlg)
101101
if (hDC != NULL) ReleaseDC(hwndDlg, hDC);
102102
}
103103

104-
104+
/**
105+
* @brief Check whether we are running in MiniNT mode (e.g. live medium).
106+
**/
105107
BOOL
106-
IsLiveCD(VOID)
108+
IsMiniNT(VOID)
107109
{
108-
HKEY ControlKey = NULL;
109-
LPWSTR SystemStartOptions = NULL;
110-
LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */
110+
HKEY hKey;
111111
LONG rc;
112-
BOOL ret = FALSE;
113112

113+
/* Check for the presence of the "MiniNT" registry key */
114114
rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
115-
REGSTR_PATH_CURRENT_CONTROL_SET,
115+
L"SYSTEM\\CurrentControlSet\\Control\\MiniNT",
116116
0,
117117
KEY_QUERY_VALUE,
118-
&ControlKey);
119-
if (rc != ERROR_SUCCESS)
120-
{
121-
WARN("RegOpenKeyEx() failed with error %lu\n", rc);
122-
goto cleanup;
123-
}
124-
125-
rc = ReadRegSzKey(ControlKey, L"SystemStartOptions", &SystemStartOptions);
126-
if (rc != ERROR_SUCCESS)
127-
{
128-
WARN("ReadRegSzKey() failed with error %lu\n", rc);
129-
goto cleanup;
130-
}
131-
132-
/* Check for CONSOLE switch in SystemStartOptions */
133-
CurrentOption = SystemStartOptions;
134-
while (CurrentOption)
135-
{
136-
NextOption = wcschr(CurrentOption, L' ');
137-
if (NextOption)
138-
*NextOption = L'\0';
139-
if (_wcsicmp(CurrentOption, L"MININT") == 0)
140-
{
141-
TRACE("Found 'MININT' boot option\n");
142-
ret = TRUE;
143-
goto cleanup;
144-
}
145-
CurrentOption = NextOption ? NextOption + 1 : NULL;
146-
}
147-
148-
cleanup:
149-
if (ControlKey != NULL)
150-
RegCloseKey(ControlKey);
151-
HeapFree(GetProcessHeap(), 0, SystemStartOptions);
118+
&hKey);
119+
if (rc == ERROR_SUCCESS)
120+
RegCloseKey(hKey);
152121

153-
TRACE("IsLiveCD() returning %u\n", ret);
154-
return ret;
122+
return (rc == ERROR_SUCCESS);
155123
}
156124

157125

‎base/system/userinit/userinit.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ wWinMain(IN HINSTANCE hInst,
677677

678678
hInstance = hInst;
679679

680-
bIsLiveCD = IsLiveCD();
680+
bIsLiveCD = IsMiniNT();
681681

682682
Restart:
683683
SetUserSettings();

‎base/system/userinit/userinit.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ ExpandInstallerPath(
7777
IN SIZE_T PathSize);
7878

7979
BOOL
80-
IsLiveCD(VOID);
80+
IsMiniNT(VOID);
8181

8282
VOID
8383
RunLiveCD(

0 commit comments

Comments
 (0)