One of the drivers I am writing is just a simple IO driver for some custom
hardware. I make DeviceIoControl calls, it reads and writes the hardware
and comes back with the results. Simple as pie.

Normally everything works fine, but sometimes when I close the user- mode
application that opened a handle to the driver, the application will perform
the CloseHandle call (and it returns TRUE) but my driver's CloseHandle code
will not get called. Afterwards, when I try to run the program again,
several things happen.

One: If I try to build the program again, the .EXE for the program is locked
up and can't be rebuilt. Like it hasn't actually exited yet.

Two: If I just run the program again, the CreateFile call refuses to open a
handle to my driver. It doesn't even reach my driver's OpenHandle call.

Any ideas about why it doesn't get to my driver's CloseHandle call?

Re: Handle To Driver Not Closing by Peter

Peter
Thu Aug 19 15:40:45 CDT 2004

do you not see a cleanup either? Or just not a close?

-p

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Gereon" <gereon_msdn@alwaysfind.us> wrote in message
news:%23JrI45hhEHA.3016@tk2msftngp13.phx.gbl...
> One of the drivers I am writing is just a simple IO driver for some custom
> hardware. I make DeviceIoControl calls, it reads and writes the hardware
> and comes back with the results. Simple as pie.
>
> Normally everything works fine, but sometimes when I close the user- mode
> application that opened a handle to the driver, the application will
> perform
> the CloseHandle call (and it returns TRUE) but my driver's CloseHandle
> code
> will not get called. Afterwards, when I try to run the program again,
> several things happen.
>
> One: If I try to build the program again, the .EXE for the program is
> locked
> up and can't be rebuilt. Like it hasn't actually exited yet.
>
> Two: If I just run the program again, the CreateFile call refuses to open
> a
> handle to my driver. It doesn't even reach my driver's OpenHandle call.
>
> Any ideas about why it doesn't get to my driver's CloseHandle call?
>
>



Re: Handle To Driver Not Closing by Doron

Doron
Thu Aug 19 23:18:14 CDT 2004

also, are you completing all requests that you have pended? if you have
left any queued in your driver, the handle will not truly close until they
are completed.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Peter Wieland [MSFT]" <peterwie@online.microsoft.com> wrote in message
news:OL$9RzihEHA.3980@TK2MSFTNGP12.phx.gbl...
> do you not see a cleanup either? Or just not a close?
>
> -p
>
> --
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> "Gereon" <gereon_msdn@alwaysfind.us> wrote in message
> news:%23JrI45hhEHA.3016@tk2msftngp13.phx.gbl...
> > One of the drivers I am writing is just a simple IO driver for some
custom
> > hardware. I make DeviceIoControl calls, it reads and writes the
hardware
> > and comes back with the results. Simple as pie.
> >
> > Normally everything works fine, but sometimes when I close the user-
mode
> > application that opened a handle to the driver, the application will
> > perform
> > the CloseHandle call (and it returns TRUE) but my driver's CloseHandle
> > code
> > will not get called. Afterwards, when I try to run the program again,
> > several things happen.
> >
> > One: If I try to build the program again, the .EXE for the program is
> > locked
> > up and can't be rebuilt. Like it hasn't actually exited yet.
> >
> > Two: If I just run the program again, the CreateFile call refuses to
open
> > a
> > handle to my driver. It doesn't even reach my driver's OpenHandle call.
> >
> > Any ideas about why it doesn't get to my driver's CloseHandle call?
> >
> >
>
>



Handle To Driver Not Closing by steve

steve
Sun Aug 22 21:49:12 CDT 2004

I don't really know the cause of your problem, but I have
a similar problem when I install/uninstall an NDIS
intermediate driver. I have a UI that uses
DeviceIoControl calls to the driver - I exit my UI and
uninstall the driver and when I attempt to reinstall the
driver it fails, and I know it is because something in
the system still has a handle open to it! The only way I
can solve my problem is to either log off and log on or
reboot.

Are sure there are no bugs in your interface to your
driver, perhaps one of your ioctrl handlers is getting
stuck in a loop or something and therefore the handle to
the driver cannot be closed. Are you opening the driver
using overlapped I/O? I would comment out all my ioctrl
handlers and just continually open and close the driver
and see if the problem still happens.

>-----Original Message-----
>One of the drivers I am writing is just a simple IO
driver for some custom
>hardware. I make DeviceIoControl calls, it reads and
writes the hardware
>and comes back with the results. Simple as pie.
>
>Normally everything works fine, but sometimes when I
close the user- mode
>application that opened a handle to the driver, the
application will perform
>the CloseHandle call (and it returns TRUE) but my
driver's CloseHandle code
>will not get called. Afterwards, when I try to run the
program again,
>several things happen.
>
>One: If I try to build the program again, the .EXE for
the program is locked
>up and can't be rebuilt. Like it hasn't actually exited
yet.
>
>Two: If I just run the program again, the CreateFile
call refuses to open a
>handle to my driver. It doesn't even reach my driver's
OpenHandle call.
>
>Any ideas about why it doesn't get to my driver's
CloseHandle call?
>
>
>.
>

Re: Handle To Driver Not Closing by Gereon

