Re: Kernel mode driver: How do I know who issued a CreateFile() ?

Well, not exactly -
A client is just a data structure - it can be a either
a process, a thread, or even 2 different clients in the same thread.

If it’s a problem - I’ll settle for “a client == a thread”, but
a process is just not enough…

thanks,

  • Barak

Don Burn wrote:

Barak,

I assume a client is defined by a process. If so use
PsGetCurrentProcess()
to get the process of the caller of the dispatch routine, ie the read, write
or create.
Note: that if someone places a filter driver above your driver, they could
cause
problems with this approach.

Don Burn

----- Original Message -----
From: “Barak Mandelovich”
> To: “NT Developers Interest List”
> Sent: Sunday, March 19, 2000 11:24 AM
> Subject: [ntdev] Kernel mode driver: How do I know who issued a CreateFile()
> ?
>
> > Hi!
> >
> > I’m writing a small driver, and I have a problem:
> >
> > I’m holding a buffer inside the driver, and I want multiple
> > clients to be using it. Every time a client issues a read
> > operation (ReadFile) - I want to give him the data from were he
> > stopped-getting
> > it the last time.
> >
> > For this purpose, I wrote an interface for a buffer that
> > holds 1 “writing” pointer, and ‘n’ “reading” pointers - one for each
> > of the n clients.
> >
> > The problem: How do I associate a read request with a client?
> > In other words: How do I know which pointer is associated with
> > which client?
> >
> > thanks in advance,
> >
> > - Barak
> >
> >
> >
> > –
> > ----------------------------------------------------
> > Barak Mandelovich Mercury Interactive ltd.
> > xxxxx@conduct.com 19 Shabazi st.
> > Tel: +972 3 539 9286 Yehud, 56100
> > Fax: +972 3 533 1617 Israel
> > ----------------------------------------------------
>
> —
> You are currently subscribed to ntdev as: xxxxx@conduct.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)


----------------------------------------------------
Barak Mandelovich Mercury Interactive ltd.
xxxxx@conduct.com 19 Shabazi st.
Tel: +972 3 539 9286 Yehud, 56100
Fax: +972 3 533 1617 Israel
----------------------------------------------------

Then use PsGetCurrentThread() instead of PsGetCurrentProcess()

Don Burn

----- Original Message -----
From: “Barak Mandelovich”
To: “NT Developers Interest List”
Sent: Sunday, March 19, 2000 11:48 AM
Subject: [ntdev] Re: Kernel mode driver: How do I know who issued a
CreateFile() ?

> Well, not exactly -
> A client is just a data structure - it can be a either
> a process, a thread, or even 2 different clients in the same thread.
>
> If it’s a problem - I’ll settle for “a client == a thread”, but
> a process is just not enough…
>
> thanks,
>
> - Barak
>
>
> Don Burn wrote:
> >
> > Barak,
> >
> > I assume a client is defined by a process. If so use
> > PsGetCurrentProcess()
> > to get the process of the caller of the dispatch routine, ie the read,
write
> > or create.
> > Note: that if someone places a filter driver above your driver, they
could
> > cause
> > problems with this approach.
> >
> > Don Burn
> >
> > ----- Original Message -----
> > From: “Barak Mandelovich”
> > To: “NT Developers Interest List”
> > Sent: Sunday, March 19, 2000 11:24 AM
> > Subject: [ntdev] Kernel mode driver: How do I know who issued a
CreateFile()
> > ?
> >
> > > Hi!
> > >
> > > I’m writing a small driver, and I have a problem:
> > >
> > > I’m holding a buffer inside the driver, and I want multiple
> > > clients to be using it. Every time a client issues a read
> > > operation (ReadFile) - I want to give him the data from were he
> > > stopped-getting
> > > it the last time.
> > >
> > > For this purpose, I wrote an interface for a buffer that
> > > holds 1 “writing” pointer, and ‘n’ “reading” pointers - one for each
> > > of the n clients.
> > >
> > > The problem: How do I associate a read request with a client?
> > > In other words: How do I know which pointer is associated with
> > > which client?
> > >
> > > thanks in advance,
> > >
> > > - Barak
> > >
> > >
> > >
> > > –
> > > ----------------------------------------------------
> > > Barak Mandelovich Mercury Interactive ltd.
> > > xxxxx@conduct.com 19 Shabazi st.
> > > Tel: +972 3 539 9286 Yehud, 56100
> > > Fax: +972 3 533 1617 Israel
> > > ----------------------------------------------------
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@conduct.com
> > To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>
> –
> ----------------------------------------------------
> Barak Mandelovich Mercury Interactive ltd.
> xxxxx@conduct.com 19 Shabazi st.
> Tel: +972 3 539 9286 Yehud, 56100
> Fax: +972 3 533 1617 Israel
> ----------------------------------------------------

