I realize that in your world following existing design patterns makes
you a spineless yes-man. But how in the world is this “simpler” than
stashing a context pointer in one of the locations the OS provides for
exactly this purpose?
* Create comes in - allocate a context and stash it in the file object
* Read comes in - grab the context from the file object and you know
what connection it is
* Close comes in - free the context
This seems much easier and safer than sharing globals between the driver
and app.
I’ll agree that it’s a bad idea to burden your driver with user-side
considerations. This does not sound like such a case to me -
maintaining connection state is a pretty standard driver-side task.
-p
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Alberto Moreira
Sent: Saturday, July 02, 2005 6:09 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] How can I differ between two handles in my driver
operations.
Oi, Fernando,
This is all too complicated and may backfire on occasion. I would just
have the driver create multiple devices, or better, I would register
multiple interfaces with multiple GUIDs, and make sure to only allow one
open per interface. Something as easy as a static member variable in the
user side would suffice, bump it every time a file gets opened,
decrement it every time the handle is closed, and use its current value
to index into a driver-supplied array of Devices or Interfaces. It’s
very easy for the app to get the array through an IoControl and to keep
track of the next available array item. With a little bit of design, you
might even be able to dynamically create new Devices or Interfaces as
need arises, and notify your app through a shared event or semaphore.
I find it not a very good idea to burden a driver with user-side
considerations, and I feel this is more of an app issue than a driver
one. It can be solved through a healthy ring 3 design strategy and a
couple of bells and whistles here and there !
Abracos from New Hampshire,
Alberto.
----- Original Message -----
From: “Maxim S. Shatskih”
To: “Windows System Software Devs Interest List”
Sent: Saturday, July 02, 2005 7:24 AM
Subject: Re: [ntdev] How can I differ between two handles in my driver
operations.
> Once I used ->FsContext in some driver of my own, not related to
> FSDs and FSFs. I had BSODs due to Mm assuming that the structure are
> ->FsContext is FSRTL_COMMON_FCB_HEADER.
>
> Since that times, I never use ->FsContext for my custom structures
> anymore.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> ----- Original Message -----
> From: “Doron Holan”
> To: “Windows System Software Devs Interest List”
>
> Sent: Saturday, July 02, 2005 1:59 AM
> Subject: RE: [ntdev] How can I differ between two handles in my driver
> operations.
>
>
> Wouldn’t FsContext usage for memory mapped files only be found on
> fileobjects which are backed by an FS? I don’t think you can create a
> memory mapped file from a device interface path.
>
> d
>
> ________________________________________
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Maxim
> S. Shatskih
> Sent: Friday, July 01, 2005 2:43 PM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] How can I differ between two handles in
> my driver
> operations.
>
> Do not do this. Use ->FsContext2 instead. ->FsContext is for
> memory-mapped file
> support only.
> Also note that filter drivers cannot use these fields - they
> belong to the
> functional driver.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
> ----- Original Message -----
> From: Anees M
> To: Windows System Software Devs Interest List
> Sent: Friday, July 01, 2005 4:40 PM
> Subject: Re: [ntdev] How can I differ between two handles in
> my driver
> operations.
>
> I think you can store some context information in
> IO_STACK_LOCATION->FileObject->FsContext pointer when you get
> a IRP_MJ_CREATE
> and then use this information in you other routines to
> differentiate them.
> On 7/1/05, Fernando Roberto wrote:
> Hi all,
>
> My question is very simple. If I have a driver and an
> application gets a handle
> for it calling CreateFile API, my driver I receive
> IRP_MJ_CREATE. But if the
> same application gets another handle calling CreateFile API
> again, how can I
> differ between theses handles when I receive IRP_MJ_READ for
> example?
>
> Thanks in advance,
> Fernando Roberto da Silva.
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
> argument: ‘’
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
> — Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256 You are currently
> subscribed to
> ntdev as: unknown lmsubst tag argument: ‘’ To unsubscribe send
> a blank email to
> xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
> argument: ‘’
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
> argument: ‘’
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@ieee.org
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com