Shared Access to a Device

Hello,

If I set the EXCLUSIVE parameter to TRUE in IoCreateDevice(), and my device
is opened by TWO DIFFERENT applications, then is there any way for my
driver to know which IRP came from which application ? If so, how ?

Thanks in advance!

Puja

IoGetCurrentProcess

regards
jeseem
mailto:xxxxx@hotmail.com

----- Original Message -----
From:
To: “NT Developers Interest List”
Sent: Friday, August 18, 2000 9:36 PM
Subject: [ntdev] Shared Access to a Device

> Hello,
>
> If I set the EXCLUSIVE parameter to TRUE in IoCreateDevice(), and my
device
> is opened by TWO DIFFERENT applications, then is there any way for my
> driver to know which IRP came from which application ? If so, how ?
>
> Thanks in advance!
>
> Puja
>
> —
> You are currently subscribed to ntdev as: xxxxx@hotmail.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>
>

If you set the exclusive flag then only one handle can be open on the device
at a time. If you don’t set the exclusive flag then you can, IN SOME CASES,
use the FsContext field of the FileObject pointed at by each Irp to store
your own identifying information that will allow you to identify which io
requests belong to which open instance of your device object.

Mark Roddy
Windows 2000/NT Consultant
Hollis Technology Solutions
www.hollistech.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of xxxxx@usa.net
Sent: Friday, August 18, 2000 9:37 PM
To: NT Developers Interest List
Subject: [ntdev] Shared Access to a Device

Hello,

If I set the EXCLUSIVE parameter to TRUE in IoCreateDevice(), and
my device
is opened by TWO DIFFERENT applications, then is there any way for my
driver to know which IRP came from which application ? If so, how ?

Thanks in advance!

Puja


You are currently subscribed to ntdev as: xxxxx@wattanuck.mv.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

According to OSR the exclusive flag doesn’t work in 2k. You have to track
the opens and closes yourself. It is the same as 9x. I know I have an old
driver that must be exclusively opened and it probably won’t work in 2k.

----- Original Message -----
From: “Mark Roddy”
To: “NT Developers Interest List”
Sent: Saturday, August 19, 2000 11:55 AM
Subject: [ntdev] RE: Shared Access to a Device

> If you set the exclusive flag then only one handle can be open on the
device
> at a time. If you don’t set the exclusive flag then you can, IN SOME
CASES,
> use the FsContext field of the FileObject pointed at by each Irp to store
> your own identifying information that will allow you to identify which io
> requests belong to which open instance of your device object.
>
> Mark Roddy
> Windows 2000/NT Consultant
> Hollis Technology Solutions
> www.hollistech.com
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com]On Behalf Of xxxxx@usa.net
> > Sent: Friday, August 18, 2000 9:37 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Shared Access to a Device
> >
> >
> > Hello,
> >
> > If I set the EXCLUSIVE parameter to TRUE in IoCreateDevice(), and
> > my device
> > is opened by TWO DIFFERENT applications, then is there any way for my
> > driver to know which IRP came from which application ? If so, how ?
> >
> > Thanks in advance!
> >
> > Puja
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@wattanuck.mv.com
> > To unsubscribe send a blank email to $subst(‘Email.Unsub’)
> >
> >
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@mindspring.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>

On 08/19/00, ““Mark Roddy” ” wrote:
> If you set the exclusive flag then only one handle can be open on the device
> at a time. If you don’t set the exclusive flag then you can, IN SOME CASES,
> use the FsContext field of the FileObject pointed at by each Irp to store
> your own identifying information that will allow you to identify which io
> requests belong to which open instance of your device object.

Are you talking about the Tail.Overlay.OriginalFileObject field of the IRP
?
Also, you mentioned “IN SOME CASES”. Could you elaborate on that ?

And somebody mentioned IoGetCurrentProcess() can be called. I am not a FS
Driver, so can I still call this, I mean will it work reliably ?

Thanks
Puja

> According to OSR the exclusive flag doesn’t work in 2k. You have to track

At least in one of the w2k beta kernels the DO_EXCLUSIVE flag is checked in
IopParseDevice (the CREATE path) using the following logic:

if( ( DeviceObject->DeviceObjectExtension->ExtensionFlags &
(DOE_UNLOAD_PENDING | DOE_DELETE_PENDING | DOE_REMOVE_PENDING |
DOE_REMOVE_PROCESSED | DOE_START_PENDING) ) || ( DeviceObject->Flags &
DO_DEVICE_INITIALIZING ) )
Status = STATUS_NO_SUCH_DEVICE;
else if( ( DeviceObject->Flags & DO_EXCLUSIVE ) &&
DeviceObject->ReferenceCount &&
( CreatePacket->RelatedFileObject == NULL ) &&
!(CreatePacket->Options & 0x0400))
Status = STATUS_ACCESS_DENIED;
else
{
DeviceObject->ReferenceCount++;
Status = STATUS_SUCCESS;
}

So, it is checked for opens which do not specify the RelatedFileObject.

Max