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}");