dinput/tests: Check IDirectInputDevice2AImpl_GetObjectInfo error codes.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-05-26 11:23:03 +02:00 committed by Alexandre Julliard
parent 2fac2e6b32
commit 49c66a3a94
4 changed files with 30 additions and 8 deletions

View File

@ -1457,9 +1457,9 @@ HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
DIDEVICEOBJECTINSTANCEW didoiW;
HRESULT res;
if (!pdidoi ||
(pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) &&
pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A)))
if (!pdidoi) return E_POINTER;
if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) &&
pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A))
return DIERR_INVALIDPARAM;
didoiW.dwSize = sizeof(didoiW);
@ -1492,9 +1492,9 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(
TRACE("(%p) %d(0x%08x) -> %p\n", This, dwHow, dwObj, pdidoi);
if (!pdidoi ||
(pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEW) &&
pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3W)))
if (!pdidoi) return E_POINTER;
if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEW) &&
pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3W))
return DIERR_INVALIDPARAM;
switch (dwHow)

View File

@ -580,12 +580,18 @@ HRESULT WINAPI JoystickAGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
HRESULT res;
DIDEVICEOBJECTINSTANCEW didoiW;
DWORD dwSize = pdidoi->dwSize;
DWORD dwSize;
if (!pdidoi) return E_POINTER;
if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) &&
pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A))
return DIERR_INVALIDPARAM;
didoiW.dwSize = sizeof(didoiW);
res = JoystickWGenericImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow);
if (res != DI_OK) return res;
dwSize = pdidoi->dwSize;
memset(pdidoi, 0, pdidoi->dwSize);
memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
pdidoi->dwSize = dwSize;

View File

@ -802,12 +802,18 @@ static HRESULT WINAPI SysMouseAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
HRESULT res;
DIDEVICEOBJECTINSTANCEW didoiW;
DWORD dwSize = pdidoi->dwSize;
DWORD dwSize;
if (!pdidoi) return E_POINTER;
if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) &&
pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A))
return DIERR_INVALIDPARAM;
didoiW.dwSize = sizeof(didoiW);
res = SysMouseWImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow);
if (res != DI_OK) return res;
dwSize = pdidoi->dwSize;
memset(pdidoi, 0, pdidoi->dwSize);
memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
pdidoi->dwSize = dwSize;

View File

@ -158,6 +158,16 @@ static void test_object_info(IDirectInputDeviceA *device, HWND hwnd)
hr = IDirectInputDevice_GetDeviceData(device, sizeof(buffer[0]), buffer, &cnt, 0);
ok(hr == DI_OK, "GetDeviceData() failed: %08x\n", hr);
hr = IDirectInputDevice_GetObjectInfo(device, NULL, 16, DIPH_BYOFFSET);
ok(hr == E_POINTER, "IDirectInputDevice_GetObjectInfo returned %08x, expected %08x\n", hr, E_POINTER);
obj_info.dwSize = 1;
hr = IDirectInputDevice_GetObjectInfo(device, &obj_info, 16, DIPH_BYOFFSET);
ok(hr == DIERR_INVALIDPARAM, "IDirectInputDevice_GetObjectInfo returned %08x, expected %08x\n", hr, DIERR_INVALIDPARAM);
obj_info.dwSize = 0xdeadbeef;
hr = IDirectInputDevice_GetObjectInfo(device, &obj_info, 16, DIPH_BYOFFSET);
ok(hr == DIERR_INVALIDPARAM, "IDirectInputDevice_GetObjectInfo returned %08x, expected %08x\n", hr, DIERR_INVALIDPARAM);
/* No need to test devices without axis */
obj_info.dwSize = sizeof(obj_info);
hr = IDirectInputDevice_GetObjectInfo(device, &obj_info, 16, DIPH_BYOFFSET);