ReactOS 0.4.15-dev-5865-g640e228
factory.c
Go to the documentation of this file.
1/*
2 * Copyright 2002 Michael G├╝nnewig
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include <stdarg.h>
20
21#define COBJMACROS
22
23#include "windef.h"
24#include "winbase.h"
25#include "wingdi.h"
26#include "winuser.h"
27#include "winerror.h"
28#include "ole2.h"
29#include "rpcproxy.h"
30
31#include "initguid.h"
32#include "vfw.h"
33#include "avifile_private.h"
34
35#include "wine/debug.h"
36
38
40
43
44typedef struct
45{
46 IClassFactory IClassFactory_iface;
47 LONG ref;
50
52{
53 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
54}
55
57 void **ppobj)
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}
70
72{
75
76 TRACE("(%p) ref = %u\n", This, ref);
77 return ref;
78}
79
81{
84
85 TRACE("(%p) ref = %u\n", This, ref);
86
87 if(!ref)
89
90 return ref;
91}
92
94 REFIID riid, void **ppobj)
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)
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}
123
125{
126 TRACE("(%p,%d)\n",iface,dolock);
127
128 AVIFILE_bLocked = dolock;
129
130 return S_OK;
131}
132
133static const IClassFactoryVtbl iclassfact = {
139};
140
142{
144 HRESULT hr;
145
146 *ppv = NULL;
147
148 cf = HeapAlloc(GetProcessHeap(), 0, sizeof(*cf));
149 if (!cf)
150 return E_OUTOFMEMORY;
151
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}
161
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}
179
180/***********************************************************************
181 * DllGetClassObject (AVIFIL32.@)
182 */
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}
198
199/*****************************************************************************
200 * DllCanUnloadNow (AVIFIL32.@)
201 */
203{
205}
206
207/*****************************************************************************
208 * DllMain [AVIFIL32.init]
209 */
211{
212 TRACE("(%p,%d,%p)\n", hInstDll, fdwReason, lpvReserved);
213
214 switch (fdwReason) {
217 AVIFILE_hModule = hInstDll;
218 break;
219 };
220
221 return TRUE;
222}
223
224/***********************************************************************
225 * DllRegisterServer (AVIFIL32.@)
226 */
228{
230}
231
232/***********************************************************************
233 * DllUnregisterServer (AVIFIL32.@)
234 */
236{
238}
HRESULT AVIFILE_CreateACMStream(REFIID riid, LPVOID *ppv)
Definition: acmstream.c:704
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
static HRESULT AVIFILE_CreateClassFactory(const CLSID *clsid, const IID *riid, void **ppv)
Definition: factory.c:141
static UINT AVIFILE_uUseCount
Definition: factory.c:42
static const IClassFactoryVtbl iclassfact
Definition: factory.c:133
LPCWSTR AVIFILE_BasenameW(LPCWSTR szPath)
Definition: factory.c:162
static BOOL AVIFILE_bLocked
Definition: factory.c:41
HRESULT WINAPI DllRegisterServer(void)
Definition: factory.c:227
static ULONG WINAPI IClassFactory_fnRelease(IClassFactory *iface)
Definition: factory.c:80
HRESULT WINAPI DllGetClassObject(REFCLSID pclsid, REFIID piid, LPVOID *ppv)
Definition: factory.c:183
static ULONG WINAPI IClassFactory_fnAddRef(IClassFactory *iface)
Definition: factory.c:71
HRESULT WINAPI DllUnregisterServer(void)
Definition: factory.c:235
HMODULE AVIFILE_hModule
Definition: factory.c:39
static HRESULT WINAPI IClassFactory_fnQueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
Definition: factory.c:56
HRESULT WINAPI DllCanUnloadNow(void)
Definition: factory.c:202
static HRESULT WINAPI IClassFactory_fnLockServer(IClassFactory *iface, BOOL dolock)
Definition: factory.c:124
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: factory.c:51
#define SLASH(w)
BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
Definition: factory.c:210
static HRESULT WINAPI IClassFactory_fnCreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
Definition: factory.c:93
HRESULT AVIFILE_CreateAVIFile(IUnknown *pUnkOuter, REFIID riid, void **ppv)
Definition: avifile.c:645
HRESULT WINAPI avifil32_DllGetClassObject(REFCLSID pclsid, REFIID piid, LPVOID *ppv) DECLSPEC_HIDDEN
HRESULT AVIFILE_CreateICMStream(REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN
Definition: icmstream.c:727
HRESULT AVIFILE_CreateWAVFile(IUnknown *outer_unk, REFIID riid, void **ret_iface) DECLSPEC_HIDDEN
Definition: wavfile.c:978
static const WCHAR avifile[]
Definition: avisplitter.c:273
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define GetProcessHeap()
Definition: compat.h:736
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_guid
Definition: kernel32.h:35
static IN DWORD IN LPVOID lpvReserved
LPCWSTR szPath
Definition: env.c:37
REFCLSID clsid
Definition: msctf.c:82
unsigned int UINT
Definition: ndis.h:50
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
IClassFactory IClassFactory_iface
Definition: inetcomm_main.c:74
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185