I have an Win2K IF driver. It is loaded and unloaded
manually from Win32, using CreateService(),
StartService, and ControlService(SERVICE_CONTROL_STOP),
DeleteService().
Using IOCTLs, Win32 tells the driver to mount or
dismount a volume. All this works fine.
My problem is with loading the driver again after it
was unloaded. Turns out that if the driver was not
asked to mount a volume before it was unloaded, then I
can always load the driver again. However, if the
driver mounted (and dismounted) a volume, I can unload
it but cannot load it again. I wonder if anyone might
have idea what am I doing wrong.
I am guessing that more info is probably needed to
answer the question. When I unload the driver, the
driver’s unload function is called correctly, and
the registry structure for the service is removed
correctly. When I load it again, here is what happens:
-
CreateService() always succeeds, and builds the
registry subtree as expected.
-
StartService() succeeds if the driver did not mount a
volume before. It fails with Win32 err=2
(ERROR_FILE_NOT_FOUND) if the driver mounted a volume
before. Note that this error is not the same as
err=3 (ERROR_PATH_NOT_FOUND) which could be returned
if the SYS file is not found. In my case, the SYS
file is there.
Any help would be highly appreciated.
Thanks
Chuck Shavit
You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
Reloading a driver is perennial trouble spot. It may be that your driver
.sys file is still marked “in use”; in my experience, a driver
executable cannot be used a second time if the OS regards the driver as
still loaded, and that is true even if a different driver name is used
on the second attempt. Try using WinObj (www.systerinals.com) or DevView
(www.oneysoft.com) to see if your driver name appears under the Driver
node. If it’s there, you won’t be able to use your executable again
until the driver is gone completely.
As to why, all I can suggest is to use the OS checked build, attach
windbg (or run SoftICE) and see if any interesting messages appear in
kernel space.
–
James Antognini
IBM Watson Research
You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
Thank you, James.
I have already tried your two suggestions before. After the driver is
unloaded, there is no trace of it in the system. I am using WinObj and
Numega’s DeviceTree. I am using SoftIce for debug, and I can see no error
message in the log.
Also, as I have mentioned, I can always re-load the driver, unless the
driver mounted a volume before being unloaded.
BTW, re WinObj, there are several flavors of this tool, all with the same
name. I am using the one from Mark Russinovich’s Inside Windows 2000 book,
which is highly recommended (both the book and the tools it has).
thanks,
Chuck
On 05/28/01, “James Antognini ” wrote:
> Reloading a driver is perennial trouble spot. It may be that your driver
> .sys file is still marked “in use”; in my experience, a driver
> executable cannot be used a second time if the OS regards the driver as
> still loaded, and that is true even if a different driver name is used
> on the second attempt. Try using WinObj (www.systerinals.com) or DevView
> (www.oneysoft.com) to see if your driver name appears under the Driver
> node. If it’s there, you won’t be able to use your executable again
> until the driver is gone completely.
>
> As to why, all I can suggest is to use the OS checked build, attach
> windbg (or run SoftICE) and see if any interesting messages appear in
> kernel space.
>
> –
> James Antognini
> IBM Watson Research
>
>
>
> —
> You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
I’m familiar with the book and share your opinion. I mentioned
www.sysinternals.com because Mark updates things from time to time and
so may have a newer version than what’s in the book.
I know you said your unload routine was called, but are you certain, and
certain that it ended normally? Eg, did you see a DbgPrint statement
just before it exited, or do you have some direct evidence (like hitting
a breakpoint) that the unload routine was about to exit normally, after
it had cleaned up everything (including deleting all devices it
created)?
–
James Antognini
IBM Watson Research
You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
Yes, the unload routine is called correctly every time. Indeed I have a
DbgPrint statement there. Plus, before returning from it, I have a lot of
ASSERTs that check that all the objects I know of (including the devices
created in the driver) are gone, all the lists used in the driver are
empty, etc.
Obviously, I must be leaving something out, but I can’t find what it is…
Chuck
On 05/28/01, “James Antognini ” wrote:
> I’m familiar with the book and share your opinion. I mentioned
> www.sysinternals.com because Mark updates things from time to time and
> so may have a newer version than what’s in the book.
>
> I know you said your unload routine was called, but are you certain, and
> certain that it ended normally? Eg, did you see a DbgPrint statement
> just before it exited, or do you have some direct evidence (like hitting
> a breakpoint) that the unload routine was about to exit normally, after
> it had cleaned up everything (including deleting all devices it
> created)?
>
> –
> James Antognini
> IBM Watson Research
>
>
>
> —
> You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
If I have the same problem I would insert a breakpoint to
the NtLoadDriver routine (or IopLoadUnloadDriver).
First of all you must be sure if something above this
lowest-level routine prevents loading of your driver.
If not then you have to trace the IopLoadUnloadDriver
to find out where is the rejection of the driver loading.
I thnik it’s not too difficult and/or time consuming.
Hope this helps
Paul
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of
xxxxx@MagicSquare.com
Sent: Monday, May 28, 2001 12:00 AM
To: File Systems Developers
Subject: [ntfsd] Re: Cannot re-load a driver
Yes, the unload routine is called correctly every time. Indeed I have a
DbgPrint statement there. Plus, before returning from it, I have a lot
of
ASSERTs that check that all the objects I know of (including the devices
created in the driver) are gone, all the lists used in the driver are
empty, etc.
Obviously, I must be leaving something out, but I can’t find what it
is…
Chuck
On 05/28/01, “James Antognini ” wrote:
> I’m familiar with the book and share your opinion. I mentioned
> www.sysinternals.com because Mark updates things from time to time and
> so may have a newer version than what’s in the book.
>
> I know you said your unload routine was called, but are you certain,
and
> certain that it ended normally? Eg, did you see a DbgPrint statement
> just before it exited, or do you have some direct evidence (like
hitting
> a breakpoint) that the unload routine was about to exit normally,
after
> it had cleaned up everything (including deleting all devices it
> created)?
>
> –
> James Antognini
> IBM Watson Research
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@compelson.com
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntfsd as: xxxxx@compelson.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> - CreateService() always succeeds, and builds the
registry subtree as expected.
- StartService() succeeds if the driver did not mount a
volume before. It fails with Win32 err=2
(ERROR_FILE_NOT_FOUND) if the driver mounted a volume
before. Note that this error is not the same as
err=3 (ERROR_PATH_NOT_FOUND) which could be returned
if the SYS file is not found. In my case, the SYS
file is there.
Keep ur Application .exe and Driver .sys file in same Directory and Try
once.
Regards,
Satish K.S
You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com