Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/rawinput.c | 6 ------ 1 file changed, 6 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 5c009624fe6..6172c500839 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -166,8 +166,6 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface)
static void find_devices(void) { - static ULONGLONG last_check; - SP_DEVICE_INTERFACE_DATA iface = { sizeof(iface) }; struct device *device; HIDD_ATTRIBUTES attr; @@ -176,10 +174,6 @@ static void find_devices(void) HDEVINFO set; DWORD idx;
- if (GetTickCount64() - last_check < 2000) - return; - last_check = GetTickCount64(); - HidD_GetHidGuid(&hid_guid);
EnterCriticalSection(&rawinput_devices_cs);
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/rawinput.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 6172c500839..1e66b394cb5 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -226,6 +226,8 @@ static void find_devices(void)
device->info.dwType = RIM_TYPEMOUSE; device->info.u.mouse = mouse_info; + HidD_FreePreparsedData(device->data); + device->data = NULL; }
SetupDiDestroyDeviceInfoList(set); @@ -241,6 +243,8 @@ static void find_devices(void)
device->info.dwType = RIM_TYPEKEYBOARD; device->info.u.keyboard = keyboard_info; + HidD_FreePreparsedData(device->data); + device->data = NULL; }
SetupDiDestroyDeviceInfoList(set);
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/rawinput.c | 16 ++++++++++++++-- dlls/user32/tests/input.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 1e66b394cb5..9a72a9a323e 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -696,8 +696,16 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT TRACE("handle %p, command %#x, data %p, data_size %p.\n", handle, command, data, data_size);
- if (!data_size) return ~0U; - if (!(device = find_device_from_handle(handle))) return ~0U; + if (!data_size) + { + SetLastError(ERROR_NOACCESS); + return ~0U; + } + if (!(device = find_device_from_handle(handle))) + { + SetLastError(ERROR_INVALID_HANDLE); + return ~0U; + }
/* each case below must set: * *data_size: length (meaning defined by command) of data we want to copy @@ -769,6 +777,7 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT
default: FIXME("command %#x not supported\n", command); + SetLastError(ERROR_INVALID_PARAMETER); return ~0U; }
@@ -776,7 +785,10 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT return 0;
if (avail_bytes < to_copy_bytes) + { + SetLastError(ERROR_INSUFFICIENT_BUFFER); return ~0U; + }
memcpy(data, to_copy, to_copy_bytes);
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 382e124e1f4..4ce2c5643cd 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -1834,6 +1834,43 @@ static void test_GetRawInputDeviceList(void) ret = pGetRawInputDeviceList(devices, &devcount, sizeof(devices[0])); ok(ret > 0, "expected non-zero\n");
+ if (devcount) + { + RID_DEVICE_INFO info; + UINT size; + + SetLastError( 0xdeadbeef ); + ret = pGetRawInputDeviceInfoW( UlongToHandle( 0xdeadbeef ), RIDI_DEVICEINFO, NULL, NULL ); + ok( ret == ~0U, "GetRawInputDeviceInfoW returned %#x, expected ~0.\n", ret ); + ok( GetLastError() == ERROR_NOACCESS, "GetRawInputDeviceInfoW last error %#x, expected 0xdeadbeef.\n", GetLastError() ); + + SetLastError( 0xdeadbeef ); + size = 0xdeadbeef; + ret = pGetRawInputDeviceInfoW( UlongToHandle( 0xdeadbeef ), RIDI_DEVICEINFO, NULL, &size ); + ok( ret == ~0U, "GetRawInputDeviceInfoW returned %#x, expected ~0.\n", ret ); + ok( size == 0xdeadbeef, "GetRawInputDeviceInfoW returned size %#x, expected 0.\n", size ); + ok( GetLastError() == ERROR_INVALID_HANDLE, "GetRawInputDeviceInfoW last error %#x, expected 0xdeadbeef.\n", GetLastError() ); + + SetLastError( 0xdeadbeef ); + size = 0xdeadbeef; + ret = pGetRawInputDeviceInfoW( devices[0].hDevice, 0xdeadbeef, NULL, &size ); + ok( ret == ~0U, "GetRawInputDeviceInfoW returned %#x, expected ~0.\n", ret ); + ok( size == 0xdeadbeef, "GetRawInputDeviceInfoW returned size %#x, expected 0.\n", size ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "GetRawInputDeviceInfoW last error %#x, expected 0xdeadbeef.\n", GetLastError() ); + + SetLastError( 0xdeadbeef ); + ret = pGetRawInputDeviceInfoW( devices[0].hDevice, RIDI_DEVICEINFO, &info, NULL ); + ok( ret == ~0U, "GetRawInputDeviceInfoW returned %#x, expected ~0.\n", ret ); + ok( GetLastError() == ERROR_NOACCESS, "GetRawInputDeviceInfoW last error %#x, expected 0xdeadbeef.\n", GetLastError() ); + + SetLastError( 0xdeadbeef ); + size = 0; + ret = pGetRawInputDeviceInfoW( devices[0].hDevice, RIDI_DEVICEINFO, &info, &size ); + ok( ret == ~0U, "GetRawInputDeviceInfoW returned %#x, expected ~0.\n", ret ); + ok( size == sizeof(info), "GetRawInputDeviceInfoW returned size %#x, expected %#x.\n", size, sizeof(info) ); + ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetRawInputDeviceInfoW last error %#x, expected 0xdeadbeef.\n", GetLastError() ); + } + for(i = 0; i < devcount; ++i) { WCHAR name[128];
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=89879
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
user32: input.c:757: Test failed: 0 (a4/0): 00 from 00 -> 80 unexpected input.c:757: Test failed: 0 (a4/0): 41 from 01 -> 00 unexpected
=== w1064v1809 (32 bit report) ===
user32: input.c:2785: Test failed: 0: expected WM_MOUSEMOVE message input.c:2785: Test failed: 1: expected WM_MOUSEMOVE message input.c:2785: Test failed: 2: expected WM_MOUSEMOVE message
=== wvistau64 (64 bit report) ===
user32: input.c:757: Test failed: 0 (a4/0): 01 from 01 -> 00 unexpected input.c:757: Test failed: 0 (a4/0): 11 from 01 -> 00 unexpected input.c:757: Test failed: 0 (a4/0): a2 from 01 -> 00 unexpected
=== w1064 (64 bit report) ===
user32: input.c:1303: Test failed: Wrong set pos: (100,100) input.c:1323: Test failed: GetCursorPos: (100,100)
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/rawinput.c | 39 ++++----------------------------------- dlls/user32/tests/input.c | 3 +-- 2 files changed, 5 insertions(+), 37 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 9a72a9a323e..15e909ebd9c 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -684,10 +684,6 @@ UINT WINAPI GetRawInputDeviceInfoA(HANDLE device, UINT command, void *data, UINT */ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT *data_size) { - /* FIXME: Most of this is made up. */ - static const RID_DEVICE_INFO_KEYBOARD keyboard_info = {0, 0, 1, 12, 3, 101}; - static const RID_DEVICE_INFO_MOUSE mouse_info = {1, 5, 0, FALSE}; - RID_DEVICE_INFO info; struct device *device; const void *to_copy; @@ -718,41 +714,15 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT case RIDI_DEVICENAME: /* for RIDI_DEVICENAME, data_size is in characters, not bytes */ avail_bytes = *data_size * sizeof(WCHAR); - if (handle == WINE_MOUSE_HANDLE) - { - *data_size = ARRAY_SIZE(L"\\?\WINE_MOUSE"); - to_copy = L"\\?\WINE_MOUSE"; - } - else if (handle == WINE_KEYBOARD_HANDLE) - { - *data_size = ARRAY_SIZE(L"\\?\WINE_KEYBOARD"); - to_copy = L"\\?\WINE_KEYBOARD"; - } - else - { - *data_size = wcslen(device->detail->DevicePath) + 1; - to_copy = device->detail->DevicePath; - } + *data_size = wcslen(device->detail->DevicePath) + 1; + to_copy = device->detail->DevicePath; to_copy_bytes = *data_size * sizeof(WCHAR); break;
case RIDI_DEVICEINFO: avail_bytes = *data_size; info.cbSize = sizeof(info); - if (handle == WINE_MOUSE_HANDLE) - { - info.dwType = RIM_TYPEMOUSE; - info.u.mouse = mouse_info; - } - else if (handle == WINE_KEYBOARD_HANDLE) - { - info.dwType = RIM_TYPEKEYBOARD; - info.u.keyboard = keyboard_info; - } - else - { - info = device->info; - } + info = device->info; to_copy_bytes = sizeof(info); *data_size = to_copy_bytes; to_copy = &info; @@ -760,8 +730,7 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT
case RIDI_PREPARSEDDATA: avail_bytes = *data_size; - if (handle == WINE_MOUSE_HANDLE || handle == WINE_KEYBOARD_HANDLE || - device->info.dwType != RIM_TYPEHID) + if (device->info.dwType != RIM_TYPEHID) { to_copy_bytes = 0; *data_size = 0; diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 4ce2c5643cd..b45adeb3cae 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -1923,8 +1923,7 @@ static void test_GetRawInputDeviceList(void) * understand that; so use the \?\ prefix instead */ name[1] = '\'; file = CreateFileW(name, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); - todo_wine_if(info.dwType == RIM_TYPEMOUSE || info.dwType == RIM_TYPEKEYBOARD) - ok(file != INVALID_HANDLE_VALUE, "Failed to open %s, error %u\n", wine_dbgstr_w(name), GetLastError()); + ok(file != INVALID_HANDLE_VALUE, "Failed to open %s, error %u\n", wine_dbgstr_w(name), GetLastError());
sz = 0; ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_PREPARSEDDATA, NULL, &sz);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=89880
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
user32: input.c:757: Test failed: 0 (a4/0): 00 from 00 -> 80 unexpected input.c:757: Test failed: 0 (a4/0): 41 from 01 -> 00 unexpected
=== w7u_el (32 bit report) ===
user32: input.c:4369: Test failed: SendInput triggered unexpected message 0xc042
=== wvistau64 (64 bit report) ===
user32: input.c:757: Test failed: 0 (a4/0): 01 from 01 -> 00 unexpected input.c:757: Test failed: 0 (a4/0): 11 from 01 -> 00 unexpected input.c:757: Test failed: 0 (a4/0): a2 from 01 -> 00 unexpected
=== w1064_tsign (64 bit report) ===
user32: input.c:3448: Test failed: expected loop with WM_NCHITTEST messages input.c:3501: Test failed: expected WM_LBUTTONDOWN message input.c:3502: Test failed: expected WM_LBUTTONUP message
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/rawinput.c | 48 ++++++++++++------------------------------ 1 file changed, 13 insertions(+), 35 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 15e909ebd9c..b954b31d12e 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -686,8 +686,7 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT { RID_DEVICE_INFO info; struct device *device; - const void *to_copy; - UINT to_copy_bytes, avail_bytes; + DWORD len, data_len;
TRACE("handle %p, command %#x, data %p, data_size %p.\n", handle, command, data, data_size); @@ -703,45 +702,26 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT return ~0U; }
- /* each case below must set: - * *data_size: length (meaning defined by command) of data we want to copy - * avail_bytes: number of bytes available in user buffer - * to_copy_bytes: number of bytes we want to copy into user buffer - * to_copy: pointer to data we want to copy into user buffer - */ + data_len = *data_size; switch (command) { case RIDI_DEVICENAME: - /* for RIDI_DEVICENAME, data_size is in characters, not bytes */ - avail_bytes = *data_size * sizeof(WCHAR); - *data_size = wcslen(device->detail->DevicePath) + 1; - to_copy = device->detail->DevicePath; - to_copy_bytes = *data_size * sizeof(WCHAR); + if ((len = wcslen(device->detail->DevicePath) + 1) <= data_len && data) + wcsncpy(data, device->detail->DevicePath, len); + *data_size = len; break;
case RIDI_DEVICEINFO: - avail_bytes = *data_size; - info.cbSize = sizeof(info); - info = device->info; - to_copy_bytes = sizeof(info); - *data_size = to_copy_bytes; - to_copy = &info; + if ((len = sizeof(info)) <= data_len && data) + memcpy(data, &device->info, len); + *data_size = len; break;
case RIDI_PREPARSEDDATA: - avail_bytes = *data_size; - if (device->info.dwType != RIM_TYPEHID) - { - to_copy_bytes = 0; - *data_size = 0; - to_copy = NULL; - } - else - { - to_copy_bytes = ((WINE_HIDP_PREPARSED_DATA*)device->data)->dwSize; - *data_size = to_copy_bytes; - to_copy = device->data; - } + len = device->data ? ((WINE_HIDP_PREPARSED_DATA*)device->data)->dwSize : 0; + if (device->data && len <= data_len && data) + memcpy(data, device->data, len); + *data_size = len; break;
default: @@ -753,14 +733,12 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT if (!data) return 0;
- if (avail_bytes < to_copy_bytes) + if (data_len < len) { SetLastError(ERROR_INSUFFICIENT_BUFFER); return ~0U; }
- memcpy(data, to_copy, to_copy_bytes); - return *data_size; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=89877
Your paranoid android.
=== debiant2 (32 bit Chinese:China report) ===
user32: msg.c:14833: Test failed: bad time f85cac1