mirror of
https://github.com/reactos/reactos.git
synced 2024-07-05 12:15:46 +00:00
[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) svn path=/trunk/; revision=49248
This commit is contained in:
parent
d90c19e431
commit
e7431a821b
|
@ -514,6 +514,21 @@ IopAssignDeviceResources(
|
||||||
IN PDEVICE_NODE DeviceNode
|
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
|
// PNP Routines
|
||||||
//
|
//
|
||||||
|
|
|
@ -38,9 +38,6 @@ NTSTATUS
|
||||||
IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
|
IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
|
||||||
PVOID Context);
|
PVOID Context);
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
IopDetectResourceConflict(IN PCM_RESOURCE_LIST ResourceList);
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
PpSetCustomTargetEvent(IN PDEVICE_OBJECT DeviceObject,
|
PpSetCustomTargetEvent(IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN OUT PKEVENT SyncEvent OPTIONAL,
|
IN OUT PKEVENT SyncEvent OPTIONAL,
|
||||||
|
@ -379,7 +376,7 @@ IoReportResourceForDetection(IN PDRIVER_OBJECT DriverObject,
|
||||||
ResourceList = DriverList;
|
ResourceList = DriverList;
|
||||||
|
|
||||||
/* Look for a resource conflict */
|
/* Look for a resource conflict */
|
||||||
Status = IopDetectResourceConflict(ResourceList);
|
Status = IopDetectResourceConflict(ResourceList, FALSE, NULL);
|
||||||
if (Status == STATUS_CONFLICTING_ADDRESSES)
|
if (Status == STATUS_CONFLICTING_ADDRESSES)
|
||||||
{
|
{
|
||||||
/* Oh noes */
|
/* Oh noes */
|
||||||
|
|
|
@ -12,12 +12,6 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
IopDetectResourceConflict(
|
|
||||||
IN PCM_RESOURCE_LIST ResourceList,
|
|
||||||
IN BOOLEAN Silent,
|
|
||||||
OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor);
|
|
||||||
|
|
||||||
static
|
static
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
IopCheckDescriptorForConflict(PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
|
IopCheckDescriptorForConflict(PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
|
||||||
|
@ -187,8 +181,8 @@ IopFindInterruptResource(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
NTSTATUS
|
NTSTATUS NTAPI
|
||||||
IopCreateResourceListFromRequirements(
|
IopCreateResourceListFromRequirements(
|
||||||
IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList,
|
IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList,
|
||||||
OUT PCM_RESOURCE_LIST *ResourceList)
|
OUT PCM_RESOURCE_LIST *ResourceList)
|
||||||
|
@ -615,40 +609,61 @@ IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2
|
||||||
|
|
||||||
if (DeviceNode->ResourceList)
|
if (DeviceNode->ResourceList)
|
||||||
{
|
{
|
||||||
PWCHAR DeviceName = NULL;
|
|
||||||
UNICODE_STRING NameU;
|
UNICODE_STRING NameU;
|
||||||
UNICODE_STRING Suffix;
|
UNICODE_STRING RawSuffix, TranslatedSuffix;
|
||||||
ULONG OldLength = 0;
|
ULONG OldLength = 0;
|
||||||
|
|
||||||
ASSERT(DeviceNode->ResourceListTranslated);
|
ASSERT(DeviceNode->ResourceListTranslated);
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&TranslatedSuffix, L".Translated");
|
||||||
|
RtlInitUnicodeString(&RawSuffix, L".Raw");
|
||||||
|
|
||||||
Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
|
Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
|
||||||
DevicePropertyPhysicalDeviceObjectName,
|
DevicePropertyPhysicalDeviceObjectName,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
&OldLength);
|
&OldLength);
|
||||||
if ((OldLength != 0) && (Status == STATUS_BUFFER_TOO_SMALL))
|
if (Status == STATUS_BUFFER_OVERFLOW || Status == STATUS_BUFFER_TOO_SMALL)
|
||||||
{
|
{
|
||||||
DeviceName = ExAllocatePool(NonPagedPool, OldLength);
|
ASSERT(OldLength);
|
||||||
ASSERT(DeviceName);
|
|
||||||
|
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;
|
||||||
|
|
||||||
IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
|
RtlAppendUnicodeStringToString(&NameU, &RawSuffix);
|
||||||
DevicePropertyPhysicalDeviceObjectName,
|
|
||||||
OldLength,
|
|
||||||
DeviceName,
|
|
||||||
&OldLength);
|
|
||||||
|
|
||||||
RtlInitUnicodeString(&NameU, DeviceName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Some failure */
|
|
||||||
ASSERT(!NT_SUCCESS(Status));
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
RtlInitUnicodeString(&Suffix, L".Raw");
|
|
||||||
RtlAppendUnicodeStringToString(&NameU, &Suffix);
|
|
||||||
|
|
||||||
Status = ZwSetValueKey(PnpMgrLevel2,
|
Status = ZwSetValueKey(PnpMgrLevel2,
|
||||||
&NameU,
|
&NameU,
|
||||||
|
@ -659,14 +674,14 @@ IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ZwClose(PnpMgrLevel2);
|
ZwClose(PnpMgrLevel2);
|
||||||
|
ExFreePool(NameU.Buffer);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "Remove" the suffix by setting the length back to what it used to be */
|
/* "Remove" the suffix by setting the length back to what it used to be */
|
||||||
NameU.Length = (USHORT)OldLength;
|
NameU.Length = OldLength;
|
||||||
|
|
||||||
RtlInitUnicodeString(&Suffix, L".Translated");
|
RtlAppendUnicodeStringToString(&NameU, &TranslatedSuffix);
|
||||||
RtlAppendUnicodeStringToString(&NameU, &Suffix);
|
|
||||||
|
|
||||||
Status = ZwSetValueKey(PnpMgrLevel2,
|
Status = ZwSetValueKey(PnpMgrLevel2,
|
||||||
&NameU,
|
&NameU,
|
||||||
|
@ -675,8 +690,8 @@ IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2
|
||||||
DeviceNode->ResourceListTranslated,
|
DeviceNode->ResourceListTranslated,
|
||||||
PnpDetermineResourceListSize(DeviceNode->ResourceListTranslated));
|
PnpDetermineResourceListSize(DeviceNode->ResourceListTranslated));
|
||||||
ZwClose(PnpMgrLevel2);
|
ZwClose(PnpMgrLevel2);
|
||||||
ASSERT(DeviceName);
|
ExFreePool(NameU.Buffer);
|
||||||
ExFreePool(DeviceName);
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -935,7 +950,7 @@ ByeBye:
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS NTAPI
|
||||||
IopDetectResourceConflict(
|
IopDetectResourceConflict(
|
||||||
IN PCM_RESOURCE_LIST ResourceList,
|
IN PCM_RESOURCE_LIST ResourceList,
|
||||||
IN BOOLEAN Silent,
|
IN BOOLEAN Silent,
|
||||||
|
|
Loading…
Reference in a new issue