Hello all,
I am developing a NDIS miniport driver which also exposes a file interface
(for CreateFile(), ReadFile(), WriteFile() etc).I created this file
interface inside the MiniportInitialize() function using
NdisMRegisterDevice() API. There are few problems which I am getting as
follows:
1. If I try to assign different dispatch entry point functions then my
driver is breaking the system (I am getting blue screen). The only way to
avoid this I found is to use the same function for all the IRP dispatche
entry points like below:
DispatchTable[IRP_MJ_CREATE] = MyDeviceHook;
DispatchTable[IRP_MJ_CLOSE] = MyDeviceHook;
DispatchTable[IRP_MJ_READ] = MyDeviceHook;
DispatchTable[IRP_MJ_WRITE] = MyDeviceHook;
DispatchTable[IRP_MJ_DEVICE_CONTROL] = MyDeviceHook;
DispatchTable[IRP_MJ_CLEANUP] = MyDeviceHook;
NdisInitUnicodeString(&DeviceName, NT_DEVICE_NAME);
NdisInitUnicodeString(&DosDeviceName, DOS_DEVICE_NAME);
Status = NdisMRegisterDevice(g_NdisWrapperHandle,
&DeviceName,&DosDeviceName,&DispatchTable[0],&tapDevice->devObj,&tapDevice->handle);
and then use switch cases inside the MyDeviceHook() function for
pIrpSp->MajorFunction to direct to particular function for handling read,
write, close etc.
My question is why I am unable to specify different dispatch entry point
functions here? Is it something wrong with NDisMRegisterDevice() API. DDK
documentation says that I should use as many different dispatch entry point
functions for my different IRP_MJ_XXX codes handle by the driver.
2. Secondly I am using Cancel-Safe Irp (not Ex version) mechanism to pend
read Irps until data is available from the other end of my Ndis miniport (i
am transferring TCP/IP packets to my the user application via ReadFile()).
However, when a read Irp is pending and I call CloseHandle() from my user
application to close the handle, I expect that Close Irp will be called but
it never get called and my application hangs. Please tell me why is it
happening like that?
I am using WinDDK (2600~1.110) on my Windows XP machine. Please reply soon
as I am meeting deadlines.
Thanks,
Arsalan