[NTOS] Drastically reduce the hackish function CmpGetRegistryPath() for the text-mode setup case (it should ultimately completely disappear).

svn path=/branches/setup_improvements/; revision=75163
This commit is contained in:
Hermès Bélusca-Maïto 2017-06-22 00:46:30 +00:00
parent cb69c4c691
commit 83d5c711b3
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -1166,76 +1166,28 @@ CmpCreateRegistryRoot(VOID)
return TRUE;
}
NTSTATUS
NTAPI
static NTSTATUS
CmpGetRegistryPath(OUT PWCHAR ConfigPath)
{
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
HANDLE KeyHandle;
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\HARDWARE");
UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"InstallPath");
ULONG BufferSize, ResultSize;
/* Just use default path */
wcscpy(ConfigPath, L"\\SystemRoot");
/* Check if we are booted in setup */
if (ExpInTextModeSetup)
if (!ExpInTextModeSetup)
{
DPRINT1("CmpGetRegistryPath TextMode setup HACK!!\n");
/* Setup the object attributes */
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL,
NULL);
/* Open the key */
Status = ZwOpenKey(&KeyHandle,
KEY_ALL_ACCESS,
&ObjectAttributes);
if (!NT_SUCCESS(Status)) return Status;
/* Allocate the buffer */
BufferSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 4096;
ValueInfo = ExAllocatePoolWithTag(PagedPool, BufferSize, TAG_CM);
if (!ValueInfo)
{
/* Fail */
ZwClose(KeyHandle);
return STATUS_INSUFFICIENT_RESOURCES;
}
/* Query the value */
Status = ZwQueryValueKey(KeyHandle,
&ValueName,
KeyValuePartialInformation,
ValueInfo,
BufferSize,
&ResultSize);
ZwClose(KeyHandle);
if (!NT_SUCCESS(Status))
{
/* Fail */
ExFreePoolWithTag(ValueInfo, TAG_CM);
return Status;
}
/* Copy the config path and null-terminate it */
RtlCopyMemory(ConfigPath,
ValueInfo->Data,
ValueInfo->DataLength);
ConfigPath[ValueInfo->DataLength / sizeof(WCHAR)] = UNICODE_NULL;
ExFreePoolWithTag(ValueInfo, TAG_CM);
/* Add registry path */
#if 0
ResultSize = wcslen(ConfigPath);
if (ResultSize && ConfigPath[ResultSize - 1] == L'\\')
ConfigPath[ResultSize - 1] = UNICODE_NULL;
#endif
wcscat(ConfigPath, L"\\System32\\Config\\");
}
else
{
/* Just use default path */
wcscpy(ConfigPath, L"\\SystemRoot");
wcscat(ConfigPath, L"\\");
}
/* Add registry path */
wcscat(ConfigPath, L"\\System32\\Config\\");
DPRINT1("CmpGetRegistryPath: ConfigPath = '%S'\n", ConfigPath);
/* Done */