Why would you go to ZwOpenFile if ioGetDeviceObjectPointer fails? They both open a file handle, the Io version just doesn?t give it back to you. You can never open keyboards and mice for read, it has always been that way. It sounds like something else is opening your HID, you could look at the handle and pointer count (!object) on the pdo. You could also put a bp on the hidclass IRP_MJ_CREATE handler and see who is opening the pdo
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Philip Lukidis
Sent: Thursday, May 28, 2015 8:52 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Question on HID on Windows 10 (build 10122)
Hi Doran,
Thank you for your answer. It seems to affect other HID devices (keyboard/mouse) also, but I suppose that I should not be surprised that I cannot open those devices. For the case of our HID wheel, it’s pretty essential that I acquire the preparsed data so I could combine axes, etc in kernel mode without having to hardcode HID report offsets.
The usage page is generic desktop. I have posted the relevant code below (both IoGetDeviceObjectPointer and ZwOpenFile return STATUS_SHARING_VIOLATION). The device is an HID wheel, but in its initial configuration it appears as an HID gamepad. Our drivers then select the best device configuration, impart the instructions to the device, which then departs and returns as the correct HID wheel (with different VID/PID and report descriptor of course). The part which fails is so early that there is no attempt to reconfigure the HID gamepad device as an HID wheel. I assume that this code would fail for the wheel as well, but I will now test this to be sure.
Thank you,
Philip Lukidis
Here is the failing code (maybe the access/share masks are not correct):
status = IoGetDeviceObjectPointer(&ucsDeviceSymbLink,
GENERIC_READ,
&pHIDClassFileObject,
&pHIDClassDeviceObject);
if(status==STATUS_SHARING_VIOLATION)
{
InitializeObjectAttributes( &objectAttributes,
&ucsDeviceSymbLink,
OBJ_KERNEL_HANDLE,
(HANDLE) NULL,
(PSECURITY_DESCRIPTOR) NULL );
status = ZwOpenFile( &fHandle,
GENERIC_READ,
&objectAttributes,
&ioStatus,
FILE_SHARE_READ,
FILE_NON_DIRECTORY_FILE );
if(NT_SUCCESS(status))
{
status = ObReferenceObjectByHandle(fHandle,
THREAD_ALL_ACCESS,
*IoFileObjectType,
KernelMode,
(PVOID *) &pHIDClassFileObject,
NULL );
if(NT_SUCCESS(status))
{
pHIDClassDeviceObject=IoGetRelatedDeviceObject(pHIDClassFileObject);
}
From: xxxxx@lists.osr.commailto:xxxxx [mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: May-28-15 11:12 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Question on HID on Windows 10 (build 10122)
Happens for all HIDs? Just yours? What usage page?
d
Bent from my phone
________________________________
From: Philip Lukidismailto:xxxxx
Sent: ?5/?28/?2015 7:42 AM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: [ntdev] Question on HID on Windows 10 (build 10122)
Hello,
The following applies to Windows 10 build 10122, and not to any other versions of Windows, where I don’t have the issue I will now describe. In a worker thread after a successful start in my HID USB minidriver, I enumerate all HID devices via IoGetDeviceInterfaces(GUID_DEVINTERFACE_HID), and then find the HIDClass device and file objects via IoGetDeviceObjectPointer, so that I may query the preparsed data and obtain caps (IOCTL_HID_GET_COLLECTION_INFORMATION, IOCTL_HID_GET_COLLECTION_DESCRIPTOR, and HidP_GetCaps, etc). However, it seems that IoGetDeviceObjectPointer(FILE_READ_ATTRIBUTES) and ZwOpenFile(STANDARD_RIGHTS_READ) both return STATUS_SHARING_VIOLATION.
So the question is, how may I obtain the HIDClass device and file objects, so that I may obtain the HID preparsed information and caps?
Thank you,
Philip Lukidis
—
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
—
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
—
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx></mailto:xxxxx>