Author: cgutman
Date: Sun Oct 24 02:38:14 2010
New Revision: 49248
URL:
http://svn.reactos.org/svn/reactos?rev=49248&view=rev
Log:
[NTOSKRNL]
- Rewrite the resource map code to fix a regression, several failures cases, and a few
memory leaks
- Remove an incorrect definition of IopDetectResourceConflict in pnpreport.c (no idea how
this didn't trigger an onslaught of warnings)
Modified:
trunk/reactos/ntoskrnl/include/internal/io.h
trunk/reactos/ntoskrnl/io/pnpmgr/pnpreport.c
trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.c
Modified: trunk/reactos/ntoskrnl/include/internal/io.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] Sun Oct 24 02:38:14 2010
@@ -514,6 +514,21 @@
IN PDEVICE_NODE DeviceNode
);
+NTSTATUS
+NTAPI
+IopCreateResourceListFromRequirements(
+ IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList,
+ OUT PCM_RESOURCE_LIST *ResourceList
+);
+
+NTSTATUS
+NTAPI
+IopDetectResourceConflict(
+ IN PCM_RESOURCE_LIST ResourceList,
+ IN BOOLEAN Silent,
+ OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor
+);
+
//
// PNP Routines
//
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpreport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnprepo…
==============================================================================
--- trunk/reactos/ntoskrnl/io/pnpmgr/pnpreport.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpreport.c [iso-8859-1] Sun Oct 24 02:38:14 2010
@@ -37,9 +37,6 @@
NTSTATUS
IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
PVOID Context);
-
-NTSTATUS
-IopDetectResourceConflict(IN PCM_RESOURCE_LIST ResourceList);
NTSTATUS
PpSetCustomTargetEvent(IN PDEVICE_OBJECT DeviceObject,
@@ -379,7 +376,7 @@
ResourceList = DriverList;
/* Look for a resource conflict */
- Status = IopDetectResourceConflict(ResourceList);
+ Status = IopDetectResourceConflict(ResourceList, FALSE, NULL);
if (Status == STATUS_CONFLICTING_ADDRESSES)
{
/* Oh noes */
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.…
==============================================================================
--- trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.c [iso-8859-1] Sun Oct 24 02:38:14 2010
@@ -12,12 +12,6 @@
#define NDEBUG
#include <debug.h>
-NTSTATUS
-IopDetectResourceConflict(
- IN PCM_RESOURCE_LIST ResourceList,
- IN BOOLEAN Silent,
- OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor);
-
static
BOOLEAN
IopCheckDescriptorForConflict(PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, OPTIONAL
PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
@@ -187,8 +181,8 @@
return FALSE;
}
-static
-NTSTATUS
+
+NTSTATUS NTAPI
IopCreateResourceListFromRequirements(
IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList,
OUT PCM_RESOURCE_LIST *ResourceList)
@@ -615,40 +609,61 @@
if (DeviceNode->ResourceList)
{
- PWCHAR DeviceName = NULL;
UNICODE_STRING NameU;
- UNICODE_STRING Suffix;
+ UNICODE_STRING RawSuffix, TranslatedSuffix;
ULONG OldLength = 0;
ASSERT(DeviceNode->ResourceListTranslated);
+
+ RtlInitUnicodeString(&TranslatedSuffix, L".Translated");
+ RtlInitUnicodeString(&RawSuffix, L".Raw");
Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
DevicePropertyPhysicalDeviceObjectName,
0,
NULL,
&OldLength);
- if ((OldLength != 0) && (Status == STATUS_BUFFER_TOO_SMALL))
- {
- DeviceName = ExAllocatePool(NonPagedPool, OldLength);
- ASSERT(DeviceName);
-
- IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
- DevicePropertyPhysicalDeviceObjectName,
- OldLength,
- DeviceName,
- &OldLength);
-
- RtlInitUnicodeString(&NameU, DeviceName);
- }
- else
- {
- /* Some failure */
- ASSERT(!NT_SUCCESS(Status));
- return Status;
- }
-
- RtlInitUnicodeString(&Suffix, L".Raw");
- RtlAppendUnicodeStringToString(&NameU, &Suffix);
+ if (Status == STATUS_BUFFER_OVERFLOW || Status == STATUS_BUFFER_TOO_SMALL)
+ {
+ ASSERT(OldLength);
+
+ NameU.Buffer = ExAllocatePool(PagedPool, OldLength + TranslatedSuffix.Length);
+ if (!NameU.Buffer)
+ {
+ ZwClose(PnpMgrLevel2);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ NameU.Length = 0;
+ NameU.MaximumLength = OldLength + TranslatedSuffix.Length;
+
+ Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
+ DevicePropertyPhysicalDeviceObjectName,
+ NameU.MaximumLength,
+ NameU.Buffer,
+ &OldLength);
+ if (!NT_SUCCESS(Status))
+ {
+ ZwClose(PnpMgrLevel2);
+ ExFreePool(NameU.Buffer);
+ return Status;
+ }
+ }
+ else if (!NT_SUCCESS(Status))
+ {
+ /* Some failure */
+ ZwClose(PnpMgrLevel2);
+ return Status;
+ }
+ else
+ {
+ /* This should never happen */
+ ASSERT(FALSE);
+ }
+
+ NameU.Length = OldLength;
+
+ RtlAppendUnicodeStringToString(&NameU, &RawSuffix);
Status = ZwSetValueKey(PnpMgrLevel2,
&NameU,
@@ -659,14 +674,14 @@
if (!NT_SUCCESS(Status))
{
ZwClose(PnpMgrLevel2);
+ ExFreePool(NameU.Buffer);
return Status;
}
/* "Remove" the suffix by setting the length back to what it used to be
*/
- NameU.Length = (USHORT)OldLength;
-
- RtlInitUnicodeString(&Suffix, L".Translated");
- RtlAppendUnicodeStringToString(&NameU, &Suffix);
+ NameU.Length = OldLength;
+
+ RtlAppendUnicodeStringToString(&NameU, &TranslatedSuffix);
Status = ZwSetValueKey(PnpMgrLevel2,
&NameU,
@@ -675,8 +690,8 @@
DeviceNode->ResourceListTranslated,
PnpDetermineResourceListSize(DeviceNode->ResourceListTranslated));
ZwClose(PnpMgrLevel2);
- ASSERT(DeviceName);
- ExFreePool(DeviceName);
+ ExFreePool(NameU.Buffer);
+
if (!NT_SUCCESS(Status))
return Status;
}
@@ -935,7 +950,7 @@
return Result;
}
-NTSTATUS
+NTSTATUS NTAPI
IopDetectResourceConflict(
IN PCM_RESOURCE_LIST ResourceList,
IN BOOLEAN Silent,