From 8f5d08dbdd23ef45c8b4d065d119cbcd605010a4 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 16 May 2011 17:52:03 +0000 Subject: [PATCH] [NTOSKRNL] - Implemented IoSetSystemPartition(). This is required by MountMgr. - Fixed buffer size in IopStoreSystemPartitionInformation(). No need to have a buffer twice bigger than maximum use. svn path=/trunk/; revision=51796 --- reactos/ntoskrnl/io/iomgr/iorsrce.c | 2 +- reactos/ntoskrnl/io/iomgr/volume.c | 48 +++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/iorsrce.c b/reactos/ntoskrnl/io/iomgr/iorsrce.c index 948db34e673..469252c135d 100644 --- a/reactos/ntoskrnl/io/iomgr/iorsrce.c +++ b/reactos/ntoskrnl/io/iomgr/iorsrce.c @@ -701,7 +701,7 @@ IopStoreSystemPartitionInformation(IN PUNICODE_STRING NtSystemPartitionDeviceNam UNICODE_STRING LinkTarget, KeyName; OBJECT_ATTRIBUTES ObjectAttributes; HANDLE LinkHandle, RegistryHandle, KeyHandle; - WCHAR LinkTargetBuffer[256], KeyNameBuffer[sizeof("SystemPartition")]; + WCHAR LinkTargetBuffer[256], KeyNameBuffer[sizeof("SystemPartition") / sizeof(WCHAR)]; UNICODE_STRING CmRegistryMachineSystemName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM"); ASSERT(NtSystemPartitionDeviceName->MaximumLength >= NtSystemPartitionDeviceName->Length + sizeof(WCHAR)); diff --git a/reactos/ntoskrnl/io/iomgr/volume.c b/reactos/ntoskrnl/io/iomgr/volume.c index 606f8fd3b35..f95e6e75201 100644 --- a/reactos/ntoskrnl/io/iomgr/volume.c +++ b/reactos/ntoskrnl/io/iomgr/volume.c @@ -937,14 +937,56 @@ IoReleaseVpbSpinLock(IN KIRQL Irql) } /* - * @unimplemented + * @implemented */ NTSTATUS NTAPI IoSetSystemPartition(IN PUNICODE_STRING VolumeNameString) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + HANDLE RootHandle, KeyHandle; + UNICODE_STRING HKLMSystem, KeyString; + WCHAR Buffer[sizeof(L"SystemPartition") / sizeof(WCHAR)]; + + RtlInitUnicodeString(&HKLMSystem, L"\\REGISTRY\\MACHINE\\SYSTEM"); + + /* Open registry to save data (HKLM\SYSTEM) */ + Status = IopOpenRegistryKeyEx(&RootHandle, 0, &HKLMSystem, KEY_ALL_ACCESS); + if (!NT_SUCCESS(Status)) + { + return Status; + } + + /* Create or open Setup subkey */ + KeyString.Buffer = Buffer; + KeyString.Length = sizeof(L"Setup") - sizeof(UNICODE_NULL); + KeyString.MaximumLength = sizeof(L"Setup"); + RtlCopyMemory(Buffer, L"Setup", sizeof(L"Setup")); + Status = IopCreateRegistryKeyEx(&KeyHandle, + RootHandle, + &KeyString, + KEY_ALL_ACCESS, + REG_OPTION_NON_VOLATILE, + NULL); + ZwClose(RootHandle); + if (!NT_SUCCESS(Status)) + { + return Status; + } + + /* Store caller value */ + KeyString.Length = sizeof(L"SystemPartition") - sizeof(UNICODE_NULL); + KeyString.MaximumLength = sizeof(L"SystemPartition"); + RtlCopyMemory(Buffer, L"SystemPartition", sizeof(L"SystemPartition")); + Status = ZwSetValueKey(KeyHandle, + &KeyString, + 0, + REG_SZ, + VolumeNameString->Buffer, + VolumeNameString->Length + sizeof(UNICODE_NULL)); + ZwClose(KeyHandle); + + return Status; } /*