ReactOS 0.4.17-dev-934-g091855f
main.c
Go to the documentation of this file.
1/*
2 * Copyright 2017 Fabian Maurer
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#define COBJMACROS
20
21
22#include <stdarg.h>
23#include <string.h>
24
25#include "windef.h"
26#include "winbase.h"
27#include "winuser.h"
28#include "winreg.h"
29
30#include "ole2.h"
31#include "rpcproxy.h"
32
33#include "unknwn.h"
34
35#include "wine/debug.h"
36
38
39typedef struct {
40 IClassFactory IClassFactory_iface;
41
42 LONG ref;
43 HRESULT (*pfnCreateInstance)(IUnknown *unk_outer, void **ppobj);
45
47{
48 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
49}
50
52{
53 const CLSID *clsid;
54 HRESULT (*pfnCreateInstance)(IUnknown *unk_outer, void **ppobj);
55};
56
58{
59 { &GUID_NULL, 0 },
60};
61
63{
65
68 {
69 IClassFactory_AddRef(iface);
70 *ppobj = &This->IClassFactory_iface;
71 return S_OK;
72 }
73
74 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
75 return E_NOINTERFACE;
76}
77
79{
81 return InterlockedIncrement(&This->ref);
82}
83
85{
88
89 if (ref == 0)
91
92 return ref;
93}
94
96{
99 IUnknown *unk;
100
101 TRACE("(%p)->(%p,%s,%p)\n", This, outer_unk, debugstr_guid(riid), ppobj);
102
103 *ppobj = NULL;
104 hres = This->pfnCreateInstance(outer_unk, (void **) &unk);
105 if (SUCCEEDED(hres))
106 {
107 hres = IUnknown_QueryInterface(unk, riid, ppobj);
108 IUnknown_Release(unk);
109 }
110 return hres;
111}
112
114{
116 FIXME("(%p)->(%d), stub!\n", This, dolock);
117 return S_OK;
118}
119
120static const IClassFactoryVtbl classfactory_Vtbl =
121{
127};
128
130{
131 unsigned int i;
133
134 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
135
138 return E_NOINTERFACE;
139
140 for (i = 0; i < ARRAY_SIZE(object_creation); i++)
141 {
142 if (IsEqualGUID(object_creation[i].clsid, rclsid))
143 break;
144 }
145
147 {
148 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
150 }
151
152 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
153 if (factory == NULL)
154 return E_OUTOFMEMORY;
155
157 factory->ref = 1;
158
159 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
160
162 return S_OK;
163}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
static const struct object_creation_info object_creation[]
Definition: main.c:60
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: main.c:153
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: main.c:49
static ULONG WINAPI classfactory_Release(IClassFactory *iface)
Definition: main.c:84
static HRESULT WINAPI classfactory_LockServer(IClassFactory *iface, BOOL dolock)
Definition: main.c:113
static const IClassFactoryVtbl classfactory_Vtbl
Definition: main.c:120
static HRESULT WINAPI classfactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
Definition: main.c:62
static HRESULT WINAPI classfactory_CreateInstance(IClassFactory *iface, IUnknown *outer_unk, REFIID riid, void **ppobj)
Definition: main.c:95
static ULONG WINAPI classfactory_AddRef(IClassFactory *iface)
Definition: main.c:78
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_guid
Definition: kernel32.h:35
#define GUID_NULL
Definition: ks.h:106
HRESULT hres
Definition: protocol.c:432
const CLSID * clsid
Definition: msctf.cpp:50
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
#define TRACE(s)
Definition: solgame.cpp:4
Definition: main.c:439
IClassFactory IClassFactory_iface
Definition: main.c:440
const CLSID * clsid
Definition: main.c:56
HRESULT(* pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: main.c:57
Definition: send.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 E_NOINTERFACE
Definition: winerror.h:3479
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:3772