mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 13:16:07 +00:00
[NTOSKRNL]
- Raise the IRQL when enumerating device lists so it doesn't get edited mid-listing - Don't hardcode the pointer size when checking the buffer size svn path=/trunk/; revision=70408
This commit is contained in:
parent
cf2573f733
commit
645acc270a
1 changed files with 10 additions and 2 deletions
|
@ -1088,6 +1088,10 @@ IoEnumerateDeviceObjectList(IN PDRIVER_OBJECT DriverObject,
|
|||
{
|
||||
ULONG ActualDevices = 1;
|
||||
PDEVICE_OBJECT CurrentDevice = DriverObject->DeviceObject;
|
||||
KIRQL OldIrql;
|
||||
|
||||
/* Raise to dispatch level */
|
||||
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
|
||||
|
||||
/* Find out how many devices we'll enumerate */
|
||||
while ((CurrentDevice = CurrentDevice->NextDevice)) ActualDevices++;
|
||||
|
@ -1099,13 +1103,14 @@ IoEnumerateDeviceObjectList(IN PDRIVER_OBJECT DriverObject,
|
|||
*ActualNumberDeviceObjects = ActualDevices;
|
||||
|
||||
/* Check if we can support so many */
|
||||
if ((ActualDevices * 4) > DeviceObjectListSize)
|
||||
if ((ActualDevices * sizeof(PDEVICE_OBJECT)) > DeviceObjectListSize)
|
||||
{
|
||||
/* Fail because the buffer was too small */
|
||||
KeLowerIrql(OldIrql);
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
/* Check if the caller only wanted the size */
|
||||
/* Check if the caller wanted the device list */
|
||||
if (DeviceObjectList)
|
||||
{
|
||||
/* Loop through all the devices */
|
||||
|
@ -1124,6 +1129,9 @@ IoEnumerateDeviceObjectList(IN PDRIVER_OBJECT DriverObject,
|
|||
}
|
||||
}
|
||||
|
||||
/* Return back to previous IRQL */
|
||||
KeLowerIrql(OldIrql);
|
||||
|
||||
/* Return the status */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue