From: R��mi Bernon rbernon@codeweavers.com
--- dlls/dinput/tests/joystick8.c | 11 +++++------ dlls/win32u/rawinput.c | 20 +++++++++++++++++--- 2 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c index 3193ee12ddc..8f6d386c952 100644 --- a/dlls/dinput/tests/joystick8.c +++ b/dlls/dinput/tests/joystick8.c @@ -4308,7 +4308,11 @@ static void test_rawinput(void)
count = ARRAY_SIZE(raw_device_list); res = GetRawInputDeviceList( raw_device_list, &count, sizeof(RAWINPUTDEVICELIST) ); - todo_wine + if (!strcmp( winetest_platform, "wine" ) && res == device_count) + { + Sleep( 2500 ); /* Wine only refreshes device list every 2s */ + res = GetRawInputDeviceList( raw_device_list, &count, sizeof(RAWINPUTDEVICELIST) ); + } ok( res == device_count + 1, "GetRawInputDeviceList returned %lu\n", res ); ok( count == ARRAY_SIZE(raw_device_list), "got count %u\n", count ); device_count = res; @@ -4326,9 +4330,7 @@ static void test_rawinput(void) if (wcsstr( path, expect_vidpid_str )) break; }
- todo_wine ok( !!wcsstr( path, expect_vidpid_str ), "got path %s\n", debugstr_w(path) ); - if (!wcsstr( path, expect_vidpid_str )) goto done;
file = CreateFileW( path, FILE_READ_ACCESS | FILE_WRITE_ACCESS, @@ -4346,12 +4348,9 @@ static void test_rawinput(void) while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
ok( !wm_input_device_change_count, "got %u WM_INPUT_DEVICE_CHANGE\n", wm_input_device_change_count ); - todo_wine ok( wm_input_count == 1, "got %u WM_INPUT\n", wm_input_count ); - todo_wine ok( wm_input_len == offsetof(RAWINPUT, data.hid.bRawData[desc.caps.InputReportByteLength]), "got wm_input_len %u\n", wm_input_len ); - todo_wine ok( !memcmp( rawinput->data.hid.bRawData, injected_input[i].report_buf, desc.caps.InputReportByteLength ), "got unexpected report data\n" ); wm_input_count = 0; diff --git a/dlls/win32u/rawinput.c b/dlls/win32u/rawinput.c index 6a018e15bb7..e59c93898c2 100644 --- a/dlls/win32u/rawinput.c +++ b/dlls/win32u/rawinput.c @@ -253,6 +253,8 @@ static struct device *add_device( HKEY key, DWORD type ) NTSTATUS status; unsigned int i; UINT32 handle; + void *buffer; + SIZE_T size; HANDLE file;
if (!query_reg_value( key, symbolic_linkW, value, sizeof(value_buffer) )) @@ -327,9 +329,21 @@ static struct device *add_device( HKEY key, DWORD type ) goto fail; }
- status = NtDeviceIoControlFile( file, NULL, NULL, NULL, &io, - IOCTL_HID_GET_COLLECTION_DESCRIPTOR, - NULL, 0, preparsed, hid_info.DescriptorSize ); + /* NtDeviceIoControlFile checks that the output buffer is writable using ntdll virtual + * memory protection information, we need an NtAllocateVirtualMemory allocated buffer. + */ + size = hid_info.DescriptorSize; + if (!(status = NtAllocateVirtualMemory( GetCurrentProcess(), (void **)&buffer, 0, &size, + MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE ))) + { + size = 0; + status = NtDeviceIoControlFile( file, NULL, NULL, NULL, &io, + IOCTL_HID_GET_COLLECTION_DESCRIPTOR, + NULL, 0, buffer, hid_info.DescriptorSize ); + if (!status) memcpy( preparsed, buffer, hid_info.DescriptorSize ); + NtFreeVirtualMemory( GetCurrentProcess(), (void **)&buffer, &size, MEM_RELEASE ); + } + if (status) { ERR( "Failed to get collection descriptor, status %#x.\n", status );