Hi!
I’m developing an application based on a driver supplied by Microchip
(mchpusb.sys) that’s developed by Walter Oney.
My applicaton now kinda works, but the problem is that the User mode
application can’t pool the Usb device in Real-time (for every frame on
1ms) so my buffer on the PIC18F4550 device gets overflowed all the time.
I just need to read from a Usb device more often.
I think that I must develop a filter driver that’s on top of this
function driver from Microchip and that I must reorganize the
IRP_MJ_READ packets so I created a timer that will send an IRP_MJ_READ
down every one msec and store the data in the buffer. And for every
IRP_MJ_READ that I handle from the user mode app I will send the data
from this buffer.
The problem is that the function driver from Microchip crashes when I
send an IRP_MJ_READ in the timer routine :::
LARGE_INTEGER Offset;
Offset.HighPart = Offset.LowPart = 0;
KEVENT Event;
KeInitializeEvent(&Event,NotificationEvent,FALSE);
IO_STATUS_BLOCK ioStatus;
PIRP Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
pdx->LowerDeviceObject, pdx->ReadBuff, 64, &Offset, &Event, &ioStatus);
if (Irp==NULL) {
return;
}
NTSTATUS ntStatus = IoCallDriver(pdx->LowerDeviceObject, Irp);
if(ntStatus == STATUS_PENDING) {
ntStatus = KeWaitForSingleObject(&Event, Executive, KernelMode,
FALSE, NULL);
}
The user mode handles are created with
\?\usb#vid_1111&pid_1111#000#{5354fa28-6d14-4e35-a1f5-75bb54e6030f}/MCH
P_EP1
Where the MCHP_EP1 stands for end point 1 of the Usb device.
Do I need to remember something in the handle from IRP_MJ_CREATE and use
that in creation on the new IRP_MJ_READ?
What am I doing wrong?
Will this function driver even work?
Martin