Commit 6a0eb7a5 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

user32: Set last error codes on GetRawInputDeviceInfoW failure.

parent 964bf968
......@@ -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);
......
......@@ -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];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment