From edc9924731e91fd31ea19866f0ca80a8afcf2aa8 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Fri, 6 Jun 2008 21:40:37 +0000 Subject: [PATCH] - Change the registry name from Registry to REGISTRY, which fixes almost all Wine registry tests and any other application using the registry in case-sensitive mode, because the real name is REGISTRY. - Add SEH to NtCreate/OpenKey, which fixes the rest of the wine registry tests. - Fix PnP Manager code that was doing case sensitive registry access with "Registry". svn path=/trunk/; revision=33869 --- reactos/ntoskrnl/config/cmsysini.c | 4 +- reactos/ntoskrnl/config/ntapi.c | 68 +++++++++++++++++++++++++++-- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 10 ++--- 3 files changed, 71 insertions(+), 11 deletions(-) diff --git a/reactos/ntoskrnl/config/cmsysini.c b/reactos/ntoskrnl/config/cmsysini.c index 15f2321209d..9d1540ce86e 100644 --- a/reactos/ntoskrnl/config/cmsysini.c +++ b/reactos/ntoskrnl/config/cmsysini.c @@ -860,7 +860,7 @@ CmpCreateRegistryRoot(VOID) } /* Create '\Registry' key. */ - RtlInitUnicodeString(&KeyName, L"\\Registry"); + RtlInitUnicodeString(&KeyName, L"\\REGISTRY"); SecurityDescriptor = CmpHiveRootSecurityDescriptor(); InitializeObjectAttributes(&ObjectAttributes, &KeyName, @@ -885,7 +885,7 @@ CmpCreateRegistryRoot(VOID) if (!KeyCell) return FALSE; /* Create the KCB */ - RtlInitUnicodeString(&KeyName, L"Registry"); + RtlInitUnicodeString(&KeyName, L"\\REGISTRY"); Kcb = CmpCreateKeyControlBlock(&CmiVolatileHive->Hive, RootIndex, KeyCell, diff --git a/reactos/ntoskrnl/config/ntapi.c b/reactos/ntoskrnl/config/ntapi.c index d65b161dc39..98edec25981 100644 --- a/reactos/ntoskrnl/config/ntapi.c +++ b/reactos/ntoskrnl/config/ntapi.c @@ -27,18 +27,55 @@ NtCreateKey(OUT PHANDLE KeyHandle, IN ULONG CreateOptions, OUT PULONG Disposition) { - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); CM_PARSE_CONTEXT ParseContext = {0}; HANDLE Handle; PAGED_CODE(); DPRINT("NtCreateKey(OB 0x%wZ)\n", ObjectAttributes->ObjectName); + /* Prepare to probe parameters */ + _SEH_TRY + { + /* Check for user-mode caller */ + if (PreviousMode == UserMode) + { + /* Check if we have a class */ + if (Class) + { + /* Probe it */ + ProbeForReadUnicodeString(Class); + ProbeForRead(ParseContext.Class.Buffer, + ParseContext.Class.Length, + sizeof(WCHAR)); + ParseContext.Class = *Class; + } + + /* Probe the key handle */ + ProbeForWriteHandle(KeyHandle); + *KeyHandle = NULL; + + /* Probe object attributes */ + ProbeForRead(ObjectAttributes, sizeof(OBJECT_ATTRIBUTES), 4); + } + else + { + /* Save the class directly */ + if (Class) ParseContext.Class = *Class; + } + } + _SEH_HANDLE + { + /* Get the status */ + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if (!NT_SUCCESS(Status)) return Status; + /* Setup the parse context */ ParseContext.CreateOperation = TRUE; ParseContext.CreateOptions = CreateOptions; - if (Class) ParseContext.Class = *Class; - + /* Do the create */ Status = ObOpenObjectByName(ObjectAttributes, CmpKeyObjectType, @@ -62,10 +99,33 @@ NtOpenKey(OUT PHANDLE KeyHandle, { CM_PARSE_CONTEXT ParseContext = {0}; HANDLE Handle; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; + KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); PAGED_CODE(); DPRINT("NtOpenKey(OB 0x%wZ)\n", ObjectAttributes->ObjectName); + /* Prepare to probe parameters */ + _SEH_TRY + { + /* Check for user-mode caller */ + if (PreviousMode == UserMode) + { + /* Probe the key handle */ + ProbeForWriteHandle(KeyHandle); + *KeyHandle = NULL; + + /* Probe object attributes */ + ProbeForRead(ObjectAttributes, sizeof(OBJECT_ATTRIBUTES), 4); + } + } + _SEH_HANDLE + { + /* Get the status */ + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if (!NT_SUCCESS(Status)) return Status; + /* Just let the object manager handle this */ Status = ObOpenObjectByName(ObjectAttributes, CmpKeyObjectType, diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index bce14a856f8..3277eaad29d 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -3217,7 +3217,7 @@ IopUpdateRootKey(VOID) HANDLE hEnum, hRoot, hHalAcpiDevice, hHalAcpiId, hLogConf; NTSTATUS Status; - InitializeObjectAttributes(&ObjectAttributes, &EnumU, OBJ_KERNEL_HANDLE, NULL, NULL); + InitializeObjectAttributes(&ObjectAttributes, &EnumU, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL); Status = ZwCreateKey(&hEnum, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, NULL); if (!NT_SUCCESS(Status)) { @@ -3225,7 +3225,7 @@ IopUpdateRootKey(VOID) return Status; } - InitializeObjectAttributes(&ObjectAttributes, &RootPathU, OBJ_KERNEL_HANDLE, hEnum, NULL); + InitializeObjectAttributes(&ObjectAttributes, &RootPathU, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hEnum, NULL); Status = ZwCreateKey(&hRoot, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, NULL); ZwClose(hEnum); if (!NT_SUCCESS(Status)) @@ -3236,12 +3236,12 @@ IopUpdateRootKey(VOID) if (IopIsAcpiComputer()) { - InitializeObjectAttributes(&ObjectAttributes, &HalAcpiDevice, OBJ_KERNEL_HANDLE, hRoot, NULL); + InitializeObjectAttributes(&ObjectAttributes, &HalAcpiDevice, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hRoot, NULL); Status = ZwCreateKey(&hHalAcpiDevice, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL); ZwClose(hRoot); if (!NT_SUCCESS(Status)) return Status; - InitializeObjectAttributes(&ObjectAttributes, &HalAcpiId, OBJ_KERNEL_HANDLE, hHalAcpiDevice, NULL); + InitializeObjectAttributes(&ObjectAttributes, &HalAcpiId, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hHalAcpiDevice, NULL); Status = ZwCreateKey(&hHalAcpiId, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL); ZwClose(hHalAcpiDevice); if (!NT_SUCCESS(Status)) @@ -3251,7 +3251,7 @@ IopUpdateRootKey(VOID) Status = ZwSetValueKey(hHalAcpiId, &HardwareIDU, 0, REG_MULTI_SZ, HalAcpiHardwareID.Buffer, HalAcpiHardwareID.MaximumLength); if (NT_SUCCESS(Status)) { - InitializeObjectAttributes(&ObjectAttributes, &LogConfU, OBJ_KERNEL_HANDLE, hHalAcpiId, NULL); + InitializeObjectAttributes(&ObjectAttributes, &LogConfU, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hHalAcpiId, NULL); Status = ZwCreateKey(&hLogConf, 0, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL); if (NT_SUCCESS(Status)) ZwClose(hLogConf);