xref: /reactos/dll/win32/ole32/oleproxy.c (revision 0f5d91b7)
1 /*
2  *	OLE32 proxy/stub handler
3  *
4  *  Copyright 2002  Marcus Meissner
5  *  Copyright 2001  Ove Kåven, TransGaming Technologies
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21 
22 #include <stdlib.h>
23 #include <stdarg.h>
24 #include <stdio.h>
25 #include <string.h>
26 
27 #define COBJMACROS
28 
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
32 #include "objbase.h"
33 #include "ole2.h"
34 #include "rpc.h"
35 
36 #include "compobj_private.h"
37 #include "moniker.h"
38 #include "comcat.h"
39 
40 #include "wine/debug.h"
41 
42 WINE_DEFAULT_DEBUG_CHANNEL(ole);
43 
ClassFactory_QueryInterface(IClassFactory * iface,REFIID riid,void ** ppv)44 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
45 {
46     TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
47 
48     if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
49     {
50         *ppv = iface;
51         return S_OK;
52     }
53 
54     *ppv = NULL;
55     return E_NOINTERFACE;
56 }
57 
ClassFactory_AddRef(IClassFactory * iface)58 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
59 {
60     return 2;
61 }
62 
ClassFactory_Release(IClassFactory * iface)63 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
64 {
65     return 1;
66 }
67 
ClassFactory_LockServer(IClassFactory * iface,BOOL fLock)68 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
69 {
70     TRACE("(%x)\n", fLock);
71     return S_OK;
72 }
73 
74 static const IClassFactoryVtbl FileMonikerCFVtbl =
75 {
76     ClassFactory_QueryInterface,
77     ClassFactory_AddRef,
78     ClassFactory_Release,
79     FileMoniker_CreateInstance,
80     ClassFactory_LockServer
81 };
82 
83 static IClassFactory FileMonikerCF = { &FileMonikerCFVtbl };
84 
85 static const IClassFactoryVtbl ItemMonikerCFVtbl =
86 {
87     ClassFactory_QueryInterface,
88     ClassFactory_AddRef,
89     ClassFactory_Release,
90     ItemMoniker_CreateInstance,
91     ClassFactory_LockServer
92 };
93 
94 static IClassFactory ItemMonikerCF = { &ItemMonikerCFVtbl };
95 
96 static const IClassFactoryVtbl AntiMonikerCFVtbl =
97 {
98     ClassFactory_QueryInterface,
99     ClassFactory_AddRef,
100     ClassFactory_Release,
101     AntiMoniker_CreateInstance,
102     ClassFactory_LockServer
103 };
104 
105 static IClassFactory AntiMonikerCF = { &AntiMonikerCFVtbl };
106 
107 static const IClassFactoryVtbl CompositeMonikerCFVtbl =
108 {
109     ClassFactory_QueryInterface,
110     ClassFactory_AddRef,
111     ClassFactory_Release,
112     CompositeMoniker_CreateInstance,
113     ClassFactory_LockServer
114 };
115 
116 static IClassFactory CompositeMonikerCF = { &CompositeMonikerCFVtbl };
117 
118 static const IClassFactoryVtbl ClassMonikerCFVtbl =
119 {
120     ClassFactory_QueryInterface,
121     ClassFactory_AddRef,
122     ClassFactory_Release,
123     ClassMoniker_CreateInstance,
124     ClassFactory_LockServer
125 };
126 
127 static IClassFactory ClassMonikerCF = { &ClassMonikerCFVtbl };
128 
129 static const IClassFactoryVtbl PointerMonikerCFVtbl =
130 {
131     ClassFactory_QueryInterface,
132     ClassFactory_AddRef,
133     ClassFactory_Release,
134     PointerMoniker_CreateInstance,
135     ClassFactory_LockServer
136 };
137 
138 static IClassFactory PointerMonikerCF = { &PointerMonikerCFVtbl };
139 
140 static const IClassFactoryVtbl ComCatCFVtbl =
141 {
142     ClassFactory_QueryInterface,
143     ClassFactory_AddRef,
144     ClassFactory_Release,
145     ComCat_CreateInstance,
146     ClassFactory_LockServer
147 };
148 
149 static IClassFactory ComCatCF = { &ComCatCFVtbl };
150 
151 static const IClassFactoryVtbl GlobalOptionsCFVtbl =
152 {
153     ClassFactory_QueryInterface,
154     ClassFactory_AddRef,
155     ClassFactory_Release,
156     GlobalOptions_CreateInstance,
157     ClassFactory_LockServer
158 };
159 
160 IClassFactory GlobalOptionsCF = { &GlobalOptionsCFVtbl };
161 
162 /***********************************************************************
163  *           DllGetClassObject [OLE32.@]
164  */
DllGetClassObject(REFCLSID rclsid,REFIID iid,LPVOID * ppv)165 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
166 {
167     HRESULT hr;
168 
169     *ppv = NULL;
170     if (IsEqualIID(rclsid,&CLSID_DfMarshal)&&(
171 		IsEqualIID(iid,&IID_IClassFactory) ||
172 		IsEqualIID(iid,&IID_IUnknown)
173 	)
174     )
175 	return MARSHAL_GetStandardMarshalCF(ppv);
176     if (IsEqualIID(rclsid,&CLSID_StdGlobalInterfaceTable) && (IsEqualIID(iid,&IID_IClassFactory) || IsEqualIID(iid,&IID_IUnknown)))
177         return StdGlobalInterfaceTable_GetFactory(ppv);
178     if (IsEqualCLSID(rclsid, &CLSID_FileMoniker))
179         return IClassFactory_QueryInterface(&FileMonikerCF, iid, ppv);
180     if (IsEqualCLSID(rclsid, &CLSID_ItemMoniker))
181         return IClassFactory_QueryInterface(&ItemMonikerCF, iid, ppv);
182     if (IsEqualCLSID(rclsid, &CLSID_AntiMoniker))
183         return IClassFactory_QueryInterface(&AntiMonikerCF, iid, ppv);
184     if (IsEqualCLSID(rclsid, &CLSID_CompositeMoniker))
185         return IClassFactory_QueryInterface(&CompositeMonikerCF, iid, ppv);
186     if (IsEqualCLSID(rclsid, &CLSID_ClassMoniker))
187         return IClassFactory_QueryInterface(&ClassMonikerCF, iid, ppv);
188     if (IsEqualCLSID(rclsid, &CLSID_PointerMoniker))
189         return IClassFactory_QueryInterface(&PointerMonikerCF, iid, ppv);
190     if (IsEqualGUID(rclsid, &CLSID_StdComponentCategoriesMgr))
191         return IClassFactory_QueryInterface(&ComCatCF, iid, ppv);
192 
193     hr = OLE32_DllGetClassObject(rclsid, iid, ppv);
194     if (SUCCEEDED(hr))
195         return hr;
196 
197     return Handler_DllGetClassObject(rclsid, iid, ppv);
198 }
199