Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntoskrnl.exe/tests/driver_hid.c | 39 ++++++++++++++++++++ dlls/ntoskrnl.exe/tests/ntoskrnl.c | 53 +++++++++++++++++++++++++--- 2 files changed, 88 insertions(+), 4 deletions(-)
diff --git a/dlls/ntoskrnl.exe/tests/driver_hid.c b/dlls/ntoskrnl.exe/tests/driver_hid.c index 7c85e9a67db..049b4232753 100644 --- a/dlls/ntoskrnl.exe/tests/driver_hid.c +++ b/dlls/ntoskrnl.exe/tests/driver_hid.c @@ -290,6 +290,26 @@ static NTSTATUS WINAPI driver_internal_ioctl(DEVICE_OBJECT *device, IRP *irp) REPORT_SIZE(1, 1), FEATURE(1, Data|Var|Abs), END_COLLECTION, + + USAGE_PAGE(1, HID_USAGE_PAGE_LED), + USAGE(1, HID_USAGE_LED_GREEN), + COLLECTION(1, Report), + REPORT_ID_OR_USAGE_PAGE(1, report_id, 0), + USAGE_PAGE(1, HID_USAGE_PAGE_LED), + REPORT_COUNT(1, 8), + REPORT_SIZE(1, 1), + OUTPUT(1, Cnst|Var|Abs), + END_COLLECTION, + + USAGE_PAGE(1, HID_USAGE_PAGE_LED), + USAGE(1, HID_USAGE_LED_RED), + COLLECTION(1, Report), + REPORT_ID_OR_USAGE_PAGE(1, report_id, 1), + USAGE_PAGE(1, HID_USAGE_PAGE_LED), + REPORT_COUNT(1, 8), + REPORT_SIZE(1, 1), + OUTPUT(1, Cnst|Var|Abs), + END_COLLECTION, END_COLLECTION, }; #undef REPORT_ID_OR_USAGE_PAGE @@ -403,6 +423,25 @@ static NTSTATUS WINAPI driver_internal_ioctl(DEVICE_OBJECT *device, IRP *irp) break; }
+ case IOCTL_HID_SET_OUTPUT_REPORT: + { + HID_XFER_PACKET *packet = irp->UserBuffer; + ULONG expected_size = 2; + todo_wine ok(in_size == sizeof(*packet), "got input size %u\n", in_size); + todo_wine ok(!out_size, "got output size %u\n", out_size); + + todo_wine_if(packet->reportId != report_id) + ok(packet->reportId == report_id, "got packet report id %u\n", packet->reportId); + todo_wine_if(packet->reportBufferLen == 0 || packet->reportBufferLen == 1) + ok(packet->reportBufferLen >= expected_size, "got packet buffer len %u, expected %d or more\n", + packet->reportBufferLen, expected_size); + ok(!!packet->reportBuffer, "got packet buffer %p\n", packet->reportBuffer); + + irp->IoStatus.Information = 3; + ret = STATUS_SUCCESS; + break; + } + case IOCTL_HID_GET_FEATURE: { HID_XFER_PACKET *packet = irp->UserBuffer; diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 4fe63e8b833..f33c56afcfc 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -1684,8 +1684,9 @@ static void test_hidp(HANDLE file, int report_id) .Usage = HID_USAGE_GENERIC_JOYSTICK, .UsagePage = HID_USAGE_PAGE_GENERIC, .InputReportByteLength = 24, + .OutputReportByteLength = 3, .FeatureReportByteLength = 18, - .NumberLinkCollectionNodes = 8, + .NumberLinkCollectionNodes = 10, .NumberInputButtonCaps = 13, .NumberInputValueCaps = 7, .NumberInputDataIndices = 43, @@ -1698,8 +1699,9 @@ static void test_hidp(HANDLE file, int report_id) .Usage = HID_USAGE_GENERIC_JOYSTICK, .UsagePage = HID_USAGE_PAGE_GENERIC, .InputReportByteLength = 23, + .OutputReportByteLength = 2, .FeatureReportByteLength = 17, - .NumberLinkCollectionNodes = 8, + .NumberLinkCollectionNodes = 10, .NumberInputButtonCaps = 13, .NumberInputValueCaps = 7, .NumberInputDataIndices = 43, @@ -1841,8 +1843,8 @@ static void test_hidp(HANDLE file, int report_id) .LinkUsage = HID_USAGE_GENERIC_JOYSTICK, .LinkUsagePage = HID_USAGE_PAGE_GENERIC, .CollectionType = 1, - .NumberOfChildren = 5, - .FirstChild = 7, + .NumberOfChildren = 7, + .FirstChild = 9, }, { .LinkUsage = HID_USAGE_GENERIC_JOYSTICK, @@ -2559,6 +2561,49 @@ static void test_hidp(HANDLE file, int report_id) todo_wine ok(value == 3, "got length %u, expected 3\n", value);
+ memset(report, 0xcd, sizeof(report)); + status = HidP_InitializeReportForID(HidP_Output, report_id, preparsed_data, report, caps.OutputReportByteLength); + ok(status == HIDP_STATUS_REPORT_DOES_NOT_EXIST, "HidP_InitializeReportForID returned %#x\n", status); + memset(report, 0, caps.OutputReportByteLength); + report[0] = report_id; + + SetLastError(0xdeadbeef); + ret = HidD_SetOutputReport(file, report, 0); + todo_wine ok(!ret, "HidD_SetOutputReport succeeded\n"); + todo_wine ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "HidD_SetOutputReport returned error %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = HidD_SetOutputReport(file, report, caps.OutputReportByteLength - 1); + todo_wine ok(!ret, "HidD_SetOutputReport succeeded\n"); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "HidD_SetOutputReport returned error %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + memset(buffer, 0x5a, sizeof(buffer)); + ret = HidD_SetOutputReport(file, buffer, caps.OutputReportByteLength); + if (!report_id) + ok(ret, "HidD_SetOutputReport failed, last error %u\n", GetLastError()); + else + { + todo_wine ok(!ret, "HidD_SetOutputReport succeeded, last error %u\n", GetLastError()); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "HidD_SetOutputReport returned error %u\n", GetLastError()); + } + + SetLastError(0xdeadbeef); + ret = HidD_SetOutputReport(file, report, caps.OutputReportByteLength); + ok(ret, "HidD_SetOutputReport failed, last error %u\n", GetLastError()); + + value = caps.OutputReportByteLength * 2; + SetLastError(0xdeadbeef); + ret = sync_ioctl(file, IOCTL_HID_SET_OUTPUT_REPORT, NULL, 0, report, &value); + todo_wine ok(!ret, "IOCTL_HID_SET_OUTPUT_REPORT succeeded\n"); + todo_wine ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "IOCTL_HID_SET_OUTPUT_REPORT returned error %u\n", GetLastError()); + value = 0; + SetLastError(0xdeadbeef); + ret = sync_ioctl(file, IOCTL_HID_SET_OUTPUT_REPORT, report, caps.OutputReportByteLength * 2, NULL, &value); + ok(ret, "IOCTL_HID_SET_OUTPUT_REPORT failed, last error %u\n", GetLastError()); + todo_wine ok(value == 3, "got length %u, expected 3\n", value); + + HidD_FreePreparsedData(preparsed_data); CloseHandle(file); }