From 7f433ed74de104db31cb790c9b2cd3dabd7bf465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 8 Apr 2026 22:53:29 +0200 Subject: [PATCH] [NTOS:CM] CmpSetSystemValues(): Export the Vista+ "FirmwareBootDevice" registry value In the `HKLM\SYSTEM\CurrentControlSet\Control` registry key, the `FirmwareBootDevice` value specifies the firmware boot (i.e. system partition) device in ARC format, obtained from `LoaderBlock->ArcHalDeviceName`. For some reason it is exposed only on Windows Vista and later. This value is similar to the `SystemBootDevice` one, which specifies instead the OS boot device in ARC format, obtained from `LoaderBlock->ArcBootDeviceName`. In addition: check the value returned by `RtlCreateUnicodeStringFromAsciiz()` and fail if so. --- ntoskrnl/config/cmsysini.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/ntoskrnl/config/cmsysini.c b/ntoskrnl/config/cmsysini.c index df1de46a210..8ea6caf7b42 100644 --- a/ntoskrnl/config/cmsysini.c +++ b/ntoskrnl/config/cmsysini.c @@ -409,8 +409,7 @@ CmpSetSystemValues(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Setup attributes for loader options */ RtlInitUnicodeString(&KeyName, - L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\" - L"Control"); + L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control"); InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE, @@ -431,19 +430,41 @@ CmpSetSystemValues(IN PLOADER_PARAMETER_BLOCK LoaderBlock) if (!NT_SUCCESS(Status)) goto Quit; - /* Setup the value for the system boot device in ARC format */ + /* Setup the value for the OS boot device in ARC format */ RtlInitUnicodeString(&KeyName, L"SystemBootDevice"); - RtlCreateUnicodeStringFromAsciiz(&ValueName, LoaderBlock->ArcBootDeviceName); + if (!RtlCreateUnicodeStringFromAsciiz(&ValueName, LoaderBlock->ArcBootDeviceName)) + { + Status = STATUS_UNSUCCESSFUL; + goto Quit; + } Status = NtSetValueKey(KeyHandle, &KeyName, 0, REG_SZ, ValueName.Buffer, ValueName.Length); - - /* Free the temporary string */ RtlFreeUnicodeString(&ValueName); + if (!NT_SUCCESS(Status)) + goto Quit; + +#if (NTDDI_VERSION >= NTDDI_VISTA) || defined(__REACTOS__) + /* Setup the value for the firmware boot (i.e. system partition) device in ARC format */ + RtlInitUnicodeString(&KeyName, L"FirmwareBootDevice"); + if (!RtlCreateUnicodeStringFromAsciiz(&ValueName, LoaderBlock->ArcHalDeviceName)) + { + Status = STATUS_UNSUCCESSFUL; + goto Quit; + } + Status = NtSetValueKey(KeyHandle, + &KeyName, + 0, + REG_SZ, + ValueName.Buffer, + ValueName.Length); + RtlFreeUnicodeString(&ValueName); +#endif + Quit: /* Close the key and return */ NtClose(KeyHandle);