ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

sti_main.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2002 Aric Stewart for CodeWeavers
00003  * Copyright (C) 2009 Damjan Jovanovic
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00018  */
00019 
00020 #include <stdarg.h>
00021 
00022 #define COBJMACROS
00023 
00024 #include "windef.h"
00025 #include "winbase.h"
00026 #include "winreg.h"
00027 #include "winerror.h"
00028 #include "objbase.h"
00029 #include "initguid.h"
00030 #include "wia_lh.h"
00031 #include "sti.h"
00032 
00033 #include "wine/debug.h"
00034 
00035 WINE_DEFAULT_DEBUG_CHANNEL(sti);
00036 
00037 extern HRESULT WINAPI STI_DllGetClassObject(REFCLSID, REFIID, LPVOID *) DECLSPEC_HIDDEN;
00038 extern BOOL WINAPI STI_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
00039 extern HRESULT WINAPI STI_DllRegisterServer(void) DECLSPEC_HIDDEN;
00040 extern HRESULT WINAPI STI_DllUnregisterServer(void) DECLSPEC_HIDDEN;
00041 
00042 typedef HRESULT (*fnCreateInstance)(REFIID riid, IUnknown *pUnkOuter, LPVOID *ppObj);
00043 
00044 typedef struct
00045 {
00046     IClassFactory IClassFactory_iface;
00047     fnCreateInstance pfnCreateInstance;
00048 } sti_cf;
00049 
00050 static inline sti_cf *impl_from_IClassFactory( IClassFactory *iface )
00051 {
00052     return CONTAINING_RECORD(iface, sti_cf, IClassFactory_iface);
00053 }
00054 
00055 static HRESULT sti_create( REFIID riid, IUnknown *pUnkOuter, LPVOID *ppObj )
00056 {
00057     if (pUnkOuter != NULL && !IsEqualIID(riid, &IID_IUnknown))
00058         return CLASS_E_NOAGGREGATION;
00059 
00060     if (IsEqualGUID(riid, &IID_IUnknown))
00061         return StiCreateInstanceW(GetCurrentProcess(), STI_VERSION_REAL | STI_VERSION_FLAG_UNICODE, (PSTIW*) ppObj, pUnkOuter);
00062     else if (IsEqualGUID(riid, &IID_IStillImageW))
00063         return StiCreateInstanceW(GetCurrentProcess(), STI_VERSION_REAL | STI_VERSION_FLAG_UNICODE, (PSTIW*) ppObj, NULL);
00064     else if (IsEqualGUID(riid, &IID_IStillImageA))
00065         return StiCreateInstanceA(GetCurrentProcess(), STI_VERSION_REAL, (PSTIA*) ppObj, NULL);
00066     else
00067     {
00068         FIXME("no interface %s\n", debugstr_guid(riid));
00069         return E_NOINTERFACE;
00070     }
00071 }
00072 
00073 static HRESULT WINAPI sti_cf_QueryInterface( IClassFactory *iface, REFIID riid, LPVOID *ppobj )
00074 {
00075     if (IsEqualGUID(riid, &IID_IUnknown) ||
00076         IsEqualGUID(riid, &IID_IClassFactory))
00077     {
00078         IClassFactory_AddRef( iface );
00079         *ppobj = iface;
00080         return S_OK;
00081     }
00082     FIXME("interface %s not implemented\n", debugstr_guid(riid));
00083     return E_NOINTERFACE;
00084 }
00085 
00086 static ULONG WINAPI sti_cf_AddRef( IClassFactory *iface )
00087 {
00088     return 2;
00089 }
00090 
00091 static ULONG WINAPI sti_cf_Release( IClassFactory *iface )
00092 {
00093     return 1;
00094 }
00095 
00096 static HRESULT WINAPI sti_cf_CreateInstance( IClassFactory *iface, LPUNKNOWN pOuter,
00097                                              REFIID riid, LPVOID *ppobj )
00098 {
00099     sti_cf *This = impl_from_IClassFactory( iface );
00100     HRESULT r;
00101     IUnknown *punk;
00102 
00103     TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj);
00104 
00105     *ppobj = NULL;
00106 
00107     r = This->pfnCreateInstance( riid, pOuter, (LPVOID *)&punk );
00108     if (FAILED(r))
00109         return r;
00110 
00111     r = IUnknown_QueryInterface( punk, riid, ppobj );
00112     if (FAILED(r))
00113         return r;
00114 
00115     IUnknown_Release( punk );
00116     return r;
00117 }
00118 
00119 static HRESULT WINAPI sti_cf_LockServer( IClassFactory *iface, BOOL dolock )
00120 {
00121     FIXME("(%p)->(%d)\n", iface, dolock);
00122     return S_OK;
00123 }
00124 
00125 static const struct IClassFactoryVtbl sti_cf_vtbl =
00126 {
00127     sti_cf_QueryInterface,
00128     sti_cf_AddRef,
00129     sti_cf_Release,
00130     sti_cf_CreateInstance,
00131     sti_cf_LockServer
00132 };
00133 
00134 static sti_cf the_sti_cf = { { &sti_cf_vtbl }, sti_create };
00135 
00136 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
00137 {
00138     TRACE("(0x%p, %d, %p)\n",hInstDLL,fdwReason,lpvReserved);
00139 
00140     if (fdwReason == DLL_WINE_PREATTACH)
00141         return FALSE;
00142     return STI_DllMain(hInstDLL, fdwReason, lpvReserved);
00143 }
00144 
00145 /******************************************************************************
00146  *           DllGetClassObject   (STI.@)
00147  */
00148 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv )
00149 {
00150     IClassFactory *cf = NULL;
00151 
00152     TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
00153 
00154     if (IsEqualGUID( rclsid, &CLSID_Sti ))
00155     {
00156        cf = &the_sti_cf.IClassFactory_iface;
00157     }
00158 
00159     if (cf)
00160         return IClassFactory_QueryInterface( cf, iid, ppv );
00161     return STI_DllGetClassObject( rclsid, iid, ppv );
00162 }
00163 
00164 /******************************************************************************
00165  *           DllCanUnloadNow   (STI.@)
00166  */
00167 HRESULT WINAPI DllCanUnloadNow( void )
00168 {
00169     return S_FALSE;
00170 }
00171 
00172 /***********************************************************************
00173  *           DllRegisterServer (STI.@)
00174  */
00175 HRESULT WINAPI DllRegisterServer(void)
00176 {
00177     return STI_DllRegisterServer();
00178 }
00179 
00180 /***********************************************************************
00181  *           DllUnRegisterServer (STI.@)
00182  */
00183 HRESULT WINAPI DllUnregisterServer(void)
00184 {
00185     return STI_DllUnregisterServer();
00186 }

Generated on Sun May 27 2012 04:26:34 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.