ReactOS 0.4.17-dev-804-g023d8af
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
41typedef struct
42{
43 IClassFactory IClassFactory_iface;
44 LONG ref;
47
49{
50 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
51}
52
54 void **ppobj)
55{
56 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppobj);
57
58 if ((IsEqualGUID(&IID_IUnknown, riid)) ||
60 *ppobj = iface;
61 IClassFactory_AddRef(iface);
62 return S_OK;
63 }
64
65 return E_NOINTERFACE;
66}
67
69{
72
73 TRACE("(%p) ref = %lu\n", This, ref);
74 return ref;
75}
76
78{
81
82 TRACE("(%p) ref = %lu\n", This, ref);
83
84 if(!ref)
85 free(This);
86
87 return ref;
88}
89
91 REFIID riid, void **ppobj)
92{
94
95 TRACE("(%p,%p,%s,%p)\n", iface, pOuter, debugstr_guid(riid),
96 ppobj);
97
98 if (!ppobj)
99 return E_INVALIDARG;
100 *ppobj = NULL;
101
102 if (pOuter && !IsEqualGUID(&IID_IUnknown, riid))
103 return E_INVALIDARG;
104
105 if (IsEqualGUID(&CLSID_AVIFile, &This->clsid))
106 return AVIFILE_CreateAVIFile(pOuter, riid, ppobj);
107 if (IsEqualGUID(&CLSID_WAVFile, &This->clsid))
108 return AVIFILE_CreateWAVFile(pOuter, riid, ppobj);
109
110 if (pOuter)
112
113 if (IsEqualGUID(&CLSID_ICMStream, &This->clsid))
114 return AVIFILE_CreateICMStream(riid,ppobj);
115 if (IsEqualGUID(&CLSID_ACMStream, &This->clsid))
116 return AVIFILE_CreateACMStream(riid,ppobj);
117
118 return E_NOINTERFACE;
119}
120
122{
123 TRACE("(%p,%d)\n",iface,dolock);
124
125 return S_OK;
126}
127
128static const IClassFactoryVtbl iclassfact = {
134};
135
137{
139 HRESULT hr;
140
141 *ppv = NULL;
142
143 cf = malloc(sizeof(*cf));
144 if (!cf)
145 return E_OUTOFMEMORY;
146
148 cf->ref = 1;
149 cf->clsid = *clsid;
150
151 hr = IClassFactory_QueryInterface(&cf->IClassFactory_iface, riid, ppv);
152 IClassFactory_Release(&cf->IClassFactory_iface);
153
154 return hr;
155}
156
158{
159#define SLASH(w) ((w) == '/' || (w) == '\\')
160
161 LPCWSTR szCur;
162
163 for (szCur = szPath + lstrlenW(szPath);
164 szCur > szPath && !SLASH(*szCur) && *szCur != ':';)
165 szCur--;
166
167 if (szCur == szPath)
168 return szCur;
169 else
170 return szCur + 1;
171
172#undef SLASH
173}
174
175/***********************************************************************
176 * DllGetClassObject (AVIFIL32.@)
177 */
179{
180 HRESULT hr;
181
182 TRACE("(%s,%s,%p)\n", debugstr_guid(pclsid), debugstr_guid(piid), ppv);
183
184 if (pclsid == NULL || piid == NULL || ppv == NULL)
185 return E_FAIL;
186
187 hr = AVIFILE_CreateClassFactory(pclsid,piid,ppv);
188 if (SUCCEEDED(hr))
189 return hr;
190
191 return avifil32_DllGetClassObject(pclsid,piid,ppv);
192}
193
194/*****************************************************************************
195 * DllMain [AVIFIL32.init]
196 */
198{
199 TRACE("(%p,%ld,%p)\n", hInstDll, fdwReason, lpvReserved);
200
201 switch (fdwReason) {
204 AVIFILE_hModule = hInstDll;
205 break;
206 };
207
208 return TRUE;
209}
HRESULT AVIFILE_CreateACMStream(REFIID riid, LPVOID *ppv)
Definition: acmstream.c:698
static DWORD const fdwReason
#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:136
static const IClassFactoryVtbl iclassfact
Definition: factory.c:128
LPCWSTR AVIFILE_BasenameW(LPCWSTR szPath)
Definition: factory.c:157
static ULONG WINAPI IClassFactory_fnRelease(IClassFactory *iface)
Definition: factory.c:77
HRESULT WINAPI DllGetClassObject(REFCLSID pclsid, REFIID piid, LPVOID *ppv)
Definition: factory.c:178
static ULONG WINAPI IClassFactory_fnAddRef(IClassFactory *iface)
Definition: factory.c:68
HMODULE AVIFILE_hModule
Definition: factory.c:39
static HRESULT WINAPI IClassFactory_fnQueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
Definition: factory.c:53
static HRESULT WINAPI IClassFactory_fnLockServer(IClassFactory *iface, BOOL dolock)
Definition: factory.c:121
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: factory.c:48
#define SLASH(w)
BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
Definition: factory.c:197
static HRESULT WINAPI IClassFactory_fnCreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
Definition: factory.c:90
HRESULT AVIFILE_CreateAVIFile(IUnknown *pUnkOuter, REFIID riid, void **ppv)
Definition: avifile.c:644
HRESULT AVIFILE_CreateWAVFile(IUnknown *outer_unk, REFIID riid, void **ret_iface)
Definition: wavfile.c:978
HRESULT WINAPI avifil32_DllGetClassObject(REFCLSID pclsid, REFIID piid, LPVOID *ppv)
HRESULT AVIFILE_CreateICMStream(REFIID riid, LPVOID *ppobj)
Definition: icmstream.c:727
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 free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#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
const CLSID * clsid
Definition: msctf.cpp: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
#define TRACE(s)
Definition: solgame.cpp:4
IClassFactory IClassFactory_iface
Definition: inetcomm_main.c:69
Definition: send.c:48
const uint16_t * LPCWSTR
Definition: typedefs.h:57
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:3479
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:3771