ReactOS
0.4.15-dev-4874-g57c84dd
classfactory.c
Go to the documentation of this file.
1
/*
2
* COPYRIGHT: See COPYING in the top level directory
3
* PROJECT: ReactOS Configuration of network devices
4
* FILE: dll/directx/dsound_new/classfactory.c
5
* PURPOSE: IClassFactory implementation
6
*
7
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8
*/
9
10
11
#include "
precomp.h
"
12
13
typedef
struct
14
{
15
const
IClassFactoryVtbl *
lpVtbl
;
16
LONG
ref
;
17
CLSID
*
rclsid
;
18
LPFNCREATEINSTANCE
lpfnCI
;
19
const
IID
*
riidInst
;
20
}
IClassFactoryImpl
;
21
22
23
static
24
HRESULT
25
WINAPI
26
IClassFactory_fnQueryInterface
(
27
LPCLASSFACTORY iface,
28
REFIID
riid
,
29
LPVOID
*ppvObj)
30
{
31
IClassFactoryImpl
*
This
= (
IClassFactoryImpl
*)iface;
32
33
*ppvObj =
NULL
;
34
35
/* check requested interface */
36
if
(
IsEqualIID
(
riid
, &
IID_IUnknown
) ||
IsEqualIID
(
riid
, &
IID_IClassFactory
))
37
{
38
*ppvObj =
This
;
39
InterlockedIncrement
(&
This
->ref);
40
return
S_OK
;
41
}
42
return
E_NOINTERFACE
;
43
}
44
45
static
46
ULONG
47
WINAPI
48
IClassFactory_fnAddRef
(
49
LPCLASSFACTORY iface)
50
{
51
IClassFactoryImpl
*
This
= (
IClassFactoryImpl
*)iface;
52
53
/* increment reference count */
54
ULONG
refCount =
InterlockedIncrement
(&
This
->ref);
55
56
return
refCount;
57
}
58
59
static
60
ULONG
61
WINAPI
62
IClassFactory_fnRelease
(
63
LPCLASSFACTORY iface)
64
{
65
IClassFactoryImpl
*
This
= (
IClassFactoryImpl
*)iface;
66
ULONG
refCount =
InterlockedDecrement
(&
This
->ref);
67
68
/* decrement reference count */
69
if
(!refCount)
70
{
71
/* free class factory */
72
CoTaskMemFree
(
This
);
73
return
0;
74
}
75
return
refCount;
76
}
77
78
static
79
HRESULT
80
WINAPI
81
IClassFactory_fnCreateInstance
(
82
LPCLASSFACTORY iface,
83
LPUNKNOWN
pUnkOuter,
84
REFIID
riid
,
85
LPVOID
*
ppvObject
)
86
{
87
IClassFactoryImpl
*
This
= (
IClassFactoryImpl
*)iface;
88
89
if
(!
ppvObject
)
90
return
E_INVALIDARG
;
91
92
*
ppvObject
=
NULL
;
93
94
if
(
This
->riidInst==
NULL
||
IsEqualCLSID
(
riid
,
This
->riidInst) ||
IsEqualCLSID
(
riid
, &
IID_IUnknown
) )
95
{
96
/* instantiate object */
97
return
This
->lpfnCI(pUnkOuter,
riid
,
ppvObject
);
98
}
99
100
return
E_NOINTERFACE
;
101
}
102
103
static
104
HRESULT
105
WINAPI
IClassFactory_fnLockServer
(
106
LPCLASSFACTORY iface,
107
BOOL
fLock)
108
{
109
//IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
110
return
E_NOTIMPL
;
111
}
112
113
114
static
const
IClassFactoryVtbl
dclfvt
=
115
{
116
IClassFactory_fnQueryInterface
,
117
IClassFactory_fnAddRef
,
118
IClassFactory_fnRelease
,
119
IClassFactory_fnCreateInstance
,
120
IClassFactory_fnLockServer
121
};
122
123
124
IClassFactory
*
125
IClassFactory_fnConstructor
(
126
LPFNCREATEINSTANCE
lpfnCI
,
127
PLONG
pcRefDll,
128
REFIID
riidInst)
129
{
130
IClassFactoryImpl
* lpclf;
131
132
lpclf =
CoTaskMemAlloc
(
sizeof
(
IClassFactoryImpl
));
133
lpclf->
ref
= 1;
134
lpclf->
lpVtbl
= &
dclfvt
;
135
lpclf->
lpfnCI
=
lpfnCI
;
136
137
if
(pcRefDll)
138
InterlockedIncrement
(pcRefDll);
139
lpclf->
riidInst
= riidInst;
140
141
return
(LPCLASSFACTORY)lpclf;
142
}
143
144
_IID
Definition:
mstsclib_i.c:50
REFIID
#define REFIID
Definition:
guiddef.h:118
E_NOINTERFACE
#define E_NOINTERFACE
Definition:
winerror.h:2364
CoTaskMemFree
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition:
ifs.c:442
riid
REFIID riid
Definition:
precomp.h:44
IClassFactoryImpl::lpfnCI
LPFNCREATEINSTANCE lpfnCI
Definition:
classfactory.c:18
IClassFactoryImpl::lpVtbl
const IClassFactoryVtbl * lpVtbl
Definition:
classfactory.c:15
precomp.h
lpfnCI
LPFNCREATEINSTANCE lpfnCI
Definition:
shellole.c:61
IClassFactoryImpl::rclsid
CLSID * rclsid
Definition:
classfactory.c:17
IClassFactory_fnRelease
static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface)
Definition:
classfactory.c:62
IClassFactoryImpl::ref
LONG ref
Definition:
classfactory.c:16
LPFNCREATEINSTANCE
HRESULT(CALLBACK * LPFNCREATEINSTANCE)(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition:
precomp.h:22
IClassFactoryImpl
struct tagIClassFactoryImpl IClassFactoryImpl
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
LONG
long LONG
Definition:
pedump.c:60
IClassFactory_fnQueryInterface
static HRESULT WINAPI IClassFactory_fnQueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
Definition:
classfactory.c:26
IClassFactoryImpl::riidInst
const IID * riidInst
Definition:
classfactory.c:19
LPUNKNOWN
static LPUNKNOWN
Definition:
ndr_ole.c:49
E_INVALIDARG
#define E_INVALIDARG
Definition:
ddrawi.h:101
IClassFactoryImpl
Definition:
classfactory.c:13
IClassFactory
Definition:
unknwn.idl:68
HRESULT
LONG HRESULT
Definition:
typedefs.h:79
IID_IUnknown
const GUID IID_IUnknown
Definition:
classfactory.cpp:11
IClassFactory_fnLockServer
static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
Definition:
classfactory.c:105
WINAPI
#define WINAPI
Definition:
msvc.h:6
InterlockedDecrement
#define InterlockedDecrement
Definition:
armddk.h:52
IClassFactory_fnAddRef
static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
Definition:
classfactory.c:48
IClassFactory_fnCreateInstance
static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
Definition:
classfactory.c:81
ppvObject
REFIID LPVOID * ppvObject
Definition:
precomp.h:44
IClassFactory_fnConstructor
IClassFactory * IClassFactory_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
Definition:
classfactory.c:125
S_OK
#define S_OK
Definition:
intsafe.h:52
InterlockedIncrement
#define InterlockedIncrement
Definition:
armddk.h:53
E_NOTIMPL
#define E_NOTIMPL
Definition:
ddrawi.h:99
NULL
#define NULL
Definition:
types.h:112
ULONG
unsigned int ULONG
Definition:
retypes.h:1
void
Definition:
nsiface.idl:2306
IID_IClassFactory
const GUID IID_IClassFactory
Definition:
classfactory.cpp:12
PLONG
signed int * PLONG
Definition:
retypes.h:5
IsEqualCLSID
#define IsEqualCLSID(rclsid1, rclsid2)
Definition:
guiddef.h:96
dclfvt
static const IClassFactoryVtbl dclfvt
Definition:
classfactory.c:114
CoTaskMemAlloc
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition:
ifs.c:426
This
IsEqualIID
#define IsEqualIID(riid1, riid2)
Definition:
guiddef.h:95
dll
directx
dsound_new
classfactory.c
Generated on Mon Jul 4 2022 06:03:58 for ReactOS by
1.8.15