mirror of
https://github.com/reactos/reactos.git
synced 2026-05-23 15:50:29 +08:00
[SMSS] "BootDir" value creation: Use a fallback if no drive letter was assigned to the SystemPartition
In `SmpTranslateSystemPartitionInformation()`, fall back to using the OS boot drive letter if none was found to be assigned to the SystemPartition. Otherwise, just fail if any other error was encountered. (This behaviour has been introduced in a post-SP1 Windows 7 update.) Additionally, simplify very slightly the code.
This commit is contained in:
@@ -872,17 +872,11 @@ SmpTranslateSystemPartitionInformation(VOID)
|
||||
TRUE,
|
||||
&Context,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SMSS: Cannot find drive letter for system partition\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Keep searching until we find it */
|
||||
do
|
||||
while (NT_SUCCESS(Status))
|
||||
{
|
||||
/* Is this it? */
|
||||
if ((RtlEqualUnicodeString(&DirInfo->TypeName, &SearchString, TRUE)) &&
|
||||
if (RtlEqualUnicodeString(&DirInfo->TypeName, &SearchString, TRUE) &&
|
||||
(DirInfo->Name.Length == 2 * sizeof(WCHAR)) &&
|
||||
(DirInfo->Name.Buffer[1] == L':'))
|
||||
{
|
||||
@@ -904,13 +898,9 @@ SmpTranslateSystemPartitionInformation(VOID)
|
||||
NtClose(LinkHandle);
|
||||
|
||||
/* Check if it matches the string we had found earlier */
|
||||
if ((NT_SUCCESS(Status)) &&
|
||||
((RtlEqualUnicodeString(&SystemPartition,
|
||||
&LinkTarget,
|
||||
TRUE)) ||
|
||||
((RtlPrefixUnicodeString(&SystemPartition,
|
||||
&LinkTarget,
|
||||
TRUE)) &&
|
||||
if (NT_SUCCESS(Status) &&
|
||||
(RtlEqualUnicodeString(&SystemPartition, &LinkTarget, TRUE) ||
|
||||
(RtlPrefixUnicodeString(&SystemPartition, &LinkTarget, TRUE) &&
|
||||
(LinkTarget.Buffer[SystemPartition.Length / sizeof(WCHAR)] == L'\\'))))
|
||||
{
|
||||
/* All done */
|
||||
@@ -927,11 +917,22 @@ SmpTranslateSystemPartitionInformation(VOID)
|
||||
FALSE,
|
||||
&Context,
|
||||
NULL);
|
||||
} while (NT_SUCCESS(Status));
|
||||
}
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SMSS: Cannot find drive letter for system partition\n");
|
||||
DPRINT1("SMSS: Cannot find drive letter for system partition: 0x%x\n", Status);
|
||||
#if (NTDDI_VERSION > NTDDI_WIN7SP1) || defined(__REACTOS__)
|
||||
/* If we failed because no drive letter associated to the system
|
||||
* volume was found (none was assigned to it), fall back to using
|
||||
* the OS boot drive letter instead. Otherwise, fail altogether.
|
||||
* NOTE: This has been introduced in a post-SP1 Windows 7 update. */
|
||||
if (Status != STATUS_NO_MORE_ENTRIES)
|
||||
return;
|
||||
DirInfo->Name.Buffer[0] = SharedUserData->NtSystemRoot[0];
|
||||
DirInfo->Name.Buffer[1] = SharedUserData->NtSystemRoot[1]; // == L':';
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Open the setup key again, for full access this time */
|
||||
@@ -945,15 +946,15 @@ SmpTranslateSystemPartitionInformation(VOID)
|
||||
Status = NtOpenKey(&KeyHandle, KEY_ALL_ACCESS, &ObjectAttributes);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SMSS: Cannot open software setup key for writing: 0x%x\n",
|
||||
Status);
|
||||
DPRINT1("SMSS: Cannot open software setup key for writing: 0x%x\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Wrap up the end of the link buffer */
|
||||
wcsncpy(LinkBuffer, DirInfo->Name.Buffer, 2);
|
||||
LinkBuffer[0] = DirInfo->Name.Buffer[0];
|
||||
LinkBuffer[1] = DirInfo->Name.Buffer[1]; // == L':';
|
||||
LinkBuffer[2] = L'\\';
|
||||
LinkBuffer[3] = L'\0';
|
||||
LinkBuffer[3] = UNICODE_NULL;
|
||||
|
||||
/* Now set this as the "BootDir" */
|
||||
RtlInitUnicodeString(&UnicodeString, L"BootDir");
|
||||
|
||||
Reference in New Issue
Block a user