Module: wine Branch: master Commit: e0ba6d8fdb9562810231df8fb0b37dd05188e3b8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=e0ba6d8fdb9562810231df8fb0...
Author: Bruno Jesus 00cpxxx@gmail.com Date: Tue May 26 12:14:29 2015 -0300
user32: Set the expected errors in GetRawInputDeviceList.
---
dlls/user32/input.c | 13 ++++++++++++- dlls/user32/tests/input.c | 14 ++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 4fcc531..40e35a9 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -496,7 +496,17 @@ UINT WINAPI GetRawInputDeviceList(RAWINPUTDEVICELIST *devices, UINT *device_coun { TRACE("devices %p, device_count %p, size %u.\n", devices, device_count, size);
- if (size != sizeof(*devices) || !device_count) return ~0U; + if (size != sizeof(*devices)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return ~0U; + } + + if (!device_count) + { + SetLastError(ERROR_NOACCESS); + return ~0U; + }
if (!devices) { @@ -506,6 +516,7 @@ UINT WINAPI GetRawInputDeviceList(RAWINPUTDEVICELIST *devices, UINT *device_coun
if (*device_count < 2) { + SetLastError(ERROR_INSUFFICIENT_BUFFER); *device_count = 2; return ~0U; } diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 7639b66..29b655c 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -1491,21 +1491,19 @@ static void test_GetMouseMovePointsEx(void) static void test_GetRawInputDeviceList(void) { RAWINPUTDEVICELIST devices[32]; - UINT ret, devcount, odevcount; + UINT ret, oret, devcount, odevcount; DWORD err;
SetLastError(0xdeadbeef); ret = pGetRawInputDeviceList(NULL, NULL, 0); err = GetLastError(); ok(ret == -1, "expected -1, got %d\n", ret); -todo_wine ok(err == ERROR_INVALID_PARAMETER, "expected 87, got %d\n", err);
SetLastError(0xdeadbeef); ret = pGetRawInputDeviceList(NULL, NULL, sizeof(devices[0])); err = GetLastError(); ok(ret == -1, "expected -1, got %d\n", ret); -todo_wine ok(err == ERROR_NOACCESS, "expected 998, got %d\n", err);
devcount = 0; @@ -1518,19 +1516,23 @@ todo_wine ret = pGetRawInputDeviceList(devices, &devcount, sizeof(devices[0])); err = GetLastError(); ok(ret == -1, "expected -1, got %d\n", ret); -todo_wine ok(err == ERROR_INSUFFICIENT_BUFFER, "expected 122, got %d\n", err); ok(devcount > 0, "expected non-zero\n");
- /* devcount contain now the correct number of devices */ + /* devcount contains now the correct number of devices */ ret = pGetRawInputDeviceList(devices, &devcount, sizeof(devices[0])); ok(ret > 0, "expected non-zero\n");
/* check if variable changes from larger to smaller value */ devcount = odevcount = sizeof(devices) / sizeof(devices[0]); - ret = pGetRawInputDeviceList(devices, &odevcount, sizeof(devices[0])); + oret = ret = pGetRawInputDeviceList(devices, &odevcount, sizeof(devices[0])); ok(ret > 0, "expected non-zero\n"); ok(devcount == odevcount, "expected %d, got %d\n", devcount, odevcount); + devcount = odevcount; + odevcount = sizeof(devices) / sizeof(devices[0]); + ret = pGetRawInputDeviceList(NULL, &odevcount, sizeof(devices[0])); + ok(ret == 0, "expected 0, got %d\n", ret); + ok(odevcount == oret, "expected %d, got %d\n", oret, odevcount); }
static void test_key_map(void)