From 6699c721fc08c9e4118b7928b5a7a95543038367 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 19 Nov 2004 21:31:02 +0000 Subject: [PATCH] - Correctly calculate size of the CM_RESOURCE_LIST structure. svn path=/trunk/; revision=11703 --- reactos/ntoskrnl/include/internal/io.h | 10 +++++++++- reactos/ntoskrnl/io/pnpmgr.c | 11 ++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/io.h b/reactos/ntoskrnl/include/internal/io.h index 50664692d74..4e369d99ab2 100644 --- a/reactos/ntoskrnl/include/internal/io.h +++ b/reactos/ntoskrnl/include/internal/io.h @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: io.h,v 1.48 2004/11/06 04:12:59 ion Exp $ +/* $Id: io.h,v 1.49 2004/11/19 21:31:02 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -522,4 +522,12 @@ STDCALL IopRemoveTimerFromTimerList( IN PIO_TIMER Timer ); + +#define CM_RESOURCE_LIST_SIZE(ResList) \ + (ResList->Count == 1) ? \ + FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList. \ + PartialDescriptors[(ResList)->List[0].PartialResourceList.Count]) \ + : \ + FIELD_OFFSET(CM_RESOURCE_LIST, List) + #endif diff --git a/reactos/ntoskrnl/io/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr.c index 14b49196a32..749534e2d0c 100644 --- a/reactos/ntoskrnl/io/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr.c @@ -1,4 +1,4 @@ -/* $Id: pnpmgr.c,v 1.51 2004/11/09 00:38:37 ion Exp $ +/* $Id: pnpmgr.c,v 1.52 2004/11/19 21:31:02 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -217,8 +217,7 @@ IoGetDeviceProperty( Length = 0; if (DeviceNode->BootResources->Count != 0) { - Length = FIELD_OFFSET(CM_RESOURCE_LIST, List) + - DeviceNode->BootResources->Count * sizeof(CM_FULL_RESOURCE_DESCRIPTOR); + Length = CM_RESOURCE_LIST_SIZE(DeviceNode->BootResources); } Data = &DeviceNode->BootResources; break; @@ -228,8 +227,7 @@ IoGetDeviceProperty( Length = 0; if (DeviceNode->BootResources->Count != 0) { - Length = FIELD_OFFSET(CM_RESOURCE_LIST, List) + - DeviceNode->BootResources->Count * sizeof(CM_FULL_RESOURCE_DESCRIPTOR); + Length = CM_RESOURCE_LIST_SIZE(DeviceNode->BootResources); } Data = &DeviceNode->BootResources; break; @@ -861,8 +859,7 @@ IopSetDeviceInstanceData(HANDLE InstanceKey, ResCount = DeviceNode->BootResources->Count; if (ResCount != 0) { - ListSize = sizeof(CM_RESOURCE_LIST) + - ((ResCount - 1) * sizeof(CM_FULL_RESOURCE_DESCRIPTOR)); + ListSize = CM_RESOURCE_LIST_SIZE(DeviceNode->BootResources); RtlInitUnicodeString(&KeyName, L"BootConfig");