ReactOS 0.4.15-dev-5664-g3bf4ef6
classfactory.c
Go to the documentation of this file.
1#include "precomp.h"
2
3typedef struct
4{
5 const IClassFactoryVtbl *lpVtbl;
6 LONG ref;
7 CLSID *rclsid;
9 const IID * riidInst;
11
12
13static
17 LPCLASSFACTORY iface,
19 LPVOID *ppvObj)
20{
22
23 *ppvObj = NULL;
25 {
26 *ppvObj = This;
28 return S_OK;
29 }
30 return E_NOINTERFACE;
31}
32
33static
37 LPCLASSFACTORY iface)
38{
40 ULONG refCount = InterlockedIncrement(&This->ref);
41
42 return refCount;
43}
44
45static
49 LPCLASSFACTORY iface)
50{
52 ULONG refCount = InterlockedDecrement(&This->ref);
53
54 if (!refCount)
55 {
57 return 0;
58 }
59 return refCount;
60}
61
62static
66 LPCLASSFACTORY iface,
67 LPUNKNOWN pUnkOuter,
70{
72
73 *ppvObject = NULL;
74
75 if ( This->riidInst==NULL || IsEqualCLSID(riid, This->riidInst) || IsEqualCLSID(riid, &IID_IUnknown) )
76 {
77 return This->lpfnCI(pUnkOuter, riid, ppvObject);
78 }
79
80 return E_NOINTERFACE;
81}
82
83static
86 LPCLASSFACTORY iface,
87 BOOL fLock)
88{
89 //IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
90 return E_NOTIMPL;
91}
92
93
94static const IClassFactoryVtbl dclfvt =
95{
101};
102
103
107 PLONG pcRefDll,
108 REFIID riidInst)
109{
110 IClassFactoryImpl* lpclf;
111
112 lpclf = CoTaskMemAlloc(sizeof(IClassFactoryImpl));
113 lpclf->ref = 1;
114 lpclf->lpVtbl = &dclfvt;
115 lpclf->lpfnCI = lpfnCI;
116
117 if (pcRefDll)
118 InterlockedIncrement(pcRefDll);
119 lpclf->riidInst = riidInst;
120
121 return (LPCLASSFACTORY)lpclf;
122}
123
124
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define E_NOTIMPL
Definition: ddrawi.h:99
static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface)
Definition: classfactory.c:62
static HRESULT WINAPI IClassFactory_fnQueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
Definition: classfactory.c:26
static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
Definition: classfactory.c:105
static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
Definition: classfactory.c:48
IClassFactory * IClassFactory_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
Definition: classfactory.c:125
static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition: classfactory.c:81
static const IClassFactoryVtbl dclfvt
Definition: classfactory.c:114
#define NULL
Definition: types.h:112
HRESULT(CALLBACK * LPFNCREATEINSTANCE)(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition: precomp.h:22
LPFNCREATEINSTANCE lpfnCI
Definition: shellole.c:61
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
signed int * PLONG
Definition: retypes.h:5
unsigned int ULONG
Definition: retypes.h:1
static LPUNKNOWN
Definition: ndr_ole.c:49
long LONG
Definition: pedump.c:60
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
LPFNCREATEINSTANCE lpfnCI
Definition: classfactory.c:18
const IID * riidInst
Definition: classfactory.c:19
const IClassFactoryVtbl * lpVtbl
Definition: classfactory.c:15
Definition: send.c:48
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364