Handle to DeviceIOControl becomes invalid

Has anyone come across the situation where the handle to DeviceIOControl
suddenly becomes invalid. The error returned by GetLastError() is 6
(ERROR_INVALID_HANDLE). The value of the handle is unchanged and looks
like this start happening after several hundred succesful calls to
DeviceIOControl with same IOCTL and same handle.

Its an ISA based driver running on Windows 2000 professional. The driver
has been stable for several years and it looks unlikely that it may have a
bug that can cause this. I am tempted to see things only in user-mode
driver dll. Can anyone set my on the right path on how to debug this
problem ? I do have a rudimentry kernel debugging setup as well. Where
should I start looking ?

thanks,
Hassan

One update on this. As a work around I decided to get a new handle each
time the old one becomes invalid. I do make sure that I call CloseHandle
on the old one once the new one is generated. This strategy seems to work
but naturally its not the right solution.

I also used the HandleEx.exe from sysinternals and found that ( without
the workaround mentioned above) there comes a point when no handle is
shown for the device object I opened. Of course even the device object is
no longer listed. All other handles are intact and everything else seems
to be working fine.

Specifically, I want to know

1 - What can cause the handle to become invalid ? ( I have double checked
CloseHandle is not being called accidently anywhere )

2 - If an handle becomes invalid and I call CloseHandle on it whats the
side effect ?

thanks for any comments,

regards,
Hassan

if the driver calls [Nt|Zw]Close on the handle somehow while in the
context of your process that could cause the problem.

-p

-----Original Message-----
From: Hassan [mailto:xxxxx@hotmail.com]
Sent: Friday, August 30, 2002 3:37 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Handle to DeviceIOControl becomes invalid

One update on this. As a work around I decided to get a new handle each
time the old one becomes invalid. I do make sure that I call CloseHandle
on the old one once the new one is generated. This strategy seems to
work but naturally its not the right solution.

I also used the HandleEx.exe from sysinternals and found that ( without
the workaround mentioned above) there comes a point when no handle is
shown for the device object I opened. Of course even the device object
is no longer listed. All other handles are intact and everything else
seems to be working fine.

Specifically, I want to know

1 - What can cause the handle to become invalid ? ( I have double
checked CloseHandle is not being called accidently anywhere )

2 - If an handle becomes invalid and I call CloseHandle on it whats the
side effect ?

thanks for any comments,

regards,
Hassan


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%