diff --git a/reactos/include/ntos/rtl.h b/reactos/include/ntos/rtl.h index 80cf87dcc02..ff7026eed26 100755 --- a/reactos/include/ntos/rtl.h +++ b/reactos/include/ntos/rtl.h @@ -458,8 +458,7 @@ RtlZeroMemory (PVOID Destination, ULONG Length); #define RTL_REGISTRY_WINDOWS_NT 3 #define RTL_REGISTRY_DEVICEMAP 4 #define RTL_REGISTRY_USER 5 -#define RTL_REGISTRY_ENUM 6 /* ReactOS specific: Used internally in kernel only */ -#define RTL_REGISTRY_MAXIMUM 7 +#define RTL_REGISTRY_MAXIMUM 6 #define RTL_REGISTRY_HANDLE 0x40000000 #define RTL_REGISTRY_OPTIONAL 0x80000000 diff --git a/reactos/lib/rtl/registry.c b/reactos/lib/rtl/registry.c index 61fb119ab4c..725c3074829 100644 --- a/reactos/lib/rtl/registry.c +++ b/reactos/lib/rtl/registry.c @@ -51,6 +51,13 @@ RtlpGetRegistryHandle(ULONG RelativeTo, 0, FALSE, DUPLICATE_SAME_ACCESS); +#ifndef NDEBUG + if(!NT_SUCCESS(Status)) + { + DPRINT("ZwDuplicateObject() failed! Status: 0x%x\n", Status); + } +#endif + return(Status); } @@ -58,18 +65,20 @@ RtlpGetRegistryHandle(ULONG RelativeTo, RelativeTo &= ~RTL_REGISTRY_OPTIONAL; if (RelativeTo >= RTL_REGISTRY_MAXIMUM) + { + DPRINT("Invalid relative flag, parameter invalid!\n"); return(STATUS_INVALID_PARAMETER); + } KeyName.Length = 0; - KeyName.MaximumLength = MAX_PATH; + KeyName.MaximumLength = sizeof(KeyBuffer); KeyName.Buffer = KeyBuffer; KeyBuffer[0] = 0; switch (RelativeTo) { case RTL_REGISTRY_ABSOLUTE: - RtlAppendUnicodeToString(&KeyName, - L"\\"); + /* nothing to prefix! */ break; case RTL_REGISTRY_SERVICES: @@ -102,16 +111,8 @@ RtlpGetRegistryHandle(ULONG RelativeTo, RtlAppendUnicodeToString (&KeyName, L"\\"); break; - - /* ReactOS specific */ - case RTL_REGISTRY_ENUM: - RtlAppendUnicodeToString(&KeyName, - L"\\Registry\\Machine\\System\\CurrentControlSet\\Enum\\"); - break; } - DPRINT("KeyName %wZ\n", &KeyName); - if (Path[0] == L'\\' && RelativeTo != RTL_REGISTRY_ABSOLUTE) { Path++; @@ -127,7 +128,7 @@ RtlpGetRegistryHandle(ULONG RelativeTo, NULL, NULL); - if (Create == TRUE) + if (Create) { Status = ZwCreateKey(KeyHandle, KEY_ALL_ACCESS, @@ -144,6 +145,13 @@ RtlpGetRegistryHandle(ULONG RelativeTo, &ObjectAttributes); } +#ifndef NDEBUG + if(!NT_SUCCESS(Status)) + { + DPRINT("%s failed! Status: 0x%x\n", (Create ? "ZwCreateKey" : "ZwOpenKey"), Status); + } +#endif + return(Status); } @@ -876,7 +884,10 @@ RtlWriteRegistryValue(IN ULONG RelativeTo, TRUE, &KeyHandle); if (!NT_SUCCESS(Status)) + { + DPRINT("RtlpGetRegistryHandle() failed! Status: 0x%x\n", Status); return(Status); + } RtlInitUnicodeString(&Name, ValueName); @@ -887,8 +898,12 @@ RtlWriteRegistryValue(IN ULONG RelativeTo, ValueType, ValueData, ValueLength); - if (NT_SUCCESS(Status)) - ZwClose(KeyHandle); + if (!NT_SUCCESS(Status)) + { + DPRINT1("ZwSetValueKey() failed! Status: 0x%x\n", Status); + } + + ZwClose(KeyHandle); return(Status); } diff --git a/reactos/ntoskrnl/cm/import.c b/reactos/ntoskrnl/cm/import.c index 21b9d65f6e4..4afca0be886 100644 --- a/reactos/ntoskrnl/cm/import.c +++ b/reactos/ntoskrnl/cm/import.c @@ -242,7 +242,8 @@ CmImportHardwareHive(PCHAR ChunkBase, &Disposition); if (!NT_SUCCESS(Status)) { - return FALSE; + DPRINT1("NtCreateKey() failed, status: 0x%x\n", Status); + return FALSE; } NtClose (HardwareKey); @@ -263,7 +264,8 @@ CmImportHardwareHive(PCHAR ChunkBase, &Disposition); if (!NT_SUCCESS(Status)) { - return FALSE; + DPRINT1("NtCreateKey() failed, status: 0x%x\n", Status); + return FALSE; } NtClose (HardwareKey); @@ -284,7 +286,8 @@ CmImportHardwareHive(PCHAR ChunkBase, &Disposition); if (!NT_SUCCESS(Status)) { - return FALSE; + DPRINT1("NtCreateKey() failed, status: 0x%x\n", Status); + return FALSE; } NtClose (HardwareKey); @@ -305,7 +308,8 @@ CmImportHardwareHive(PCHAR ChunkBase, &Disposition); if (!NT_SUCCESS(Status)) { - return FALSE; + DPRINT1("NtCreateKey() failed, status: 0x%x\n", Status); + return FALSE; } NtClose (HardwareKey); diff --git a/reactos/ntoskrnl/cm/ntfunc.c b/reactos/ntoskrnl/cm/ntfunc.c index 379fe6ae9b9..c68ca938ed3 100644 --- a/reactos/ntoskrnl/cm/ntfunc.c +++ b/reactos/ntoskrnl/cm/ntfunc.c @@ -77,6 +77,7 @@ NtCreateKey(OUT PHANDLE KeyHandle, CmiKeyType); if (!NT_SUCCESS(Status)) { + DPRINT("ObFindObject failed, Status: 0x%x\n", Status); return(Status); } @@ -89,6 +90,7 @@ NtCreateKey(OUT PHANDLE KeyHandle, { ObDereferenceObject(Object); RtlFreeUnicodeString(&RemainingPath); + DPRINT("Object marked for delete!\n"); return(STATUS_UNSUCCESSFUL); } @@ -101,7 +103,7 @@ NtCreateKey(OUT PHANDLE KeyHandle, TRUE, KeyHandle); - DPRINT("Status %x\n", Status); + DPRINT("ObCreateHandle failed Status 0x%x\n", Status); ObDereferenceObject(Object); RtlFreeUnicodeString(&RemainingPath); return Status; @@ -118,6 +120,7 @@ NtCreateKey(OUT PHANDLE KeyHandle, { ObDereferenceObject(Object); RtlFreeUnicodeString(&RemainingPath); + DPRINT1("NtCreateKey() can't create trees! (found \'\\\' in remaining path: \"%wZ\"!)\n", &RemainingPath); return STATUS_OBJECT_NAME_NOT_FOUND; } @@ -134,6 +137,7 @@ NtCreateKey(OUT PHANDLE KeyHandle, (PVOID*)&KeyObject); if (!NT_SUCCESS(Status)) { + DPRINT1("ObCreateObject() failed!\n"); return(Status); } @@ -147,6 +151,7 @@ NtCreateKey(OUT PHANDLE KeyHandle, { ObDereferenceObject(KeyObject); RtlFreeUnicodeString(&RemainingPath); + DPRINT1("ObInsertObject() failed!\n"); return(Status); } @@ -965,7 +970,7 @@ NtOpenKey(OUT PHANDLE KeyHandle, ObjectAttributes ? ObjectAttributes->ObjectName : NULL); PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY diff --git a/reactos/ntoskrnl/io/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr.c index a5f20ad0515..105421866ba 100644 --- a/reactos/ntoskrnl/io/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr.c @@ -1378,6 +1378,13 @@ IopActionConfigureChildServices( if (!IopDeviceNodeHasFlag(DeviceNode, DNF_DISABLED)) { + WCHAR RegKeyBuffer[MAX_PATH]; + UNICODE_STRING RegKey; + + RegKey.Length = 0; + RegKey.MaximumLength = sizeof(RegKeyBuffer); + RegKey.Buffer = RegKeyBuffer; + /* * Retrieve configuration from Enum key */ @@ -1391,8 +1398,11 @@ IopActionConfigureChildServices( QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; QueryTable[0].EntryContext = Service; - Status = RtlQueryRegistryValues(RTL_REGISTRY_ENUM, - DeviceNode->InstancePath.Buffer, QueryTable, NULL, NULL); + RtlAppendUnicodeToString(&RegKey, L"\\Registry\\Machine\\System\\CurrentControlSet\\Enum\\"); + RtlAppendUnicodeStringToString(&RegKey, &DeviceNode->InstancePath); + + Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, + RegKey.Buffer, QueryTable, NULL, NULL); if (!NT_SUCCESS(Status)) { diff --git a/reactos/ntoskrnl/io/pnproot.c b/reactos/ntoskrnl/io/pnproot.c index a3cb5ba33cc..cc9fd6d402e 100644 --- a/reactos/ntoskrnl/io/pnproot.c +++ b/reactos/ntoskrnl/io/pnproot.c @@ -409,7 +409,8 @@ PnpRootFdoReadDeviceInfo( DeviceDesc = &Device->DeviceDescription; - wcscpy(KeyName, ENUM_NAME_ROOT); + wcscpy(KeyName, L"\\Registry\\Machine\\System\\CurrentControlSet\\Enum\\"); + wcscat(KeyName, ENUM_NAME_ROOT); wcscat(KeyName, L"\\"); wcscat(KeyName, Device->ServiceName.Buffer); wcscat(KeyName, L"\\"); @@ -426,7 +427,7 @@ PnpRootFdoReadDeviceInfo( QueryTable[0].EntryContext = DeviceDesc; Status = RtlQueryRegistryValues( - RTL_REGISTRY_ENUM, + RTL_REGISTRY_ABSOLUTE, KeyName, QueryTable, NULL,