IoGetDeviceObjectPointer and "Detach" problem

When using IoGetDeviceObjectPointer to set up a “connection” to
the next lower driver, do I need to do something to “Detach” or flush
all R/W requests from the lower device before unload?
My driver wont unload and there will be a bunch of R/W requests
when the computer is shutdown.

// Get pointer to
IoGetDeviceObjectPointer(
&deviceDir, // (in) \Device\Harddisk1\Partition0
FILE_READ_ATTRIBUTES,
&(pFileObj),
&(PTargetDevObj));
// Setup my dev obj
pDevObj->AlignmentRequirement =
PTargetDevObj->AlignmentRequirement;
pDevObj->StackSize =
PTargetDevObj->StackSize + 1;
pDevObj->Flags |=
(PTargetDevObj->Flags &
(DO_BUFFERED_IO | DO_DIRECT_IO));
pDevObj->Characteristics |=
(PTargetDevObj->Characteristics
& FILE_CHARACTERISTICS_PROPAGATED);

//IRP_MJ_READ, IRP_MJ_WRITE

IoCallDriver(PTargetDevObj, Irp)

You don’t need to modify AlignmentRequirement and StackSize. Io will do
this for you when you attach. In my code, this is what I currently do to
prepare the new device object:

if (targetDevObj->Flags & DO_BUFFERED_IO)
filterDevice->Flags |= DO_BUFFERED_IO;

if (targetDevObj->Flags & DO_DIRECT_IO)
filterDevice->Flags |= DO_DIRECT_IO;

filterDevice->Flags &= ~DO_DEVICE_INITIALIZING;

But more importantly, why are you attaching to the storage device? Do
you want to filter filesystem requests or storage requests? If it’s a
storage filter, I’ll let someone more knowledgeable on that area comment
on what’s necessary. If you’re developing a filesystem filter, you don’t
have to do anything special to detach aside from providing a
‘FastIoDetachDevice’ entry point in your fast I/O table and calling
‘IoDetachDevice’ and ‘IoDeleteDevice’ from within your implementation
(with additional checks needed for Windows 2k and NT to work around an
OS bug, search the list archive for IoDetachDevice).

  • Nick Ryan

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of ChuBun
Sent: Wednesday, May 21, 2003 3:21 PM
To: File Systems Developers
Subject: [ntfsd] IoGetDeviceObjectPointer and “Detach” problem

When using IoGetDeviceObjectPointer to set up a “connection”
to the next lower driver, do I need to do something to
“Detach” or flush all R/W requests from the lower device
before unload? My driver wont unload and there will be a
bunch of R/W requests when the computer is shutdown.

// Get pointer to
IoGetDeviceObjectPointer(
&deviceDir, // (in) \Device\Harddisk1\Partition0
FILE_READ_ATTRIBUTES,
&(pFileObj),
&(PTargetDevObj));
// Setup my dev obj
pDevObj->AlignmentRequirement =
PTargetDevObj->AlignmentRequirement;
pDevObj->StackSize =
PTargetDevObj->StackSize + 1;
pDevObj->Flags |=
(PTargetDevObj->Flags &
(DO_BUFFERED_IO | DO_DIRECT_IO));
pDevObj->Characteristics |=
(PTargetDevObj->Characteristics
& FILE_CHARACTERISTICS_PROPAGATED);

//IRP_MJ_READ, IRP_MJ_WRITE

IoCallDriver(PTargetDevObj, Irp)


You are currently subscribed to ntfsd as: xxxxx@nryan.com
To unsubscribe send a blank email to xxxxx@lists.osr.com