From: R��mi Bernon rbernon@codeweavers.com
--- dlls/dinput/tests/joystick8.c | 11 +++++------ dlls/win32u/rawinput.c | 12 +++++++++--- 2 files changed, 14 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..39f511d1019 100644 --- a/dlls/win32u/rawinput.c +++ b/dlls/win32u/rawinput.c @@ -253,6 +253,7 @@ static struct device *add_device( HKEY key, DWORD type ) NTSTATUS status; unsigned int i; UINT32 handle; + SIZE_T size; HANDLE file;
if (!query_reg_value( key, symbolic_linkW, value, sizeof(value_buffer) )) @@ -321,7 +322,9 @@ static struct device *add_device( HKEY key, DWORD type ) info.hid.dwProductId = hid_info.ProductID; info.hid.dwVersionNumber = hid_info.VersionNumber;
- if (!(preparsed = malloc( hid_info.DescriptorSize ))) + size = hid_info.DescriptorSize; + if (NtAllocateVirtualMemory( GetCurrentProcess(), (void **)&preparsed, 0, &size, + MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE )) { ERR( "Failed to allocate memory.\n" ); goto fail; @@ -370,7 +373,8 @@ static struct device *add_device( HKEY key, DWORD type ) return device;
fail: - free( preparsed ); + size = 0; + NtFreeVirtualMemory( GetCurrentProcess(), (void **)&preparsed, &size, MEM_RELEASE ); NtClose( file ); free( path ); return NULL; @@ -451,7 +455,9 @@ static void rawinput_update_device_list(void) /* destroy previous list */ for (i = 0; i < rawinput_devices_count; ++i) { - free( rawinput_devices[i].data ); + SIZE_T size = 0; + NtFreeVirtualMemory( GetCurrentProcess(), (void **)&rawinput_devices[i].data, + &size, MEM_RELEASE ); NtClose( rawinput_devices[i].file ); free( rawinput_devices[i].path ); }