(Note: I am not subscribed to the list; please CC me on any replies.)
When GetRawInputDeviceList() is passed a buffer which is too small, the function should set the last error code to ERROR_INSUFFICIENT_BUFFER and return failure (see http://msdn.microsoft.com/en-us/library/windows/desktop/ms645598(v=vs.85).aspx). However, the current Wine implementation does not set the last error code, meaning that callers expecting to see ERROR_INSUFFICIENT_BUFFER will behave incorrectly. I've confirmed that Windows itself (at least XP and 8) matches the documented behavior.
See also: https://bugs.winehq.org/show_bug.cgi?id=37667
--Andrew Church http://achurch.org/
diff -urN wine-1.7.43-orig/dlls/user32/input.c wine-1.7.43/dlls/user32/input.c --- wine-1.7.43-orig/dlls/user32/input.c 2015-05-15 22:36:39 +0900 +++ wine-1.7.43/dlls/user32/input.c 2015-05-25 22:47:49 +0900 @@ -507,6 +507,7 @@ if (*device_count < 2) { *device_count = 2; + SetLastError(ERROR_INSUFFICIENT_BUFFER); return ~0U; }
diff -urN wine-1.7.43-orig/dlls/user32/tests/Makefile.in wine-1.7.43/dlls/user32/tests/Makefile.in --- wine-1.7.43-orig/dlls/user32/tests/Makefile.in 2015-05-15 22:36:39 +0900 +++ wine-1.7.43/dlls/user32/tests/Makefile.in 2015-05-25 22:48:27 +0900 @@ -17,6 +17,7 @@ menu.c \ monitor.c \ msg.c \ + rawinput.c \ resource.c \ scroll.c \ static.c \ diff -urN wine-1.7.43-orig/dlls/user32/tests/rawinput.c wine-1.7.43/dlls/user32/tests/rawinput.c --- wine-1.7.43-orig/dlls/user32/tests/rawinput.c 1970-01-01 09:00:00 +0900 +++ wine-1.7.43/dlls/user32/tests/rawinput.c 2015-05-25 22:44:36 +0900 @@ -0,0 +1,43 @@ + /* Unit test suite for the rawinput functions + * + * Copyright 2015 Andrew Church + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define WINVER 0x0501 + +#include "wine/test.h" +#include "windef.h" +#include "winbase.h" +#include "winuser.h" + +static void GRIDLShortArrayTest() +{ + RAWINPUTDEVICELIST devices[1]; + UINT device_count = 1; + int result, error; + + result = GetRawInputDeviceList(devices, &device_count, sizeof(*devices)); + ok(result == ~0U, "wrong result: %d\n", result); + ok(device_count >= 2, "wrong device_count: %d\n", device_count); + error = GetLastError(); + ok(error == ERROR_INSUFFICIENT_BUFFER, "wrong error code: %d\n", error); +} + +START_TEST(rawinput) +{ + GRIDLShortArrayTest(); +}
On Wed, May 27, 2015 at 03:23:40PM +0900, Andrew Church wrote:
(Note: I am not subscribed to the list; please CC me on any replies.)
Looks like your patch got stuck in moderation for a week because you aren't subscribed. Bruno Jesus beat you to submitting it:
http://source.winehq.org/git/wine.git/commitdiff/e0ba6d8fdb9562810231df8fb0b...
Thanks for contributing to Wine, Andrew