=?UTF-8?Q?Bernhard=20=C3=9Cbelacker=20?=: dinput: Fail in SetCooperativeLevel on invalid hwnd.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Nov 25 10:11:19 CST 2015
Module: wine
Branch: master
Commit: dd08ef4063bdf97a80441b88e41b3d5eb25cf158
URL: http://source.winehq.org/git/wine.git/?a=commit;h=dd08ef4063bdf97a80441b88e41b3d5eb25cf158
Author: Bernhard Übelacker <bernhardu at vr-web.de>
Date: Tue Nov 24 21:25:58 2015 +0100
dinput: Fail in SetCooperativeLevel on invalid hwnd.
MotoGP 3 demo fails to accept key presses to control the driver.
The game calls SetCooperativeLevel twice. First with an invalid hwnd
(but not NULL) and later with the real hwnd.
Signed-off-by: Bernhard Übelacker <bernhardu at vr-web.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/device.c | 4 ++--
dlls/dinput/tests/keyboard.c | 11 +++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index 1ba6ffc..e525f01 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -1028,10 +1028,10 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8
if (hwnd && GetWindowLongW(hwnd, GWL_STYLE) & WS_CHILD) return E_HANDLE;
- if (dwflags == (DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))
+ if (!hwnd && dwflags == (DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))
hwnd = GetDesktopWindow();
- if (!hwnd) return E_HANDLE;
+ if (!IsWindow(hwnd)) return E_HANDLE;
/* For security reasons native does not allow exclusive background level
for mouse and keyboard only */
diff --git a/dlls/dinput/tests/keyboard.c b/dlls/dinput/tests/keyboard.c
index 520740d..e51e332 100644
--- a/dlls/dinput/tests/keyboard.c
+++ b/dlls/dinput/tests/keyboard.c
@@ -121,6 +121,12 @@ static const HRESULT SetCoop_null_window[16] = {
E_INVALIDARG, E_HANDLE, S_OK, E_INVALIDARG,
E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
+static const HRESULT SetCoop_invalid_window[16] = {
+ E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
+ E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
+ E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG,
+ E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG};
+
static const HRESULT SetCoop_real_window[16] = {
E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG,
E_INVALIDARG, S_OK, S_OK, E_INVALIDARG,
@@ -151,6 +157,11 @@ static void test_set_coop(IDirectInputA *pDI, HWND hwnd)
}
for (i=0; i<16; i++)
{
+ hr = IDirectInputDevice_SetCooperativeLevel(pKeyboard, (HWND)0x400000, i);
+ ok(hr == SetCoop_invalid_window[i], "SetCooperativeLevel(invalid, %d): %08x\n", i, hr);
+ }
+ for (i=0; i<16; i++)
+ {
hr = IDirectInputDevice_SetCooperativeLevel(pKeyboard, hwnd, i);
ok(hr == SetCoop_real_window[i], "SetCooperativeLevel(hwnd, %d): %08x\n", i, hr);
}
More information about the wine-cvs
mailing list