// JP opened flex table

Click to See Complete Forum and Search --> : HID minidriver


sriranga_s
November 30th, 2004, 01:49 AM
Hi,
I have developed a HID minidriver for a USB keyboard(for win 2k) in DDK. My keyboard is not a standard keyboard since it contains some sliders and other keys. I have been able to load the my driver instead of the system supplied driver. In my application, I want a ahndle to this keyboard so that I can read\write data. So I ahve called the SetupDiXXX() routines in order. At the end, if I call CreateFile(..), with dwDesiredAccess as GENERIC_READ|GENERIC_WRITE its returning INVALID_HANDLE_VALUE. When I called GetLastError(), it gave a value of 5, which means ACCESS_DENIED. However when I calll CraeteFile() with the dwDesiredAccess = 0, it opens a handle but I cant do read\write with this.
So my question is why am getting that error when I try to open a ahndle with dwDesiredAccess = GENERIC_READ|GENERIC_WRITE .
Plz help me out.

Thanks,
Sri

And-or
November 30th, 2004, 09:11 AM
How do you handle IRP_MJ_CREATE in your driver? The problem is probably in this dispatch routine.

Best regards
And-or

sriranga_s
December 1st, 2004, 07:19 AM
Hi,
In my IRP_MJ_CREATE/CLOSE dispatch routines, I'm simply completing the request. So my doubt is - Do I have to do something in these dispatch routines? Like setting some previliges or something?
One more doubt I have - If HidUsb.sys is loaded as default driver, it will not allow any handles to be opened. Since I'm replacing HidUsb.sys with my driver, is this problem happening?

Thanks,
Sriranga

And-or
December 1st, 2004, 08:36 AM
Hmm, completing IRP should work fine (I assume that you're completing IRP with STATUS_SUCCESS). Here is how I would do this:

In my driver:
1. Create device and create symbolic link (say, "\\DosDevices\\UsbKeyboard") or other interface
2. In dispatch routines - complete IRPs with STATUS_SUCCESS : IRP_MJ_CREATE, IRP_MJ_CLOSE, IRP_MJ_CLEANUP

In my app:
1. Open device handle: CreateFile("\\\\.\\UsbKeyboard", GENERIC_READ | GENERIC_WRITE ....).

This _should_ work. If it doesn't, maybe there is upper filter installed above your device and it rejects all IRP_MJ_CREATE IRPs.
I'm sorry, but I can't help you more :(.

Try this article:
http://www.phdcc.com/WDMarticle.html
maybe it will help you.

Best regards
And-or

sriranga_s
December 1st, 2004, 10:33 PM
Thanks for the reply.
I'm indeed completing the IRP_MJ_CREATE dispatch routine with STATUS_SUCCESS only. The steps which u have indicated is fine for any normal USB driver. But for HID - minidriver, I'll not be creating a deviceobject. I'll be just registering for HID class driver and will be using its device object. SO its a diffrerent story altogether!!!!
Anyone else has any idea about my prob???

And-or
December 3rd, 2004, 08:57 AM
I did't know that. Well, now I do :).
Anyway I've asked google about CreateFile and HID, and I have found something about that:

http://groups.google.pl/groups?hl=pl&lr=&threadm=072701c30b3b%2420f1a830%24a601280a%40phx.gbl&rnum=6&prev=/groups%3Fq%3Dcreatefile%2Bhid%26hl%3Dpl%26lr%3D%26selm%3D072701c30b3b%252420f1a830%2524a601280a%2540phx.gbl%26rnum%3D6

And-or

//JP added flex table