From d524789ed0ed6455a1e012d2d765763c06e2ebbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 27 Jul 2026 18:23:12 +0200 Subject: [PATCH] [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 8c9a41db96 (r70607). --- base/system/userinit/livecd.c | 54 +++++++-------------------------- base/system/userinit/userinit.c | 2 +- base/system/userinit/userinit.h | 2 +- 3 files changed, 13 insertions(+), 45 deletions(-) diff --git a/base/system/userinit/livecd.c b/base/system/userinit/livecd.c index 9229cd3c7fc..eb6b710052b 100644 --- a/base/system/userinit/livecd.c +++ b/base/system/userinit/livecd.c @@ -101,57 +101,25 @@ Cleanup: if (hDC != NULL) ReleaseDC(hwndDlg, hDC); } - +/** + * @brief Check whether we are running in MiniNT mode (e.g. live medium). + **/ BOOL -IsLiveCD(VOID) +IsMiniNT(VOID) { - HKEY ControlKey = NULL; - LPWSTR SystemStartOptions = NULL; - LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */ + HKEY hKey; LONG rc; - BOOL ret = FALSE; + /* Check for the presence of the "MiniNT" registry key */ rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, - REGSTR_PATH_CURRENT_CONTROL_SET, + L"SYSTEM\\CurrentControlSet\\Control\\MiniNT", 0, KEY_QUERY_VALUE, - &ControlKey); - if (rc != ERROR_SUCCESS) - { - WARN("RegOpenKeyEx() failed with error %lu\n", rc); - goto cleanup; - } + &hKey); + if (rc == ERROR_SUCCESS) + RegCloseKey(hKey); - rc = ReadRegSzKey(ControlKey, L"SystemStartOptions", &SystemStartOptions); - if (rc != ERROR_SUCCESS) - { - WARN("ReadRegSzKey() failed with error %lu\n", rc); - goto cleanup; - } - - /* Check for CONSOLE switch in SystemStartOptions */ - CurrentOption = SystemStartOptions; - while (CurrentOption) - { - NextOption = wcschr(CurrentOption, L' '); - if (NextOption) - *NextOption = L'\0'; - if (_wcsicmp(CurrentOption, L"MININT") == 0) - { - TRACE("Found 'MININT' boot option\n"); - ret = TRUE; - goto cleanup; - } - CurrentOption = NextOption ? NextOption + 1 : NULL; - } - -cleanup: - if (ControlKey != NULL) - RegCloseKey(ControlKey); - HeapFree(GetProcessHeap(), 0, SystemStartOptions); - - TRACE("IsLiveCD() returning %u\n", ret); - return ret; + return (rc == ERROR_SUCCESS); } diff --git a/base/system/userinit/userinit.c b/base/system/userinit/userinit.c index 882be9324a4..84b59eb18ec 100644 --- a/base/system/userinit/userinit.c +++ b/base/system/userinit/userinit.c @@ -677,7 +677,7 @@ wWinMain(IN HINSTANCE hInst, hInstance = hInst; - bIsLiveCD = IsLiveCD(); + bIsLiveCD = IsMiniNT(); Restart: SetUserSettings(); diff --git a/base/system/userinit/userinit.h b/base/system/userinit/userinit.h index ecb0fa8205c..5c2dc68d852 100644 --- a/base/system/userinit/userinit.h +++ b/base/system/userinit/userinit.h @@ -77,7 +77,7 @@ ExpandInstallerPath( IN SIZE_T PathSize); BOOL -IsLiveCD(VOID); +IsMiniNT(VOID); VOID RunLiveCD(