ReactOS 0.4.15-dev-7958-gcd0bb1a
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
38extern BOOL WINAPI STI_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
39extern HRESULT WINAPI STI_DllRegisterServer(void) DECLSPEC_HIDDEN;
40extern HRESULT WINAPI STI_DllUnregisterServer(void) DECLSPEC_HIDDEN;
41
42typedef HRESULT (*fnCreateInstance)(REFIID riid, IUnknown *pUnkOuter, LPVOID *ppObj);
43
44typedef struct
45{
46 IClassFactory IClassFactory_iface;
47 fnCreateInstance pfnCreateInstance;
49
51{
52 return CONTAINING_RECORD(iface, sti_cf, IClassFactory_iface);
53}
54
55static HRESULT sti_create( REFIID riid, IUnknown *pUnkOuter, LPVOID *ppObj )
56{
57 if (pUnkOuter != NULL && !IsEqualIID(riid, &IID_IUnknown))
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{
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
125static 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{
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 WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define FIXME(fmt,...)
Definition: debug.h:111
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
#define GetCurrentProcess()
Definition: compat.h:759
HRESULT WINAPI StiCreateInstanceA(HINSTANCE hinst, DWORD dwVer, PSTIA *ppSti, LPUNKNOWN pUnkOuter)
Definition: sti.c:320
HRESULT WINAPI StiCreateInstanceW(HINSTANCE hinst, DWORD dwVer, PSTIW *ppSti, LPUNKNOWN pUnkOuter)
Definition: sti.c:329
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
HRESULT(* fnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: hnetcfg.c:37
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
static IN DWORD IN LPVOID lpvReserved
static LPUNKNOWN
Definition: ndr_ole.c:49
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define STI_VERSION_FLAG_UNICODE
Definition: sti.h:39
struct IStillImageW * PSTIW
Definition: sti.h:50
struct IStillImageA * PSTIA
Definition: sti.h:49
#define STI_VERSION_REAL
Definition: sti.h:38
HRESULT WINAPI DllRegisterServer(void)
Definition: sti_main.c:175
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: sti_main.c:136
static HRESULT sti_create(REFIID riid, IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: sti_main.c:55
static sti_cf * impl_from_IClassFactory(IClassFactory *iface)
Definition: sti_main.c:50
static ULONG WINAPI sti_cf_AddRef(IClassFactory *iface)
Definition: sti_main.c:86
HRESULT WINAPI DllUnregisterServer(void)
Definition: sti_main.c:183
static HRESULT WINAPI sti_cf_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppobj)
Definition: sti_main.c:73
static HRESULT WINAPI sti_cf_LockServer(IClassFactory *iface, BOOL dolock)
Definition: sti_main.c:119
static HRESULT WINAPI sti_cf_CreateInstance(IClassFactory *iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
Definition: sti_main.c:96
static const struct IClassFactoryVtbl sti_cf_vtbl
Definition: sti_main.c:125
static ULONG WINAPI sti_cf_Release(IClassFactory *iface)
Definition: sti_main.c:91
HRESULT WINAPI STI_DllGetClassObject(REFCLSID, REFIID, LPVOID *)
Definition: sti_main.c:37
HRESULT WINAPI DllCanUnloadNow(void)
Definition: sti_main.c:167
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
Definition: sti_main.c:148
static sti_cf the_sti_cf
Definition: sti_main.c:134
sti_cf
Definition: sti_main.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662