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 "config.h" 23 24 #include <stdlib.h> 25 #include <stdarg.h> 26 #include <stdio.h> 27 #include <string.h> 28 29 #define COBJMACROS 30 31 #include "windef.h" 32 #include "winbase.h" 33 #include "winuser.h" 34 #include "objbase.h" 35 #include "ole2.h" 36 #include "rpc.h" 37 38 #include "compobj_private.h" 39 #include "moniker.h" 40 #include "comcat.h" 41 42 #include "wine/debug.h" 43 44 WINE_DEFAULT_DEBUG_CHANNEL(ole); 45 46 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv) 47 { 48 TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv); 49 50 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory)) 51 { 52 *ppv = iface; 53 return S_OK; 54 } 55 56 *ppv = NULL; 57 return E_NOINTERFACE; 58 } 59 60 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface) 61 { 62 return 2; 63 } 64 65 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface) 66 { 67 return 1; 68 } 69 70 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock) 71 { 72 TRACE("(%x)\n", fLock); 73 return S_OK; 74 } 75 76 static const IClassFactoryVtbl FileMonikerCFVtbl = 77 { 78 ClassFactory_QueryInterface, 79 ClassFactory_AddRef, 80 ClassFactory_Release, 81 FileMoniker_CreateInstance, 82 ClassFactory_LockServer 83 }; 84 85 static IClassFactory FileMonikerCF = { &FileMonikerCFVtbl }; 86 87 static const IClassFactoryVtbl ItemMonikerCFVtbl = 88 { 89 ClassFactory_QueryInterface, 90 ClassFactory_AddRef, 91 ClassFactory_Release, 92 ItemMoniker_CreateInstance, 93 ClassFactory_LockServer 94 }; 95 96 static IClassFactory ItemMonikerCF = { &ItemMonikerCFVtbl }; 97 98 static const IClassFactoryVtbl AntiMonikerCFVtbl = 99 { 100 ClassFactory_QueryInterface, 101 ClassFactory_AddRef, 102 ClassFactory_Release, 103 AntiMoniker_CreateInstance, 104 ClassFactory_LockServer 105 }; 106 107 static IClassFactory AntiMonikerCF = { &AntiMonikerCFVtbl }; 108 109 static const IClassFactoryVtbl CompositeMonikerCFVtbl = 110 { 111 ClassFactory_QueryInterface, 112 ClassFactory_AddRef, 113 ClassFactory_Release, 114 CompositeMoniker_CreateInstance, 115 ClassFactory_LockServer 116 }; 117 118 static IClassFactory CompositeMonikerCF = { &CompositeMonikerCFVtbl }; 119 120 static const IClassFactoryVtbl ClassMonikerCFVtbl = 121 { 122 ClassFactory_QueryInterface, 123 ClassFactory_AddRef, 124 ClassFactory_Release, 125 ClassMoniker_CreateInstance, 126 ClassFactory_LockServer 127 }; 128 129 static IClassFactory ClassMonikerCF = { &ClassMonikerCFVtbl }; 130 131 static const IClassFactoryVtbl PointerMonikerCFVtbl = 132 { 133 ClassFactory_QueryInterface, 134 ClassFactory_AddRef, 135 ClassFactory_Release, 136 PointerMoniker_CreateInstance, 137 ClassFactory_LockServer 138 }; 139 140 static IClassFactory PointerMonikerCF = { &PointerMonikerCFVtbl }; 141 142 static const IClassFactoryVtbl ComCatCFVtbl = 143 { 144 ClassFactory_QueryInterface, 145 ClassFactory_AddRef, 146 ClassFactory_Release, 147 ComCat_CreateInstance, 148 ClassFactory_LockServer 149 }; 150 151 static IClassFactory ComCatCF = { &ComCatCFVtbl }; 152 153 static const IClassFactoryVtbl GlobalOptionsCFVtbl = 154 { 155 ClassFactory_QueryInterface, 156 ClassFactory_AddRef, 157 ClassFactory_Release, 158 GlobalOptions_CreateInstance, 159 ClassFactory_LockServer 160 }; 161 162 IClassFactory GlobalOptionsCF = { &GlobalOptionsCFVtbl }; 163 164 /*********************************************************************** 165 * DllGetClassObject [OLE32.@] 166 */ 167 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) 168 { 169 HRESULT hr; 170 171 *ppv = NULL; 172 if (IsEqualIID(rclsid,&CLSID_DfMarshal)&&( 173 IsEqualIID(iid,&IID_IClassFactory) || 174 IsEqualIID(iid,&IID_IUnknown) 175 ) 176 ) 177 return MARSHAL_GetStandardMarshalCF(ppv); 178 if (IsEqualIID(rclsid,&CLSID_StdGlobalInterfaceTable) && (IsEqualIID(iid,&IID_IClassFactory) || IsEqualIID(iid,&IID_IUnknown))) 179 return StdGlobalInterfaceTable_GetFactory(ppv); 180 if (IsEqualCLSID(rclsid, &CLSID_FileMoniker)) 181 return IClassFactory_QueryInterface(&FileMonikerCF, iid, ppv); 182 if (IsEqualCLSID(rclsid, &CLSID_ItemMoniker)) 183 return IClassFactory_QueryInterface(&ItemMonikerCF, iid, ppv); 184 if (IsEqualCLSID(rclsid, &CLSID_AntiMoniker)) 185 return IClassFactory_QueryInterface(&AntiMonikerCF, iid, ppv); 186 if (IsEqualCLSID(rclsid, &CLSID_CompositeMoniker)) 187 return IClassFactory_QueryInterface(&CompositeMonikerCF, iid, ppv); 188 if (IsEqualCLSID(rclsid, &CLSID_ClassMoniker)) 189 return IClassFactory_QueryInterface(&ClassMonikerCF, iid, ppv); 190 if (IsEqualCLSID(rclsid, &CLSID_PointerMoniker)) 191 return IClassFactory_QueryInterface(&PointerMonikerCF, iid, ppv); 192 if (IsEqualGUID(rclsid, &CLSID_StdComponentCategoriesMgr)) 193 return IClassFactory_QueryInterface(&ComCatCF, iid, ppv); 194 195 hr = OLE32_DllGetClassObject(rclsid, iid, ppv); 196 if (SUCCEEDED(hr)) 197 return hr; 198 199 return Handler_DllGetClassObject(rclsid, iid, ppv); 200 } 201