Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/dinput/device.c | 12 ++++++------
dlls/dinput/joystick.c | 8 +++++++-
dlls/dinput/mouse.c | 8 +++++++-
dlls/dinput/tests/device.c | 10 ++++++++++
4 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index 31b859801c7..c1388551644 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -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)
diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
index 3749eed7efe..ab8b87f552b 100644
--- a/dlls/dinput/joystick.c
+++ b/dlls/dinput/joystick.c
@@ -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;
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
index 65f173daa81..bc99ea37c68 100644
--- a/dlls/dinput/mouse.c
+++ b/dlls/dinput/mouse.c
@@ -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;
diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c
index 9be00a671fb..485acca4f61 100644
--- a/dlls/dinput/tests/device.c
+++ b/dlls/dinput/tests/device.c
@@ -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);
--
2.31.0