ReactOS  0.4.13-dev-100-gc8611ae
dinput8_main.c File Reference
#include "config.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include "wine/debug.h"
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "objbase.h"
#include "rpcproxy.h"
#include "dinput.h"
Include dependency graph for dinput8_main.c:

Go to the source code of this file.

Classes

struct  IClassFactoryImpl
 

Macros

#define COBJMACROS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dinput)
 
static void LockModule (void)
 
static void UnlockModule (void)
 
HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create (HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI, LPUNKNOWN punkOuter)
 
static IClassFactoryImplimpl_from_IClassFactory (IClassFactory *iface)
 
static HRESULT WINAPI DI8CF_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
 
static ULONG WINAPI DI8CF_AddRef (LPCLASSFACTORY iface)
 
static ULONG WINAPI DI8CF_Release (LPCLASSFACTORY iface)
 
static HRESULT WINAPI DI8CF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
 
static HRESULT WINAPI DI8CF_LockServer (LPCLASSFACTORY iface, BOOL dolock)
 
HRESULT WINAPI DllCanUnloadNow (void)
 
HRESULT WINAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv)
 
BOOL WINAPI DllMain (HINSTANCE hInstDLL, DWORD reason, LPVOID lpv)
 
HRESULT WINAPI DllRegisterServer (void)
 
HRESULT WINAPI DllUnregisterServer (void)
 

Variables

typedef helpstring
 
static HINSTANCE instance
 
static LONG dll_count
 
static const IClassFactoryVtbl DI8CF_Vtbl
 
static IClassFactoryImpl DINPUT8_CF = { { &DI8CF_Vtbl } }
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 26 of file dinput8_main.c.

Function Documentation

◆ DI8CF_AddRef()

static ULONG WINAPI DI8CF_AddRef ( LPCLASSFACTORY  iface)
static

Definition at line 141 of file dinput8_main.c.

141  {
142  LockModule();
143  return 2;
144 }
static void LockModule(void)
Definition: dinput8_main.c:44

◆ DI8CF_CreateInstance()

static HRESULT WINAPI DI8CF_CreateInstance ( LPCLASSFACTORY  iface,
LPUNKNOWN  pOuter,
REFIID  riid,
LPVOID ppobj 
)
static

Definition at line 151 of file dinput8_main.c.

151  {
153 
154  TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
155  if( IsEqualGUID( &IID_IDirectInput8A, riid ) || IsEqualGUID( &IID_IDirectInput8W, riid ) || IsEqualGUID( &IID_IUnknown, riid )) {
156  IDirectInputA *ppDI;
157  HRESULT hr;
158 
159  hr = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInputA, (void **)&ppDI);
160  if (FAILED(hr))
161  return hr;
162 
163  hr = IDirectInput_QueryInterface(ppDI, riid, ppobj);
164  IDirectInput_Release(ppDI);
165 
166  return hr;
167  }
168 
169  ERR("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
170  return E_NOINTERFACE;
171 }
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
#define IDirectInput_QueryInterface(p, a, b)
Definition: dinput.h:2239
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
#define IDirectInput_Release(p)
Definition: dinput.h:2241
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define ERR(fmt,...)
Definition: debug.h:109
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: dinput8_main.c:130
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021

◆ DI8CF_LockServer()

static HRESULT WINAPI DI8CF_LockServer ( LPCLASSFACTORY  iface,
BOOL  dolock 
)
static

Definition at line 173 of file dinput8_main.c.

173  {
174  TRACE("(%p)->(%d)\n", iface, dolock);
175 
176  if(dolock)
177  LockModule();
178  else
179  UnlockModule();
180 
181  return S_OK;
182 }
static void UnlockModule(void)
Definition: dinput8_main.c:49
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
static void LockModule(void)
Definition: dinput8_main.c:44

◆ DI8CF_QueryInterface()

