Rémi Bernon : dinput8/tests: Read HID_DEVICE_ATTRIBUTES from the registry.

Alexandre Julliard julliard at winehq.org
Fri Sep 10 15:29:46 CDT 2021


Module: wine
Branch: master
Commit: 97a6870c10e36f7f8c94f9fed4e3b24cd84e2cef
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=97a6870c10e36f7f8c94f9fed4e3b24cd84e2cef

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Fri Sep 10 09:22:42 2021 +0200

dinput8/tests: Read HID_DEVICE_ATTRIBUTES from the registry.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput8/tests/driver_hid.c | 24 +++++++++++-------------
 dlls/dinput8/tests/hid.c        | 11 +++++++++++
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/dlls/dinput8/tests/driver_hid.c b/dlls/dinput8/tests/driver_hid.c
index 6bd5611c86c..06b223d1611 100644
--- a/dlls/dinput8/tests/driver_hid.c
+++ b/dlls/dinput8/tests/driver_hid.c
@@ -39,6 +39,7 @@
 static UNICODE_STRING control_symlink;
 
 static unsigned int got_start_device;
+static HID_DEVICE_ATTRIBUTES attributes;
 static char report_descriptor_buf[4096];
 static DWORD report_descriptor_len;
 static DWORD report_id;
@@ -228,25 +229,16 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
         break;
 
     case IOCTL_HID_GET_DEVICE_ATTRIBUTES:
-    {
-        HID_DEVICE_ATTRIBUTES *attr = irp->UserBuffer;
-
         ok( !in_size, "got input size %u\n", in_size );
-        ok( out_size == sizeof(*attr), "got output size %u\n", out_size );
+        ok( out_size == sizeof(attributes), "got output size %u\n", out_size );
 
-        if (out_size == sizeof(*attr))
+        if (out_size == sizeof(attributes))
         {
-            ok( !attr->Size, "got size %u\n", attr->Size );
-
-            attr->Size = sizeof(*attr);
-            attr->VendorID = 0x1209;
-            attr->ProductID = 0x0001;
-            attr->VersionNumber = 0xface;
-            irp->IoStatus.Information = sizeof(*attr);
+            memcpy( irp->UserBuffer, &attributes, sizeof(attributes) );
+            irp->IoStatus.Information = sizeof(attributes);
         }
         ret = STATUS_SUCCESS;
         break;
-    }
 
     case IOCTL_HID_READ_REPORT:
     {
@@ -472,6 +464,12 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *registry )
     memcpy( report_descriptor_buf, buffer + info_size, size - info_size );
     report_descriptor_len = size - info_size;
 
+    RtlInitUnicodeString( &name_str, L"Attributes" );
+    size = info_size + sizeof(attributes);
+    ret = ZwQueryValueKey( hkey, &name_str, KeyValuePartialInformation, buffer, size, &size );
+    ok( !ret, "ZwQueryValueKey returned %#x\n", ret );
+    memcpy( &attributes, buffer + info_size, size - info_size );
+
     driver->DriverExtension->AddDevice = driver_add_device;
     driver->DriverUnload = driver_unload;
     driver->MajorFunction[IRP_MJ_PNP] = driver_pnp;
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index ec2575aa9c1..51b204c736d 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -2301,6 +2301,14 @@ static void test_hid_driver( DWORD report_id, DWORD polled )
 #undef REPORT_ID_OR_USAGE_PAGE
 #include "pop_hid_macros.h"
 
+    static const HID_DEVICE_ATTRIBUTES attributes =
+    {
+        .Size = sizeof(HID_DEVICE_ATTRIBUTES),
+        .VendorID = 0x1209,
+        .ProductID = 0x0001,
+        .VersionNumber = 0x0100,
+    };
+
     WCHAR cwd[MAX_PATH], tempdir[MAX_PATH];
     LSTATUS status;
     HKEY hkey;
@@ -2322,6 +2330,9 @@ static void test_hid_driver( DWORD report_id, DWORD polled )
     status = RegSetValueExW( hkey, L"Descriptor", 0, REG_BINARY, (void *)report_desc, sizeof(report_desc) );
     ok( !status, "RegSetValueExW returned %#x\n", status );
 
+    status = RegSetValueExW( hkey, L"Attributes", 0, REG_BINARY, (void *)&attributes, sizeof(attributes) );
+    ok( !status, "RegSetValueExW returned %#x\n", status );
+
     if (pnp_driver_start( L"driver_hid.dll" )) test_hid_device( report_id, polled );
 
     pnp_driver_stop();




More information about the wine-cvs mailing list