Added dinput8-shared-code patchset

This commit is contained in:
Alistair Leslie-Hughes 2018-07-30 12:00:52 +10:00
parent a5044d57dd
commit ea7016fe39
3 changed files with 425 additions and 0 deletions

View File

@ -0,0 +1,405 @@
From b545fa3045a535c75e0611ca6c80b43e5dde57d5 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 30 Jul 2018 09:33:29 +1000
Subject: [PATCH] dinput8: Use shared source directory.
Based off a patch by Andrew Wesie.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
---
dlls/dinput/Makefile.in | 1 +
dlls/dinput/dinput_main.c | 63 +++++++++++
dlls/dinput8/Makefile.in | 17 ++-
dlls/dinput8/dinput8_main.c | 247 --------------------------------------------
4 files changed, 79 insertions(+), 249 deletions(-)
delete mode 100644 dlls/dinput8/dinput8_main.c
diff --git a/dlls/dinput/Makefile.in b/dlls/dinput/Makefile.in
index 5d287a3..b1107ee 100644
--- a/dlls/dinput/Makefile.in
+++ b/dlls/dinput/Makefile.in
@@ -1,6 +1,7 @@
MODULE = dinput.dll
IMPORTLIB = dinput
IMPORTS = dxguid uuid comctl32 ole32 user32 advapi32
+EXTRADEFS = -DDIRECTINPUT_VERSION=0x0700
EXTRALIBS = $(IOKIT_LIBS) $(FORCEFEEDBACK_LIBS)
C_SRCS = \
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
index e4538a0..d42a826 100644
--- a/dlls/dinput/dinput_main.c
+++ b/dlls/dinput/dinput_main.c
@@ -164,6 +164,60 @@ HRESULT WINAPI DirectInputCreateEx(
return DI_OK;
}
+#if DIRECTINPUT_VERSION == 0x0800
+/******************************************************************************
+ * DirectInput8Create (DINPUT8.@)
+ */
+HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI, LPUNKNOWN punkOuter)
+{
+ IDirectInputImpl *This;
+ HRESULT hr;
+
+ TRACE("hInst (%p), dwVersion: %d, riid (%s), punkOuter (%p)\n", hinst, dwVersion, debugstr_guid(riid), punkOuter);
+
+ if (!ppDI)
+ return E_POINTER;
+
+ if (!IsEqualGUID(&IID_IDirectInput8A, riid) &&
+ !IsEqualGUID(&IID_IDirectInput8W, riid) &&
+ !IsEqualGUID(&IID_IUnknown, riid))
+ {
+ *ppDI = NULL;
+ return DIERR_NOINTERFACE;
+ }
+
+ hr = create_directinput_instance(riid, ppDI, &This);
+
+ if (FAILED(hr)) {
+ ERR("CoCreateInstance failed with hr = 0x%08x\n", hr);
+ return hr;
+ }
+
+ /* When aggregation is used (punkOuter!=NULL) the application needs to manually call Initialize. */
+ if(punkOuter == NULL && IsEqualGUID(&IID_IDirectInput8A, riid)) {
+ hr = IDirectInput8_Initialize(&This->IDirectInput8A_iface, hinst, dwVersion);
+ if (FAILED(hr))
+ {
+ IDirectInput8_Release(&This->IDirectInput8A_iface);
+ *ppDI = NULL;
+ return hr;
+ }
+ }
+
+ if(punkOuter == NULL && IsEqualGUID(&IID_IDirectInput8W, riid)) {
+ hr = IDirectInput8_Initialize(&This->IDirectInput8W_iface, hinst, dwVersion);
+ if (FAILED(hr))
+ {
+ IDirectInput8_Release(&This->IDirectInput8W_iface);
+ *ppDI = NULL;
+ return hr;
+ }
+ }
+
+ return S_OK;
+}
+#endif
+
/******************************************************************************
* DirectInputCreateA (DINPUT.@)
*/
@@ -1513,6 +1567,7 @@ static HRESULT WINAPI DICF_CreateInstance(
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
+#if DIRECTINPUT_VERSION < 0x0800
if ( IsEqualGUID( &IID_IUnknown, riid ) ||
IsEqualGUID( &IID_IDirectInputA, riid ) ||
IsEqualGUID( &IID_IDirectInputW, riid ) ||
@@ -1522,6 +1577,13 @@ static HRESULT WINAPI DICF_CreateInstance(
IsEqualGUID( &IID_IDirectInput7W, riid ) ) {
return create_directinput_instance(riid, ppobj, NULL);
}
+#else
+ if( IsEqualGUID( &IID_IDirectInput8A, riid ) ||
+ IsEqualGUID( &IID_IDirectInput8W, riid ) ||
+ IsEqualGUID( &IID_IUnknown, riid )) {
+ return create_directinput_instance(riid, ppobj, NULL);
+ }
+#endif
FIXME("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
return E_NOINTERFACE;
@@ -1833,3 +1895,4 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved)
}
return TRUE;
}
+
diff --git a/dlls/dinput8/Makefile.in b/dlls/dinput8/Makefile.in
index 26672ae..6b62969 100644
--- a/dlls/dinput8/Makefile.in
+++ b/dlls/dinput8/Makefile.in
@@ -1,9 +1,22 @@
MODULE = dinput8.dll
IMPORTLIB = dinput8
-IMPORTS = uuid dxguid dinput ole32 advapi32
+IMPORTS = dxguid uuid comctl32 ole32 user32 advapi32
+EXTRADEFS = -DDIRECTINPUT_VERSION=0x0800
+EXTRALIBS = $(IOKIT_LIBS) $(FORCEFEEDBACK_LIBS)
+PARENTSRC = ../dinput
C_SRCS = \
- dinput8_main.c
+ config.c \
+ data_formats.c \
+ device.c \
+ dinput_main.c \
+ effect_linuxinput.c \
+ joystick.c \
+ joystick_linux.c \
+ joystick_linuxinput.c \
+ joystick_osx.c \
+ keyboard.c \
+ mouse.c
IDL_SRCS = dinput8.idl
diff --git a/dlls/dinput8/dinput8_main.c b/dlls/dinput8/dinput8_main.c
deleted file mode 100644
index 9824c76..0000000
--- a/dlls/dinput8/dinput8_main.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/* DirectInput 8
- *
- * Copyright 2002 TransGaming Technologies Inc.
- * Copyright 2006 Roderick Colenbrander
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "config.h"
-#include <assert.h>
-#include <stdarg.h>
-#include <string.h>
-
-#define COBJMACROS
-
-#include "wine/debug.h"
-#include "windef.h"
-#include "winbase.h"
-#include "winerror.h"
-#include "objbase.h"
-#include "rpcproxy.h"
-#include "dinput.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(dinput);
-
-static HINSTANCE instance;
-static LONG dll_count;
-
-/*
- * Dll lifetime tracking declaration
- */
-static void LockModule(void)
-{
- InterlockedIncrement(&dll_count);
-}
-
-static void UnlockModule(void)
-{
- InterlockedDecrement(&dll_count);
-}
-
-/******************************************************************************
- * DirectInput8Create (DINPUT8.@)
- */
-HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI, LPUNKNOWN punkOuter) {
- IDirectInputA *pDI;
- HRESULT hr, hrCo;
-
- TRACE("hInst (%p), dwVersion: %d, riid (%s), punkOuter (%p)\n", hinst, dwVersion, debugstr_guid(riid), punkOuter);
-
- if (!ppDI)
- return E_POINTER;
-
- if (!IsEqualGUID(&IID_IDirectInput8A, riid) &&
- !IsEqualGUID(&IID_IDirectInput8W, riid) &&
- !IsEqualGUID(&IID_IUnknown, riid))
- {
- *ppDI = NULL;
- return DIERR_NOINTERFACE;
- }
-
- hrCo = CoInitialize(NULL);
-
- hr = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInputA, (void **)&pDI);
-
- /* Ensure balance of calls. */
- if (SUCCEEDED(hrCo))
- CoUninitialize();
-
- if (FAILED(hr)) {
- ERR("CoCreateInstance failed with hr = 0x%08x\n", hr);
- return hr;
- }
-
- hr = IDirectInput_QueryInterface(pDI, riid, ppDI);
- IDirectInput_Release(pDI);
-
- if (FAILED(hr))
- return hr;
-
- /* When aggregation is used (punkOuter!=NULL) the application needs to manually call Initialize. */
- if(punkOuter == NULL && IsEqualGUID(&IID_IDirectInput8A, riid)) {
- IDirectInput8A *DI = *ppDI;
-
- hr = IDirectInput8_Initialize(DI, hinst, dwVersion);
- if (FAILED(hr))
- {
- IDirectInput8_Release(DI);
- *ppDI = NULL;
- return hr;
- }
- }
-
- if(punkOuter == NULL && IsEqualGUID(&IID_IDirectInput8W, riid)) {
- IDirectInput8W *DI = *ppDI;
-
- hr = IDirectInput8_Initialize(DI, hinst, dwVersion);
- if (FAILED(hr))
- {
- IDirectInput8_Release(DI);
- *ppDI = NULL;
- return hr;
- }
- }
-
- return S_OK;
-}
-
-/*******************************************************************************
- * DirectInput8 ClassFactory
- */
-typedef struct
-{
- /* IUnknown fields */
- IClassFactory IClassFactory_iface;
-} IClassFactoryImpl;
-
-static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
-{
- return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
-}
-
-static HRESULT WINAPI DI8CF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
- IClassFactoryImpl *This = impl_from_IClassFactory(iface);
- FIXME("%p %s %p\n",This,debugstr_guid(riid),ppobj);
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI DI8CF_AddRef(LPCLASSFACTORY iface) {
- LockModule();
- return 2;
-}
-
-static ULONG WINAPI DI8CF_Release(LPCLASSFACTORY iface) {
- UnlockModule();
- return 1;
-}
-
-static HRESULT WINAPI DI8CF_CreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj) {
- IClassFactoryImpl *This = impl_from_IClassFactory(iface);
-
- TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
- if( IsEqualGUID( &IID_IDirectInput8A, riid ) || IsEqualGUID( &IID_IDirectInput8W, riid ) || IsEqualGUID( &IID_IUnknown, riid )) {
- IDirectInputA *ppDI;
- HRESULT hr;
-
- hr = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInputA, (void **)&ppDI);
- if (FAILED(hr))
- return hr;
-
- hr = IDirectInput_QueryInterface(ppDI, riid, ppobj);
- IDirectInput_Release(ppDI);
-
- return hr;
- }
-
- ERR("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
- return E_NOINTERFACE;
-}
-
-static HRESULT WINAPI DI8CF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
- TRACE("(%p)->(%d)\n", iface, dolock);
-
- if(dolock)
- LockModule();
- else
- UnlockModule();
-
- return S_OK;
-}
-
-static const IClassFactoryVtbl DI8CF_Vtbl = {
- DI8CF_QueryInterface,
- DI8CF_AddRef,
- DI8CF_Release,
- DI8CF_CreateInstance,
- DI8CF_LockServer
-};
-static IClassFactoryImpl DINPUT8_CF = { { &DI8CF_Vtbl } };
-
-
-/***********************************************************************
- * DllCanUnloadNow (DINPUT8.@)
- */
-HRESULT WINAPI DllCanUnloadNow(void)
-{
- return dll_count == 0 ? S_OK : S_FALSE;
-}
-
-/***********************************************************************
- * DllGetClassObject (DINPUT8.@)
- */
-HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
-{
- TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
- if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
- *ppv = &DINPUT8_CF;
- IClassFactory_AddRef((IClassFactory*)*ppv);
- return S_OK;
- }
-
- FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
- return CLASS_E_CLASSNOTAVAILABLE;
-}
-
-/***********************************************************************
- * DllMain
- */
-BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD reason, LPVOID lpv)
-{
- switch (reason)
- {
- case DLL_PROCESS_ATTACH:
- instance = hInstDLL;
- DisableThreadLibraryCalls( hInstDLL );
- break;
- }
- return TRUE;
-}
-
-/***********************************************************************
- * DllRegisterServer (DINPUT8.@)
- */
-HRESULT WINAPI DllRegisterServer(void)
-{
- return __wine_register_resources( instance );
-}
-
-/***********************************************************************
- * DllUnregisterServer (DINPUT8.@)
- */
-HRESULT WINAPI DllUnregisterServer(void)
-{
- return __wine_unregister_resources( instance );
-}
--
1.9.1

