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