Commit 49c66a3a authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput/tests: Check IDirectInputDevice2AImpl_GetObjectInfo error codes.

parent 2fac2e6b
...@@ -1457,9 +1457,9 @@ HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo( ...@@ -1457,9 +1457,9 @@ HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
DIDEVICEOBJECTINSTANCEW didoiW; DIDEVICEOBJECTINSTANCEW didoiW;
HRESULT res; HRESULT res;
if (!pdidoi || if (!pdidoi) return E_POINTER;
(pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) && if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) &&
pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A))) pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A))
return DIERR_INVALIDPARAM; return DIERR_INVALIDPARAM;
didoiW.dwSize = sizeof(didoiW); didoiW.dwSize = sizeof(didoiW);
...@@ -1492,9 +1492,9 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo( ...@@ -1492,9 +1492,9 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(
TRACE("(%p) %d(0x%08x) -> %p\n", This, dwHow, dwObj, pdidoi); TRACE("(%p) %d(0x%08x) -> %p\n", This, dwHow, dwObj, pdidoi);
if (!pdidoi || if (!pdidoi) return E_POINTER;
(pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEW) && if (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEW) &&
pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3W))) pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3W))
return DIERR_INVALIDPARAM; return DIERR_INVALIDPARAM;
switch (dwHow) switch (dwHow)
......
...@@ -580,12 +580,18 @@ HRESULT WINAPI JoystickAGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface, ...@@ -580,12 +580,18 @@ HRESULT WINAPI JoystickAGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface); JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
HRESULT res; HRESULT res;
DIDEVICEOBJECTINSTANCEW didoiW; 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); didoiW.dwSize = sizeof(didoiW);
res = JoystickWGenericImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow); res = JoystickWGenericImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow);
if (res != DI_OK) return res; if (res != DI_OK) return res;
dwSize = pdidoi->dwSize;
memset(pdidoi, 0, pdidoi->dwSize); memset(pdidoi, 0, pdidoi->dwSize);
memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName)); memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
pdidoi->dwSize = dwSize; pdidoi->dwSize = dwSize;
......
...@@ -802,12 +802,18 @@ static HRESULT WINAPI SysMouseAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface, ...@@ -802,12 +802,18 @@ static HRESULT WINAPI SysMouseAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface); SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
HRESULT res; HRESULT res;
DIDEVICEOBJECTINSTANCEW didoiW; 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); didoiW.dwSize = sizeof(didoiW);
res = SysMouseWImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow); res = SysMouseWImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow);
if (res != DI_OK) return res; if (res != DI_OK) return res;
dwSize = pdidoi->dwSize;
memset(pdidoi, 0, pdidoi->dwSize); memset(pdidoi, 0, pdidoi->dwSize);
memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName)); memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
pdidoi->dwSize = dwSize; pdidoi->dwSize = dwSize;
......
...@@ -158,6 +158,16 @@ static void test_object_info(IDirectInputDeviceA *device, HWND hwnd) ...@@ -158,6 +158,16 @@ static void test_object_info(IDirectInputDeviceA *device, HWND hwnd)
hr = IDirectInputDevice_GetDeviceData(device, sizeof(buffer[0]), buffer, &cnt, 0); hr = IDirectInputDevice_GetDeviceData(device, sizeof(buffer[0]), buffer, &cnt, 0);
ok(hr == DI_OK, "GetDeviceData() failed: %08x\n", hr); 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 */ /* No need to test devices without axis */
obj_info.dwSize = sizeof(obj_info); obj_info.dwSize = sizeof(obj_info);
hr = IDirectInputDevice_GetObjectInfo(device, &obj_info, 16, DIPH_BYOFFSET); hr = IDirectInputDevice_GetObjectInfo(device, &obj_info, 16, DIPH_BYOFFSET);
......
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