[CSRSRV]: Fix two DPRINTs.
[reactos.git] / reactos / include / psdk / objbase.h
1 /*
2 * Copyright (C) 1998-1999 Francois Gouget
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 #include <rpc.h>
20 #include <rpcndr.h>
21
22 #ifndef _OBJBASE_H_
23 #define _OBJBASE_H_
24
25 /*****************************************************************************
26 * Macros to define a COM interface
27 */
28 /*
29 * The goal of the following set of definitions is to provide a way to use the same
30 * header file definitions to provide both a C interface and a C++ object oriented
31 * interface to COM interfaces. The type of interface is selected automatically
32 * depending on the language but it is always possible to get the C interface in C++
33 * by defining CINTERFACE.
34 *
35 * It is based on the following assumptions:
36 * - all COM interfaces derive from IUnknown, this should not be a problem.
37 * - the header file only defines the interface, the actual fields are defined
38 * separately in the C file implementing the interface.
39 *
40 * The natural approach to this problem would be to make sure we get a C++ class and
41 * virtual methods in C++ and a structure with a table of pointer to functions in C.
42 * Unfortunately the layout of the virtual table is compiler specific, the layout of
43 * g++ virtual tables is not the same as that of an egcs virtual table which is not the
44 * same as that generated by Visual C+. There are workarounds to make the virtual tables
45 * compatible via padding but unfortunately the one which is imposed to the WINE emulator
46 * by the Windows binaries, i.e. the Visual C++ one, is the most compact of all.
47 *
48 * So the solution I finally adopted does not use virtual tables. Instead I use inline
49 * non virtual methods that dereference the method pointer themselves and perform the call.
50 *
51 * Let's take Direct3D as an example:
52 *
53 * #define INTERFACE IDirect3D
54 * DECLARE_INTERFACE_(IDirect3D,IUnknown)
55 * {
56 * // *** IUnknown methods *** //
57 * STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID, void**) PURE;
58 * STDMETHOD_(ULONG,AddRef)(THIS) PURE;
59 * STDMETHOD_(ULONG,Release)(THIS) PURE;
60 * // *** IDirect3D methods *** //
61 * STDMETHOD(Initialize)(THIS_ REFIID) PURE;
62 * STDMETHOD(EnumDevices)(THIS_ LPD3DENUMDEVICESCALLBACK, LPVOID) PURE;
63 * STDMETHOD(CreateLight)(THIS_ LPDIRECT3DLIGHT *, IUnknown *) PURE;
64 * STDMETHOD(CreateMaterial)(THIS_ LPDIRECT3DMATERIAL *, IUnknown *) PURE;
65 * STDMETHOD(CreateViewport)(THIS_ LPDIRECT3DVIEWPORT *, IUnknown *) PURE;
66 * STDMETHOD(FindDevice)(THIS_ LPD3DFINDDEVICESEARCH, LPD3DFINDDEVICERESULT) PURE;
67 * };
68 * #undef INTERFACE
69 *
70 * #ifdef COBJMACROS
71 * // *** IUnknown methods *** //
72 * #define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
73 * #define IDirect3D_AddRef(p) (p)->lpVtbl->AddRef(p)
74 * #define IDirect3D_Release(p) (p)->lpVtbl->Release(p)
75 * // *** IDirect3D methods *** //
76 * #define IDirect3D_Initialize(p,a) (p)->lpVtbl->Initialize(p,a)
77 * #define IDirect3D_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevice(p,a,b)
78 * #define IDirect3D_CreateLight(p,a,b) (p)->lpVtbl->CreateLight(p,a,b)
79 * #define IDirect3D_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial(p,a,b)
80 * #define IDirect3D_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport(p,a,b)
81 * #define IDirect3D_FindDevice(p,a,b) (p)->lpVtbl->FindDevice(p,a,b)
82 * #endif
83 *
84 * Comments:
85 * - The INTERFACE macro is used in the STDMETHOD macros to define the type of the 'this'
86 * pointer. Defining this macro here saves us the trouble of having to repeat the interface
87 * name everywhere. Note however that because of the way macros work, a macro like STDMETHOD
88 * cannot use 'INTERFACE##_VTABLE' because this would give 'INTERFACE_VTABLE' and not
89 * 'IDirect3D_VTABLE'.
90 * - The DECLARE_INTERFACE declares all the structures necessary for the interface. We have to
91 * explicitly use the interface name for macro expansion reasons again. It defines the list of
92 * methods that are inheritable from this interface. It must be written manually (rather than
93 * using a macro to generate the equivalent code) to avoid macro recursion (which compilers
94 * don't like). It must start with the methods definition of the parent interface so that
95 * method inheritance works properly.
96 * - The 'undef INTERFACE' is here to remind you that using INTERFACE in the following macros
97 * will not work.
98 * - Finally the set of 'IDirect3D_Xxx' macros is a standard set of macros defined to ease access
99 * to the interface methods in C. Unfortunately I don't see any way to avoid having to duplicate
100 * the inherited method definitions there. This time I could have used a trick to use only one
101 * macro whatever the number of parameters but I preferred to have it work the same way as above.
102 * - You probably have noticed that we don't define the fields we need to actually implement this
103 * interface: reference count, pointer to other resources and miscellaneous fields. That's
104 * because these interfaces are just that: interfaces. They may be implemented more than once, in
105 * different contexts and sometimes not even in Wine. Thus it would not make sense to impose
106 * that the interface contains some specific fields.
107 *
108 *
109 * In C this gives:
110 * typedef struct IDirect3DVtbl IDirect3DVtbl;
111 * struct IDirect3D {
112 * IDirect3DVtbl* lpVtbl;
113 * };
114 * struct IDirect3DVtbl {
115 * HRESULT (*QueryInterface)(IDirect3D* me, REFIID riid, LPVOID* ppvObj);
116 * ULONG (*AddRef)(IDirect3D* me);
117 * ULONG (*Release)(IDirect3D* me);
118 * HRESULT (*Initialize)(IDirect3D* me, REFIID a);
119 * HRESULT (*EnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
120 * HRESULT (*CreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
121 * HRESULT (*CreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
122 * HRESULT (*CreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
123 * HRESULT (*FindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
124 * };
125 *
126 * #ifdef COBJMACROS
127 * // *** IUnknown methods *** //
128 * #define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
129 * #define IDirect3D_AddRef(p) (p)->lpVtbl->AddRef(p)
130 * #define IDirect3D_Release(p) (p)->lpVtbl->Release(p)
131 * // *** IDirect3D methods *** //
132 * #define IDirect3D_Initialize(p,a) (p)->lpVtbl->Initialize(p,a)
133 * #define IDirect3D_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevice(p,a,b)
134 * #define IDirect3D_CreateLight(p,a,b) (p)->lpVtbl->CreateLight(p,a,b)
135 * #define IDirect3D_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial(p,a,b)
136 * #define IDirect3D_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport(p,a,b)
137 * #define IDirect3D_FindDevice(p,a,b) (p)->lpVtbl->FindDevice(p,a,b)
138 * #endif
139 *
140 * Comments:
141 * - IDirect3D only contains a pointer to the IDirect3D virtual/jump table. This is the only thing
142 * the user needs to know to use the interface. Of course the structure we will define to
143 * implement this interface will have more fields but the first one will match this pointer.
144 * - The code generated by DECLARE_INTERFACE defines both the structure representing the interface and
145 * the structure for the jump table.
146 * - Each method is declared as a pointer to function field in the jump table. The implementation
147 * will fill this jump table with appropriate values, probably using a static variable, and
148 * initialize the lpVtbl field to point to this variable.
149 * - The IDirect3D_Xxx macros then just derefence the lpVtbl pointer and use the function pointer
150 * corresponding to the macro name. This emulates the behavior of a virtual table and should be
151 * just as fast.
152 * - This C code should be quite compatible with the Windows headers both for code that uses COM
153 * interfaces and for code implementing a COM interface.
154 *
155 *
156 * And in C++ (with gcc's g++):
157 *
158 * typedef struct IDirect3D: public IUnknown {
159 * virtual HRESULT Initialize(REFIID a) = 0;
160 * virtual HRESULT EnumDevices(LPD3DENUMDEVICESCALLBACK a, LPVOID b) = 0;
161 * virtual HRESULT CreateLight(LPDIRECT3DLIGHT* a, IUnknown* b) = 0;
162 * virtual HRESULT CreateMaterial(LPDIRECT3DMATERIAL* a, IUnknown* b) = 0;
163 * virtual HRESULT CreateViewport(LPDIRECT3DVIEWPORT* a, IUnknown* b) = 0;
164 * virtual HRESULT FindDevice(LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b) = 0;
165 * };
166 *
167 * Comments:
168 * - Of course in C++ we use inheritance so that we don't have to duplicate the method definitions.
169 * - Finally there is no IDirect3D_Xxx macro. These are not needed in C++ unless the CINTERFACE
170 * macro is defined in which case we would not be here.
171 *
172 *
173 * Implementing a COM interface.
174 *
175 * This continues the above example. This example assumes that the implementation is in C.
176 *
177 * typedef struct IDirect3DImpl {
178 * void* lpVtbl;
179 * // ...
180 *
181 * } IDirect3DImpl;
182 *
183 * static IDirect3DVtbl d3dvt;
184 *
185 * // implement the IDirect3D methods here
186 *
187 * int IDirect3D_QueryInterface(IDirect3D* me)
188 * {
189 * IDirect3DImpl *This = (IDirect3DImpl *)me;
190 * // ...
191 * }
192 *
193 * // ...
194 *
195 * static IDirect3DVtbl d3dvt = {
196 * IDirect3D_QueryInterface,
197 * IDirect3D_Add,
198 * IDirect3D_Add2,
199 * IDirect3D_Initialize,
200 * IDirect3D_SetWidth
201 * };
202 *
203 * Comments:
204 * - We first define what the interface really contains. This is the IDirect3DImpl structure. The
205 * first field must of course be the virtual table pointer. Everything else is free.
206 * - Then we predeclare our static virtual table variable, we will need its address in some
207 * methods to initialize the virtual table pointer of the returned interface objects.
208 * - Then we implement the interface methods. To match what has been declared in the header file
209 * they must take a pointer to an IDirect3D structure and we must cast it to an IDirect3DImpl so
210 * that we can manipulate the fields.
211 * - Finally we initialize the virtual table.
212 */
213
214 #if defined(__cplusplus) && !defined(CINTERFACE)
215
216 /* C++ interface */
217
218 #define STDMETHOD(method) virtual HRESULT STDMETHODCALLTYPE method
219 #define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method
220 #define STDMETHODV(method) virtual HRESULT STDMETHODVCALLTYPE method
221 #define STDMETHODV_(type,method) virtual type STDMETHODVCALLTYPE method
222
223 #define PURE = 0
224 #define THIS_
225 #define THIS void
226
227 #define interface struct
228 #define DECLARE_INTERFACE(iface) interface DECLSPEC_NOVTABLE iface
229 #define DECLARE_INTERFACE_(iface,ibase) interface DECLSPEC_NOVTABLE iface : public ibase
230 #define DECLARE_INTERFACE_IID_(iface, ibase, iid) interface DECLSPEC_UUID(iid) DECLSPEC_NOVTABLE iface : public ibase
231
232 #define BEGIN_INTERFACE
233 #define END_INTERFACE
234
235 #else /* __cplusplus && !CINTERFACE */
236
237 /* C interface */
238
239 #define STDMETHOD(method) HRESULT (STDMETHODCALLTYPE *method)
240 #define STDMETHOD_(type,method) type (STDMETHODCALLTYPE *method)
241 #define STDMETHODV(method) HRESULT (STDMETHODVCALLTYPE *method)
242 #define STDMETHODV_(type,method) type (STDMETHODVCALLTYPE *method)
243
244 #define PURE
245 #define THIS_ INTERFACE *This,
246 #define THIS INTERFACE *This
247
248 #define interface struct
249
250 #ifdef __WINESRC__
251 #define CONST_VTABLE
252 #endif
253
254 #ifdef CONST_VTABLE
255 #undef CONST_VTBL
256 #define CONST_VTBL const
257 #define DECLARE_INTERFACE(iface) \
258 typedef interface iface { const struct iface##Vtbl *lpVtbl; } iface; \
259 typedef struct iface##Vtbl iface##Vtbl; \
260 struct iface##Vtbl
261 #else
262 #undef CONST_VTBL
263 #define CONST_VTBL
264 #define DECLARE_INTERFACE(iface) \
265 typedef interface iface { struct iface##Vtbl *lpVtbl; } iface; \
266 typedef struct iface##Vtbl iface##Vtbl; \
267 struct iface##Vtbl
268 #endif
269 #define DECLARE_INTERFACE_(iface,ibase) DECLARE_INTERFACE(iface)
270 #define DECLARE_INTERFACE_IID_(iface, ibase, iid) DECLARE_INTERFACE_(iface, ibase)
271
272 #define BEGIN_INTERFACE
273 #define END_INTERFACE
274
275 #endif /* __cplusplus && !CINTERFACE */
276
277 #ifndef __IRpcStubBuffer_FWD_DEFINED__
278 #define __IRpcStubBuffer_FWD_DEFINED__
279 typedef interface IRpcStubBuffer IRpcStubBuffer;
280 #endif
281 #ifndef __IRpcChannelBuffer_FWD_DEFINED__
282 #define __IRpcChannelBuffer_FWD_DEFINED__
283 typedef interface IRpcChannelBuffer IRpcChannelBuffer;
284 #endif
285
286 #ifndef RC_INVOKED
287 /* For compatibility only, at least for now */
288 #include <stdlib.h>
289 #endif
290
291 #include <wtypes.h>
292 #include <unknwn.h>
293 #include <objidl.h>
294
295 #include <guiddef.h>
296 #ifndef INITGUID
297 #include <cguid.h>
298 #endif
299
300 #ifdef __cplusplus
301 extern "C" {
302 #endif
303
304 #ifndef NONAMELESSSTRUCT
305 #define LISet32(li, v) ((li).HighPart = (v) < 0 ? -1 : 0, (li).LowPart = (v))
306 #define ULISet32(li, v) ((li).HighPart = 0, (li).LowPart = (v))
307 #else
308 #define LISet32(li, v) ((li).u.HighPart = (v) < 0 ? -1 : 0, (li).u.LowPart = (v))
309 #define ULISet32(li, v) ((li).u.HighPart = 0, (li).u.LowPart = (v))
310 #endif
311
312 /*****************************************************************************
313 * Standard API
314 */
315 DWORD WINAPI CoBuildVersion(void);
316
317 typedef enum tagCOINIT
318 {
319 COINIT_APARTMENTTHREADED = 0x2, /* Apartment model */
320 COINIT_MULTITHREADED = 0x0, /* OLE calls objects on any thread */
321 COINIT_DISABLE_OLE1DDE = 0x4, /* Don't use DDE for Ole1 support */
322 COINIT_SPEED_OVER_MEMORY = 0x8 /* Trade memory for speed */
323 } COINIT;
324
325 _Check_return_ HRESULT WINAPI CoInitialize(_In_opt_ LPVOID lpReserved);
326
327 _Check_return_
328 HRESULT
329 WINAPI
330 CoInitializeEx(
331 _In_opt_ LPVOID lpReserved,
332 _In_ DWORD dwCoInit);
333
334 void WINAPI CoUninitialize(void);
335 DWORD WINAPI CoGetCurrentProcess(void);
336
337 HINSTANCE WINAPI CoLoadLibrary(_In_ LPOLESTR lpszLibName, _In_ BOOL bAutoFree);
338 void WINAPI CoFreeAllLibraries(void);
339 void WINAPI CoFreeLibrary(_In_ HINSTANCE hLibrary);
340 void WINAPI CoFreeUnusedLibraries(void);
341
342 void
343 WINAPI
344 CoFreeUnusedLibrariesEx(
345 _In_ DWORD dwUnloadDelay,
346 _In_ DWORD dwReserved);
347
348 _Check_return_
349 HRESULT
350 WINAPI
351 CoCreateInstance(
352 _In_ REFCLSID rclsid,
353 _In_opt_ LPUNKNOWN pUnkOuter,
354 _In_ DWORD dwClsContext,
355 _In_ REFIID iid,
356 _Outptr_ _At_(*ppv, _Post_readable_size_(_Inexpressible_(varies))) LPVOID *ppv);
357
358 _Check_return_
359 HRESULT
360 WINAPI
361 CoCreateInstanceEx(
362 _In_ REFCLSID rclsid,
363 _In_opt_ LPUNKNOWN pUnkOuter,
364 _In_ DWORD dwClsContext,
365 _In_opt_ COSERVERINFO *pServerInfo,
366 _In_ ULONG cmq,
367 _Inout_updates_(cmq) MULTI_QI *pResults);
368
369 _Check_return_
370 HRESULT
371 WINAPI
372 CoGetInstanceFromFile(
373 _In_opt_ COSERVERINFO *pServerInfo,
374 _In_opt_ CLSID *pClsid,
375 _In_opt_ IUnknown *punkOuter,
376 _In_ DWORD dwClsCtx,
377 _In_ DWORD grfMode,
378 _In_ _Null_terminated_ OLECHAR *pwszName,
379 _In_ DWORD dwCount,
380 _Inout_updates_(dwCount) MULTI_QI *pResults);
381
382 _Check_return_
383 HRESULT
384 WINAPI
385 CoGetInstanceFromIStorage(
386 _In_opt_ COSERVERINFO *pServerInfo,
387 _In_opt_ CLSID *pClsid,
388 _In_opt_ IUnknown *punkOuter,
389 _In_ DWORD dwClsCtx,
390 _In_ IStorage *pstg,
391 _In_ DWORD dwCount,
392 _Inout_updates_(dwCount) MULTI_QI *pResults);
393
394 _Check_return_
395 HRESULT
396 WINAPI
397 CoGetMalloc(
398 _In_ DWORD dwMemContext,
399 _Outptr_ LPMALLOC *lpMalloc);
400
401 _Ret_opt_
402 _Post_writable_byte_size_(size)
403 __drv_allocatesMem(Mem)
404 _Check_return_
405 LPVOID
406 WINAPI
407 CoTaskMemAlloc(_In_ ULONG size) __WINE_ALLOC_SIZE(1);
408
409 void
410 WINAPI
411 CoTaskMemFree(
412 _In_opt_ __drv_freesMem(Mem) _Post_invalid_ LPVOID ptr);
413
414 _Ret_opt_
415 _Post_writable_byte_size_(size)
416 _When_(size > 0, __drv_allocatesMem(Mem) _Check_return_)
417 LPVOID
418 WINAPI
419 CoTaskMemRealloc(
420 _In_opt_ __drv_freesMem(Mem) _Post_invalid_ LPVOID ptr,
421 _In_ ULONG size);
422
423 HRESULT WINAPI CoRegisterMallocSpy(_In_ LPMALLOCSPY pMallocSpy);
424 HRESULT WINAPI CoRevokeMallocSpy(void);
425
426 _Check_return_ HRESULT WINAPI CoGetContextToken(_Out_ ULONG_PTR *token);
427
428 /* class registration flags; passed to CoRegisterClassObject */
429 typedef enum tagREGCLS
430 {
431 REGCLS_SINGLEUSE = 0,
432 REGCLS_MULTIPLEUSE = 1,
433 REGCLS_MULTI_SEPARATE = 2,
434 REGCLS_SUSPENDED = 4,
435 REGCLS_SURROGATE = 8
436 } REGCLS;
437
438 _Check_return_
439 HRESULT
440 WINAPI
441 CoGetClassObject(
442 _In_ REFCLSID rclsid,
443 _In_ DWORD dwClsContext,
444 _In_opt_ COSERVERINFO *pServerInfo,
445 _In_ REFIID iid,
446 _Outptr_ LPVOID *ppv);
447
448 _Check_return_
449 HRESULT
450 WINAPI
451 CoRegisterClassObject(
452 _In_ REFCLSID rclsid,
453 _In_ LPUNKNOWN pUnk,
454 _In_ DWORD dwClsContext,
455 _In_ DWORD flags,
456 _Out_ LPDWORD lpdwRegister);
457
458 _Check_return_
459 HRESULT
460 WINAPI
461 CoRevokeClassObject(
462 _In_ DWORD dwRegister);
463
464 _Check_return_
465 HRESULT
466 WINAPI
467 CoGetPSClsid(
468 _In_ REFIID riid,
469 _Out_ CLSID *pclsid);
470
471 _Check_return_
472 HRESULT
473 WINAPI
474 CoRegisterPSClsid(
475 _In_ REFIID riid,
476 _In_ REFCLSID rclsid);
477
478 _Check_return_ HRESULT WINAPI CoRegisterSurrogate(_In_ LPSURROGATE pSurrogate);
479 _Check_return_ HRESULT WINAPI CoSuspendClassObjects(void);
480 _Check_return_ HRESULT WINAPI CoResumeClassObjects(void);
481 ULONG WINAPI CoAddRefServerProcess(void);
482 ULONG WINAPI CoReleaseServerProcess(void);
483
484 /* marshalling */
485
486 _Check_return_
487 HRESULT
488 WINAPI
489 CoCreateFreeThreadedMarshaler(
490 _In_opt_ LPUNKNOWN punkOuter,
491 _Outptr_ LPUNKNOWN *ppunkMarshal);
492
493 _Check_return_
494 HRESULT
495 WINAPI
496 CoGetInterfaceAndReleaseStream(
497 _In_ LPSTREAM pStm,
498 _In_ REFIID iid,
499 _Outptr_ LPVOID *ppv);
500
501 _Check_return_
502 HRESULT
503 WINAPI
504 CoGetMarshalSizeMax(
505 _Out_ ULONG *pulSize,
506 _In_ REFIID riid,
507 _In_ LPUNKNOWN pUnk,
508 _In_ DWORD dwDestContext,
509 _In_opt_ LPVOID pvDestContext,
510 _In_ DWORD mshlflags);
511
512 _Check_return_
513 HRESULT
514 WINAPI
515 CoGetStandardMarshal(
516 _In_ REFIID riid,
517 _In_ LPUNKNOWN pUnk,
518 _In_ DWORD dwDestContext,
519 _In_opt_ LPVOID pvDestContext,
520 _In_ DWORD mshlflags,
521 _Outptr_ LPMARSHAL *ppMarshal);
522
523 HRESULT WINAPI CoMarshalHresult(_In_ LPSTREAM pstm, _In_ HRESULT hresult);
524
525 _Check_return_
526 HRESULT
527 WINAPI
528 CoMarshalInterface(
529 _In_ LPSTREAM pStm,
530 _In_ REFIID riid,
531 _In_ LPUNKNOWN pUnk,
532 _In_ DWORD dwDestContext,
533 _In_opt_ LPVOID pvDestContext,
534 _In_ DWORD mshlflags);
535
536 _Check_return_
537 HRESULT
538 WINAPI
539 CoMarshalInterThreadInterfaceInStream(
540 _In_ REFIID riid,
541 _In_ LPUNKNOWN pUnk,
542 _Outptr_ LPSTREAM *ppStm);
543
544 _Check_return_ HRESULT WINAPI CoReleaseMarshalData(_In_ LPSTREAM pStm);
545
546 _Check_return_
547 HRESULT
548 WINAPI
549 CoDisconnectObject(
550 _In_ LPUNKNOWN lpUnk,
551 _In_ DWORD reserved);
552
553 HRESULT WINAPI CoUnmarshalHresult(_In_ LPSTREAM pstm, _Out_ HRESULT *phresult);
554
555 _Check_return_
556 HRESULT
557 WINAPI
558 CoUnmarshalInterface(
559 _In_ LPSTREAM pStm,
560 _In_ REFIID riid,
561 _Outptr_ LPVOID *ppv);
562
563 _Check_return_
564 HRESULT
565 WINAPI
566 CoLockObjectExternal(
567 _In_ LPUNKNOWN pUnk,
568 _In_ BOOL fLock,
569 _In_ BOOL fLastUnlockReleases);
570
571 BOOL WINAPI CoIsHandlerConnected(_In_ LPUNKNOWN pUnk);
572
573 /* security */
574
575 _Check_return_
576 HRESULT
577 WINAPI
578 CoInitializeSecurity(
579 _In_opt_ PSECURITY_DESCRIPTOR pSecDesc,
580 _In_ LONG cAuthSvc,
581 _In_reads_opt_(cAuthSvc) SOLE_AUTHENTICATION_SERVICE *asAuthSvc,
582 _In_opt_ void *pReserved1,
583 _In_ DWORD dwAuthnLevel,
584 _In_ DWORD dwImpLevel,
585 _In_opt_ void *pReserved2,
586 _In_ DWORD dwCapabilities,
587 _In_opt_ void *pReserved3);
588
589 _Check_return_
590 HRESULT
591 WINAPI
592 CoGetCallContext(
593 _In_ REFIID riid,
594 _Outptr_ void **ppInterface);
595
596 _Check_return_
597 HRESULT
598 WINAPI
599 CoSwitchCallContext(
600 _In_opt_ IUnknown *pContext,
601 _Outptr_ IUnknown **ppOldContext);
602
603 _Check_return_
604 HRESULT
605 WINAPI
606 CoQueryAuthenticationServices(
607 _Out_ DWORD *pcAuthSvc,
608 _Outptr_result_buffer_(*pcAuthSvc) SOLE_AUTHENTICATION_SERVICE **asAuthSvc);
609
610 _Check_return_
611 HRESULT
612 WINAPI
613 CoQueryProxyBlanket(
614 _In_ IUnknown *pProxy,
615 _Out_opt_ DWORD *pwAuthnSvc,
616 _Out_opt_ DWORD *pAuthzSvc,
617 _Outptr_opt_ OLECHAR **pServerPrincName,
618 _Out_opt_ DWORD *pAuthnLevel,
619 _Out_opt_ DWORD *pImpLevel,
620 _Out_opt_ RPC_AUTH_IDENTITY_HANDLE *pAuthInfo,
621 _Out_opt_ DWORD *pCapabilities);
622
623 _Check_return_
624 HRESULT
625 WINAPI
626 CoSetProxyBlanket(
627 _In_ IUnknown *pProxy,
628 _In_ DWORD dwAuthnSvc,
629 _In_ DWORD dwAuthzSvc,
630 _In_opt_ OLECHAR *pServerPrincName,
631 _In_ DWORD dwAuthnLevel,
632 _In_ DWORD dwImpLevel,
633 _In_opt_ RPC_AUTH_IDENTITY_HANDLE pAuthInfo,
634 _In_ DWORD dwCapabilities);
635
636 _Check_return_
637 HRESULT
638 WINAPI CoCopyProxy(
639 _In_ IUnknown *pProxy,
640 _Outptr_ IUnknown **ppCopy);
641
642 _Check_return_ HRESULT WINAPI CoImpersonateClient(void);
643
644 _Check_return_
645 HRESULT
646 WINAPI
647 CoQueryClientBlanket(
648 _Out_opt_ DWORD *pAuthnSvc,
649 _Out_opt_ DWORD *pAuthzSvc,
650 _Outptr_opt_ OLECHAR **pServerPrincName,
651 _Out_opt_ DWORD *pAuthnLevel,
652 _Out_opt_ DWORD *pImpLevel,
653 _Outptr_opt_ RPC_AUTHZ_HANDLE *pPrivs,
654 _Inout_opt_ DWORD *pCapabilities);
655
656 _Check_return_ HRESULT WINAPI CoRevertToSelf(void);
657
658 /* misc */
659
660 _Check_return_
661 HRESULT
662 WINAPI
663 CoGetTreatAsClass(
664 _In_ REFCLSID clsidOld,
665 _Out_ LPCLSID pClsidNew);
666
667 _Check_return_
668 HRESULT
669 WINAPI
670 CoTreatAsClass(
671 _In_ REFCLSID clsidOld,
672 _In_ REFCLSID clsidNew);
673
674 HRESULT
675 WINAPI
676 CoAllowSetForegroundWindow(
677 _In_ IUnknown *pUnk,
678 _In_opt_ LPVOID lpvReserved);
679
680 _Check_return_
681 HRESULT
682 WINAPI
683 CoGetObjectContext(
684 _In_ REFIID riid,
685 _Outptr_ LPVOID *ppv);
686
687 _Check_return_ HRESULT WINAPI CoCreateGuid(_Out_ GUID *pguid);
688 BOOL WINAPI CoIsOle1Class(_In_ REFCLSID rclsid);
689
690 BOOL
691 WINAPI
692 CoDosDateTimeToFileTime(
693 _In_ WORD nDosDate,
694 _In_ WORD nDosTime,
695 _Out_ FILETIME *lpFileTime);
696
697 BOOL
698 WINAPI
699 CoFileTimeToDosDateTime(
700 _In_ FILETIME *lpFileTime,
701 _Out_ WORD *lpDosDate,
702 _Out_ WORD *lpDosTime);
703
704 HRESULT WINAPI CoFileTimeNow(_Out_ FILETIME *lpFileTime);
705
706 _Check_return_
707 HRESULT
708 WINAPI
709 CoRegisterMessageFilter(
710 _In_opt_ LPMESSAGEFILTER lpMessageFilter,
711 _Outptr_opt_result_maybenull_ LPMESSAGEFILTER *lplpMessageFilter);
712
713 HRESULT
714 WINAPI
715 CoRegisterChannelHook(
716 _In_ REFGUID ExtensionGuid,
717 _In_ IChannelHook *pChannelHook);
718
719 typedef enum tagCOWAIT_FLAGS
720 {
721 COWAIT_WAITALL = 0x00000001,
722 COWAIT_ALERTABLE = 0x00000002
723 } COWAIT_FLAGS;
724
725 _Check_return_
726 HRESULT
727 WINAPI
728 CoWaitForMultipleHandles(
729 _In_ DWORD dwFlags,
730 _In_ DWORD dwTimeout,
731 _In_ ULONG cHandles,
732 _In_reads_(cHandles) LPHANDLE pHandles,
733 _Out_ LPDWORD lpdwindex);
734
735 /*****************************************************************************
736 * GUID API
737 */
738
739 _Check_return_
740 HRESULT
741 WINAPI
742 StringFromCLSID(
743 _In_ REFCLSID id,
744 _Outptr_ LPOLESTR*);
745
746 _Check_return_
747 HRESULT
748 WINAPI
749 CLSIDFromString(
750 _In_ LPCOLESTR,
751 _Out_ LPCLSID);
752
753 _Check_return_
754 HRESULT
755 WINAPI
756 CLSIDFromProgID(
757 _In_ LPCOLESTR progid,
758 _Out_ LPCLSID riid);
759
760 _Check_return_
761 HRESULT
762 WINAPI
763 ProgIDFromCLSID(
764 _In_ REFCLSID clsid,
765 _Outptr_ LPOLESTR *lplpszProgID);
766
767 _Check_return_
768 INT
769 WINAPI
770 StringFromGUID2(
771 _In_ REFGUID id,
772 _Out_writes_to_(cmax, return) LPOLESTR str,
773 _In_ INT cmax);
774
775 /*****************************************************************************
776 * COM Server dll - exports
777 */
778
779 _Check_return_
780 HRESULT
781 WINAPI
782 DllGetClassObject(
783 _In_ REFCLSID rclsid,
784 _In_ REFIID riid,
785 _Outptr_ LPVOID *ppv) DECLSPEC_HIDDEN;
786
787 HRESULT WINAPI DllCanUnloadNow(void) DECLSPEC_HIDDEN;
788
789 /* shouldn't be here, but is nice for type checking */
790 #ifdef __WINESRC__
791 HRESULT WINAPI DllRegisterServer(void) DECLSPEC_HIDDEN;
792 HRESULT WINAPI DllUnregisterServer(void) DECLSPEC_HIDDEN;
793 #endif
794
795
796 /*****************************************************************************
797 * Data Object
798 */
799
800 HRESULT
801 WINAPI
802 CreateDataAdviseHolder(
803 _Outptr_ LPDATAADVISEHOLDER *ppDAHolder);
804
805 HRESULT
806 WINAPI
807 CreateDataCache(
808 _In_opt_ LPUNKNOWN pUnkOuter,
809 _In_ REFCLSID rclsid,
810 _In_ REFIID iid,
811 _Out_ LPVOID *ppv);
812
813 /*****************************************************************************
814 * Moniker API
815 */
816
817 _Check_return_
818 HRESULT
819 WINAPI
820 BindMoniker(
821 _In_ LPMONIKER pmk,
822 _In_ DWORD grfOpt,
823 _In_ REFIID iidResult,
824 _Outptr_ LPVOID *ppvResult);
825
826 _Check_return_
827 HRESULT
828 WINAPI
829 CoGetObject(
830 _In_ LPCWSTR pszName,
831 _In_opt_ BIND_OPTS *pBindOptions,
832 _In_ REFIID riid,
833 _Outptr_ void **ppv);
834
835 _Check_return_ HRESULT WINAPI CreateAntiMoniker(_Outptr_ LPMONIKER *ppmk);
836
837 _Check_return_
838 HRESULT
839 WINAPI
840 CreateBindCtx(
841 _In_ DWORD reserved,
842 _Outptr_ LPBC *ppbc);
843
844 _Check_return_
845 HRESULT
846 WINAPI
847 CreateClassMoniker(
848 _In_ REFCLSID rclsid,
849 _Outptr_ LPMONIKER *ppmk);
850
851 _Check_return_
852 HRESULT
853 WINAPI
854 CreateFileMoniker(
855 _In_ LPCOLESTR lpszPathName,
856 _Outptr_ LPMONIKER *ppmk);
857
858 _Check_return_
859 HRESULT
860 WINAPI
861 CreateGenericComposite(
862 _In_opt_ LPMONIKER pmkFirst,
863 _In_opt_ LPMONIKER pmkRest,
864 _Outptr_ LPMONIKER *ppmkComposite);
865
866 _Check_return_
867 HRESULT
868 WINAPI
869 CreateItemMoniker(
870 _In_ LPCOLESTR lpszDelim,
871 _In_ LPCOLESTR lpszItem,
872 _Outptr_ LPMONIKER *ppmk);
873
874 _Check_return_
875 HRESULT
876 WINAPI
877 CreateObjrefMoniker(
878 _In_opt_ LPUNKNOWN punk,
879 _Outptr_ LPMONIKER *ppmk);
880
881 _Check_return_
882 HRESULT
883 WINAPI
884 CreatePointerMoniker(
885 _In_opt_ LPUNKNOWN punk,
886 _Outptr_ LPMONIKER *ppmk);
887
888 _Check_return_
889 HRESULT
890 WINAPI
891 GetClassFile(
892 _In_ LPCOLESTR filePathName,
893 _Out_ CLSID *pclsid);
894
895 _Check_return_
896 HRESULT
897 WINAPI
898 GetRunningObjectTable(
899 _In_ DWORD reserved,
900 _Outptr_ LPRUNNINGOBJECTTABLE *pprot);
901
902 _Check_return_
903 HRESULT
904 WINAPI
905 MkParseDisplayName(
906 _In_ LPBC pbc,
907 _In_ LPCOLESTR szUserName,
908 _Out_ ULONG *pchEaten,
909 _Outptr_ LPMONIKER *ppmk);
910
911 _Check_return_
912 HRESULT
913 WINAPI
914 MonikerCommonPrefixWith(
915 _In_ IMoniker *pmkThis,
916 _In_ IMoniker *pmkOther,
917 _Outptr_ IMoniker **ppmkCommon);
918
919 _Check_return_
920 HRESULT
921 WINAPI
922 MonikerRelativePathTo(
923 _In_ LPMONIKER pmkSrc,
924 _In_ LPMONIKER pmkDest,
925 _Outptr_ LPMONIKER *ppmkRelPath,
926 _In_ BOOL dwReserved);
927
928 /*****************************************************************************
929 * Storage API
930 */
931 #define STGM_DIRECT 0x00000000
932 #define STGM_TRANSACTED 0x00010000
933 #define STGM_SIMPLE 0x08000000
934 #define STGM_READ 0x00000000
935 #define STGM_WRITE 0x00000001
936 #define STGM_READWRITE 0x00000002
937 #define STGM_SHARE_DENY_NONE 0x00000040
938 #define STGM_SHARE_DENY_READ 0x00000030
939 #define STGM_SHARE_DENY_WRITE 0x00000020
940 #define STGM_SHARE_EXCLUSIVE 0x00000010
941 #define STGM_PRIORITY 0x00040000
942 #define STGM_DELETEONRELEASE 0x04000000
943 #define STGM_CREATE 0x00001000
944 #define STGM_CONVERT 0x00020000
945 #define STGM_FAILIFTHERE 0x00000000
946 #define STGM_NOSCRATCH 0x00100000
947 #define STGM_NOSNAPSHOT 0x00200000
948 #define STGM_DIRECT_SWMR 0x00400000
949
950 #define STGFMT_STORAGE 0
951 #define STGFMT_FILE 3
952 #define STGFMT_ANY 4
953 #define STGFMT_DOCFILE 5
954
955 typedef struct tagSTGOPTIONS
956 {
957 USHORT usVersion;
958 USHORT reserved;
959 ULONG ulSectorSize;
960 const WCHAR* pwcsTemplateFile;
961 } STGOPTIONS;
962
963 _Check_return_
964 HRESULT
965 WINAPI
966 StringFromIID(
967 _In_ REFIID rclsid,
968 _Outptr_ LPOLESTR *lplpsz);
969
970 _Check_return_
971 HRESULT
972 WINAPI
973 StgCreateDocfile(
974 _In_opt_ _Null_terminated_ LPCOLESTR pwcsName,
975 _In_ DWORD grfMode,
976 _Reserved_ DWORD reserved,
977 _Outptr_ IStorage **ppstgOpen);
978
979 _Check_return_
980 HRESULT
981 WINAPI
982 StgCreateStorageEx(
983 _In_opt_ _Null_terminated_ const WCHAR*,
984 _In_ DWORD,
985 _In_ DWORD,
986 _In_ DWORD,
987 _Inout_opt_ STGOPTIONS*,
988 _In_opt_ void*,
989 _In_ REFIID,
990 _Outptr_ void**);
991
992 _Check_return_
993 HRESULT
994 WINAPI
995 StgIsStorageFile(
996 _In_ _Null_terminated_ LPCOLESTR fn);
997
998 _Check_return_
999 HRESULT
1000 WINAPI
1001 StgIsStorageILockBytes(
1002 _In_ ILockBytes *plkbyt);
1003
1004 _Check_return_
1005 HRESULT
1006 WINAPI
1007 StgOpenStorage(
1008 _In_opt_ _Null_terminated_ const OLECHAR *pwcsName,
1009 _In_opt_ IStorage *pstgPriority,
1010 _In_ DWORD grfMode,
1011 _In_opt_z_ SNB snbExclude,
1012 _In_ DWORD reserved,
1013 _Outptr_ IStorage **ppstgOpen);
1014
1015 _Check_return_
1016 HRESULT
1017 WINAPI
1018 StgOpenStorageEx(
1019 _In_ _Null_terminated_ const WCHAR *pwcwName,
1020 _In_ DWORD grfMode,
1021 _In_ DWORD stgfmt,
1022 _In_ DWORD grfAttrs,
1023 _Inout_opt_ STGOPTIONS *pStgOptions,
1024 _In_opt_ void *reserved,
1025 _In_ REFIID riid,
1026 _Outptr_ void **ppObjectOpen);
1027
1028 _Check_return_
1029 HRESULT
1030 WINAPI
1031 StgCreateDocfileOnILockBytes(
1032 _In_ ILockBytes *plkbyt,
1033 _In_ DWORD grfMode,
1034 _In_ DWORD reserved,
1035 _Outptr_ IStorage **ppstgOpen);
1036
1037 _Check_return_
1038 HRESULT
1039 WINAPI
1040 StgOpenStorageOnILockBytes(
1041 _In_ ILockBytes *plkbyt,
1042 _In_opt_ IStorage *pstgPriority,
1043 _In_ DWORD grfMode,
1044 _In_opt_z_ SNB snbExclude,
1045 _Reserved_ DWORD reserved,
1046 _Outptr_ IStorage **ppstgOpen);
1047
1048 _Check_return_
1049 HRESULT
1050 WINAPI
1051 StgSetTimes(
1052 _In_ _Null_terminated_ OLECHAR const *lpszName,
1053 _In_opt_ FILETIME const *pctime,
1054 _In_opt_ FILETIME const *patime,
1055 _In_opt_ FILETIME const *pmtime);
1056
1057 #ifdef __cplusplus
1058 }
1059 #endif
1060
1061 #ifndef __WINESRC__
1062 # include <urlmon.h>
1063 #endif
1064 #include <propidl.h>
1065
1066 #ifndef __WINESRC__
1067
1068 #define FARSTRUCT
1069 #define HUGEP
1070
1071 #define WINOLEAPI STDAPI
1072 #define WINOLEAPI_(type) STDAPI_(type)
1073
1074 #endif /* __WINESRC__ */
1075
1076 #endif /* _OBJBASE_H_ */