[NTOSKRNL]

- Use PnpDetermineResourceListSize to determine the resource list size and remove the broken IopCalculateResourceListSize function

svn path=/trunk/; revision=47390
This commit is contained in:
Cameron Gutman 2010-05-28 23:17:59 +00:00
parent 58055397a5
commit 848f77424e
3 changed files with 7 additions and 33 deletions

View file

@ -496,9 +496,7 @@ typedef struct _DEVICETREE_TRAVERSE_CONTEXT
// //
ULONG ULONG
NTAPI NTAPI
IopCalculateResourceListSize( PnpDetermineResourceListSize(IN PCM_RESOURCE_LIST ResourceList);
IN PCM_RESOURCE_LIST ResourceList
);
NTSTATUS NTSTATUS
NTAPI NTAPI

View file

@ -948,7 +948,7 @@ IopSetDeviceInstanceData(HANDLE InstanceKey,
0, 0,
REG_RESOURCE_LIST, REG_RESOURCE_LIST,
DeviceNode->BootResources, DeviceNode->BootResources,
IopCalculateResourceListSize(DeviceNode->BootResources)); PnpDetermineResourceListSize(DeviceNode->BootResources));
} }
} }

View file

@ -18,30 +18,6 @@ IopDetectResourceConflict(
IN BOOLEAN Silent, IN BOOLEAN Silent,
OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor); OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor);
ULONG
NTAPI
IopCalculateResourceListSize(
IN PCM_RESOURCE_LIST ResourceList)
{
ULONG Size, i, j;
PCM_PARTIAL_RESOURCE_LIST pPartialResourceList;
Size = FIELD_OFFSET(CM_RESOURCE_LIST, List);
for (i = 0; i < ResourceList->Count; i++)
{
pPartialResourceList = &ResourceList->List[i].PartialResourceList;
Size += FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList.PartialDescriptors) +
pPartialResourceList->Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
for (j = 0; j < pPartialResourceList->Count; j++)
{
if (pPartialResourceList->PartialDescriptors[j].Type == CmResourceTypeDeviceSpecific)
Size += pPartialResourceList->PartialDescriptors[j].u.DeviceSpecificData.DataSize;
}
}
return Size;
}
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)
@ -533,7 +509,7 @@ IopUpdateControlKeyWithResources(IN PDEVICE_NODE DeviceNode)
0, 0,
REG_RESOURCE_LIST, REG_RESOURCE_LIST,
DeviceNode->ResourceList, DeviceNode->ResourceList,
IopCalculateResourceListSize(DeviceNode->ResourceList)); PnpDetermineResourceListSize(DeviceNode->ResourceList));
ZwClose(ControlKey); ZwClose(ControlKey);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -674,7 +650,7 @@ IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2
0, 0,
REG_RESOURCE_LIST, REG_RESOURCE_LIST,
DeviceNode->ResourceList, DeviceNode->ResourceList,
IopCalculateResourceListSize(DeviceNode->ResourceList)); PnpDetermineResourceListSize(DeviceNode->ResourceList));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ZwClose(PnpMgrLevel2); ZwClose(PnpMgrLevel2);
@ -692,7 +668,7 @@ IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2
0, 0,
REG_RESOURCE_LIST, REG_RESOURCE_LIST,
DeviceNode->ResourceListTranslated, DeviceNode->ResourceListTranslated,
IopCalculateResourceListSize(DeviceNode->ResourceListTranslated)); PnpDetermineResourceListSize(DeviceNode->ResourceListTranslated));
ZwClose(PnpMgrLevel2); ZwClose(PnpMgrLevel2);
ASSERT(DeviceName); ASSERT(DeviceName);
ExFreePool(DeviceName); ExFreePool(DeviceName);
@ -732,7 +708,7 @@ IopTranslateDeviceResources(
/* That's easy to translate a resource list. Just copy the /* That's easy to translate a resource list. Just copy the
* untranslated one and change few fields in the copy * untranslated one and change few fields in the copy
*/ */
ListSize = IopCalculateResourceListSize(DeviceNode->ResourceList); ListSize = PnpDetermineResourceListSize(DeviceNode->ResourceList);
DeviceNode->ResourceListTranslated = ExAllocatePool(PagedPool, ListSize); DeviceNode->ResourceListTranslated = ExAllocatePool(PagedPool, ListSize);
if (!DeviceNode->ResourceListTranslated) if (!DeviceNode->ResourceListTranslated)
@ -852,7 +828,7 @@ IopAssignDeviceResources(
if (DeviceNode->BootResources) if (DeviceNode->BootResources)
{ {
ListSize = IopCalculateResourceListSize(DeviceNode->BootResources); ListSize = PnpDetermineResourceListSize(DeviceNode->BootResources);
DeviceNode->ResourceList = ExAllocatePool(PagedPool, ListSize); DeviceNode->ResourceList = ExAllocatePool(PagedPool, ListSize);
if (!DeviceNode->ResourceList) if (!DeviceNode->ResourceList)