View File

@ -0,0 +1 @@
Fixes: [45327] Stop access volation in League of Legends

View File

@ -140,6 +140,7 @@ patch_enable_all ()
enable_ddraw_Write_Vtable="$1"
enable_dinput_Deadlock="$1"
enable_dinput_Initialize="$1"
enable_dinput8_shared_code="$1"
enable_dsound_EAX="$1"
enable_dsound_Fast_Mixer="$1"
enable_dsound_Revert_Cleanup="$1"
@ -594,6 +595,9 @@ patch_enable ()
dinput-Initialize)
enable_dinput_Initialize="$2"
;;
dinput8-shared-code)
enable_dinput8_shared_code="$2"
;;
dsound-EAX)
enable_dsound_EAX="$2"
;;
@ -3546,6 +3550,21 @@ if test "$enable_dinput_Initialize" -eq 1; then
) >> "$patchlist"
fi
# Patchset dinput8-shared-code
# |
# | This patchset fixes the following Wine bugs:
# | * [#45327] Stop access volation in League of Legends
# |
# | Modified files:
# | * dlls/dinput/Makefile.in, dlls/dinput/dinput_main.c, dlls/dinput8/Makefile.in, dlls/dinput8/dinput8_main.c
# |
if test "$enable_dinput8_shared_code" -eq 1; then
patch_apply dinput8-shared-code/0001-dinput8-Use-shared-source-directory.patch
(
printf '%s\n' '+ { "Alistair Leslie-Hughes", "dinput8: Use shared source directory.", 1 },';
) >> "$patchlist"
fi
# Patchset dsound-Fast_Mixer
# |
# | This patchset fixes the following Wine bugs: