ReactOS  0.4.15-dev-1397-g19779b3
sti_main.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002 Aric Stewart for CodeWeavers
3  * Copyright (C) 2009 Damjan Jovanovic
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19 
20 #include <stdarg.h>
21 
22 #define COBJMACROS
23 
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winreg.h"
27 #include "winerror.h"
28 #include "objbase.h"
29 #include "initguid.h"
30 #include "wia_lh.h"
31 #include "sti.h"
32 
33 #include "wine/debug.h"
34 
36 
38 extern BOOL WINAPI STI_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
39 extern HRESULT WINAPI STI_DllRegisterServer(void) DECLSPEC_HIDDEN;
40 extern HRESULT WINAPI STI_DllUnregisterServer(void) DECLSPEC_HIDDEN;
41 
42 typedef HRESULT (*fnCreateInstance)(REFIID riid, IUnknown *pUnkOuter, LPVOID *ppObj);
43 
44 typedef struct
45 {
46  IClassFactory IClassFactory_iface;
47  fnCreateInstance pfnCreateInstance;
49 
51 {
52  return CONTAINING_RECORD(iface, sti_cf, IClassFactory_iface);
53 }
54 
55 static HRESULT sti_create( REFIID riid, IUnknown *pUnkOuter, LPVOID *ppObj )
56 {
57  if (pUnkOuter != NULL && !IsEqualIID(riid, &IID_IUnknown))
58  return CLASS_E_NOAGGREGATION;
59 
62  else if (IsEqualGUID(riid, &IID_IStillImageW))
64  else if (IsEqualGUID(riid, &IID_IStillImageA))
66  else
67  {
68  FIXME("no interface %s\n", debugstr_guid(riid));
69  return E_NOINTERFACE;
70  }
71 }
72 
74 {
75  if (IsEqualGUID(riid, &IID_IUnknown) ||
77  {
78  IClassFactory_AddRef( iface );
79  *ppobj = iface;
80  return S_OK;
81  }
82  FIXME("interface %s not implemented\n", debugstr_guid(riid));
83  return E_NOINTERFACE;
84 }
85 
87 {
88  return 2;
89 }
90 
92 {
93  return 1;
94 }
95 
97  REFIID riid, LPVOID *ppobj )
98 {
100  HRESULT r;
101  IUnknown *punk;
102 
103  TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj);
104 
105  *ppobj = NULL;
106 
107  r = This->pfnCreateInstance( riid, pOuter, (LPVOID *)&punk );
108  if (FAILED(r))
109  return r;
110 
111  r = IUnknown_QueryInterface( punk, riid, ppobj );
112  if (FAILED(r))
113  return r;
114 
115  IUnknown_Release( punk );
116  return r;
117 }
118 
120 {
121  FIXME("(%p)->(%d)\n", iface, dolock);
122  return S_OK;
123 }
124 
125 static const struct IClassFactoryVtbl sti_cf_vtbl =
126 {
132 };
133 
135 
137 {
138  TRACE("(0x%p, %d, %p)\n",hInstDLL,fdwReason,lpvReserved);
139 
140  if (fdwReason == DLL_WINE_PREATTACH)
141  return FALSE;
142  return STI_DllMain(hInstDLL, fdwReason, lpvReserved);
143 }
144 
145 /******************************************************************************
146  * DllGetClassObject (STI.@)
147  */
149 {
150  IClassFactory *cf = NULL;
151 
152  TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
153 
154  if (IsEqualGUID( rclsid, &CLSID_Sti ))
155  {
156  cf = &the_sti_cf.IClassFactory_iface;
157  }
158 
159  if (cf)
160  return IClassFactory_QueryInterface( cf, iid, ppv );
161  return STI_DllGetClassObject( rclsid, iid, ppv );
162 }
163 
164 /******************************************************************************
165  * DllCanUnloadNow (STI.@)
166  */
168 {
169  return S_FALSE;
170 }
171 
172 /***********************************************************************
173  * DllRegisterServer (STI.@)
174  */
176 {
177  return STI_DllRegisterServer();
178 }
179 
180 /***********************************************************************
181  * DllUnRegisterServer (STI.@)
182  */
184 {
185  return STI_DllUnregisterServer();
186 }
#define STI_VERSION_REAL
Definition: sti.h:38
#define HRESULT
Definition: msvc.h:7
struct IStillImageW * PSTIW
Definition: sti.h:50
#define REFIID
Definition: guiddef.h:118
static ULONG WINAPI sti_cf_AddRef(IClassFactory *iface)
Definition: sti_main.c:86
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define REFCLSID
Definition: guiddef.h:117
WINE_DEFAULT_DEBUG_CHANNEL(sti)
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: sti_main.c:136
HRESULT WINAPI StiCreateInstanceA(HINSTANCE hinst, DWORD dwVer, PSTIA *ppSti, LPUNKNOWN pUnkOuter)
Definition: sti.c:320
static ULONG WINAPI sti_cf_Release(IClassFactory *iface)
Definition: sti_main.c:91
static sti_cf the_sti_cf
Definition: sti_main.c:134
static IN DWORD IN LPVOID lpvReserved
static HRESULT sti_create(REFIID riid, IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: sti_main.c:55
#define sti()
Definition: utils.h:288
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static LPUNKNOWN
Definition: ndr_ole.c:49
#define FIXME(fmt,...)
Definition: debug.h:111
#define S_FALSE
Definition: winerror.h:2357
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define STI_VERSION_FLAG_UNICODE
Definition: sti.h:39
struct IStillImageA * PSTIA
Definition: sti.h:49
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
const GUID IID_IUnknown
static sti_cf * impl_from_IClassFactory(IClassFactory *iface)
Definition: sti_main.c:50
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT WINAPI DllUnregisterServer(void)
Definition: sti_main.c:183
static const struct IClassFactoryVtbl sti_cf_vtbl
Definition: sti_main.c:125
#define GetCurrentProcess()
Definition: compat.h:618
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
static HRESULT WINAPI sti_cf_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppobj)
Definition: sti_main.c:73
HRESULT(* fnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: hnetcfg.c:37
#define S_OK
Definition: intsafe.h:51
static HRESULT WINAPI sti_cf_CreateInstance(IClassFactory *iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
Definition: sti_main.c:96
HRESULT WINAPI STI_DllGetClassObject(REFCLSID, REFIID, LPVOID *)
Definition: sti_main.c:37
#define NULL
Definition: types.h:112
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
static HRESULT WINAPI sti_cf_LockServer(IClassFactory *iface, BOOL dolock)
Definition: sti_main.c:119
HRESULT WINAPI DllCanUnloadNow(void)
Definition: sti_main.c:167
HRESULT WINAPI StiCreateInstanceW(HINSTANCE hinst, DWORD dwVer, PSTIW *ppSti, LPUNKNOWN pUnkOuter)
Definition: sti.c:329
unsigned int ULONG
Definition: retypes.h:1
sti_cf
Definition: sti_main.c:48
const GUID IID_IClassFactory
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
HRESULT WINAPI DllRegisterServer(void)
Definition: sti_main.c:175
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
Definition: sti_main.c:148