Commit 310859db authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

dinput: Add more parameter checking to enum devices.

parent a84d2fe2
......@@ -208,7 +208,8 @@ static void _dump_EnumDevices_dwFlags(DWORD dwFlags) {
FE(DIEDFL_ATTACHEDONLY),
FE(DIEDFL_FORCEFEEDBACK),
FE(DIEDFL_INCLUDEALIASES),
FE(DIEDFL_INCLUDEPHANTOMS)
FE(DIEDFL_INCLUDEPHANTOMS),
FE(DIEDFL_INCLUDEHIDDEN)
#undef FE
};
TRACE(" flags: ");
......@@ -356,7 +357,9 @@ static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
lpCallback, pvRef, dwFlags);
_dump_EnumDevices_dwFlags(dwFlags);
if (!lpCallback)
if (!lpCallback ||
dwFlags & ~(DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK | DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN) ||
dwDevType > 4)
return DIERR_INVALIDPARAM;
if (!This->initialized)
......@@ -393,7 +396,9 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
lpCallback, pvRef, dwFlags);
_dump_EnumDevices_dwFlags(dwFlags);
if (!lpCallback)
if (!lpCallback ||
dwFlags & ~(DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK | DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN) ||
dwDevType > 4)
return DIERR_INVALIDPARAM;
if (!This->initialized)
......
......@@ -86,11 +86,11 @@ static void test_preinitialization(void)
{0, NULL, 0, DIERR_INVALIDPARAM},
{0, NULL, ~0u, DIERR_INVALIDPARAM},
{0, dummy_callback, 0, DIERR_NOTINITIALIZED},
{0, dummy_callback, ~0u, DIERR_INVALIDPARAM, 1},
{0, dummy_callback, ~0u, DIERR_INVALIDPARAM},
{0xdeadbeef, NULL, 0, DIERR_INVALIDPARAM},
{0xdeadbeef, NULL, ~0u, DIERR_INVALIDPARAM},
{0xdeadbeef, dummy_callback, 0, DIERR_INVALIDPARAM, 1},
{0xdeadbeef, dummy_callback, ~0u, DIERR_INVALIDPARAM, 1},
{0xdeadbeef, dummy_callback, 0, DIERR_INVALIDPARAM},
{0xdeadbeef, dummy_callback, ~0u, DIERR_INVALIDPARAM},
};
IDirectInputA *pDI;
......@@ -434,11 +434,9 @@ static void test_EnumDevices(void)
ok(hr == DIERR_INVALIDPARAM, "IDirectInput_EnumDevices returned 0x%08x\n", hr);
hr = IDirectInput_EnumDevices(pDI, 0xdeadbeef, enum_devices_callback, NULL, 0);
todo_wine
ok(hr == DIERR_INVALIDPARAM, "IDirectInput_EnumDevices returned 0x%08x\n", hr);
hr = IDirectInput_EnumDevices(pDI, 0xdeadbeef, enum_devices_callback, NULL, ~0u);
todo_wine
ok(hr == DIERR_INVALIDPARAM, "IDirectInput_EnumDevices returned 0x%08x\n", hr);
enum_test.device_count = 0;
......
......@@ -63,11 +63,11 @@ static void test_preinitialization(void)
{0, NULL, 0, DIERR_INVALIDPARAM},
{0, NULL, ~0u, DIERR_INVALIDPARAM},
{0, dummy_callback, 0, DIERR_NOTINITIALIZED},
{0, dummy_callback, ~0u, DIERR_INVALIDPARAM, 1},
{0, dummy_callback, ~0u, DIERR_INVALIDPARAM},
{0xdeadbeef, NULL, 0, DIERR_INVALIDPARAM},
{0xdeadbeef, NULL, ~0u, DIERR_INVALIDPARAM},
{0xdeadbeef, dummy_callback, 0, DIERR_INVALIDPARAM, 1},
{0xdeadbeef, dummy_callback, ~0u, DIERR_INVALIDPARAM, 1},
{0xdeadbeef, dummy_callback, 0, DIERR_INVALIDPARAM},
{0xdeadbeef, dummy_callback, ~0u, DIERR_INVALIDPARAM},
};
IDirectInput8A *pDI;
......@@ -404,11 +404,9 @@ static void test_EnumDevices(void)
ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr);
hr = IDirectInput8_EnumDevices(pDI, 0xdeadbeef, enum_devices_callback, NULL, 0);
todo_wine
ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr);
hr = IDirectInput8_EnumDevices(pDI, 0xdeadbeef, enum_devices_callback, NULL, ~0u);
todo_wine
ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_EnumDevices returned 0x%08x\n", hr);
enum_test.device_count = 0;
......
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