/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
- * FILE: ntoskrnl/io/device.c
+ * FILE: ntoskrnl/io/iomgr/device.c
* PURPOSE: Device Object Management, including Notifications and Queues.
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
* Filip Navara (navaraf@reactos.org)
IN IOP_DEVICE_LIST_OPERATION Type)
{
PDEVICE_OBJECT Previous;
+ KIRQL OldIrql;
+
+ /* Lock the Device list while we edit it */
+ OldIrql = KeAcquireQueuedSpinLock(LockQueueIoDatabaseLock);
/* Check the type of operation */
if (Type == IopRemove)
while (Previous->NextDevice != DeviceObject)
{
/* Not this one, keep moving */
+ if (!Previous->NextDevice)
+ {
+ DPRINT1("Failed to remove PDO %p (not found)\n",
+ DeviceObject);
+
+ ASSERT(FALSE);
+ KeReleaseQueuedSpinLock(LockQueueIoDatabaseLock, OldIrql);
+ return;
+ }
Previous = Previous->NextDevice;
}
DeviceObject->NextDevice = DriverObject->DeviceObject;
DriverObject->DeviceObject = DeviceObject;
}
+
+ /* Release the device list lock */
+ KeReleaseQueuedSpinLock(LockQueueIoDatabaseLock, OldIrql);
}
VOID
/* Check if we have a Security Descriptor */
if (DeviceObject->SecurityDescriptor)
{
- /* Free it */
- ExFreePoolWithTag(DeviceObject->SecurityDescriptor, TAG_SD);
+ /* Dereference it */
+ ObDereferenceSecurityDescriptor(DeviceObject->SecurityDescriptor, 1);
}
/* Remove the device from the list */
/* Initialize the name */
RtlInitUnicodeString(&AutoName, AutoNameBuffer);
DeviceName = &AutoName;
- }
+ }
/* Initialize the Object Attributes */
InitializeObjectAttributes(&ObjectAttributes,
DeviceName,
OBJ_KERNEL_HANDLE,
NULL,
- NULL);
+ SePublicOpenUnrestrictedSd);
/* Honor exclusive flag */
if (Exclusive) ObjectAttributes.Attributes |= OBJ_EXCLUSIVE;
{
ULONG ActualDevices = 1;
PDEVICE_OBJECT CurrentDevice = DriverObject->DeviceObject;
+ KIRQL OldIrql;
+
+ /* Lock the Device list while we enumerate it */
+ OldIrql = KeAcquireQueuedSpinLock(LockQueueIoDatabaseLock);
/* Find out how many devices we'll enumerate */
while ((CurrentDevice = CurrentDevice->NextDevice)) ActualDevices++;
*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 */
+ KeReleaseQueuedSpinLock(LockQueueIoDatabaseLock, 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 */
}
}
+ /* Release the device list lock */
+ KeReleaseQueuedSpinLock(LockQueueIoDatabaseLock, OldIrql);
+
/* Return the status */
return STATUS_SUCCESS;
}
/* Check if the extension is really present */
if (FileObject->FileObjectExtension)
{
- /* FIXME: Unhandled yet */
- DPRINT1("FOEs not supported\n");
+ PFILE_OBJECT_EXTENSION FileObjectExtension;
ASSERT(FALSE);
+
+ /* Cast the buffer to something we understand */
+ FileObjectExtension = FileObject->FileObjectExtension;
+
+ /* Check if have a replacement top level device */
+ if (FileObjectExtension->TopDeviceObjectHint)
+ {
+ /* Use this instead of returning the top level device */
+ return FileObjectExtension->TopDeviceObjectHint;
+ }
}
}