dinput: Add more parameter checking to enum devices.

This commit is contained in:
Vitaliy Margolen 2011-11-26 10:30:16 -07:00 committed by Alexandre Julliard
parent a84d2fe20e
commit 310859db67
3 changed files with 14 additions and 13 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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;