static HRESULT WINAPI DI8CF_QueryInterface ( LPCLASSFACTORY  iface,
REFIID  riid,
LPVOID ppobj 
)
static

Definition at line 135 of file dinput8_main.c.

135  {
137  FIXME("%p %s %p\n",This,debugstr_guid(riid),ppobj);
138  return E_NOINTERFACE;
139 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define FIXME(fmt,...)
Definition: debug.h:110
#define debugstr_guid
Definition: kernel32.h:35
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: dinput8_main.c:130

◆ DI8CF_Release()

static ULONG WINAPI DI8CF_Release ( LPCLASSFACTORY  iface)
static

Definition at line 146 of file dinput8_main.c.

146  {
147  UnlockModule();
148  return 1;
149 }
static void UnlockModule(void)
Definition: dinput8_main.c:49

◆ DirectInput8Create()

HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create ( HINSTANCE  hinst,
DWORD  dwVersion,
REFIID  riid,
LPVOID ppDI,
LPUNKNOWN  punkOuter 
)

Definition at line 57 of file dinput8_main.c.

57  {
58  IDirectInputA *pDI;
59  HRESULT hr, hrCo;
60 
61  TRACE("hInst (%p), dwVersion: %d, riid (%s), punkOuter (%p)\n", hinst, dwVersion, debugstr_guid(riid), punkOuter);
62 
63  if (!ppDI)
64  return E_POINTER;
65 
66  if (!IsEqualGUID(&IID_IDirectInput8A, riid) &&
67  !IsEqualGUID(&IID_IDirectInput8W, riid) &&
69  {
70  *ppDI = NULL;
71  return DIERR_NOINTERFACE;
72  }
73 
74  hrCo = CoInitialize(NULL);
75 
76  hr = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInputA, (void **)&pDI);
77 
78  /* Ensure balance of calls. */
79  if (SUCCEEDED(hrCo))
81 
82  if (FAILED(hr)) {
83  ERR("CoCreateInstance failed with hr = 0x%08x\n", hr);
84  return hr;
85  }
86 
87  hr = IDirectInput_QueryInterface(pDI, riid, ppDI);
89 
90  if (FAILED(hr))
91  return hr;
92 
93  /* When aggregation is used (punkOuter!=NULL) the application needs to manually call Initialize. */
94  if(punkOuter == NULL && IsEqualGUID(&IID_IDirectInput8A, riid)) {
95  IDirectInput8A *DI = *ppDI;
96 
97  hr = IDirectInput8_Initialize(DI, hinst, dwVersion);
98  if (FAILED(hr))
99  {
101  *ppDI = NULL;
102  return hr;
103  }
104  }
105 
106  if(punkOuter == NULL && IsEqualGUID(&IID_IDirectInput8W, riid)) {
107  IDirectInput8W *DI = *ppDI;
108 
109  hr = IDirectInput8_Initialize(DI, hinst, dwVersion);
110  if (FAILED(hr))
111  {
113  *ppDI = NULL;
114  return hr;
115  }
116  }
117 
118  return S_OK;
119 }
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
#define IDirectInput_QueryInterface(p, a, b)
Definition: dinput.h:2239
smooth NULL
Definition: ftsmooth.c:416
#define IDirectInput8_Initialize(p, a, b)
Definition: dinput.h:2464
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
#define IDirectInput_Release(p)
Definition: dinput.h:2241
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
#define DIERR_NOINTERFACE
Definition: dinput.h:153
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
static HINSTANCE hinst
Definition: edit.c:551
#define E_POINTER
Definition: winerror.h:2365
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define IDirectInput8_Release(p)
Definition: dinput.h:2458

◆ DllCanUnloadNow()

HRESULT WINAPI DllCanUnloadNow ( void  )

Definition at line 197 of file dinput8_main.c.

198 {
199  return dll_count == 0 ? S_OK : S_FALSE;
200 }
#define S_FALSE
Definition: winerror.h:2357
static LONG dll_count
Definition: dinput8_main.c:39
#define S_OK
Definition: intsafe.h:59

◆ DllGetClassObject()

HRESULT WINAPI DllGetClassObject ( REFCLSID  rclsid,
REFIID  riid,
LPVOID ppv 
)

Definition at line 205 of file dinput8_main.c.

206 {
207  TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
208  if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
209  *ppv = &DINPUT8_CF;
210  IClassFactory_AddRef((IClassFactory*)*ppv);
211  return S_OK;
212  }
213 
214  FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
216 }
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
#define FIXME(fmt,...)
Definition: debug.h:110
static IClassFactoryImpl DINPUT8_CF
Definition: dinput8_main.c:191
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
const GUID IID_IClassFactory
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:91

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hInstDLL,
DWORD  reason,
LPVOID  lpv 
)

