HELP: Disabling Interrupts in multiple process environment

G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.device_driver.dev,microsoft.public.win32.programmer.kernel,comp.os.ms-windows.programmer.nt.kernel-mode (More info?)

Hello.

I maintain a WDM driver that get's instantiated/created by multiple
processes. Problem is that any process could possible call my
DISABLE_INTERRUPTS ioctl call which would disable interrupts for all
remaining processes.

Is there a way to disable interrupts only if the calling process is the only
process that has created an instance of the driver? Any suggestions?

I was think of something similar to a counting semaphore, but this semaphore
counter would need to be decremented even if a process died without a
"clean" exit. Is there a way to tell how many processes are attached (or
have created a handle to) a given device driver?

thank you for any guidance
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.device_driver.dev,microsoft.public.win32.programmer.kernel,comp.os.ms-windows.programmer.nt.kernel-mode (More info?)

You definitely should NOT do that. Your design is fundamentally flawed if
you need such DISABLE_INTERRUPTS call.

Tell what you're using DISABLE_INTERRUPTS for. Are you serializing access to
the device? You can use a mutex. Mutex has 'ownership' semantics. You can
also track ownership by handle (FILE_OBJECT).

"kindsol" <kindsol@hotmail.com> wrote in message
news:4071d33f$0$4556$39cecf19@news.twtelecom.net...
> Hello.
>
> I maintain a WDM driver that get's instantiated/created by multiple
> processes. Problem is that any process could possible call my
> DISABLE_INTERRUPTS ioctl call which would disable interrupts for all
> remaining processes.
>
> Is there a way to disable interrupts only if the calling process is the
only
> process that has created an instance of the driver? Any suggestions?
>
> I was think of something similar to a counting semaphore, but this
semaphore
> counter would need to be decremented even if a process died without a
> "clean" exit. Is there a way to tell how many processes are attached (or
> have created a handle to) a given device driver?
>
> thank you for any guidance
>
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.device_driver.dev,microsoft.public.win32.programmer.kernel,comp.os.ms-windows.programmer.nt.kernel-mode (More info?)

First what do you mean by disable interrupts? Providing control of
interrupts from user space is almost never a good idea.

The IRP_MJ_CREATE call will be called for each process that creates a
handle, and the IRP_MJ_CLOSE will indicate the close of a handle. You will
get an IRP_MJ_CLOSE even if the process dies, the problem here is that it
may be a while after the process dies for the close to come.

--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

"kindsol" <kindsol@hotmail.com> wrote in message
news:4071d33f$0$4556$39cecf19@news.twtelecom.net...
> Hello.
>
> I maintain a WDM driver that get's instantiated/created by multiple
> processes. Problem is that any process could possible call my
> DISABLE_INTERRUPTS ioctl call which would disable interrupts for all
> remaining processes.
>
> Is there a way to disable interrupts only if the calling process is the
only
> process that has created an instance of the driver? Any suggestions?
>
> I was think of something similar to a counting semaphore, but this
semaphore
> counter would need to be decremented even if a process died without a
> "clean" exit. Is there a way to tell how many processes are attached (or
> have created a handle to) a given device driver?
>
> thank you for any guidance
>
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.device_driver.dev,microsoft.public.win32.programmer.kernel,comp.os.ms-windows.programmer.nt.kernel-mode (More info?)

IRP_MJ_CLEANUP and IRP cancellation should be used instead. IRP_MJ_CLOSE is
not issued until all the references to the FILE_OBJECT (including those held
by the pending IRPs) are released.

"Don Burn" <burn@stopspam.acm.org> wrote in message
news:10756q8ph09b5d9@corp.supernews.com...
> First what do you mean by disable interrupts? Providing control of
> interrupts from user space is almost never a good idea.
>
> The IRP_MJ_CREATE call will be called for each process that creates a
> handle, and the IRP_MJ_CLOSE will indicate the close of a handle. You
will
> get an IRP_MJ_CLOSE even if the process dies, the problem here is that it
> may be a while after the process dies for the close to come.
>
> --
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Remove StopSpam from the email to reply
>
> "kindsol" <kindsol@hotmail.com> wrote in message
> news:4071d33f$0$4556$39cecf19@news.twtelecom.net...
> > Hello.
> >
> > I maintain a WDM driver that get's instantiated/created by multiple
> > processes. Problem is that any process could possible call my
> > DISABLE_INTERRUPTS ioctl call which would disable interrupts for all
> > remaining processes.
> >
> > Is there a way to disable interrupts only if the calling process is the
> only
> > process that has created an instance of the driver? Any suggestions?
> >
> > I was think of something similar to a counting semaphore, but this
> semaphore
> > counter would need to be decremented even if a process died without a
> > "clean" exit. Is there a way to tell how many processes are attached
(or
> > have created a handle to) a given device driver?
> >
> > thank you for any guidance
> >
> >
> >
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.device_driver.dev,microsoft.public.win32.programmer.kernel,comp.os.ms-windows.programmer.nt.kernel-mode (More info?)

