Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntoskrnl.exe/tests/driver_hid.c | 28 ++++---- dlls/ntoskrnl.exe/tests/pop_hid_macros.h | 83 +++++++++++++++++++++++ dlls/ntoskrnl.exe/tests/psh_hid_macros.h | 85 ++++++++++++++++++++++++ 3 files changed, 184 insertions(+), 12 deletions(-) create mode 100644 dlls/ntoskrnl.exe/tests/pop_hid_macros.h create mode 100644 dlls/ntoskrnl.exe/tests/psh_hid_macros.h
diff --git a/dlls/ntoskrnl.exe/tests/driver_hid.c b/dlls/ntoskrnl.exe/tests/driver_hid.c index 44ec1b09526..819d4174dcf 100644 --- a/dlls/ntoskrnl.exe/tests/driver_hid.c +++ b/dlls/ntoskrnl.exe/tests/driver_hid.c @@ -85,22 +85,26 @@ static NTSTATUS WINAPI driver_power(DEVICE_OBJECT *device, IRP *irp) return PoCallDriver(ext->NextDeviceObject, irp); }
+#include "psh_hid_macros.h" + static const unsigned char report_descriptor[] = { - 0x05, HID_USAGE_PAGE_GENERIC, - 0x09, HID_USAGE_GENERIC_JOYSTICK, - 0xa1, 0x01, /* application collection */ - 0x05, HID_USAGE_PAGE_GENERIC, - 0x09, HID_USAGE_GENERIC_X, - 0x09, HID_USAGE_GENERIC_Y, - 0x15, 0x80, /* logical minimum -128 */ - 0x25, 0x7f, /* logical maximum 127 */ - 0x75, 0x08, /* report size */ - 0x95, 0x02, /* report count */ - 0x81, 0x02, /* input, variable */ - 0xc0, /* end collection */ + USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), + USAGE(1, HID_USAGE_GENERIC_JOYSTICK), + COLLECTION(1, Application), + USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), + USAGE(1, HID_USAGE_GENERIC_X), + USAGE(1, HID_USAGE_GENERIC_Y), + LOGICAL_MINIMUM(1, -128), + LOGICAL_MAXIMUM(1, 127), + REPORT_SIZE(1, 8), + REPORT_COUNT(1, 2), + INPUT(1, Data|Var|Abs), + END_COLLECTION, };
+#include "pop_hid_macros.h" + static NTSTATUS WINAPI driver_internal_ioctl(DEVICE_OBJECT *device, IRP *irp) { IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp); diff --git a/dlls/ntoskrnl.exe/tests/pop_hid_macros.h b/dlls/ntoskrnl.exe/tests/pop_hid_macros.h new file mode 100644 index 00000000000..767c26e8ecb --- /dev/null +++ b/dlls/ntoskrnl.exe/tests/pop_hid_macros.h @@ -0,0 +1,83 @@ +/* + * HID report helper macros. + * + * Copyright 2021 Rémi Bernon for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#undef Data +#undef Cnst +#undef Array +#undef Var +#undef Abs +#undef Rel +#undef NoWrap +#undef Wrap +#undef NonLin +#undef Lin +#undef NoPref +#undef Pref +#undef NoNull +#undef Null +#undef NonVol +#undef Vol +#undef Bits +#undef Buff + +#undef Physical +#undef Application +#undef Logical +#undef Report +#undef NamedArray +#undef UsageSwitch +#undef UsageModifier + +#undef SHORT_ITEM_0 +#undef SHORT_ITEM_1 +#undef SHORT_ITEM_2 +#undef SHORT_ITEM_4 + +#undef LONG_ITEM + +#undef INPUT +#undef OUTPUT +#undef FEATURE +#undef COLLECTION +#undef END_COLLECTION + +#undef USAGE_PAGE +#undef LOGICAL_MINIMUM +#undef LOGICAL_MAXIMUM +#undef PHYSICAL_MINIMUM +#undef PHYSICAL_MAXIMUM +#undef UNIT_EXPONENT +#undef UNIT +#undef REPORT_SIZE +#undef REPORT_ID +#undef REPORT_COUNT +#undef PUSH +#undef POP + +#undef USAGE +#undef USAGE_MINIMUM +#undef USAGE_MAXIMUM +#undef DESIGNATOR_INDEX +#undef DESIGNATOR_MINIMUM +#undef DESIGNATOR_MAXIMUM +#undef STRING_INDEX +#undef STRING_MINIMUM +#undef STRING_MAXIMUM +#undef DELIMITER diff --git a/dlls/ntoskrnl.exe/tests/psh_hid_macros.h b/dlls/ntoskrnl.exe/tests/psh_hid_macros.h new file mode 100644 index 00000000000..4623af20598 --- /dev/null +++ b/dlls/ntoskrnl.exe/tests/psh_hid_macros.h @@ -0,0 +1,85 @@ +/* + * HID report helper macros. + * + * Copyright 2021 Rémi Bernon for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <hidusage.h> + +#define Data 0 +#define Cnst 0x01 +#define Ary 0 +#define Var 0x02 +#define Abs 0 +#define Rel 0x04 +#define NoWrap 0 +#define Wrap 0x08 +#define NonLin 0 +#define Lin 0x10 +#define NoPref 0 +#define Pref 0x20 +#define NoNull 0 +#define Null 0x40 +#define NonVol 0 +#define Vol 0x80 +#define Bits 0 +#define Buff 0x100 + +#define Physical 0x00 +#define Application 0x01 +#define Logical 0x02 +#define Report 0x03 +#define NamedArray 0x04 +#define UsageSwitch 0x05 +#define UsageModifier 0x06 + +#define SHORT_ITEM_0(tag,type) (((tag)<<4)|((type)<<2)|0) +#define SHORT_ITEM_1(tag,type,data) (((tag)<<4)|((type)<<2)|1),((data)&0xff) +#define SHORT_ITEM_2(tag,type,data) (((tag)<<4)|((type)<<2)|2),((data)&0xff),(((data)>>8)&0xff) +#define SHORT_ITEM_4(tag,type,data) (((tag)<<4)|((type)<<2)|3),((data)&0xff),(((data)>>8)&0xff),(((data)>>16)&0xff),(((data)>>24)&0xff) + +#define LONG_ITEM(tag,size) SHORT_ITEM_2(0xf,0x3,((tag)<<8)|(size)) + +#define INPUT(n,data) SHORT_ITEM_##n(0x8,0,data) +#define OUTPUT(n,data) SHORT_ITEM_##n(0x9,0,data) +#define FEATURE(n,data) SHORT_ITEM_##n(0xb,0,data) +#define COLLECTION(n,data) SHORT_ITEM_##n(0xa,0,data) +#define END_COLLECTION SHORT_ITEM_0(0xc,0) + +#define USAGE_PAGE(n,data) SHORT_ITEM_##n(0x0,1,data) +#define LOGICAL_MINIMUM(n,data) SHORT_ITEM_##n(0x1,1,data) +#define LOGICAL_MAXIMUM(n,data) SHORT_ITEM_##n(0x2,1,data) +#define PHYSICAL_MINIMUM(n,data) SHORT_ITEM_##n(0x3,1,data) +#define PHYSICAL_MAXIMUM(n,data) SHORT_ITEM_##n(0x4,1,data) +#define UNIT_EXPONENT(n,data) SHORT_ITEM_##n(0x5,1,data) +#define UNIT(n,data) SHORT_ITEM_##n(0x6,1,data) +#define REPORT_SIZE(n,data) SHORT_ITEM_##n(0x7,1,data) +#define REPORT_ID(n,data) SHORT_ITEM_##n(0x8,1,data) +#define REPORT_COUNT(n,data) SHORT_ITEM_##n(0x9,1,data) +#define PUSH(n,data) SHORT_ITEM_##n(0xa,1,data) +#define POP(n,data) SHORT_ITEM_##n(0xb,1,data) + +#define USAGE(n,data) SHORT_ITEM_##n(0x0,2,data) +#define USAGE_MINIMUM(n,data) SHORT_ITEM_##n(0x1,2,data) +#define USAGE_MAXIMUM(n,data) SHORT_ITEM_##n(0x2,2,data) +#define DESIGNATOR_INDEX(n,data) SHORT_ITEM_##n(0x3,2,data) +#define DESIGNATOR_MINIMUM(n,data) SHORT_ITEM_##n(0x4,2,data) +#define DESIGNATOR_MAXIMUM(n,data) SHORT_ITEM_##n(0x5,2,data) +#define STRING_INDEX(n,data) SHORT_ITEM_##n(0x6,2,data) +#define STRING_MINIMUM(n,data) SHORT_ITEM_##n(0x7,2,data) +#define STRING_MAXIMUM(n,data) SHORT_ITEM_##n(0x8,2,data) +#define DELIMITER(n,data) SHORT_ITEM_##n(0x9,2,data)
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 2 +- dlls/ntoskrnl.exe/tests/Makefile.in | 2 +- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index c4d162695a9..e936da418f2 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -221,7 +221,7 @@ NTSTATUS WINAPI HidP_GetCaps(PHIDP_PREPARSED_DATA PreparsedData,
TRACE("(%p, %p)\n",PreparsedData, Capabilities);
- if (data->magic != HID_MAGIC) + if (!data || data->magic != HID_MAGIC) return HIDP_STATUS_INVALID_PREPARSED_DATA;
*Capabilities = data->caps; diff --git a/dlls/ntoskrnl.exe/tests/Makefile.in b/dlls/ntoskrnl.exe/tests/Makefile.in index 8c2115984c5..863fad30f63 100644 --- a/dlls/ntoskrnl.exe/tests/Makefile.in +++ b/dlls/ntoskrnl.exe/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = ntoskrnl.exe -IMPORTS = advapi32 crypt32 newdev setupapi user32 wintrust ws2_32 +IMPORTS = advapi32 crypt32 newdev setupapi user32 wintrust ws2_32 hid
driver_IMPORTS = winecrt0 ntoskrnl driver_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 5e2520a3e12..6b70d98b6fd 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -40,6 +40,8 @@ #include "initguid.h" #include "devguid.h" #include "ddk/hidclass.h" +#include "ddk/hidsdi.h" +#include "ddk/hidpi.h" #include "wine/test.h" #include "wine/heap.h" #include "wine/mssign.h" @@ -1502,11 +1504,13 @@ static void test_hid_device(void) SP_DEVICE_INTERFACE_DETAIL_DATA_A *iface_detail = (void *)buffer; SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)}; SP_DEVINFO_DATA device = {sizeof(device)}; + PHIDP_PREPARSED_DATA preparsed_data; BOOL ret, found = FALSE; OBJECT_ATTRIBUTES attr; UNICODE_STRING string; IO_STATUS_BLOCK io; NTSTATUS status; + HIDP_CAPS caps; unsigned int i; HDEVINFO set; HANDLE file; @@ -1541,6 +1545,31 @@ static void test_hid_device(void) FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+ ret = HidD_GetPreparsedData(file, &preparsed_data); + ok(ret, "HidD_GetPreparsedData failed with error %u\n", GetLastError()); + + status = HidP_GetCaps(NULL, NULL); + ok(status == HIDP_STATUS_INVALID_PREPARSED_DATA, "HidP_GetCaps returned %#x\n", status); + status = HidP_GetCaps(preparsed_data, &caps); + ok(status == HIDP_STATUS_SUCCESS, "HidP_GetCaps returned %#x\n", status); + + ok(caps.Usage == HID_USAGE_GENERIC_JOYSTICK, "unexpected caps Usage %x, expected %x\n", caps.Usage, HID_USAGE_GENERIC_JOYSTICK); + ok(caps.UsagePage == HID_USAGE_PAGE_GENERIC, "unexpected caps UsagePage %x, expected %x\n", caps.UsagePage, HID_USAGE_PAGE_GENERIC); + ok(caps.InputReportByteLength == 3, "unexpected caps InputReportByteLength %d, expected %d\n", caps.InputReportByteLength, 3); + ok(caps.OutputReportByteLength == 0, "unexpected caps OutputReportByteLength %d, expected %d\n", caps.OutputReportByteLength, 0); + ok(caps.FeatureReportByteLength == 0, "unexpected caps FeatureReportByteLength %d, expected %d\n", caps.FeatureReportByteLength, 0); + ok(caps.NumberLinkCollectionNodes == 1, "unexpected caps NumberLinkCollectionNodes %d, expected %d\n", caps.NumberLinkCollectionNodes, 1); + ok(caps.NumberInputButtonCaps == 0, "unexpected caps NumberInputButtonCaps %d, expected %d\n", caps.NumberInputButtonCaps, 0); + ok(caps.NumberInputValueCaps == 2, "unexpected caps NumberInputValueCaps %d, expected %d\n", caps.NumberInputValueCaps, 2); + ok(caps.NumberInputDataIndices == 2, "unexpected caps NumberInputDataIndices %d, expected %d\n", caps.NumberInputDataIndices, 2); + ok(caps.NumberOutputButtonCaps == 0, "unexpected caps NumberOutputButtonCaps %d, expected %d\n", caps.NumberOutputButtonCaps, 0); + ok(caps.NumberOutputValueCaps == 0, "unexpected caps NumberOutputValueCaps %d, expected %d\n", caps.NumberOutputValueCaps, 0); + ok(caps.NumberOutputDataIndices == 0, "unexpected caps NumberOutputDataIndices %d, expected %d\n", caps.NumberOutputDataIndices, 0); + ok(caps.NumberFeatureButtonCaps == 0, "unexpected caps NumberFeatureButtonCaps %d, expected %d\n", caps.NumberFeatureButtonCaps, 0); + ok(caps.NumberFeatureValueCaps == 0, "unexpected caps NumberFeatureValueCaps %d, expected %d\n", caps.NumberFeatureValueCaps, 0); + ok(caps.NumberFeatureDataIndices == 0, "unexpected caps NumberFeatureDataIndices %d, expected %d\n", caps.NumberFeatureDataIndices, 0); + + HidD_FreePreparsedData(preparsed_data); CloseHandle(file);
RtlInitUnicodeString(&string, L"\??\root#winetest#0#{deadbeef-29ef-4538-a5fd-b69573a362c0}");
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=91703
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
ntoskrnl.exe: ntoskrnl.c:1236: Test failed: got 0 bus arrival messages ntoskrnl.c:1252: Test failed: got 0 bus arrival messages 0f48:ntoskrnl: unhandled exception c0000005 at 74881B19
=== w7u_el (32 bit report) ===
ntoskrnl.exe: 0a50:ntoskrnl: unhandled exception c0000005 at 73C51B19
=== w864 (64 bit report) ===
Report validation errors: ntoskrnl.exe:ntoskrnl crashed (c0000374)
=== debiant2 (32 bit Japanese:Japan report) ===
Report validation errors: ntoskrnl.exe:ntoskrnl prints too much data (33014 bytes)
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntoskrnl.exe/tests/driver_hid.c | 23 ++++++++++++++++++++++- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 8 ++++---- 2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/dlls/ntoskrnl.exe/tests/driver_hid.c b/dlls/ntoskrnl.exe/tests/driver_hid.c index 819d4174dcf..527dad65b53 100644 --- a/dlls/ntoskrnl.exe/tests/driver_hid.c +++ b/dlls/ntoskrnl.exe/tests/driver_hid.c @@ -100,6 +100,27 @@ static const unsigned char report_descriptor[] = REPORT_SIZE(1, 8), REPORT_COUNT(1, 2), INPUT(1, Data|Var|Abs), + + USAGE_PAGE(1, HID_USAGE_PAGE_BUTTON), + USAGE_MINIMUM(1, 1), + USAGE_MAXIMUM(1, 8), + LOGICAL_MINIMUM(1, 0), + LOGICAL_MAXIMUM(1, 1), + PHYSICAL_MINIMUM(1, 0), + PHYSICAL_MAXIMUM(1, 1), + REPORT_COUNT(1, 8), + REPORT_SIZE(1, 1), + INPUT(1, Data|Var|Abs), + + USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), + USAGE(1, HID_USAGE_GENERIC_HATSWITCH), + LOGICAL_MINIMUM(1, 1), + LOGICAL_MAXIMUM(1, 8), + PHYSICAL_MINIMUM(1, 0), + PHYSICAL_MAXIMUM(1, 8), + REPORT_SIZE(1, 4), + REPORT_COUNT(1, 2), + INPUT(1, Data|Var|Abs), END_COLLECTION, };
@@ -180,7 +201,7 @@ static NTSTATUS WINAPI driver_internal_ioctl(DEVICE_OBJECT *device, IRP *irp)
case IOCTL_HID_READ_REPORT: ok(!in_size, "got input size %u\n", in_size); - todo_wine ok(out_size == 2, "got output size %u\n", out_size); + todo_wine ok(out_size == 4, "got output size %u\n", out_size);
ret = STATUS_NOT_IMPLEMENTED; break; diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 6b70d98b6fd..27c8bcb33db 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -1555,13 +1555,13 @@ static void test_hid_device(void)
ok(caps.Usage == HID_USAGE_GENERIC_JOYSTICK, "unexpected caps Usage %x, expected %x\n", caps.Usage, HID_USAGE_GENERIC_JOYSTICK); ok(caps.UsagePage == HID_USAGE_PAGE_GENERIC, "unexpected caps UsagePage %x, expected %x\n", caps.UsagePage, HID_USAGE_PAGE_GENERIC); - ok(caps.InputReportByteLength == 3, "unexpected caps InputReportByteLength %d, expected %d\n", caps.InputReportByteLength, 3); + ok(caps.InputReportByteLength == 5, "unexpected caps InputReportByteLength %d, expected %d\n", caps.InputReportByteLength, 5); ok(caps.OutputReportByteLength == 0, "unexpected caps OutputReportByteLength %d, expected %d\n", caps.OutputReportByteLength, 0); ok(caps.FeatureReportByteLength == 0, "unexpected caps FeatureReportByteLength %d, expected %d\n", caps.FeatureReportByteLength, 0); ok(caps.NumberLinkCollectionNodes == 1, "unexpected caps NumberLinkCollectionNodes %d, expected %d\n", caps.NumberLinkCollectionNodes, 1); - ok(caps.NumberInputButtonCaps == 0, "unexpected caps NumberInputButtonCaps %d, expected %d\n", caps.NumberInputButtonCaps, 0); - ok(caps.NumberInputValueCaps == 2, "unexpected caps NumberInputValueCaps %d, expected %d\n", caps.NumberInputValueCaps, 2); - ok(caps.NumberInputDataIndices == 2, "unexpected caps NumberInputDataIndices %d, expected %d\n", caps.NumberInputDataIndices, 2); + ok(caps.NumberInputButtonCaps == 1, "unexpected caps NumberInputButtonCaps %d, expected %d\n", caps.NumberInputButtonCaps, 1); + ok(caps.NumberInputValueCaps == 3, "unexpected caps NumberInputValueCaps %d, expected %d\n", caps.NumberInputValueCaps, 3); + ok(caps.NumberInputDataIndices == 11, "unexpected caps NumberInputDataIndices %d, expected %d\n", caps.NumberInputDataIndices, 11); ok(caps.NumberOutputButtonCaps == 0, "unexpected caps NumberOutputButtonCaps %d, expected %d\n", caps.NumberOutputButtonCaps, 0); ok(caps.NumberOutputValueCaps == 0, "unexpected caps NumberOutputValueCaps %d, expected %d\n", caps.NumberOutputValueCaps, 0); ok(caps.NumberOutputDataIndices == 0, "unexpected caps NumberOutputDataIndices %d, expected %d\n", caps.NumberOutputDataIndices, 0);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=91704
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
ntoskrnl.exe: ntoskrnl.c:1236: Test failed: got 0 bus arrival messages ntoskrnl.c:1252: Test failed: got 0 bus arrival messages ntoskrnl.c:1253: Test failed: got 0 bus removal messages ntoskrnl.c:1278: Test failed: got 0 child arrival messages ntoskrnl.c:1285: Test failed: failed to get device, error 0x103 ntoskrnl.c:1286: Test failed: wrong class {4d36e97d-e325-11ce-bfc1-08002be10318} ntoskrnl.c:1289: Test failed: failed to get device ID, error 0x57 ntoskrnl.c:1290: Test failed: got ID "\x05" ntoskrnl.c:1294: Test failed: got error 0x57 ntoskrnl.c:1311: Test failed: got error 0x57 ntoskrnl.c:1316: Test failed: got error 0x57 ntoskrnl.c:1320: Test failed: got error 0x57 ntoskrnl.c:1321: Test failed: got type 6357104 ntoskrnl.c:1322: Test failed: got size 0 ntoskrnl.c:1327: Test failed: got error 0x57 ntoskrnl.c:1328: Test failed: got type 6357104 ntoskrnl.c:1329: Test failed: got size 0 ntoskrnl.c:1334: Test failed: got error 0x57 ntoskrnl.c:1361: Test failed: got 0 child arrival messages ntoskrnl.c:1362: Test failed: got 0 child removal messages ntoskrnl.c:1365: Test failed: got 0 ntoskrnl.c:1464: Test failed: failed to get device list, error 0xd ntoskrnl.c:294: Test failed: expected SERVICE_STOPPED, got 4 ntoskrnl.c:1640: Test failed: failed to install device, error 0x430 ntoskrnl.c:1542: Test failed: didn't find device ntoskrnl.c:1546: Test failed: got error 3 ntoskrnl.c:1549: Test failed: HidD_GetPreparsedData failed with error 6 0ddc:ntoskrnl: unhandled exception c0000005 at 73551B19
=== w7u_el (32 bit report) ===
ntoskrnl.exe: 0a48:ntoskrnl: unhandled exception c0000005 at 73C51B19
=== w864 (64 bit report) ===
Report validation errors: ntoskrnl.exe:ntoskrnl crashed (c0000374)
=== debiant2 (32 bit Japanese:Japan report) ===
Report validation errors: ntoskrnl.exe:ntoskrnl prints too much data (33067 bytes)
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 5 +++-- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 36 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index e936da418f2..9c7bac55abc 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -162,14 +162,14 @@ NTSTATUS WINAPI HidP_GetButtonCaps(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAP PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData) { PWINE_HIDP_PREPARSED_DATA data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData; - WINE_HID_ELEMENT *elems = HID_ELEMS(data); + WINE_HID_ELEMENT *elems; WINE_HID_REPORT *report = NULL; USHORT b_count = 0, r_count = 0; int i,j,u;
TRACE("(%i, %p, %p, %p)\n",ReportType, ButtonCaps, ButtonCapsLength, PreparsedData);
- if (data->magic != HID_MAGIC) + if (!data || data->magic != HID_MAGIC) return HIDP_STATUS_INVALID_PREPARSED_DATA;
switch(ReportType) @@ -200,6 +200,7 @@ NTSTATUS WINAPI HidP_GetButtonCaps(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAP b_count = min(b_count, *ButtonCapsLength);
u = 0; + elems = HID_ELEMS(data); for (j = 0; j < r_count && u < b_count; j++) { for (i = 0; i < report[j].elementCount && u < b_count; i++) diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 27c8bcb33db..ca253dae7e5 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -1505,6 +1505,7 @@ static void test_hid_device(void) SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)}; SP_DEVINFO_DATA device = {sizeof(device)}; PHIDP_PREPARSED_DATA preparsed_data; + HIDP_BUTTON_CAPS button_caps[16]; BOOL ret, found = FALSE; OBJECT_ATTRIBUTES attr; UNICODE_STRING string; @@ -1513,6 +1514,7 @@ static void test_hid_device(void) HIDP_CAPS caps; unsigned int i; HDEVINFO set; + USHORT count; HANDLE file;
set = SetupDiGetClassDevsA(&GUID_DEVINTERFACE_HID, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT); @@ -1569,6 +1571,40 @@ static void test_hid_device(void) ok(caps.NumberFeatureValueCaps == 0, "unexpected caps NumberFeatureValueCaps %d, expected %d\n", caps.NumberFeatureValueCaps, 0); ok(caps.NumberFeatureDataIndices == 0, "unexpected caps NumberFeatureDataIndices %d, expected %d\n", caps.NumberFeatureDataIndices, 0);
+ count = 0; + status = HidP_GetButtonCaps(HidP_Output, button_caps, &count, preparsed_data); + todo_wine ok(status == HIDP_STATUS_USAGE_NOT_FOUND, "HidP_GetButtonCaps returned %#x\n", status); + status = HidP_GetButtonCaps(HidP_Feature + 1, button_caps, &count, preparsed_data); + ok(status == HIDP_STATUS_INVALID_REPORT_TYPE, "HidP_GetButtonCaps returned %#x\n", status); + status = HidP_GetButtonCaps(HidP_Input, button_caps, &count, preparsed_data); + todo_wine ok(status == HIDP_STATUS_BUFFER_TOO_SMALL, "HidP_GetButtonCaps returned %#x\n", status); + count = ARRAY_SIZE(button_caps); + status = HidP_GetButtonCaps(HidP_Input, button_caps, &count, NULL); + ok(status == HIDP_STATUS_INVALID_PREPARSED_DATA, "HidP_GetButtonCaps returned %#x\n", status); + status = HidP_GetButtonCaps(HidP_Input, button_caps, &count, preparsed_data); + ok(status == HIDP_STATUS_SUCCESS, "HidP_GetButtonCaps returned %#x\n", status); + ok(count == caps.NumberInputButtonCaps, "HidP_GetButtonCaps returned count %d, expected %d\n", count, caps.NumberInputButtonCaps); + + ok(button_caps[0].UsagePage == HID_USAGE_PAGE_BUTTON, "unexpected button caps UsagePage %x, expected %x\n", button_caps[0].UsagePage, HID_USAGE_PAGE_BUTTON); + ok(button_caps[0].ReportID == 0, "unexpected button caps ReportID %d, expected %d\n", button_caps[0].ReportID, 0); + ok(!button_caps[0].IsAlias, "unexpected button caps IsAlias %d, expected %d\n", button_caps[0].IsAlias, 0); + todo_wine ok(button_caps[0].BitField == 2, "unexpected button caps BitField %d, expected %d\n", button_caps[0].BitField, 2); + ok(button_caps[0].LinkCollection == 0, "unexpected button caps LinkCollection %d, expected %d\n", button_caps[0].LinkCollection, 0); + ok(button_caps[0].LinkUsage == HID_USAGE_GENERIC_JOYSTICK, "unexpected button caps LinkUsage %x, expected %x\n", button_caps[0].LinkUsage, HID_USAGE_GENERIC_JOYSTICK); + ok(button_caps[0].LinkUsagePage == HID_USAGE_PAGE_GENERIC, "unexpected button caps LinkUsagePage %x, expected %x\n", button_caps[0].LinkUsagePage, HID_USAGE_PAGE_GENERIC); + ok(button_caps[0].IsRange, "unexpected button caps IsRange %d, expected %d\n", button_caps[0].IsRange, 1); + ok(!button_caps[0].IsStringRange, "unexpected button caps IsStringRange %d, expected %d\n", button_caps[0].IsStringRange, 0); + ok(!button_caps[0].IsDesignatorRange, "unexpected button caps IsDesignatorRange %d, expected %d\n", button_caps[0].IsDesignatorRange, 0); + ok(button_caps[0].IsAbsolute, "unexpected button caps IsAbsolute %d, expected %d\n", button_caps[0].IsAbsolute, 1); + ok(button_caps[0].Range.UsageMin == 1, "unexpected button caps Range.UsageMin %d, expected %d\n", button_caps[0].Range.UsageMin, 1); + ok(button_caps[0].Range.UsageMax == 8, "unexpected button caps Range.UsageMax %d, expected %d\n", button_caps[0].Range.UsageMax, 8); + ok(button_caps[0].Range.StringMin == 0, "unexpected button caps Range.StringMin %d, expected %d\n", button_caps[0].Range.StringMin, 0); + ok(button_caps[0].Range.StringMax == 0, "unexpected button caps Range.StringMax %d, expected %d\n", button_caps[0].Range.StringMax, 0); + ok(button_caps[0].Range.DesignatorMin == 0, "unexpected button caps Range.DesignatorMin %d, expected %d\n", button_caps[0].Range.DesignatorMin, 0); + ok(button_caps[0].Range.DesignatorMax == 0, "unexpected button caps Range.DesignatorMax %d, expected %d\n", button_caps[0].Range.DesignatorMax, 0); + ok(button_caps[0].Range.DataIndexMin == 2, "unexpected button caps Range.DataIndexMin %d, expected %d\n", button_caps[0].Range.DataIndexMin, 2); + ok(button_caps[0].Range.DataIndexMax == 9, "unexpected button caps Range.DataIndexMax %d, expected %d\n", button_caps[0].Range.DataIndexMax, 9); + HidD_FreePreparsedData(preparsed_data); CloseHandle(file);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=91705
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
ntoskrnl.exe: ntoskrnl.c:1236: Test failed: got 0 bus arrival messages ntoskrnl.c:1252: Test failed: got 0 bus arrival messages 0f30:ntoskrnl: unhandled exception c0000005 at 74811B19
=== w7u_el (32 bit report) ===
ntoskrnl.exe: 0a70:ntoskrnl: unhandled exception c0000005 at 73C51B19
=== w864 (64 bit report) ===
Report validation errors: ntoskrnl.exe:ntoskrnl crashed (c0000374)
=== debiant2 (32 bit Arabic:Morocco report) ===
Report validation errors: ntoskrnl.exe:ntoskrnl prints too much data (39677 bytes)
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 5 ++-- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 43 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 9c7bac55abc..03c6a897248 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -474,14 +474,14 @@ NTSTATUS WINAPI HidP_GetValueCaps(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData) { PWINE_HIDP_PREPARSED_DATA data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData; - WINE_HID_ELEMENT *elems = HID_ELEMS(data); + WINE_HID_ELEMENT *elems; WINE_HID_REPORT *report = NULL; USHORT v_count = 0, r_count = 0; int i,j,u;
TRACE("(%i, %p, %p, %p)\n", ReportType, ValueCaps, ValueCapsLength, PreparsedData);
- if (data->magic != HID_MAGIC) + if (!data || data->magic != HID_MAGIC) return HIDP_STATUS_INVALID_PREPARSED_DATA;
switch(ReportType) @@ -512,6 +512,7 @@ NTSTATUS WINAPI HidP_GetValueCaps(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS v_count = min(v_count, *ValueCapsLength);
u = 0; + elems = HID_ELEMS(data); for (j = 0; j < r_count && u < v_count; j++) { for (i = 0; i < report[j].elementCount && u < v_count; i++) diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index ca253dae7e5..9c500885e75 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -1506,6 +1506,7 @@ static void test_hid_device(void) SP_DEVINFO_DATA device = {sizeof(device)}; PHIDP_PREPARSED_DATA preparsed_data; HIDP_BUTTON_CAPS button_caps[16]; + HIDP_VALUE_CAPS value_caps[16]; BOOL ret, found = FALSE; OBJECT_ATTRIBUTES attr; UNICODE_STRING string; @@ -1605,6 +1606,48 @@ static void test_hid_device(void) ok(button_caps[0].Range.DataIndexMin == 2, "unexpected button caps Range.DataIndexMin %d, expected %d\n", button_caps[0].Range.DataIndexMin, 2); ok(button_caps[0].Range.DataIndexMax == 9, "unexpected button caps Range.DataIndexMax %d, expected %d\n", button_caps[0].Range.DataIndexMax, 9);
+ count = 0; + status = HidP_GetValueCaps(HidP_Output, value_caps, &count, preparsed_data); + todo_wine ok(status == HIDP_STATUS_USAGE_NOT_FOUND, "HidP_GetValueCaps returned %#x\n", status); + status = HidP_GetValueCaps(HidP_Feature + 1, value_caps, &count, preparsed_data); + ok(status == HIDP_STATUS_INVALID_REPORT_TYPE, "HidP_GetValueCaps returned %#x\n", status); + status = HidP_GetValueCaps(HidP_Input, value_caps, &count, preparsed_data); + todo_wine ok(status == HIDP_STATUS_BUFFER_TOO_SMALL, "HidP_GetValueCaps returned %#x\n", status); + count = ARRAY_SIZE(value_caps); + status = HidP_GetValueCaps(HidP_Input, value_caps, &count, NULL); + ok(status == HIDP_STATUS_INVALID_PREPARSED_DATA, "HidP_GetValueCaps returned %#x\n", status); + status = HidP_GetValueCaps(HidP_Input, value_caps, &count, preparsed_data); + ok(status == HIDP_STATUS_SUCCESS, "HidP_GetValueCaps returned %#x\n", status); + ok(count == caps.NumberInputValueCaps, "HidP_GetValueCaps returned count %d, expected %d\n", count, caps.NumberInputButtonCaps); + + ok(value_caps[0].UsagePage == HID_USAGE_PAGE_GENERIC, "unexpected value caps UsagePage %x, expected %x\n", value_caps[0].UsagePage, HID_USAGE_PAGE_GENERIC); + ok(value_caps[0].ReportID == 0, "unexpected value caps ReportID %d, expected %d\n", value_caps[0].ReportID, 0); + ok(value_caps[0].IsAlias == 0, "unexpected value caps IsAlias %d, expected %d\n", value_caps[0].IsAlias, 0); + todo_wine ok(value_caps[0].BitField == 2, "unexpected value caps BitField %d, expected %d\n", value_caps[0].BitField, 2); + ok(value_caps[0].LinkCollection == 0, "unexpected value caps LinkCollection %d, expected %d\n", value_caps[0].LinkCollection, 0); + ok(value_caps[0].LinkUsage == HID_USAGE_GENERIC_JOYSTICK, "unexpected value caps LinkUsage %x, expected %x\n", value_caps[0].LinkUsage, HID_USAGE_GENERIC_JOYSTICK); + ok(value_caps[0].LinkUsagePage == HID_USAGE_PAGE_GENERIC, "unexpected value caps LinkUsagePage %x, expected %x\n", value_caps[0].LinkUsagePage, HID_USAGE_PAGE_GENERIC); + ok(!value_caps[0].IsRange, "unexpected value caps IsRange %d, expected %d\n", value_caps[0].IsRange, 0); + ok(!value_caps[0].IsStringRange, "unexpected value caps IsStringRange %d, expected %d\n", value_caps[0].IsStringRange, 0); + ok(!value_caps[0].IsDesignatorRange, "unexpected value caps IsDesignatorRange %d, expected %d\n", value_caps[0].IsDesignatorRange, 0); + ok(value_caps[0].IsAbsolute, "unexpected value caps IsAbsolute %d, expected %d\n", value_caps[0].IsAbsolute, 1); + ok(value_caps[0].HasNull == 0, "unexpected value caps HasNull %d, expected %d\n", value_caps[0].HasNull, 0); + ok(value_caps[0].BitSize == 8, "unexpected value caps BitSize %d, expected %d\n", value_caps[0].BitSize, 8); + ok(value_caps[0].ReportCount == 1, "unexpected value caps ReportCount %d, expected %d\n", value_caps[0].ReportCount, 1); + ok(value_caps[0].UnitsExp == 0, "unexpected value caps UnitsExp %d, expected %d\n", value_caps[0].UnitsExp, 0); + ok(value_caps[0].Units == 0, "unexpected value caps Units %d, expected %d\n", value_caps[0].Units, 0); + ok(value_caps[0].LogicalMin == -128, "unexpected value caps LogicalMin %d, expected %d\n", value_caps[0].LogicalMin, -128); + ok(value_caps[0].LogicalMax == 127, "unexpected value caps LogicalMax %d, expected %d\n", value_caps[0].LogicalMax, 127); + ok(value_caps[0].PhysicalMin == 0, "unexpected value caps PhysicalMin %d, expected %d\n", value_caps[0].PhysicalMin, 0); + ok(value_caps[0].PhysicalMax == 0, "unexpected value caps PhysicalMax %d, expected %d\n", value_caps[0].PhysicalMax, 0); + todo_wine ok(value_caps[0].NotRange.Usage == HID_USAGE_GENERIC_Y, "unexpected value caps NotRange.Usage %d, expected %d\n", value_caps[0].NotRange.Usage, HID_USAGE_GENERIC_Y); + ok(value_caps[0].NotRange.StringIndex == 0, "unexpected value caps NotRange.StringIndex %d, expected %d\n", value_caps[0].NotRange.StringIndex, 0); + ok(value_caps[0].NotRange.DesignatorIndex == 0, "unexpected value caps NotRange.DesignatorIndex %d, expected %d\n", value_caps[0].NotRange.DesignatorIndex, 0); + ok(value_caps[0].NotRange.DataIndex == 0, "unexpected value caps NotRange.DataIndex %d, expected %d\n", value_caps[0].NotRange.DataIndex, 0); + + todo_wine ok(value_caps[1].NotRange.Usage == HID_USAGE_GENERIC_X, "unexpected value caps NotRange.Usage %d, expected %d\n", value_caps[0].NotRange.Usage, HID_USAGE_GENERIC_X); + ok(value_caps[2].NotRange.Usage == HID_USAGE_GENERIC_HATSWITCH, "unexpected value caps NotRange.Usage %d, expected %d\n", value_caps[0].NotRange.Usage, HID_USAGE_GENERIC_HATSWITCH); + HidD_FreePreparsedData(preparsed_data); CloseHandle(file);
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 6 +++++- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 03c6a897248..94ff7ab3cd3 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -999,14 +999,18 @@ NTSTATUS WINAPI HidP_GetLinkCollectionNodes(HIDP_LINK_COLLECTION_NODE *LinkColle ULONG *LinkCollectionNodeLength, PHIDP_PREPARSED_DATA PreparsedData) { WINE_HIDP_PREPARSED_DATA *data = (WINE_HIDP_PREPARSED_DATA*)PreparsedData; - WINE_HID_LINK_COLLECTION_NODE *nodes = HID_NODES(data); + WINE_HID_LINK_COLLECTION_NODE *nodes; ULONG i;
TRACE("(%p, %p, %p)\n", LinkCollectionNode, LinkCollectionNodeLength, PreparsedData);
+ if (!data || data->magic != HID_MAGIC) + return HIDP_STATUS_INVALID_PREPARSED_DATA; + if (*LinkCollectionNodeLength < data->caps.NumberLinkCollectionNodes) return HIDP_STATUS_BUFFER_TOO_SMALL;
+ nodes = HID_NODES(data); for (i = 0; i < data->caps.NumberLinkCollectionNodes; ++i) { LinkCollectionNode[i].LinkUsage = nodes[i].LinkUsage; diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 9c500885e75..b27ac091cae 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -1504,10 +1504,12 @@ static void test_hid_device(void) SP_DEVICE_INTERFACE_DETAIL_DATA_A *iface_detail = (void *)buffer; SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)}; SP_DEVINFO_DATA device = {sizeof(device)}; + HIDP_LINK_COLLECTION_NODE collections[16]; PHIDP_PREPARSED_DATA preparsed_data; HIDP_BUTTON_CAPS button_caps[16]; HIDP_VALUE_CAPS value_caps[16]; BOOL ret, found = FALSE; + DWORD collection_count; OBJECT_ATTRIBUTES attr; UNICODE_STRING string; IO_STATUS_BLOCK io; @@ -1572,6 +1574,25 @@ static void test_hid_device(void) ok(caps.NumberFeatureValueCaps == 0, "unexpected caps NumberFeatureValueCaps %d, expected %d\n", caps.NumberFeatureValueCaps, 0); ok(caps.NumberFeatureDataIndices == 0, "unexpected caps NumberFeatureDataIndices %d, expected %d\n", caps.NumberFeatureDataIndices, 0);
+ collection_count = 0; + status = HidP_GetLinkCollectionNodes(collections, &collection_count, preparsed_data); + ok(status == HIDP_STATUS_BUFFER_TOO_SMALL, "HidP_GetLinkCollectionNodes returned %#x\n", status); + collection_count = ARRAY_SIZE(collections); + status = HidP_GetLinkCollectionNodes(collections, &collection_count, NULL); + ok(status == HIDP_STATUS_INVALID_PREPARSED_DATA, "HidP_GetLinkCollectionNodes returned %#x\n", status); + status = HidP_GetLinkCollectionNodes(collections, &collection_count, preparsed_data); + ok(status == HIDP_STATUS_SUCCESS, "HidP_GetLinkCollectionNodes returned %#x\n", status); + ok(collection_count == caps.NumberLinkCollectionNodes, "HidP_GetLinkCollectionNodes returned count %d, expected %d\n", collection_count, caps.NumberLinkCollectionNodes); + + ok(collections[0].LinkUsage == HID_USAGE_GENERIC_JOYSTICK, "unexpected collection LinkUsage %x, expected %x\n", collections[0].LinkUsage, HID_USAGE_GENERIC_JOYSTICK); + ok(collections[0].LinkUsagePage == HID_USAGE_PAGE_GENERIC, "unexpected collection LinkUsagePage %x, expected %x\n", collections[0].LinkUsagePage, HID_USAGE_PAGE_GENERIC); + ok(collections[0].Parent == 0, "unexpected collection Parent %d, expected %d\n", collections[0].Parent, 0); + ok(collections[0].NumberOfChildren == 0, "unexpected collection NumberOfChildren %d, expected %d\n", collections[0].NumberOfChildren, 0); + ok(collections[0].NextSibling == 0, "unexpected collection NextSibling %d, expected %d\n", collections[0].NextSibling, 0); + ok(collections[0].FirstChild == 0, "unexpected collection FirstChild %d, expected %d\n", collections[0].FirstChild, 0); + ok(collections[0].CollectionType == 1, "unexpected collection CollectionType %d, expected %d\n", collections[0].CollectionType, 1); + ok(collections[0].IsAlias == 0, "unexpected collection IsAlias %d, expected %d\n", collections[0].IsAlias, 0); + count = 0; status = HidP_GetButtonCaps(HidP_Output, button_caps, &count, preparsed_data); todo_wine ok(status == HIDP_STATUS_USAGE_NOT_FOUND, "HidP_GetButtonCaps returned %#x\n", status);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=91702
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
ntoskrnl.exe: ntoskrnl.c:1234: Test failed: got 0 bus arrival messages ntoskrnl.c:1250: Test failed: got 0 bus arrival messages