- Correctly calculate size of the CM_RESOURCE_LIST structure.

svn path=/trunk/; revision=11703
This commit is contained in:
Filip Navara 2004-11-19 21:31:02 +00:00
parent 7857b6c7e9
commit 6699c721fc
2 changed files with 13 additions and 8 deletions

View file

@ -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

View file

@ -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");