ReactOS  0.4.15-dev-1018-g0695ecb
factory.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
#include "ole2.h"
#include "rpcproxy.h"
#include "initguid.h"
#include "vfw.h"
#include "avifile_private.h"
#include "wine/debug.h"
Include dependency graph for factory.c:

Go to the source code of this file.

Classes

struct  IClassFactoryImpl
 

Macros

#define COBJMACROS
 
#define SLASH(w)   ((w) == '/' || (w) == '\\')
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (avifile)
 
static IClassFactoryImplimpl_from_IClassFactory (IClassFactory *iface)
 
static HRESULT WINAPI IClassFactory_fnQueryInterface (IClassFactory *iface, REFIID riid, void **ppobj)
 
static ULONG WINAPI IClassFactory_fnAddRef (IClassFactory *iface)
 
static ULONG WINAPI IClassFactory_fnRelease (IClassFactory *iface)
 
static HRESULT WINAPI IClassFactory_fnCreateInstance (IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
 
static HRESULT WINAPI IClassFactory_fnLockServer (IClassFactory *iface, BOOL dolock)
 
static HRESULT AVIFILE_CreateClassFactory (const CLSID *clsid, const IID *riid, void **ppv)
 
LPCWSTR AVIFILE_BasenameW (LPCWSTR szPath)
 
HRESULT WINAPI DllGetClassObject (REFCLSID pclsid, REFIID piid, LPVOID *ppv)
 
HRESULT WINAPI DllCanUnloadNow (void)
 
BOOL WINAPI DllMain (HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
 
HRESULT WINAPI DllRegisterServer (void)
 
HRESULT WINAPI DllUnregisterServer (void)
 

Variables

HMODULE AVIFILE_hModule = NULL
 
static BOOL AVIFILE_bLocked
 
static UINT AVIFILE_uUseCount
 
static const IClassFactoryVtbl iclassfact
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file factory.c.

◆ SLASH

#define SLASH (   w)    ((w) == '/' || (w) == '\\')

Function Documentation

◆ AVIFILE_BasenameW()

LPCWSTR AVIFILE_BasenameW ( LPCWSTR  szPath)

Definition at line 162 of file factory.c.

163 {
164 #define SLASH(w) ((w) == '/' || (w) == '\\')
165 
166  LPCWSTR szCur;
167 
168  for (szCur = szPath + lstrlenW(szPath);
169  szCur > szPath && !SLASH(*szCur) && *szCur != ':';)
170  szCur--;
171 
172  if (szCur == szPath)
173  return szCur;
174  else
175  return szCur + 1;
176 
177 #undef SLASH
178 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define lstrlenW
Definition: compat.h:498
#define SLASH(w)
LPCWSTR szPath
Definition: env.c:35

Referenced by AVIFILE_LoadFile(), and IPersistFile_fnLoad().

◆ AVIFILE_CreateClassFactory()

static HRESULT AVIFILE_CreateClassFactory ( const CLSID clsid,
const IID riid,
void **  ppv 
)
static

Definition at line 141 of file factory.c.

142 {
144  HRESULT hr;
145 
146  *ppv = NULL;
147 
148  cf = HeapAlloc(GetProcessHeap(), 0, sizeof(*cf));
149  if (!cf)
150  return E_OUTOFMEMORY;
151 
152  cf->IClassFactory_iface.lpVtbl = &iclassfact;
153  cf->ref = 1;
154  cf->clsid = *clsid;
155 
156  hr = IClassFactory_QueryInterface(&cf->IClassFactory_iface, riid, ppv);
157  IClassFactory_Release(&cf->IClassFactory_iface);
158 
159  return hr;
160 }
static IClassFactory * cf
static const IClassFactoryVtbl iclassfact
Definition: factory.c:133
IClassFactory IClassFactory_iface
Definition: inetcomm_main.c:74
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:79
REFCLSID clsid
Definition: msctf.c:82

Referenced by DllGetClassObject().

◆ DllCanUnloadNow()

HRESULT WINAPI DllCanUnloadNow ( void  )

Definition at line 202 of file factory.c.

203 {
204  return ((AVIFILE_bLocked || AVIFILE_uUseCount) ? S_FALSE : S_OK);
205 }
static UINT AVIFILE_uUseCount
Definition: factory.c:42
static BOOL AVIFILE_bLocked
Definition: factory.c:41
#define S_FALSE
Definition: winerror.h:2357
#define S_OK
Definition: intsafe.h:59

◆ DllGetClassObject()

HRESULT WINAPI DllGetClassObject ( REFCLSID  pclsid,
REFIID  piid,
LPVOID ppv 
)

Definition at line 183 of file factory.c.

184 {
185  HRESULT hr;
186 
187  TRACE("(%s,%s,%p)\n", debugstr_guid(pclsid), debugstr_guid(piid), ppv);
188 
189  if (pclsid == NULL || piid == NULL || ppv == NULL)
190  return E_FAIL;
191 
192  hr = AVIFILE_CreateClassFactory(pclsid,piid,ppv);
193  if (SUCCEEDED(hr))
194  return hr;
195 
196  return avifil32_DllGetClassObject(pclsid,piid,ppv);
197 }
HRESULT WINAPI avifil32_DllGetClassObject(REFCLSID pclsid, REFIID piid, LPVOID *ppv) DECLSPEC_HIDDEN
HRESULT hr
Definition: shlfolder.c:183
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
static HRESULT AVIFILE_CreateClassFactory(const CLSID *clsid, const IID *riid, void **ppv)
Definition: factory.c:141
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hInstDll,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Definition at line 210 of file factory.c.

211 {
212  TRACE("(%p,%d,%p)\n", hInstDll, fdwReason, lpvReserved);
213 
214  switch (fdwReason) {
215  case DLL_PROCESS_ATTACH:
216  DisableThreadLibraryCalls(hInstDll);
217  AVIFILE_hModule = hInstDll;
218  break;
219  };
220 
221  return TRUE;
222 }
#define TRUE
Definition: types.h:120
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
static IN DWORD IN LPVOID lpvReserved
#define TRACE(s)
Definition: solgame.cpp:4
HMODULE AVIFILE_hModule
Definition: factory.c:39

◆ DllRegisterServer()

HRESULT WINAPI DllRegisterServer ( void  )

Definition at line 227 of file factory.c.

228 {
230 }
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
HMODULE AVIFILE_hModule
Definition: factory.c:39

◆ DllUnregisterServer()

HRESULT WINAPI DllUnregisterServer ( void  )

Definition at line 235 of file factory.c.

236 {
238 }
HMODULE AVIFILE_hModule
Definition: factory.c:39
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110

◆ IClassFactory_fnAddRef()

static ULONG WINAPI IClassFactory_fnAddRef ( IClassFactory iface)
static

Definition at line 71 of file factory.c.

72 {
75 
76  TRACE("(%p) ref = %u\n", This, ref);
77  return ref;
78 }
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: factory.c:51
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ IClassFactory_fnCreateInstance()

static HRESULT WINAPI IClassFactory_fnCreateInstance ( IClassFactory iface,
IUnknown pOuter,
REFIID  riid,
void **  ppobj 
)
static

Definition at line 93 of file factory.c.

95 {
97 
98  TRACE("(%p,%p,%s,%p)\n", iface, pOuter, debugstr_guid(riid),
99  ppobj);
100 
101  if (!ppobj)
102  return E_INVALIDARG;
103  *ppobj = NULL;
104 
105  if (pOuter && !IsEqualGUID(&IID_IUnknown, riid))
106  return E_INVALIDARG;
107 
108  if (IsEqualGUID(&CLSID_AVIFile, &This->clsid))
109  return AVIFILE_CreateAVIFile(pOuter, riid, ppobj);
110  if (IsEqualGUID(&CLSID_WAVFile, &This->clsid))
111  return AVIFILE_CreateWAVFile(pOuter, riid, ppobj);
112 
113  if (pOuter)
114  return CLASS_E_NOAGGREGATION;
115 
116  if (IsEqualGUID(&CLSID_ICMStream, &This->clsid))
117  return AVIFILE_CreateICMStream(riid,ppobj);
118  if (IsEqualGUID(&CLSID_ACMStream, &This->clsid))
119  return AVIFILE_CreateACMStream(riid,ppobj);
120 
121  return E_NOINTERFACE;
122 }
#define E_NOINTERFACE
Definition: winerror.h:2364
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: factory.c:51
REFIID riid
Definition: precomp.h:44
HRESULT AVIFILE_CreateACMStream(REFIID riid, LPVOID *ppv)
Definition: acmstream.c:704
HRESULT AVIFILE_CreateAVIFile(IUnknown *pUnkOuter, REFIID riid, void **ppv)
Definition: avifile.c:645
HRESULT AVIFILE_CreateWAVFile(IUnknown *outer_unk, REFIID riid, void **ret_iface) DECLSPEC_HIDDEN
Definition: wavfile.c:978
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
HRESULT AVIFILE_CreateICMStream(REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN
Definition: icmstream.c:727
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ IClassFactory_fnLockServer()

static HRESULT WINAPI IClassFactory_fnLockServer ( IClassFactory iface,
BOOL  dolock 
)
static

Definition at line 124 of file factory.c.

125 {
126  TRACE("(%p,%d)\n",iface,dolock);
127 
128  AVIFILE_bLocked = dolock;
129 
130  return S_OK;
131 }
static BOOL AVIFILE_bLocked
Definition: factory.c:41
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ IClassFactory_fnQueryInterface()

static HRESULT WINAPI IClassFactory_fnQueryInterface ( IClassFactory iface,
REFIID  riid,
void **  ppobj 
)
static

Definition at line 56 of file factory.c.

58 {
59  TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppobj);
60 
61  if ((IsEqualGUID(&IID_IUnknown, riid)) ||
63  *ppobj = iface;
64  IClassFactory_AddRef(iface);
65  return S_OK;
66  }
67 
68  return E_NOINTERFACE;
69 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
const GUID IID_IClassFactory

◆ IClassFactory_fnRelease()

static ULONG WINAPI IClassFactory_fnRelease ( IClassFactory iface)
static

Definition at line 80 of file factory.c.

81 {
84 
85  TRACE("(%p) ref = %u\n", This, ref);
86 
87  if(!ref)
89 
90  return ref;
91 }
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: factory.c:51
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:483

◆ impl_from_IClassFactory()

static IClassFactoryImpl* impl_from_IClassFactory ( IClassFactory iface)
inlinestatic

Definition at line 51 of file factory.c.

52 {
53  return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
54 }
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 IClassFactory_fnAddRef(), IClassFactory_fnCreateInstance(), and IClassFactory_fnRelease().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( avifile  )

Variable Documentation

◆ AVIFILE_bLocked

BOOL AVIFILE_bLocked
static

Definition at line 41 of file factory.c.

Referenced by DllCanUnloadNow(), and IClassFactory_fnLockServer().

◆ AVIFILE_hModule

◆ AVIFILE_uUseCount

UINT AVIFILE_uUseCount
static

Definition at line 42 of file factory.c.

Referenced by DllCanUnloadNow().

◆ iclassfact

const IClassFactoryVtbl iclassfact
static
Initial value:
= {
}
static ULONG WINAPI IClassFactory_fnAddRef(IClassFactory *iface)
Definition: factory.c:71
static ULONG WINAPI IClassFactory_fnRelease(IClassFactory *iface)
Definition: factory.c:80
static HRESULT WINAPI IClassFactory_fnCreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
Definition: factory.c:93
static HRESULT WINAPI IClassFactory_fnLockServer(IClassFactory *iface, BOOL dolock)
Definition: factory.c:124
static HRESULT WINAPI IClassFactory_fnQueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
Definition: factory.c:56

Definition at line 133 of file factory.c.

Referenced by AVIFILE_CreateClassFactory().