Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenitss.c
Go to the documentation of this file.
00001 /* 00002 * ITSS Class Factory 00003 * 00004 * Copyright 2002 Lionel Ulmer 00005 * Copyright 2004 Mike McCormack 00006 * 00007 * see http://bonedaddy.net/pabs3/hhm/#chmspec 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00022 */ 00023 00024 #include "config.h" 00025 00026 #include <stdarg.h> 00027 #include <stdio.h> 00028 00029 #define COBJMACROS 00030 00031 #include "windef.h" 00032 #include "winbase.h" 00033 #include "winuser.h" 00034 #include "winreg.h" 00035 #include "ole2.h" 00036 #include "rpcproxy.h" 00037 #include "advpub.h" 00038 00039 #include "wine/unicode.h" 00040 #include "wine/debug.h" 00041 00042 #include "itsstor.h" 00043 00044 #include "initguid.h" 00045 #include "wine/itss.h" 00046 00047 WINE_DEFAULT_DEBUG_CHANNEL(itss); 00048 00049 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj); 00050 00051 LONG dll_count = 0; 00052 static HINSTANCE hInst; 00053 00054 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) 00055 { 00056 switch(fdwReason) { 00057 case DLL_PROCESS_ATTACH: 00058 DisableThreadLibraryCalls(hInstDLL); 00059 hInst = hInstDLL; 00060 break; 00061 case DLL_PROCESS_DETACH: 00062 break; 00063 } 00064 return TRUE; 00065 } 00066 00067 /****************************************************************************** 00068 * ITSS ClassFactory 00069 */ 00070 typedef struct { 00071 IClassFactory IClassFactory_iface; 00072 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj); 00073 } IClassFactoryImpl; 00074 00075 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface) 00076 { 00077 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface); 00078 } 00079 00080 static HRESULT WINAPI 00081 ITSSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) 00082 { 00083 IClassFactoryImpl *This = impl_from_IClassFactory(iface); 00084 00085 if (IsEqualGUID(riid, &IID_IUnknown) || 00086 IsEqualGUID(riid, &IID_IClassFactory)) 00087 { 00088 IClassFactory_AddRef(iface); 00089 *ppobj = This; 00090 return S_OK; 00091 } 00092 00093 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj); 00094 return E_NOINTERFACE; 00095 } 00096 00097 static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface) 00098 { 00099 ITSS_LockModule(); 00100 return 2; 00101 } 00102 00103 static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface) 00104 { 00105 ITSS_UnlockModule(); 00106 return 1; 00107 } 00108 00109 00110 static HRESULT WINAPI ITSSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, 00111 REFIID riid, LPVOID *ppobj) 00112 { 00113 IClassFactoryImpl *This = impl_from_IClassFactory(iface); 00114 HRESULT hres; 00115 LPUNKNOWN punk; 00116 00117 TRACE("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj); 00118 00119 *ppobj = NULL; 00120 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk); 00121 if (SUCCEEDED(hres)) { 00122 hres = IUnknown_QueryInterface(punk, riid, ppobj); 00123 IUnknown_Release(punk); 00124 } 00125 return hres; 00126 } 00127 00128 static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock) 00129 { 00130 TRACE("(%p)->(%d)\n", iface, dolock); 00131 00132 if (dolock) 00133 ITSS_LockModule(); 00134 else 00135 ITSS_UnlockModule(); 00136 00137 return S_OK; 00138 } 00139 00140 static const IClassFactoryVtbl ITSSCF_Vtbl = 00141 { 00142 ITSSCF_QueryInterface, 00143 ITSSCF_AddRef, 00144 ITSSCF_Release, 00145 ITSSCF_CreateInstance, 00146 ITSSCF_LockServer 00147 }; 00148 00149 static const IClassFactoryImpl ITStorage_factory = { { &ITSSCF_Vtbl }, ITSS_create }; 00150 static const IClassFactoryImpl MSITStore_factory = { { &ITSSCF_Vtbl }, ITS_IParseDisplayName_create }; 00151 static const IClassFactoryImpl ITSProtocol_factory = { { &ITSSCF_Vtbl }, ITSProtocol_create }; 00152 00153 /*********************************************************************** 00154 * DllGetClassObject (ITSS.@) 00155 */ 00156 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) 00157 { 00158 const IClassFactoryImpl *factory; 00159 00160 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv); 00161 00162 if (IsEqualGUID(&CLSID_ITStorage, rclsid)) 00163 factory = &ITStorage_factory; 00164 else if (IsEqualGUID(&CLSID_MSITStore, rclsid)) 00165 factory = &MSITStore_factory; 00166 else if (IsEqualGUID(&CLSID_ITSProtocol, rclsid)) 00167 factory = &ITSProtocol_factory; 00168 else 00169 { 00170 FIXME("%s: no class found.\n", debugstr_guid(rclsid)); 00171 return CLASS_E_CLASSNOTAVAILABLE; 00172 } 00173 00174 return IUnknown_QueryInterface( (IUnknown*) factory, iid, ppv ); 00175 } 00176 00177 /*****************************************************************************/ 00178 00179 typedef struct { 00180 IITStorage IITStorage_iface; 00181 LONG ref; 00182 } ITStorageImpl; 00183 00184 static inline ITStorageImpl *impl_from_IITStorage(IITStorage *iface) 00185 { 00186 return CONTAINING_RECORD(iface, ITStorageImpl, IITStorage_iface); 00187 } 00188 00189 00190 static HRESULT WINAPI ITStorageImpl_QueryInterface( 00191 IITStorage* iface, 00192 REFIID riid, 00193 void** ppvObject) 00194 { 00195 ITStorageImpl *This = impl_from_IITStorage(iface); 00196 if (IsEqualGUID(riid, &IID_IUnknown) 00197 || IsEqualGUID(riid, &IID_IITStorage)) 00198 { 00199 IClassFactory_AddRef(iface); 00200 *ppvObject = This; 00201 return S_OK; 00202 } 00203 00204 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject); 00205 return E_NOINTERFACE; 00206 } 00207 00208 static ULONG WINAPI ITStorageImpl_AddRef( 00209 IITStorage* iface) 00210 { 00211 ITStorageImpl *This = impl_from_IITStorage(iface); 00212 TRACE("%p\n", This); 00213 return InterlockedIncrement(&This->ref); 00214 } 00215 00216 static ULONG WINAPI ITStorageImpl_Release( 00217 IITStorage* iface) 00218 { 00219 ITStorageImpl *This = impl_from_IITStorage(iface); 00220 ULONG ref = InterlockedDecrement(&This->ref); 00221 00222 if (ref == 0) { 00223 HeapFree(GetProcessHeap(), 0, This); 00224 ITSS_UnlockModule(); 00225 } 00226 00227 return ref; 00228 } 00229 00230 static HRESULT WINAPI ITStorageImpl_StgCreateDocfile( 00231 IITStorage* iface, 00232 const WCHAR* pwcsName, 00233 DWORD grfMode, 00234 DWORD reserved, 00235 IStorage** ppstgOpen) 00236 { 00237 ITStorageImpl *This = impl_from_IITStorage(iface); 00238 00239 TRACE("%p %s %u %u %p\n", This, 00240 debugstr_w(pwcsName), grfMode, reserved, ppstgOpen ); 00241 00242 return ITSS_StgOpenStorage( pwcsName, NULL, grfMode, 00243 0, reserved, ppstgOpen); 00244 } 00245 00246 static HRESULT WINAPI ITStorageImpl_StgCreateDocfileOnILockBytes( 00247 IITStorage* iface, 00248 ILockBytes* plkbyt, 00249 DWORD grfMode, 00250 DWORD reserved, 00251 IStorage** ppstgOpen) 00252 { 00253 ITStorageImpl *This = impl_from_IITStorage(iface); 00254 FIXME("%p\n", This); 00255 return E_NOTIMPL; 00256 } 00257 00258 static HRESULT WINAPI ITStorageImpl_StgIsStorageFile( 00259 IITStorage* iface, 00260 const WCHAR* pwcsName) 00261 { 00262 ITStorageImpl *This = impl_from_IITStorage(iface); 00263 FIXME("%p\n", This); 00264 return E_NOTIMPL; 00265 } 00266 00267 static HRESULT WINAPI ITStorageImpl_StgIsStorageILockBytes( 00268 IITStorage* iface, 00269 ILockBytes* plkbyt) 00270 { 00271 ITStorageImpl *This = impl_from_IITStorage(iface); 00272 FIXME("%p\n", This); 00273 return E_NOTIMPL; 00274 } 00275 00276 static HRESULT WINAPI ITStorageImpl_StgOpenStorage( 00277 IITStorage* iface, 00278 const WCHAR* pwcsName, 00279 IStorage* pstgPriority, 00280 DWORD grfMode, 00281 SNB snbExclude, 00282 DWORD reserved, 00283 IStorage** ppstgOpen) 00284 { 00285 ITStorageImpl *This = impl_from_IITStorage(iface); 00286 00287 TRACE("%p %s %p %d %p\n", This, debugstr_w( pwcsName ), 00288 pstgPriority, grfMode, snbExclude ); 00289 00290 return ITSS_StgOpenStorage( pwcsName, pstgPriority, grfMode, 00291 snbExclude, reserved, ppstgOpen); 00292 } 00293 00294 static HRESULT WINAPI ITStorageImpl_StgOpenStorageOnILockBytes( 00295 IITStorage* iface, 00296 ILockBytes* plkbyt, 00297 IStorage* pStgPriority, 00298 DWORD grfMode, 00299 SNB snbExclude, 00300 DWORD reserved, 00301 IStorage** ppstgOpen) 00302 { 00303 ITStorageImpl *This = impl_from_IITStorage(iface); 00304 FIXME("%p\n", This); 00305 return E_NOTIMPL; 00306 } 00307 00308 static HRESULT WINAPI ITStorageImpl_StgSetTimes( 00309 IITStorage* iface, 00310 const WCHAR* lpszName, 00311 const FILETIME* pctime, 00312 const FILETIME* patime, 00313 const FILETIME* pmtime) 00314 { 00315 ITStorageImpl *This = impl_from_IITStorage(iface); 00316 FIXME("%p\n", This); 00317 return E_NOTIMPL; 00318 } 00319 00320 static HRESULT WINAPI ITStorageImpl_SetControlData( 00321 IITStorage* iface, 00322 PITS_Control_Data pControlData) 00323 { 00324 ITStorageImpl *This = impl_from_IITStorage(iface); 00325 FIXME("%p\n", This); 00326 return E_NOTIMPL; 00327 } 00328 00329 static HRESULT WINAPI ITStorageImpl_DefaultControlData( 00330 IITStorage* iface, 00331 PITS_Control_Data* ppControlData) 00332 { 00333 ITStorageImpl *This = impl_from_IITStorage(iface); 00334 FIXME("%p\n", This); 00335 return E_NOTIMPL; 00336 } 00337 00338 static HRESULT WINAPI ITStorageImpl_Compact( 00339 IITStorage* iface, 00340 const WCHAR* pwcsName, 00341 ECompactionLev iLev) 00342 { 00343 ITStorageImpl *This = impl_from_IITStorage(iface); 00344 FIXME("%p\n", This); 00345 return E_NOTIMPL; 00346 } 00347 00348 static const IITStorageVtbl ITStorageImpl_Vtbl = 00349 { 00350 ITStorageImpl_QueryInterface, 00351 ITStorageImpl_AddRef, 00352 ITStorageImpl_Release, 00353 ITStorageImpl_StgCreateDocfile, 00354 ITStorageImpl_StgCreateDocfileOnILockBytes, 00355 ITStorageImpl_StgIsStorageFile, 00356 ITStorageImpl_StgIsStorageILockBytes, 00357 ITStorageImpl_StgOpenStorage, 00358 ITStorageImpl_StgOpenStorageOnILockBytes, 00359 ITStorageImpl_StgSetTimes, 00360 ITStorageImpl_SetControlData, 00361 ITStorageImpl_DefaultControlData, 00362 ITStorageImpl_Compact, 00363 }; 00364 00365 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj) 00366 { 00367 ITStorageImpl *its; 00368 00369 if( pUnkOuter ) 00370 return CLASS_E_NOAGGREGATION; 00371 00372 its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl) ); 00373 its->IITStorage_iface.lpVtbl = &ITStorageImpl_Vtbl; 00374 its->ref = 1; 00375 00376 TRACE("-> %p\n", its); 00377 *ppObj = its; 00378 00379 ITSS_LockModule(); 00380 return S_OK; 00381 } 00382 00383 /*****************************************************************************/ 00384 00385 HRESULT WINAPI DllCanUnloadNow(void) 00386 { 00387 TRACE("dll_count = %u\n", dll_count); 00388 return dll_count ? S_FALSE : S_OK; 00389 } 00390 00391 /*********************************************************************** 00392 * DllRegisterServer (ITSS.@) 00393 */ 00394 HRESULT WINAPI DllRegisterServer(void) 00395 { 00396 return __wine_register_resources( hInst ); 00397 } 00398 00399 /*********************************************************************** 00400 * DllUnregisterServer (ITSS.@) 00401 */ 00402 HRESULT WINAPI DllUnregisterServer(void) 00403 { 00404 return __wine_unregister_resources( hInst ); 00405 } Generated on Sat May 26 2012 04:22:43 for ReactOS by
1.7.6.1
|