About IOCTL_HID_GET_REPORT

Hi,

I have a driver installed as the lower filter of the hid mouse class driver to retrieve the mouse raw HID report. Meanwhile, I have a raw pdo to communicate with our app to send out the raw hid report. When the raw pdo receive the read request, I open the remote IO target of the mouse the device with its pdo’s name with the FILE_WRITE_ACCESS. It succeeds. However, when I tried to send the IOCTL_HID_GET_REPORT to that remote IO target with calling the WdfIoTargetFormatRequestForIoCtrl/WdfIoTargetFormatRequestForInternalIoctl, it failed with the status code 0xc0000010 and then crashed.

2: kd> !error 0n-1073741808 1
Error code: (NTSTATUS) 0xc0000010 - The specified request is not a valid operation for the target device.

Is it right way to go? Or maybe I should try IOCTL_HID_GET_INPUT_REPORT?

Thanks,
Marshall

On May 28, 2018, at 12:01 AM, xxxxx@hotmail.com wrote:
>
> I have a driver installed as the lower filter of the hid mouse class driver to retrieve the mouse raw HID report. Meanwhile, I have a raw pdo to communicate with our app to send out the raw hid report. When the raw pdo receive the read request, I open the remote IO target of the mouse the device with its pdo’s name with the FILE_WRITE_ACCESS. It succeeds. However, when I tried to send the IOCTL_HID_GET_REPORT to that remote IO target with calling the WdfIoTargetFormatRequestForIoCtrl/WdfIoTargetFormatRequestForInternalIoctl, it failed with the status code 0xc0000010 and then crashed.
>
> 2: kd> !error 0n-1073741808 1
> Error code: (NTSTATUS) 0xc0000010 - The specified request is not a valid operation for the target device.
>
> Is it right way to go? Or maybe I should try IOCTL_HID_GET_INPUT_REPORT?

Which driver are you filtering, exactly? Depending on your location in the stack, your PDO may actually be expecting URBs, not HID requests.

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi Tim,

It’s the mouse class lower filter driver. I want to borrow the idea from the WDK sample VFeature.

[Version]
Signature = “$Windows NT$”
CatalogFile = mc_mouse_hid_filter.cat
Class = Mouse
ClassGUID = {4D36E96F-E325-11CE-BFC1-08002BE10318}
Provider = %MC%
DriverVer=05/12/2017,0.01.999

[Hid_LowerFilter]
HKR,“LowerFilters”,%REG_MULTI_SZ%,“mc_generic_hid_filter”

Since this is on the mouse stack, I open the remote IO target with the FILE_WRITE_ACCESS.
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.ParentObject = hDevice;

status = WdfIoTargetCreate(hDevice, &attributes, &hIoTarget);
IfFailGoToExit(status, LSH_IO, “WdfIoTargetCreate failed”);

WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(
&openParams,
pTargetName,
FILE_WRITE_ACCESS
);

//
// We will let the framework to respond automatically to the pnp
// state changes of the target by closing and opening the handle.
//
openParams.ShareAccess = FILE_SHARE_WRITE | FILE_SHARE_READ;

status = WdfIoTargetOpen(hIoTarget, &openParams);
IfFailGoToExit(status, LSH_IO, “WdfIoTargetOpen failed”);

When the raw pdo receives the read request from the application, it creates the new request to send out the IOCTL code.
status = WdfRequestRetrieveOutputMemory(Request, &hMemory);
IfFailGoToExit(status, LSH_IO, “WdfRequestRetrieveOutputMemory failed”);

WdfMemoryGetBuffer(hMemory, &bufferSize);

status = WdfMemoryCreate(
WDF_NO_OBJECT_ATTRIBUTES,
NonPagedPoolNx,
DRIVERTAG,
bufferSize,
&hMemory,
NULL
);

status = WdfRequestCreate(NULL, pFileObjectExtension->hIoTarget, &hRequest);

status = WdfIoTargetFormatRequestForInternalIoctl(pFileObjectExtension->hIoTarget,
hRequest, IOCTL_HID_READ_REPORT, NULL, NULL, hMemory, NULL);
IfFailGoToExit(status, LSH_IO, “WdfIoTargetFormatRequestForIoctl failed”);

Thanks,
Marshall