> OK, good point, I think indeed this might be the problem. Just to be
sure: DriverEntry is called each time I connect the first of my 1394
device. And the driver will be unloaded not before I disconnected my
last 1394 device, is that correct?
If yes, I have that “unload” problem, but I don’t know why. It even
happens if I didn’t access the device from an application.
Driver Entry is called when the driver is loaded. This generally occurs
when you plug in the first device.
The DriverUnload routine will be called when the driver is unloaded.
If this routine has not been declared the driver will not be unloaded
(I think). It will generally be called when the last device is removed
but not if some process still has a handle open.
I use dbgview from sysinternals.com to see debug messages. I haven’t
used SoftIce (but I would like to) but I’m sure it will give you
something equivalent (or better). I place a debug message in the load
and unload routine to directly observe loading and unloading. I do not
trust to any other method or logical argument (usually based on
observations of AddDevice and IRP_MN_REMOVE_DEVICE) period.
There are just too many
things that can interfere and it is very annoying when you update the
driver and can’t figure out why your changes haven’t accomplished
anything, only to discover after much work that the driver isn’t being
updated (this can also be dealt with by religiously updating the
version number).
I too used 1394diag as a starting point for my driver (I would do
things differently know that I know a little more). If you use the
SubmitIrpSynch routine for communication with the 1394 driver than
fixing the UserMode issue can be as simple as the following code:
if (Irb) {
if (!Irp || Irp->RequestorMode == UserMode) {
// allocate an IRP
Irp = IoAllocateIrp(…
Robert Newton