Definition at line 221 of file dinput8_main.c.

222 {
223  switch (reason)
224  {
225  case DLL_PROCESS_ATTACH:
226  instance = hInstDLL;
227  DisableThreadLibraryCalls( hInstDLL );
228  break;
229  }
230  return TRUE;
231 }
static HINSTANCE instance
Definition: dinput8_main.c:38
#define TRUE
Definition: types.h:120
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904

◆ DllRegisterServer()

HRESULT WINAPI DllRegisterServer ( void  )

Definition at line 236 of file dinput8_main.c.

237 {
239 }
static HINSTANCE instance
Definition: dinput8_main.c:38
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98

◆ DllUnregisterServer()

HRESULT WINAPI DllUnregisterServer ( void  )

Definition at line 244 of file dinput8_main.c.

245 {
247 }
static HINSTANCE instance
Definition: dinput8_main.c:38
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110

◆ impl_from_IClassFactory()

static IClassFactoryImpl* impl_from_IClassFactory ( IClassFactory iface)
inlinestatic

Definition at line 130 of file dinput8_main.c.

131 {
132  return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
133 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by DI8CF_CreateInstance(), and DI8CF_QueryInterface().

◆ LockModule()

static void LockModule ( void  )
static

Definition at line 44 of file dinput8_main.c.

45 {
47 }
static LONG dll_count
Definition: dinput8_main.c:39
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by DI8CF_AddRef(), and DI8CF_LockServer().

◆ UnlockModule()

static void UnlockModule ( void  )
static

Definition at line 49 of file dinput8_main.c.

50 {
52 }
static LONG dll_count
Definition: dinput8_main.c:39
#define InterlockedDecrement
Definition: armddk.h:52

Referenced by DI8CF_LockServer(), and DI8CF_Release().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dinput  )

Variable Documentation

◆ DI8CF_Vtbl

const IClassFactoryVtbl DI8CF_Vtbl
static
Initial value:
= {
}
static HRESULT WINAPI DI8CF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
Definition: dinput8_main.c:173
static ULONG WINAPI DI8CF_AddRef(LPCLASSFACTORY iface)
Definition: dinput8_main.c:141
static ULONG WINAPI DI8CF_Release(LPCLASSFACTORY iface)
Definition: dinput8_main.c:146
static HRESULT WINAPI DI8CF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
Definition: dinput8_main.c:135
static HRESULT WINAPI DI8CF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
Definition: dinput8_main.c:151

Definition at line 184 of file dinput8_main.c.

◆ DINPUT8_CF

IClassFactoryImpl DINPUT8_CF = { { &DI8CF_Vtbl } }
static

Definition at line 191 of file dinput8_main.c.

Referenced by DllGetClassObject().

◆ dll_count

LONG dll_count
static

Definition at line 39 of file dinput8_main.c.

Referenced by DllCanUnloadNow(), LockModule(), and UnlockModule().

◆ helpstring

typedef helpstring

◆ instance

HINSTANCE instance
static

Definition at line 38 of file dinput8_main.c.

Referenced by DllMain(), DllRegisterServer(), and DllUnregisterServer().