Why not use the FileObject->FsContext? Its yours to use, and as long as you
aren’t a filesyste, you can use it anyway you see fit. You would set this
field as appropriate on DispatchCreate and then use its value to reference
the appropriate internal data structure in your driver on read/write
operations.

=
Mark Roddy

Windows 2000/Windows NT Consulting:

xxxxx@hollistech.com
www.hollistech.com

=

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Don Burn
Sent: Sunday, March 19, 2000 12:09 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Kernel mode driver: How do I know who issued a
CreateFile() ?

Then use PsGetCurrentThread() instead of PsGetCurrentProcess()

Don Burn

----- Original Message -----
From: “Barak Mandelovich”
> To: “NT Developers Interest List”
> Sent: Sunday, March 19, 2000 11:48 AM
> Subject: [ntdev] Re: Kernel mode driver: How do I know who issued a
> CreateFile() ?
>
>
> > Well, not exactly -
> > A client is just a data structure - it can be a either
> > a process, a thread, or even 2 different clients in the same thread.
> >
> > If it’s a problem - I’ll settle for “a client == a thread”, but
> > a process is just not enough…
> >
> > thanks,
> >
> > - Barak
> >
> >
> > Don Burn wrote:
> > >
> > > Barak,
> > >
> > > I assume a client is defined by a process. If so use
> > > PsGetCurrentProcess()
> > > to get the process of the caller of the dispatch routine, ie the read,
> write
> > > or create.
> > > Note: that if someone places a filter driver above your driver, they
> could
> > > cause
> > > problems with this approach.
> > >
> > > Don Burn
> > >
> > > ----- Original Message -----
> > > From: “Barak Mandelovich”
> > > To: “NT Developers Interest List”
> > > Sent: Sunday, March 19, 2000 11:24 AM
> > > Subject: [ntdev] Kernel mode driver: How do I know who issued a
> CreateFile()
> > > ?
> > >
> > > > Hi!
> > > >
> > > > I’m writing a small driver, and I have a problem:
> > > >
> > > > I’m holding a buffer inside the driver, and I want multiple
> > > > clients to be using it. Every time a client issues a read
> > > > operation (ReadFile) - I want to give him the data from were he
> > > > stopped-getting
> > > > it the last time.
> > > >
> > > > For this purpose, I wrote an interface for a buffer that
> > > > holds 1 “writing” pointer, and ‘n’ “reading” pointers - one for each
> > > > of the n clients.
> > > >
> > > > The problem: How do I associate a read request with a client?
> > > > In other words: How do I know which pointer is associated with
> > > > which client?
> > > >
> > > > thanks in advance,
> > > >
> > > > - Barak
> > > >
> > > >
> > > >
> > > > –
> > > > ----------------------------------------------------
> > > > Barak Mandelovich Mercury Interactive ltd.
> > > > xxxxx@conduct.com 19 Shabazi st.
> > > > Tel: +972 3 539 9286 Yehud, 56100
> > > > Fax: +972 3 533 1617 Israel
> > > > ----------------------------------------------------
> > >
> > > —
> > > You are currently subscribed to ntdev as: xxxxx@conduct.com
> > > To unsubscribe send a blank email to $subst(‘Email.Unsub’)
> >
> > –
> > ----------------------------------------------------
> > Barak Mandelovich Mercury Interactive ltd.
> > xxxxx@conduct.com 19 Shabazi st.
> > Tel: +972 3 539 9286 Yehud, 56100
> > Fax: +972 3 533 1617 Israel
> > ----------------------------------------------------
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@wattanuck.mv.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>
>

> A client is just a data structure - it can be a either

a process, a thread, or even 2 different clients in the same thread.

Then using a custom “set client ID” IOCTL is absolutely necessary.

Max