Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


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

OSR_Community_UserOSR_Community_User Member Posts: 110,217
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.
> > [email protected] 19 Shabazi st.
> > Tel: +972 3 539 9286 Yehud, 56100
> > Fax: +972 3 533 1617 Israel
> > ----------------------------------------------------
>
> ---
> You are currently subscribed to ntdev as: [email protected]
> To unsubscribe send a blank email to $subst('Email.Unsub')

--
----------------------------------------------------
Barak Mandelovich Mercury Interactive ltd.
[email protected] 19 Shabazi st.
Tel: +972 3 539 9286 Yehud, 56100
Fax: +972 3 533 1617 Israel
----------------------------------------------------

Comments

  • Don_Burn_1Don_Burn_1 Member Posts: 4,311
    Then use PsGetCurrentThread() instead of PsGetCurrentProcess()

    Don Burn

    ----- Original Message -----
    From: "Barak Mandelovich" <[email protected]>
    To: "NT Developers Interest List" <[email protected]>
    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" <[email protected]>
    > > To: "NT Developers Interest List" <[email protected]>
    > > 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.
    > > > [email protected] 19 Shabazi st.
    > > > Tel: +972 3 539 9286 Yehud, 56100
    > > > Fax: +972 3 533 1617 Israel
    > > > ----------------------------------------------------
    > >
    > > ---
    > > You are currently subscribed to ntdev as: [email protected]
    > > To unsubscribe send a blank email to $subst('Email.Unsub')
    >
    > --
    > ----------------------------------------------------
    > Barak Mandelovich Mercury Interactive ltd.
    > [email protected] 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:

    [email protected]
    www.hollistech.com

    =


    > -----Original Message-----
    > From: [email protected]
    > [mailto:[email protected]]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" <[email protected]>
    > To: "NT Developers Interest List" <[email protected]>
    > 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" <[email protected]>
    > > > To: "NT Developers Interest List" <[email protected]>
    > > > 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.
    > > > > [email protected] 19 Shabazi st.
    > > > > Tel: +972 3 539 9286 Yehud, 56100
    > > > > Fax: +972 3 533 1617 Israel
    > > > > ----------------------------------------------------
    > > >
    > > > ---
    > > > You are currently subscribed to ntdev as: [email protected]
    > > > To unsubscribe send a blank email to $subst('Email.Unsub')
    > >
    > > --
    > > ----------------------------------------------------
    > > Barak Mandelovich Mercury Interactive ltd.
    > > [email protected] 19 Shabazi st.
    > > Tel: +972 3 539 9286 Yehud, 56100
    > > Fax: +972 3 533 1617 Israel
    > > ----------------------------------------------------
    >
    >
    > ---
    > You are currently subscribed to ntdev as: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
    >
    >
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    > 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
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 30 January 2023 Live, Online
Developing Minifilters 20 March 2023 Live, Online
Internals & Software Drivers 17 April 2023 Live, Online
Writing WDF Drivers 22 May 2023 Live, Online