[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.
This commit is contained in:
Hermès Bélusca-Maïto
2026-04-08 22:53:29 +02:00
parent 9336919fec
commit 7f433ed74d

View File

@@ -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);