dinput8/tests: Read HID_DEVICE_ATTRIBUTES from the registry.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-09-10 09:22:42 +02:00 committed by Alexandre Julliard
parent b648e67fd3
commit 97a6870c10
2 changed files with 22 additions and 13 deletions

View File

@ -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;

View File

@ -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();