Commit a2c10f4d authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

dinput: Don't return unsupported interfaces.

parent c50b19c9
...@@ -566,53 +566,39 @@ static HRESULT WINAPI IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface, RE ...@@ -566,53 +566,39 @@ static HRESULT WINAPI IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface, RE
if (!riid || !ppobj) if (!riid || !ppobj)
return E_POINTER; return E_POINTER;
*ppobj = NULL;
#if DIRECTINPUT_VERSION == 0x0700
if (IsEqualGUID( &IID_IUnknown, riid ) || if (IsEqualGUID( &IID_IUnknown, riid ) ||
IsEqualGUID( &IID_IDirectInputA, riid ) || IsEqualGUID( &IID_IDirectInputA, riid ) ||
IsEqualGUID( &IID_IDirectInput2A, riid ) || IsEqualGUID( &IID_IDirectInput2A, riid ) ||
IsEqualGUID( &IID_IDirectInput7A, riid )) IsEqualGUID( &IID_IDirectInput7A, riid ))
{
*ppobj = &This->IDirectInput7A_iface; *ppobj = &This->IDirectInput7A_iface;
IUnknown_AddRef( (IUnknown*)*ppobj ); else if (IsEqualGUID( &IID_IDirectInputW, riid ) ||
IsEqualGUID( &IID_IDirectInput2W, riid ) ||
return DI_OK; IsEqualGUID( &IID_IDirectInput7W, riid ))
}
if (IsEqualGUID( &IID_IDirectInputW, riid ) ||
IsEqualGUID( &IID_IDirectInput2W, riid ) ||
IsEqualGUID( &IID_IDirectInput7W, riid ))
{
*ppobj = &This->IDirectInput7W_iface; *ppobj = &This->IDirectInput7W_iface;
IUnknown_AddRef( (IUnknown*)*ppobj );
return DI_OK; #else
} if (IsEqualGUID( &IID_IUnknown, riid ) ||
IsEqualGUID( &IID_IDirectInput8A, riid ))
if (IsEqualGUID( &IID_IDirectInput8A, riid ))
{
*ppobj = &This->IDirectInput8A_iface; *ppobj = &This->IDirectInput8A_iface;
IUnknown_AddRef( (IUnknown*)*ppobj );
return DI_OK;
}
if (IsEqualGUID( &IID_IDirectInput8W, riid )) else if (IsEqualGUID( &IID_IDirectInput8W, riid ))
{
*ppobj = &This->IDirectInput8W_iface; *ppobj = &This->IDirectInput8W_iface;
IUnknown_AddRef( (IUnknown*)*ppobj );
return DI_OK; #endif
}
if (IsEqualGUID( &IID_IDirectInputJoyConfig8, riid )) if (IsEqualGUID( &IID_IDirectInputJoyConfig8, riid ))
{
*ppobj = &This->IDirectInputJoyConfig8_iface; *ppobj = &This->IDirectInputJoyConfig8_iface;
IUnknown_AddRef( (IUnknown*)*ppobj );
if(*ppobj)
{
IUnknown_AddRef( (IUnknown*)*ppobj );
return DI_OK; return DI_OK;
} }
FIXME( "Unsupported interface: %s\n", debugstr_guid(riid)); WARN( "Unsupported interface: %s\n", debugstr_guid(riid));
*ppobj = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
......
...@@ -269,23 +269,19 @@ static void test_QueryInterface(void) ...@@ -269,23 +269,19 @@ static void test_QueryInterface(void)
&IID_IDirectInput2A, &IID_IDirectInput2W, &IID_IDirectInput2A, &IID_IDirectInput2W,
&IID_IDirectInput7A, &IID_IDirectInput7W}; &IID_IDirectInput7A, &IID_IDirectInput7W};
static const struct static const REFIID no_interface_list[] =
{
REFIID riid;
int test_todo;
} no_interface_list[] =
{ {
{&IID_IDirectInput8A, 1}, &IID_IDirectInput8A,
{&IID_IDirectInput8W, 1}, &IID_IDirectInput8W,
{&IID_IDirectInputDeviceA}, &IID_IDirectInputDeviceA,
{&IID_IDirectInputDeviceW}, &IID_IDirectInputDeviceW,
{&IID_IDirectInputDevice2A}, &IID_IDirectInputDevice2A,
{&IID_IDirectInputDevice2W}, &IID_IDirectInputDevice2W,
{&IID_IDirectInputDevice7A}, &IID_IDirectInputDevice7A,
{&IID_IDirectInputDevice7W}, &IID_IDirectInputDevice7W,
{&IID_IDirectInputDevice8A}, &IID_IDirectInputDevice8A,
{&IID_IDirectInputDevice8W}, &IID_IDirectInputDevice8W,
{&IID_IDirectInputEffect}, &IID_IDirectInputEffect,
}; };
IDirectInputA *pDI; IDirectInputA *pDI;
...@@ -323,21 +319,9 @@ static void test_QueryInterface(void) ...@@ -323,21 +319,9 @@ static void test_QueryInterface(void)
for (i = 0; i < ARRAY_SIZE(no_interface_list); i++) for (i = 0; i < ARRAY_SIZE(no_interface_list); i++)
{ {
pUnk = (void *)0xdeadbeef; pUnk = (void *)0xdeadbeef;
hr = IDirectInput_QueryInterface(pDI, no_interface_list[i].riid, (void **)&pUnk); hr = IDirectInput_QueryInterface(pDI, no_interface_list[i], (void **)&pUnk);
if (no_interface_list[i].test_todo) ok(hr == E_NOINTERFACE, "[%d] IDirectInput_QueryInterface returned 0x%08x\n", i, hr);
{ ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk);
todo_wine
ok(hr == E_NOINTERFACE, "[%d] IDirectInput_QueryInterface returned 0x%08x\n", i, hr);
todo_wine
ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk);
if (pUnk) IUnknown_Release(pUnk);
}
else
{
ok(hr == E_NOINTERFACE, "[%d] IDirectInput_QueryInterface returned 0x%08x\n", i, hr);
ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk);
}
} }
IDirectInput_Release(pDI); IDirectInput_Release(pDI);
......
...@@ -222,27 +222,23 @@ static void test_QueryInterface(void) ...@@ -222,27 +222,23 @@ static void test_QueryInterface(void)
{ {
static REFIID iid_list[] = {&IID_IUnknown, &IID_IDirectInput8A, &IID_IDirectInput8W, &IID_IDirectInputJoyConfig8}; static REFIID iid_list[] = {&IID_IUnknown, &IID_IDirectInput8A, &IID_IDirectInput8W, &IID_IDirectInputJoyConfig8};
static const struct static const REFIID no_interface_list[] =
{
REFIID riid;
int test_todo;
} no_interface_list[] =
{ {
{&IID_IDirectInputA, 1}, &IID_IDirectInputA,
{&IID_IDirectInputW, 1}, &IID_IDirectInputW,
{&IID_IDirectInput2A, 1}, &IID_IDirectInput2A,
{&IID_IDirectInput2W, 1}, &IID_IDirectInput2W,
{&IID_IDirectInput7A, 1}, &IID_IDirectInput7A,
{&IID_IDirectInput7W, 1}, &IID_IDirectInput7W,
{&IID_IDirectInputDeviceA}, &IID_IDirectInputDeviceA,
{&IID_IDirectInputDeviceW}, &IID_IDirectInputDeviceW,
{&IID_IDirectInputDevice2A}, &IID_IDirectInputDevice2A,
{&IID_IDirectInputDevice2W}, &IID_IDirectInputDevice2W,
{&IID_IDirectInputDevice7A}, &IID_IDirectInputDevice7A,
{&IID_IDirectInputDevice7W}, &IID_IDirectInputDevice7W,
{&IID_IDirectInputDevice8A}, &IID_IDirectInputDevice8A,
{&IID_IDirectInputDevice8W}, &IID_IDirectInputDevice8W,
{&IID_IDirectInputEffect}, &IID_IDirectInputEffect,
}; };
IDirectInput8A *pDI; IDirectInput8A *pDI;
...@@ -292,21 +288,10 @@ static void test_QueryInterface(void) ...@@ -292,21 +288,10 @@ static void test_QueryInterface(void)
for (i = 0; i < ARRAY_SIZE(no_interface_list); i++) for (i = 0; i < ARRAY_SIZE(no_interface_list); i++)
{ {
pUnk = (void *)0xdeadbeef; pUnk = (void *)0xdeadbeef;
hr = IDirectInput8_QueryInterface(pDI, no_interface_list[i].riid, (void **)&pUnk); hr = IDirectInput8_QueryInterface(pDI, no_interface_list[i], (void **)&pUnk);
if (no_interface_list[i].test_todo)
{
todo_wine
ok(hr == E_NOINTERFACE, "[%d] IDirectInput8_QueryInterface returned 0x%08x\n", i, hr);
todo_wine
ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk);
if (pUnk) IUnknown_Release(pUnk); ok(hr == E_NOINTERFACE, "[%d] IDirectInput8_QueryInterface returned 0x%08x\n", i, hr);
} ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk);
else
{
ok(hr == E_NOINTERFACE, "[%d] IDirectInput8_QueryInterface returned 0x%08x\n", i, hr);
ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk);
}
} }
IDirectInput8_Release(pDI); IDirectInput8_Release(pDI);
......
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