Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 1 | /* |
Ove Kaaven | 2a8bd72 | 2002-12-23 01:41:51 +0000 | [diff] [blame] | 2 | * Copyright (C) 1998-1999 François Gouget |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | |
Alexandre Julliard | dc818a5 | 2002-12-05 22:11:43 +0000 | [diff] [blame] | 19 | #include "rpc.h" |
| 20 | #include "rpcndr.h" |
François Gouget | d604eb1 | 1998-12-18 16:00:03 +0000 | [diff] [blame] | 21 | |
Alexandre Julliard | dc818a5 | 2002-12-05 22:11:43 +0000 | [diff] [blame] | 22 | #ifndef _OBJBASE_H_ |
Paul Quinn | aaa8306 | 1999-06-05 15:23:20 +0000 | [diff] [blame] | 23 | #define _OBJBASE_H_ |
François Gouget | d604eb1 | 1998-12-18 16:00:03 +0000 | [diff] [blame] | 24 | |
Ove Kaaven | 2a8bd72 | 2002-12-23 01:41:51 +0000 | [diff] [blame] | 25 | /***************************************************************************** |
| 26 | * define ICOM_MSVTABLE_COMPAT |
| 27 | * to implement the microsoft com vtable compatibility workaround for g++. |
| 28 | * |
| 29 | * NOTE: Turning this option on will produce a winelib that is incompatible |
| 30 | * with the binary emulator. |
| 31 | * |
| 32 | * If the compiler supports the com_interface attribute, leave this off, and |
| 33 | * define the ICOM_USE_COM_INTERFACE_ATTRIBUTE macro below. This may also |
| 34 | * require the addition of the -vtable-thunks option for g++. |
| 35 | * |
| 36 | * If you aren't interested in Winelib C++ compatibility at all, leave both |
| 37 | * options off. |
| 38 | * |
| 39 | * The preferable method for using ICOM_USE_COM_INTERFACE_ATTRIBUTE macro |
| 40 | * would be to define it only for your Winelib application. This allows you |
| 41 | * to have both binary and Winelib compatibility for C and C++ at the same |
| 42 | * time :) |
| 43 | */ |
| 44 | /* #define ICOM_MSVTABLE_COMPAT 1 */ |
| 45 | /* #define ICOM_USE_COM_INTERFACE_ATTRIBUTE 1 */ |
| 46 | |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 47 | |
| 48 | /***************************************************************************** |
| 49 | * Macros to define a COM interface |
| 50 | */ |
| 51 | /* |
| 52 | * The goal of the following set of definitions is to provide a way to use the same |
| 53 | * header file definitions to provide both a C interface and a C++ object oriented |
| 54 | * interface to COM interfaces. The type of interface is selected automatically |
| 55 | * depending on the language but it is always possible to get the C interface in C++ |
| 56 | * by defining CINTERFACE. |
| 57 | * |
| 58 | * It is based on the following assumptions: |
| 59 | * - all COM interfaces derive from IUnknown, this should not be a problem. |
| 60 | * - the header file only defines the interface, the actual fields are defined |
| 61 | * separately in the C file implementing the interface. |
| 62 | * |
| 63 | * The natural approach to this problem would be to make sure we get a C++ class and |
| 64 | * virtual methods in C++ and a structure with a table of pointer to functions in C. |
| 65 | * Unfortunately the layout of the virtual table is compiler specific, the layout of |
| 66 | * g++ virtual tables is not the same as that of an egcs virtual table which is not the |
| 67 | * same as that generated by Visual C+. There are workarounds to make the virtual tables |
| 68 | * compatible via padding but unfortunately the one which is imposed to the WINE emulator |
| 69 | * by the Windows binaries, i.e. the Visual C++ one, is the most compact of all. |
| 70 | * |
| 71 | * So the solution I finally adopted does not use virtual tables. Instead I use inline |
| 72 | * non virtual methods that dereference the method pointer themselves and perform the call. |
| 73 | * |
| 74 | * Let's take Direct3D as an example: |
| 75 | * |
| 76 | * #define INTERFACE IDirect3D |
| 77 | * #define IDirect3D_METHODS \ |
Alexandre Julliard | aae3cb6 | 2003-04-11 00:31:02 +0000 | [diff] [blame] | 78 | * IUnknown_METHODS \ |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 79 | * STDMETHOD(Initialize)(THIS_ REFIID) PURE; \ |
| 80 | * STDMETHOD(EnumDevices)(THIS_ LPD3DENUMDEVICESCALLBACK, LPVOID) PURE; \ |
| 81 | * STDMETHOD(CreateLight)(THIS_ LPDIRECT3DLIGHT*, IUnknown*) PURE; \ |
| 82 | * STDMETHOD(CreateMaterial)(THIS_ LPDIRECT3DMATERIAL*, IUnknown*) PURE; \ |
| 83 | * STDMETHOD(CreateViewport)(THIS_ LPDIRECT3DVIEWPORT*, IUnknown*) PURE; \ |
| 84 | * STDMETHOD(FindDevice)(THIS_ LPD3DFINDDEVICESEARCH, LPD3DFINDDEVICERESULT) PURE; |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 85 | * ICOM_DEFINE(IDirect3D,IUnknown) |
| 86 | * #undef INTERFACE |
| 87 | * |
| 88 | * #ifdef COBJMACROS |
| 89 | * // *** IUnknown methods *** // |
| 90 | * #define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) |
| 91 | * #define IDirect3D_AddRef(p) (p)->lpVtbl->AddRef(p) |
| 92 | * #define IDirect3D_Release(p) (p)->lpVtbl->Release(p) |
| 93 | * // *** IDirect3D methods *** // |
| 94 | * #define IDirect3D_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) |
| 95 | * #define IDirect3D_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevice(p,a,b) |
| 96 | * #define IDirect3D_CreateLight(p,a,b) (p)->lpVtbl->CreateLight(p,a,b) |
| 97 | * #define IDirect3D_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial(p,a,b) |
| 98 | * #define IDirect3D_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport(p,a,b) |
| 99 | * #define IDirect3D_FindDevice(p,a,b) (p)->lpVtbl->FindDevice(p,a,b) |
| 100 | * #endif |
| 101 | * |
| 102 | * Comments: |
| 103 | * - The INTERFACE macro is used in the STDMETHOD macros to define the type of the 'this' |
| 104 | * pointer. Defining this macro here saves us the trouble of having to repeat the interface |
| 105 | * name everywhere. Note however that because of the way macros work, a macro like STDMETHOD |
| 106 | * cannot use 'INTERFACE##_VTABLE' because this would give 'INTERFACE_VTABLE' and not |
| 107 | * 'IDirect3D_VTABLE'. |
Alexandre Julliard | aae3cb6 | 2003-04-11 00:31:02 +0000 | [diff] [blame] | 108 | * - ICOM_METHODS defines the list of methods that are inheritable from this interface. It must |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 109 | * be written manually (rather than using a macro to generate the equivalent code) to avoid |
Alexandre Julliard | aae3cb6 | 2003-04-11 00:31:02 +0000 | [diff] [blame] | 110 | * macro recursion (which compilers don't like). It must start with the METHODS definition |
| 111 | * of the parent interface so that method inheritance works properly. |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 112 | * - The ICOM_DEFINE finally declares all the structures necessary for the interface. We have to |
| 113 | * explicitly use the interface name for macro expansion reasons again. |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 114 | * - The 'undef INTERFACE' is here to remind you that using INTERFACE in the following macros |
| 115 | * will not work. |
| 116 | * - Finally the set of 'IDirect3D_Xxx' macros is a standard set of macros defined to ease access |
| 117 | * to the interface methods in C. Unfortunately I don't see any way to avoid having to duplicate |
| 118 | * the inherited method definitions there. This time I could have used a trick to use only one |
| 119 | * macro whatever the number of parameters but I prefered to have it work the same way as above. |
| 120 | * - You probably have noticed that we don't define the fields we need to actually implement this |
| 121 | * interface: reference count, pointer to other resources and miscellaneous fields. That's |
| 122 | * because these interfaces are just that: interfaces. They may be implemented more than once, in |
| 123 | * different contexts and sometimes not even in Wine. Thus it would not make sense to impose |
| 124 | * that the interface contains some specific fields. |
| 125 | * |
| 126 | * |
| 127 | * In C this gives: |
| 128 | * typedef struct IDirect3DVtbl IDirect3DVtbl; |
| 129 | * struct IDirect3D { |
| 130 | * IDirect3DVtbl* lpVtbl; |
| 131 | * }; |
| 132 | * struct IDirect3DVtbl { |
| 133 | * HRESULT (*QueryInterface)(IDirect3D* me, REFIID riid, LPVOID* ppvObj); |
| 134 | * ULONG (*QueryInterface)(IDirect3D* me); |
| 135 | * ULONG (*QueryInterface)(IDirect3D* me); |
| 136 | * HRESULT (*Initialize)(IDirect3D* me, REFIID a); |
| 137 | * HRESULT (*EnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b); |
| 138 | * HRESULT (*CreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b); |
| 139 | * HRESULT (*CreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b); |
| 140 | * HRESULT (*CreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b); |
| 141 | * HRESULT (*FindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b); |
| 142 | * }; |
| 143 | * |
| 144 | * #ifdef COBJMACROS |
| 145 | * // *** IUnknown methods *** // |
| 146 | * #define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) |
| 147 | * #define IDirect3D_AddRef(p) (p)->lpVtbl->AddRef(p) |
| 148 | * #define IDirect3D_Release(p) (p)->lpVtbl->Release(p) |
| 149 | * // *** IDirect3D methods *** // |
| 150 | * #define IDirect3D_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) |
| 151 | * #define IDirect3D_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevice(p,a,b) |
| 152 | * #define IDirect3D_CreateLight(p,a,b) (p)->lpVtbl->CreateLight(p,a,b) |
| 153 | * #define IDirect3D_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial(p,a,b) |
| 154 | * #define IDirect3D_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport(p,a,b) |
| 155 | * #define IDirect3D_FindDevice(p,a,b) (p)->lpVtbl->FindDevice(p,a,b) |
| 156 | * #endif |
| 157 | * |
| 158 | * Comments: |
| 159 | * - IDirect3D only contains a pointer to the IDirect3D virtual/jump table. This is the only thing |
| 160 | * the user needs to know to use the interface. Of course the structure we will define to |
| 161 | * implement this interface will have more fields but the first one will match this pointer. |
| 162 | * - The code generated by ICOM_DEFINE defines both the structure representing the interface and |
Alexandre Julliard | aae3cb6 | 2003-04-11 00:31:02 +0000 | [diff] [blame] | 163 | * the structure for the jump table. ICOM_DEFINE uses the parent's Xxx_METHODS macro to |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 164 | * automatically repeat the prototypes of all the inherited methods and then uses IDirect3D_METHODS |
| 165 | * to define the IDirect3D methods. |
| 166 | * - Each method is declared as a pointer to function field in the jump table. The implementation |
| 167 | * will fill this jump table with appropriate values, probably using a static variable, and |
| 168 | * initialize the lpVtbl field to point to this variable. |
| 169 | * - The IDirect3D_Xxx macros then just derefence the lpVtbl pointer and use the function pointer |
| 170 | * corresponding to the macro name. This emulates the behavior of a virtual table and should be |
| 171 | * just as fast. |
| 172 | * - This C code should be quite compatible with the Windows headers both for code that uses COM |
| 173 | * interfaces and for code implementing a COM interface. |
| 174 | * |
| 175 | * |
| 176 | * And in C++ (with gcc's g++): |
| 177 | * |
| 178 | * typedef struct IDirect3D: public IUnknown { |
| 179 | * virtual HRESULT Initialize(REFIID a) = 0; |
| 180 | * virtual HRESULT EnumDevices(LPD3DENUMDEVICESCALLBACK a, LPVOID b) = 0; |
| 181 | * virtual HRESULT CreateLight(LPDIRECT3DLIGHT* a, IUnknown* b) = 0; |
| 182 | * virtual HRESULT CreateMaterial(LPDIRECT3DMATERIAL* a, IUnknown* b) = 0; |
| 183 | * virtual HRESULT CreateViewport(LPDIRECT3DVIEWPORT* a, IUnknown* b) = 0; |
| 184 | * virtual HRESULT FindDevice(LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b) = 0; |
| 185 | * }; |
| 186 | * |
| 187 | * Comments: |
| 188 | * - Of course in C++ we use inheritance so that we don't have to duplicate the method definitions. |
| 189 | * - Finally there is no IDirect3D_Xxx macro. These are not needed in C++ unless the CINTERFACE |
| 190 | * macro is defined in which case we would not be here. |
| 191 | * |
| 192 | * |
| 193 | * Implementing a COM interface. |
| 194 | * |
| 195 | * This continues the above example. This example assumes that the implementation is in C. |
| 196 | * |
| 197 | * typedef struct _IDirect3D { |
| 198 | * void* lpVtbl; |
| 199 | * // ... |
| 200 | * |
| 201 | * } _IDirect3D; |
| 202 | * |
| 203 | * static ICOM_VTABLE(IDirect3D) d3dvt; |
| 204 | * |
| 205 | * // implement the IDirect3D methods here |
| 206 | * |
| 207 | * int IDirect3D_QueryInterface(IDirect3D* me) |
| 208 | * { |
| 209 | * ICOM_THIS(IDirect3D,me); |
| 210 | * // ... |
| 211 | * } |
| 212 | * |
| 213 | * // ... |
| 214 | * |
| 215 | * static ICOM_VTABLE(IDirect3D) d3dvt = { |
| 216 | * ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE |
| 217 | * IDirect3D_QueryInterface, |
| 218 | * IDirect3D_Add, |
| 219 | * IDirect3D_Add2, |
| 220 | * IDirect3D_Initialize, |
| 221 | * IDirect3D_SetWidth |
| 222 | * }; |
| 223 | * |
| 224 | * Comments: |
| 225 | * - We first define what the interface really contains. This is th e_IDirect3D structure. The |
| 226 | * first field must of course be the virtual table pointer. Everything else is free. |
| 227 | * - Then we predeclare our static virtual table variable, we will need its address in some |
| 228 | * methods to initialize the virtual table pointer of the returned interface objects. |
| 229 | * - Then we implement the interface methods. To match what has been declared in the header file |
| 230 | * they must take a pointer to a IDirect3D structure and we must cast it to an _IDirect3D so that |
| 231 | * we can manipulate the fields. This is performed by the ICOM_THIS macro. |
| 232 | * - Finally we initialize the virtual table. |
| 233 | */ |
| 234 | |
| 235 | #if defined(__cplusplus) && !defined(CINTERFACE) |
| 236 | |
| 237 | /* C++ interface */ |
| 238 | |
| 239 | #define STDMETHOD(method) virtual HRESULT STDMETHODCALLTYPE method |
| 240 | #define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method |
| 241 | #define STDMETHODV(method) virtual HRESULT STDMETHODVCALLTYPE method |
| 242 | #define STDMETHODV_(type,method) virtual type STDMETHODVCALLTYPE method |
| 243 | |
| 244 | #define PURE = 0 |
| 245 | #define THIS_ |
| 246 | #define THIS void |
| 247 | |
| 248 | #define interface struct |
Alexandre Julliard | 2d5519f | 2003-04-12 00:09:14 +0000 | [diff] [blame] | 249 | #ifdef ICOM_USE_COM_INTERFACE_ATTRIBUTE |
| 250 | #define DECLARE_INTERFACE(iface) interface __attribute__((com_interface)) iface |
| 251 | #else |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 252 | #define DECLARE_INTERFACE(iface) interface iface |
Alexandre Julliard | 2d5519f | 2003-04-12 00:09:14 +0000 | [diff] [blame] | 253 | #endif |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 254 | #define DECLARE_INTERFACE_(iface,ibase) interface iface : public ibase |
| 255 | |
| 256 | #define BEGIN_INTERFACE |
| 257 | #define END_INTERFACE |
| 258 | |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 259 | #else /* __cplusplus && !CINTERFACE */ |
| 260 | |
| 261 | /* C interface */ |
| 262 | |
| 263 | #define COBJMACROS |
| 264 | |
| 265 | #define STDMETHOD(method) HRESULT (STDMETHODCALLTYPE *method) |
| 266 | #define STDMETHOD_(type,method) type (STDMETHODCALLTYPE *method) |
| 267 | #define STDMETHODV(method) HRESULT (STDMETHODVCALLTYPE *method) |
| 268 | #define STDMETHODV_(type,method) type (STDMETHODVCALLTYPE *method) |
| 269 | |
| 270 | #define PURE |
| 271 | #define THIS_ INTERFACE *This, |
| 272 | #define THIS INTERFACE *This |
| 273 | |
| 274 | #define interface struct |
| 275 | |
| 276 | #ifdef CONST_VTABLE |
| 277 | #undef CONST_VTBL |
| 278 | #define CONST_VTBL const |
| 279 | #define DECLARE_INTERFACE(iface) \ |
| 280 | /*typedef*/ interface iface { const struct iface##Vtbl *lpVtbl; } /*iface*/; \ |
| 281 | typedef const struct iface##Vtbl iface##Vtbl; \ |
| 282 | const struct iface##Vtbl |
| 283 | #else |
| 284 | #undef CONST_VTBL |
| 285 | #define CONST_VTBL |
| 286 | #define DECLARE_INTERFACE(iface) \ |
| 287 | /*typedef*/ interface iface { struct iface##Vtbl *lpVtbl; } /*iface*/; \ |
| 288 | typedef struct iface##Vtbl iface##Vtbl; \ |
| 289 | struct iface##Vtbl |
| 290 | #endif |
| 291 | #define DECLARE_INTERFACE_(iface,ibase) DECLARE_INTERFACE(iface) |
| 292 | |
| 293 | #define BEGIN_INTERFACE |
| 294 | #define END_INTERFACE |
| 295 | |
Alexandre Julliard | aae3cb6 | 2003-04-11 00:31:02 +0000 | [diff] [blame] | 296 | #endif /* __cplusplus && !CINTERFACE */ |
| 297 | |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 298 | /* Wine-specific macros */ |
| 299 | |
Alexandre Julliard | 2d5519f | 2003-04-12 00:09:14 +0000 | [diff] [blame] | 300 | #define ICOM_DEFINE(iface,ibase) DECLARE_INTERFACE_(iface,ibase) { iface##_METHODS }; |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 301 | #define ICOM_VTABLE(iface) iface##Vtbl |
| 302 | #define ICOM_VFIELD(iface) ICOM_VTABLE(iface)* lpVtbl |
Alexandre Julliard | 2d5519f | 2003-04-12 00:09:14 +0000 | [diff] [blame] | 303 | #define ICOM_THIS(impl,iface) impl* const This=(impl*)(iface) |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 304 | #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field)) |
Alexandre Julliard | 5537911 | 2003-04-10 21:13:58 +0000 | [diff] [blame] | 305 | |
Ove Kaaven | 1f5315c | 2002-12-05 20:33:07 +0000 | [diff] [blame] | 306 | #include "objidl.h" |
Paul Quinn | ea1640f | 1999-03-10 18:03:53 +0000 | [diff] [blame] | 307 | |
Francois Gouget | f2973ca | 2000-09-22 22:17:49 +0000 | [diff] [blame] | 308 | #ifndef RC_INVOKED |
| 309 | /* For compatibility only, at least for now */ |
| 310 | #include <stdlib.h> |
| 311 | #endif |
| 312 | |
Peter Hunnisett | 3d7cd87 | 2001-04-12 21:10:54 +0000 | [diff] [blame] | 313 | #ifndef INITGUID |
François Gouget | 504973d | 2001-01-02 20:55:40 +0000 | [diff] [blame] | 314 | #include "cguid.h" |
Peter Hunnisett | 3d7cd87 | 2001-04-12 21:10:54 +0000 | [diff] [blame] | 315 | #endif |
François Gouget | 504973d | 2001-01-02 20:55:40 +0000 | [diff] [blame] | 316 | |
Francois Gouget | 0062892 | 2000-10-19 20:32:18 +0000 | [diff] [blame] | 317 | #ifdef __cplusplus |
| 318 | extern "C" { |
| 319 | #endif |
| 320 | |
Ove Kaaven | 41dfa05 | 2002-12-06 19:49:56 +0000 | [diff] [blame] | 321 | #ifndef NONAMELESSSTRUCT |
| 322 | #define LISet32(li, v) ((li).HighPart = (v) < 0 ? -1 : 0, (li).LowPart = (v)) |
| 323 | #define ULISet32(li, v) ((li).HighPart = 0, (li).LowPart = (v)) |
| 324 | #else |
| 325 | #define LISet32(li, v) ((li).s.HighPart = (v) < 0 ? -1 : 0, (li).s.LowPart = (v)) |
| 326 | #define ULISet32(li, v) ((li).s.HighPart = 0, (li).s.LowPart = (v)) |
| 327 | #endif |
| 328 | |
| 329 | /***************************************************************************** |
| 330 | * Standard API |
| 331 | */ |
Ove Kaaven | 99c8526 | 2002-12-18 20:49:16 +0000 | [diff] [blame] | 332 | DWORD WINAPI CoBuildVersion(void); |
Ove Kaaven | 41dfa05 | 2002-12-06 19:49:56 +0000 | [diff] [blame] | 333 | |
| 334 | typedef enum tagCOINIT |
| 335 | { |
| 336 | COINIT_APARTMENTTHREADED = 0x2, /* Apartment model */ |
| 337 | COINIT_MULTITHREADED = 0x0, /* OLE calls objects on any thread */ |
| 338 | COINIT_DISABLE_OLE1DDE = 0x4, /* Don't use DDE for Ole1 support */ |
| 339 | COINIT_SPEED_OVER_MEMORY = 0x8 /* Trade memory for speed */ |
| 340 | } COINIT; |
| 341 | |
Ove Kaaven | 99c8526 | 2002-12-18 20:49:16 +0000 | [diff] [blame] | 342 | HRESULT WINAPI CoInitialize(LPVOID lpReserved); |
| 343 | HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit); |
| 344 | void WINAPI CoUninitialize(void); |
| 345 | DWORD WINAPI CoGetCurrentProcess(void); |
Ove Kaaven | 41dfa05 | 2002-12-06 19:49:56 +0000 | [diff] [blame] | 346 | |
Ove Kaaven | 99c8526 | 2002-12-18 20:49:16 +0000 | [diff] [blame] | 347 | HINSTANCE WINAPI CoLoadLibrary(LPOLESTR lpszLibName, BOOL bAutoFree); |
| 348 | void WINAPI CoFreeAllLibraries(void); |
| 349 | void WINAPI CoFreeLibrary(HINSTANCE hLibrary); |
| 350 | void WINAPI CoFreeUnusedLibraries(void); |
Ove Kaaven | 41dfa05 | 2002-12-06 19:49:56 +0000 | [diff] [blame] | 351 | |
Ove Kaaven | 99c8526 | 2002-12-18 20:49:16 +0000 | [diff] [blame] | 352 | HRESULT WINAPI CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv); |
| 353 | HRESULT WINAPI CoCreateInstanceEx(REFCLSID rclsid, |
| 354 | LPUNKNOWN pUnkOuter, |
| 355 | DWORD dwClsContext, |
| 356 | COSERVERINFO* pServerInfo, |
| 357 | ULONG cmq, |
| 358 | MULTI_QI* pResults); |
| 359 | |
| 360 | HRESULT WINAPI CoGetInstanceFromFile(COSERVERINFO* pServerInfo, CLSID* pClsid, IUnknown* punkOuter, DWORD dwClsCtx, DWORD grfMode, OLECHAR* pwszName, DWORD dwCount, MULTI_QI* pResults); |
| 361 | HRESULT WINAPI CoGetInstanceFromIStorage(COSERVERINFO* pServerInfo, CLSID* pClsid, IUnknown* punkOuter, DWORD dwClsCtx, IStorage* pstg, DWORD dwCount, MULTI_QI* pResults); |
| 362 | |
| 363 | HRESULT WINAPI CoGetMalloc(DWORD dwMemContext, LPMALLOC* lpMalloc); |
| 364 | LPVOID WINAPI CoTaskMemAlloc(ULONG size); |
| 365 | void WINAPI CoTaskMemFree(LPVOID ptr); |
| 366 | LPVOID WINAPI CoTaskMemRealloc(LPVOID ptr, ULONG size); |
| 367 | |
| 368 | HRESULT WINAPI CoRegisterMallocSpy(LPMALLOCSPY pMallocSpy); |
| 369 | HRESULT WINAPI CoRevokeMallocSpy(void); |
Ove Kaaven | 41dfa05 | 2002-12-06 19:49:56 +0000 | [diff] [blame] | 370 | |
| 371 | /* class registration flags; passed to CoRegisterClassObject */ |
| 372 | typedef enum tagREGCLS |
| 373 | { |
| 374 | REGCLS_SINGLEUSE = 0, |
| 375 | REGCLS_MULTIPLEUSE = 1, |
| 376 | REGCLS_MULTI_SEPARATE = 2, |
| 377 | REGCLS_SUSPENDED = 4 |
| 378 | } REGCLS; |
| 379 | |
Ove Kaaven | 99c8526 | 2002-12-18 20:49:16 +0000 | [diff] [blame] | 380 | HRESULT WINAPI CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo, REFIID iid, LPVOID *ppv); |
Ove Kaaven | 41dfa05 | 2002-12-06 19:49:56 +0000 | [diff] [blame] | 381 | HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid,LPUNKNOWN pUnk,DWORD dwClsContext,DWORD flags,LPDWORD lpdwRegister); |
Ove Kaaven | 41dfa05 | 2002-12-06 19:49:56 +0000 | [diff] [blame] | 382 | HRESULT WINAPI CoRevokeClassObject(DWORD dwRegister); |
Ove Kaaven | 41dfa05 | 2002-12-06 19:49:56 +0000 | [diff] [blame] | 383 | HRESULT WINAPI CoGetPSClsid(REFIID riid,CLSID *pclsid); |
Ove Kaaven | 99c8526 | 2002-12-18 20:49:16 +0000 | [diff] [blame] | 384 | HRESULT WINAPI CoRegisterPSClsid(REFIID riid, REFCLSID rclsid); |
| 385 | HRESULT WINAPI CoSuspendClassObjects(void); |
| 386 | HRESULT WINAPI CoResumeClassObjects(void); |
| 387 | ULONG WINAPI CoAddRefServerProcess(void); |
| 388 | HRESULT WINAPI CoReleaseServerProcess(void); |
| 389 | |
| 390 | /* marshalling */ |
| 391 | HRESULT WINAPI CoCreateFreeThreadedMarshaler(LPUNKNOWN punkOuter, LPUNKNOWN* ppunkMarshal); |
| 392 | HRESULT WINAPI CoGetInterfaceAndReleaseStream(LPSTREAM pStm, REFIID iid, LPVOID* ppv); |
| 393 | HRESULT WINAPI CoGetMarshalSizeMax(ULONG* pulSize, REFIID riid, LPUNKNOWN pUnk, DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags); |
| 394 | HRESULT WINAPI CoGetStandardMarshal(REFIID riid, LPUNKNOWN pUnk, DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags, LPMARSHAL* ppMarshal); |
| 395 | HRESULT WINAPI CoMarshalHresult(LPSTREAM pstm, HRESULT hresult); |
| 396 | HRESULT WINAPI CoMarshalInterface(LPSTREAM pStm, REFIID riid, LPUNKNOWN pUnk, DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags); |
| 397 | HRESULT WINAPI CoMarshalInterThreadInterfaceInStream(REFIID riid, LPUNKNOWN pUnk, LPSTREAM* ppStm); |
| 398 | HRESULT WINAPI CoReleaseMarshalData(LPSTREAM pStm); |
| 399 | HRESULT WINAPI CoUnmarshalHresult(LPSTREAM pstm, HRESULT* phresult); |
| 400 | HRESULT WINAPI CoUnmarshalInterface(LPSTREAM pStm, REFIID riid, LPVOID* ppv); |
| 401 | HRESULT WINAPI CoLockObjectExternal(LPUNKNOWN pUnk, BOOL fLock, BOOL fLastUnlockReleases); |
| 402 | BOOL WINAPI CoIsHandlerConnected(LPUNKNOWN pUnk); |
| 403 | |
| 404 | /* security */ |
| 405 | HRESULT WINAPI CoInitializeSecurity(PSECURITY_DESCRIPTOR pSecDesc, LONG cAuthSvc, SOLE_AUTHENTICATION_SERVICE* asAuthSvc, void* pReserved1, DWORD dwAuthnLevel, DWORD dwImpLevel, void* pReserved2, DWORD dwCapabilities, void* pReserved3); |
| 406 | HRESULT WINAPI CoGetCallContext(REFIID riid, void** ppInterface); |
| 407 | HRESULT WINAPI CoQueryAuthenticationServices(DWORD* pcAuthSvc, SOLE_AUTHENTICATION_SERVICE** asAuthSvc); |
| 408 | |
| 409 | HRESULT WINAPI CoQueryProxyBlanket(IUnknown* pProxy, DWORD* pwAuthnSvc, DWORD* pAuthzSvc, OLECHAR** pServerPrincName, DWORD* pAuthnLevel, DWORD* pImpLevel, RPC_AUTH_IDENTITY_HANDLE* pAuthInfo, DWORD* pCapabilites); |
| 410 | HRESULT WINAPI CoSetProxyBlanket(IUnknown* pProxy, DWORD dwAuthnSvc, DWORD dwAuthzSvc, OLECHAR* pServerPrincName, DWORD dwAuthnLevel, DWORD dwImpLevel, RPC_AUTH_IDENTITY_HANDLE pAuthInfo, DWORD dwCapabilities); |
| 411 | HRESULT WINAPI CoCopyProxy(IUnknown* pProxy, IUnknown** ppCopy); |
| 412 | |
| 413 | HRESULT WINAPI CoImpersonateClient(void); |
| 414 | HRESULT WINAPI CoQueryClientBlanket(DWORD* pAuthnSvc, DWORD* pAuthzSvc, OLECHAR16** pServerPrincName, DWORD* pAuthnLevel, DWORD* pImpLevel, RPC_AUTHZ_HANDLE* pPrivs, DWORD* pCapabilities); |
| 415 | HRESULT WINAPI CoRevertToSelf(void); |
| 416 | |
| 417 | /* misc */ |
| 418 | HRESULT WINAPI CoGetTreatAsClass(REFCLSID clsidOld, LPCLSID pClsidNew); |
| 419 | HRESULT WINAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew); |
| 420 | |
| 421 | HRESULT WINAPI CoCreateGuid(GUID* pguid); |
| 422 | BOOL WINAPI CoIsOle1Class(REFCLSID rclsid); |
| 423 | |
| 424 | BOOL WINAPI CoDosDateTimeToFileTime(WORD nDosDate, WORD nDosTime, FILETIME* lpFileTime); |
| 425 | BOOL WINAPI CoFileTimeToDosDateTime(FILETIME* lpFileTime, WORD* lpDosDate, WORD* lpDosTime); |
| 426 | HRESULT WINAPI CoFileTimeNow(FILETIME* lpFileTime); |
Ove Kaaven | 41dfa05 | 2002-12-06 19:49:56 +0000 | [diff] [blame] | 427 | |
| 428 | /***************************************************************************** |
Ove Kaaven | 99c8526 | 2002-12-18 20:49:16 +0000 | [diff] [blame] | 429 | * GUID API |
Ove Kaaven | 41dfa05 | 2002-12-06 19:49:56 +0000 | [diff] [blame] | 430 | */ |
| 431 | HRESULT WINAPI StringFromCLSID16(REFCLSID id, LPOLESTR16*); |
| 432 | HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR*); |
| 433 | |
| 434 | HRESULT WINAPI CLSIDFromString16(LPCOLESTR16, CLSID *); |
| 435 | HRESULT WINAPI CLSIDFromString(LPCOLESTR, CLSID *); |
| 436 | |
| 437 | HRESULT WINAPI CLSIDFromProgID16(LPCOLESTR16 progid, LPCLSID riid); |
| 438 | HRESULT WINAPI CLSIDFromProgID(LPCOLESTR progid, LPCLSID riid); |
| 439 | |
| 440 | HRESULT WINAPI ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *lplpszProgID); |
| 441 | |
| 442 | INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax); |
| 443 | |
| 444 | /***************************************************************************** |
| 445 | * COM Server dll - exports |
| 446 | */ |
| 447 | HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID * ppv); |
| 448 | HRESULT WINAPI DllCanUnloadNow(void); |
| 449 | |
| 450 | /***************************************************************************** |
Ove Kaaven | 99c8526 | 2002-12-18 20:49:16 +0000 | [diff] [blame] | 451 | * Data Object |
| 452 | */ |
| 453 | HRESULT WINAPI CreateDataAdviseHolder(LPDATAADVISEHOLDER* ppDAHolder); |
| 454 | HRESULT WINAPI CreateDataCache(LPUNKNOWN pUnkOuter, REFCLSID rclsid, REFIID iid, LPVOID* ppv); |
| 455 | |
| 456 | /***************************************************************************** |
Ove Kaaven | 41dfa05 | 2002-12-06 19:49:56 +0000 | [diff] [blame] | 457 | * Moniker API |
| 458 | */ |
François Gouget | 9a8c2e2 | 2000-12-15 21:29:41 +0000 | [diff] [blame] | 459 | HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid); |
Noomen Hamza | ed494ec | 1999-03-23 13:48:56 +0000 | [diff] [blame] | 460 | |
Ove Kaaven | 99c8526 | 2002-12-18 20:49:16 +0000 | [diff] [blame] | 461 | HRESULT WINAPI CreateBindCtx16(DWORD reserved, LPBC* ppbc); |
| 462 | HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC* ppbc); |
| 463 | |
| 464 | HRESULT WINAPI CreateFileMoniker16(LPCOLESTR16 lpszPathName, LPMONIKER* ppmk); |
| 465 | HRESULT WINAPI CreateFileMoniker(LPCOLESTR lpszPathName, LPMONIKER* ppmk); |
| 466 | |
| 467 | HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim, LPCOLESTR lpszItem, LPMONIKER* ppmk); |
| 468 | HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim, LPCOLESTR lpszItem, LPMONIKER* ppmk); |
| 469 | |
| 470 | HRESULT WINAPI CreateAntiMoniker(LPMONIKER * ppmk); |
| 471 | |
| 472 | HRESULT WINAPI CreateGenericComposite(LPMONIKER pmkFirst, LPMONIKER pmkRest, LPMONIKER* ppmkComposite); |
| 473 | |
| 474 | HRESULT WINAPI BindMoniker(LPMONIKER pmk, DWORD grfOpt, REFIID iidResult, LPVOID* ppvResult); |
| 475 | |
| 476 | HRESULT WINAPI CreateClassMoniker(REFCLSID rclsid, LPMONIKER* ppmk); |
| 477 | |
| 478 | HRESULT WINAPI CreatePointerMoniker(LPUNKNOWN punk, LPMONIKER* ppmk); |
| 479 | |
| 480 | HRESULT WINAPI MonikerCommonPrefixWith(IMoniker* pmkThis,IMoniker* pmkOther,IMoniker** ppmkCommon); |
| 481 | |
| 482 | HRESULT WINAPI GetRunningObjectTable(DWORD reserved, LPRUNNINGOBJECTTABLE *pprot); |
| 483 | HRESULT WINAPI GetRunningObjectTable16(DWORD reserved, LPRUNNINGOBJECTTABLE *pprot); |
| 484 | |
| 485 | /***************************************************************************** |
| 486 | * Storage API |
| 487 | */ |
| 488 | #define STGM_DIRECT 0x00000000 |
| 489 | #define STGM_TRANSACTED 0x00010000 |
| 490 | #define STGM_SIMPLE 0x08000000 |
| 491 | #define STGM_READ 0x00000000 |
| 492 | #define STGM_WRITE 0x00000001 |
| 493 | #define STGM_READWRITE 0x00000002 |
| 494 | #define STGM_SHARE_DENY_NONE 0x00000040 |
| 495 | #define STGM_SHARE_DENY_READ 0x00000030 |
| 496 | #define STGM_SHARE_DENY_WRITE 0x00000020 |
| 497 | #define STGM_SHARE_EXCLUSIVE 0x00000010 |
| 498 | #define STGM_PRIORITY 0x00040000 |
| 499 | #define STGM_DELETEONRELEASE 0x04000000 |
| 500 | #define STGM_CREATE 0x00001000 |
| 501 | #define STGM_CONVERT 0x00020000 |
| 502 | #define STGM_FAILIFTHERE 0x00000000 |
| 503 | #define STGM_NOSCRATCH 0x00100000 |
| 504 | #define STGM_NOSNAPSHOT 0x00200000 |
| 505 | |
| 506 | HRESULT WINAPI StgCreateDocFile16(LPCOLESTR16 pwcsName,DWORD grfMode,DWORD reserved,IStorage16 **ppstgOpen); |
| 507 | HRESULT WINAPI StgCreateDocfile(LPCOLESTR pwcsName,DWORD grfMode,DWORD reserved,IStorage **ppstgOpen); |
| 508 | |
| 509 | HRESULT WINAPI StgIsStorageFile16(LPCOLESTR16 fn); |
| 510 | HRESULT WINAPI StgIsStorageFile(LPCOLESTR fn); |
| 511 | HRESULT WINAPI StgIsStorageILockBytes(ILockBytes *plkbyt); |
| 512 | |
| 513 | HRESULT WINAPI StgOpenStorage16(const OLECHAR16* pwcsName,IStorage16* pstgPriority,DWORD grfMode,SNB16 snbExclude,DWORD reserved,IStorage16**ppstgOpen); |
| 514 | HRESULT WINAPI StgOpenStorage(const OLECHAR* pwcsName,IStorage* pstgPriority,DWORD grfMode,SNB snbExclude,DWORD reserved,IStorage**ppstgOpen); |
| 515 | |
| 516 | HRESULT WINAPI WriteClassStg(IStorage* pStg, REFCLSID rclsid); |
| 517 | HRESULT WINAPI ReadClassStg(IStorage *pstg,CLSID *pclsid); |
| 518 | |
| 519 | HRESULT WINAPI StgCreateDocfileOnILockBytes(ILockBytes *plkbyt,DWORD grfMode, DWORD reserved, IStorage** ppstgOpen); |
| 520 | HRESULT WINAPI StgOpenStorageOnILockBytes(ILockBytes *plkbyt, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen); |
| 521 | |
Francois Gouget | 0062892 | 2000-10-19 20:32:18 +0000 | [diff] [blame] | 522 | #ifdef __cplusplus |
| 523 | } |
| 524 | #endif |
| 525 | |
Ove Kaaven | 2a8bd72 | 2002-12-23 01:41:51 +0000 | [diff] [blame] | 526 | |
Dimitrie O. Paun | 8b36681 | 2003-01-04 00:52:18 +0000 | [diff] [blame] | 527 | #ifndef __WINESRC__ |
Alexandre Julliard | f00c46f | 2003-04-10 00:19:24 +0000 | [diff] [blame] | 528 | |
Paul Quinn | aaa8306 | 1999-06-05 15:23:20 +0000 | [diff] [blame] | 529 | #define FARSTRUCT |
| 530 | #define HUGEP |
| 531 | |
Paul Quinn | ea1640f | 1999-03-10 18:03:53 +0000 | [diff] [blame] | 532 | #define WINOLEAPI STDAPI |
| 533 | #define WINOLEAPI_(type) STDAPI_(type) |
| 534 | |
Dimitrie O. Paun | 8b36681 | 2003-01-04 00:52:18 +0000 | [diff] [blame] | 535 | #endif /* __WINESRC__ */ |
François Gouget | d604eb1 | 1998-12-18 16:00:03 +0000 | [diff] [blame] | 536 | |
Alexandre Julliard | dc818a5 | 2002-12-05 22:11:43 +0000 | [diff] [blame] | 537 | #endif /* _OBJBASE_H_ */ |