Yes, except the OP was asking for when all references are released!

--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

"Alexander Grigoriev" <alegr@earthlink.net> wrote in message
news:%23bkyUDBHEHA.128@tk2msftngp13.phx.gbl...
> IRP_MJ_CLEANUP and IRP cancellation should be used instead. IRP_MJ_CLOSE
is
> not issued until all the references to the FILE_OBJECT (including those
held
> by the pending IRPs) are released.
>
> "Don Burn" <burn@stopspam.acm.org> wrote in message
> news:10756q8ph09b5d9@corp.supernews.com...
> > First what do you mean by disable interrupts? Providing control of
> > interrupts from user space is almost never a good idea.
> >
> > The IRP_MJ_CREATE call will be called for each process that creates a
> > handle, and the IRP_MJ_CLOSE will indicate the close of a handle. You
> will
> > get an IRP_MJ_CLOSE even if the process dies, the problem here is that
it
> > may be a while after the process dies for the close to come.
> >
> > --
> > Don Burn (MVP, Windows DDK)
> > Windows 2k/XP/2k3 Filesystem and Driver Consulting
> > Remove StopSpam from the email to reply
> >
> > "kindsol" <kindsol@hotmail.com> wrote in message
> > news:4071d33f$0$4556$39cecf19@news.twtelecom.net...
> > > Hello.
> > >
> > > I maintain a WDM driver that get's instantiated/created by multiple
> > > processes. Problem is that any process could possible call my
> > > DISABLE_INTERRUPTS ioctl call which would disable interrupts for all
> > > remaining processes.
> > >
> > > Is there a way to disable interrupts only if the calling process is
the
> > only
> > > process that has created an instance of the driver? Any suggestions?
> > >
> > > I was think of something similar to a counting semaphore, but this
> > semaphore
> > > counter would need to be decremented even if a process died without a
> > > "clean" exit. Is there a way to tell how many processes are attached
> (or
> > > have created a handle to) a given device driver?
> > >
> > > thank you for any guidance
> > >
> > >
> > >
> >
> >
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.device_driver.dev,microsoft.public.win32.programmer.kernel,comp.os.ms-windows.programmer.nt.kernel-mode (More info?)

"Alexander Grigoriev" <alegr@earthlink.net> wrote in message news:<eLsWBp5GEHA.2576@TK2MSFTNGP11.phx.gbl>...
> You can also track ownership by handle (FILE_OBJECT).
I can't find any Reference Count field in FILE_OBJECT.
How does a FILE_OBJECT keeps count of open handles on itself?
Thanks
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.device_driver.dev,microsoft.public.win32.programmer.kernel,comp.os.ms-windows.programmer.nt.kernel-mode (More info?)

You can set a pointer to your own context structure in
FILE_OBJECT::FsContext2, and keep there whatever per-handle state you need.

"pkk" <pawankhatri@rediffmail.com> wrote in message
news:628724e8.0404070318.6afbc729@posting.google.com...
> "Alexander Grigoriev" <alegr@earthlink.net> wrote in message
news:<eLsWBp5GEHA.2576@TK2MSFTNGP11.phx.gbl>...
> > You can also track ownership by handle (FILE_OBJECT).
> I can't find any Reference Count field in FILE_OBJECT.
> How does a FILE_OBJECT keeps count of open handles on itself?
> Thanks
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.device_driver.dev,microsoft.public.win32.programmer.kernel,comp.os.ms-windows.programmer.nt.kernel-mode (More info?)

"pkk" <pawankhatri@rediffmail.com> wrote in message
news:628724e8.0404070318.6afbc729@posting.google.com...

> I can't find any Reference Count field in FILE_OBJECT.
> How does a FILE_OBJECT keeps count of open handles on itself?

Why do you care? The system does that for you, so you concentrate on your
task. But if it is just curiosity, then here's the answer: all Object
Manager's allocated objects have a prefix, which is _before_ the object you
have a pointer to, and the refcount is a field in that prefix.

S