[ros-diffs] [ion] 22741: - Use IoGetDevObjExtension and STDCALL->NTAPI. - Fix some bugs in IoGetRelatedDeviceObject: We should make sure that FO_DIRECT_DEVICE_OPEN isn't set when reading from the VPB's DO, otherwise we return the FO's DO directly. Also check for attachment before trying to get any attached device.
ion at svn.reactos.org
ion at svn.reactos.org
Sat Jul 1 19:51:45 CEST 2006
Author: ion
Date: Sat Jul 1 21:51:45 2006
New Revision: 22741
URL: http://svn.reactos.org/svn/reactos?rev=22741&view=rev
Log:
- Use IoGetDevObjExtension and STDCALL->NTAPI.
- Fix some bugs in IoGetRelatedDeviceObject: We should make sure that FO_DIRECT_DEVICE_OPEN isn't set when reading from the VPB's DO, otherwise we return the FO's DO directly. Also check for attachment before trying to get any attached device.
Modified:
trunk/reactos/ntoskrnl/io/device.c
Modified: trunk/reactos/ntoskrnl/io/device.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/device.c?rev=22741&r1=22740&r2=22741&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/io/device.c (original)
+++ trunk/reactos/ntoskrnl/io/device.c Sat Jul 1 21:51:45 2006
@@ -954,11 +954,11 @@
* @implemented
*/
PDEVICE_OBJECT
-STDCALL
+NTAPI
IoGetDeviceAttachmentBaseRef(IN PDEVICE_OBJECT DeviceObject)
{
/* Return the attached Device */
- return (((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->AttachedTo);
+ return IoGetDevObjExtension(DeviceObject)->AttachedTo;
}
/*
@@ -968,7 +968,7 @@
* @implemented
*/
NTSTATUS
-STDCALL
+NTAPI
IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName,
IN ACCESS_MASK DesiredAccess,
OUT PFILE_OBJECT *FileObject,
@@ -986,8 +986,8 @@
* @implemented
*/
NTSTATUS
-STDCALL
-IoGetDiskDeviceObject(IN PDEVICE_OBJECT FileSystemDeviceObject,
+NTAPI
+IoGetDiskDeviceObject(IN PDEVICE_OBJECT FileSystemDeviceObject,
OUT PDEVICE_OBJECT *DiskDeviceObject)
{
PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
@@ -1001,14 +1001,18 @@
IoAcquireVpbSpinLock(&OldIrql);
/* Get the Device Extension */
- DeviceExtension = (PEXTENDED_DEVOBJ_EXTENSION)FileSystemDeviceObject->DeviceObjectExtension;
+ DeviceExtension = IoGetDevObjExtension(FileSystemDeviceObject);
/* Make sure this one has a VPB too */
Vpb = DeviceExtension->Vpb;
if (!Vpb) return STATUS_INVALID_PARAMETER;
- /* Make sure someone it's mounted */
- if ((!Vpb->ReferenceCount) || (Vpb->Flags & VPB_MOUNTED)) return STATUS_VOLUME_DISMOUNTED;
+ /* Make sure that it's mounted */
+ if ((!Vpb->ReferenceCount) || (Vpb->Flags & VPB_MOUNTED))
+ {
+ /* It's not, so return failure */
+ return STATUS_VOLUME_DISMOUNTED;
+ }
/* Return the Disk Device Object */
*DiskDeviceObject = Vpb->RealDevice;
@@ -1022,13 +1026,14 @@
* @implemented
*/
PDEVICE_OBJECT
-STDCALL
+NTAPI
IoGetLowerDeviceObject(IN PDEVICE_OBJECT DeviceObject)
{
- PEXTENDED_DEVOBJ_EXTENSION DeviceExtension = (PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension;
+ PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
PDEVICE_OBJECT LowerDeviceObject = NULL;
/* Make sure it's not getting deleted */
+ DeviceExtension = IoGetDevObjExtension(DeviceObject);
if (DeviceExtension->ExtensionFlags & (DOE_UNLOAD_PENDING |
DOE_DELETE_PENDING |
DOE_REMOVE_PENDING |
@@ -1055,29 +1060,40 @@
* @implemented
*/
PDEVICE_OBJECT
-STDCALL
+NTAPI
IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
{
PDEVICE_OBJECT DeviceObject = FileObject->DeviceObject;
- /* Get logical volume mounted on a physical/virtual/logical device */
- if (FileObject->Vpb && FileObject->Vpb->DeviceObject)
- {
+ /* Check if we have a VPB with a device object */
+ if ((FileObject->Vpb) && (FileObject->Vpb->DeviceObject))
+ {
+ /* Then use the DO from the VPB */
+ ASSERT(!(FileObject->Flags & FO_DIRECT_DEVICE_OPEN));
DeviceObject = FileObject->Vpb->DeviceObject;
}
-
- /*
- * Check if file object has an associated device object mounted by some
- * other file system.
- */
- if (FileObject->DeviceObject->Vpb &&
- FileObject->DeviceObject->Vpb->DeviceObject)
- {
+ else if (!(FileObject->Flags & FO_DIRECT_DEVICE_OPEN) &&
+ (FileObject->DeviceObject->Vpb) &&
+ (FileObject->DeviceObject->Vpb->DeviceObject))
+ {
+ /* The disk device actually has a VPB, so get the DO from there */
DeviceObject = FileObject->DeviceObject->Vpb->DeviceObject;
}
-
- /* Return the highest attached device */
- return IoGetAttachedDevice(DeviceObject);
+ else
+ {
+ /* Otherwise, this was a direct open */
+ DeviceObject = FileObject->DeviceObject;
+ }
+
+ /* Check if we were attached */
+ if (DeviceObject->AttachedDevice)
+ {
+ /* Return the highest attached device */
+ DeviceObject = IoGetAttachedDevice(DeviceObject);
+ }
+
+ /* Return the DO we found */
+ return DeviceObject;
}
/*
More information about the Ros-diffs
mailing list