Gereon
Mon Aug 30 14:05:30 CDT 2004

I'm sorry I didn't get back to maintaining my post sooner. I have so many
disparate things going on, stuff falls through the cracks everywhere. I
really would like to find out why this happened with this driver, but ever
since I unintentionally "fixed" it, I haven't been able to reproduce the
problem.

So far, all the IOCTL calls I make are synchronous on this particular
driver; I don't pend anything. The majority end up just reading hardware
registers and passing back the results. However, a couple of them perform
writes, and I was able to track the "failure to close" problem as occurring
after I made an IOCTL call that specified METHOD_IN_DIRECT,
FILE_WRITE_ACCESS. I thought hmm, inadequate permission somehow? So using
SysInternal's WINOBJ tool, I turned on all the privileges for Administrators
on the driver and the problem stopped. I tried to get it to occur again by
putting the permissions back, but of course now it continues to work. I
system- restored to an earlier time and re- installed the hardware, but it
still continues to work.

If/ when this shows up again, I'll make sure and investigate with the
suggestions I have received. If this post gives any more insight into what
the problem might have been (including, but not limited to, the possibility
that I'm just a clueless hack), feel free to suggest them. Until then, all
I can do about it is hope that it pops up again and investigate it more
carefully.


"Doron Holan [MS]" <doronh@nospam.microsoft.com> wrote in message
news:ed%23W4ymhEHA.1644@tk2msftngp13.phx.gbl...
> also, are you completing all requests that you have pended? if you have
> left any queued in your driver, the handle will not truly close until they
> are completed.
>
> d
>
> --
> Please do not send e-mail directly to this alias. this alias is for
> newsgroup purposes only.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
> "Peter Wieland [MSFT]" <peterwie@online.microsoft.com> wrote in message
> news:OL$9RzihEHA.3980@TK2MSFTNGP12.phx.gbl...
>> do you not see a cleanup either? Or just not a close?
>>
>> -p
>>
>> --
>> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>> "Gereon" <gereon_msdn@alwaysfind.us> wrote in message
>> news:%23JrI45hhEHA.3016@tk2msftngp13.phx.gbl...
>> > One of the drivers I am writing is just a simple IO driver for some
> custom
>> > hardware. I make DeviceIoControl calls, it reads and writes the
> hardware
>> > and comes back with the results. Simple as pie.
>> >
>> > Normally everything works fine, but sometimes when I close the user-
> mode
>> > application that opened a handle to the driver, the application will
>> > perform
>> > the CloseHandle call (and it returns TRUE) but my driver's CloseHandle
>> > code
>> > will not get called. Afterwards, when I try to run the program again,
>> > several things happen.
>> >
>> > One: If I try to build the program again, the .EXE for the program is
>> > locked
>> > up and can't be rebuilt. Like it hasn't actually exited yet.
>> >
>> > Two: If I just run the program again, the CreateFile call refuses to
> open
>> > a
>> > handle to my driver. It doesn't even reach my driver's OpenHandle
>> > call.
>> >
>> > Any ideas about why it doesn't get to my driver's CloseHandle call?
>> >
>> >
>>
>>
>
>



Re: Handle To Driver Not Closing by m

m
Tue Aug 31 09:00:54 CDT 2004

you can use process explorer from sysinternals to search for your
driver handle and see which component has it open

"steve" <anonymous@discussions.microsoft.com> wrote in message news:<b0d001c488bb$c55c29f0$a601280a@phx.gbl>...
> I don't really know the cause of your problem, but I have
> a similar problem when I install/uninstall an NDIS
> intermediate driver. I have a UI that uses
> DeviceIoControl calls to the driver - I exit my UI and
> uninstall the driver and when I attempt to reinstall the
> driver it fails, and I know it is because something in
> the system still has a handle open to it! The only way I
> can solve my problem is to either log off and log on or
> reboot.
>
> Are sure there are no bugs in your interface to your
> driver, perhaps one of your ioctrl handlers is getting
> stuck in a loop or something and therefore the handle to
> the driver cannot be closed. Are you opening the driver
> using overlapped I/O? I would comment out all my ioctrl
> handlers and just continually open and close the driver
> and see if the problem still happens.
>
> >-----Original Message-----
> >One of the drivers I am writing is just a simple IO
> driver for some custom
> >hardware. I make DeviceIoControl calls, it reads and
> writes the hardware
> >and comes back with the results. Simple as pie.
> >
> >Normally everything works fine, but sometimes when I
> close the user- mode
> >application that opened a handle to the driver, the
> application will perform
> >the CloseHandle call (and it returns TRUE) but my
> driver's CloseHandle code
> >will not get called. Afterwards, when I try to run the
> program again,
> >several things happen.
> >
> >One: If I try to build the program again, the .EXE for
> the program is locked
> >up and can't be rebuilt. Like it hasn't actually exited
> yet.
> >
> >Two: If I just run the program again, the CreateFile
> call refuses to open a
> >handle to my driver. It doesn't even reach my driver's
> OpenHandle call.
> >
> >Any ideas about why it doesn't get to my driver's
> CloseHandle call?
> >
> >
> >.
> >