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 #if defined(__cplusplus) && !defined(CINTERFACE) 174 175 /* C++ interface */ 176 177 #define STDMETHOD(method) virtual HRESULT STDMETHODCALLTYPE method 178 #define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method 179 #define STDMETHODV(method) virtual HRESULT STDMETHODVCALLTYPE method 180 #define STDMETHODV_(type,method) virtual type STDMETHODVCALLTYPE method 181 182 #define PURE = 0 183 #define THIS_ 184 #define THIS void 185 186 #define interface struct 187 #define DECLARE_INTERFACE(iface) interface DECLSPEC_NOVTABLE iface 188 #define DECLARE_INTERFACE_(iface,ibase) interface DECLSPEC_NOVTABLE iface : public ibase 189 #define DECLARE_INTERFACE_IID_(iface, ibase, iid) interface DECLSPEC_UUID(iid) DECLSPEC_NOVTABLE iface : public ibase 190 191 #define BEGIN_INTERFACE 192 #define END_INTERFACE 193 194 #else /* __cplusplus && !CINTERFACE */ 195 196 /* C interface */ 197 198 #define STDMETHOD(method) HRESULT (STDMETHODCALLTYPE *method) 199 #define STDMETHOD_(type,method) type (STDMETHODCALLTYPE *method) 200 #define STDMETHODV(method) HRESULT (STDMETHODVCALLTYPE *method) 201 #define STDMETHODV_(type,method) type (STDMETHODVCALLTYPE *method) 202 203 #define PURE 204 #define THIS_ INTERFACE *This, 205 #define THIS INTERFACE *This 206 207 #define interface struct 208 209 #ifdef __WINESRC__ 210 #define CONST_VTABLE 211 #endif 212 213 #ifdef CONST_VTABLE 214 #undef CONST_VTBL 215 #define CONST_VTBL const 216 #define DECLARE_INTERFACE(iface) \ 217 typedef interface iface { const struct iface##Vtbl *lpVtbl; } iface; \ 218 typedef struct iface##Vtbl iface##Vtbl; \ 219 struct iface##Vtbl 220 #else 221 #undef CONST_VTBL 222 #define CONST_VTBL 223 #define DECLARE_INTERFACE(iface) \ 224 typedef interface iface { struct iface##Vtbl *lpVtbl; } iface; \ 225 typedef struct iface##Vtbl iface##Vtbl; \ 226 struct iface##Vtbl 227 #endif 228 #define DECLARE_INTERFACE_(iface,ibase) DECLARE_INTERFACE(iface) 229 #define DECLARE_INTERFACE_IID_(iface, ibase, iid) DECLARE_INTERFACE_(iface, ibase) 230 231 #define BEGIN_INTERFACE 232 #define END_INTERFACE 233 234 #endif /* __cplusplus && !CINTERFACE */ 235 236 #ifndef __IRpcStubBuffer_FWD_DEFINED__ 237 #define __IRpcStubBuffer_FWD_DEFINED__ 238 typedef interface IRpcStubBuffer IRpcStubBuffer; 239 #endif 240 #ifndef __IRpcChannelBuffer_FWD_DEFINED__ 241 #define __IRpcChannelBuffer_FWD_DEFINED__ 242 typedef interface IRpcChannelBuffer IRpcChannelBuffer; 243 #endif 244 245 #ifndef RC_INVOKED 246 /* For compatibility only, at least for now */ 247 #include <stdlib.h> 248 #endif 249 250 #include <wtypes.h> 251 #include <unknwn.h> 252 #include <objidl.h> 253 254 #include <guiddef.h> 255 #ifndef INITGUID 256 #include <cguid.h> 257 #endif 258 259 #ifdef __cplusplus 260 extern "C" { 261 #endif 262 263 #ifndef NONAMELESSSTRUCT 264 #define LISet32(li, v) ((li).HighPart = (v) < 0 ? -1 : 0, (li).LowPart = (v)) 265 #define ULISet32(li, v) ((li).HighPart = 0, (li).LowPart = (v)) 266 #else 267 #define LISet32(li, v) ((li).u.HighPart = (v) < 0 ? -1 : 0, (li).u.LowPart = (v)) 268 #define ULISet32(li, v) ((li).u.HighPart = 0, (li).u.LowPart = (v)) 269 #endif 270 271 /***************************************************************************** 272 * Standard API 273 */ 274 DWORD WINAPI CoBuildVersion(void); 275 276 typedef enum tagCOINIT 277 { 278 COINIT_APARTMENTTHREADED = 0x2, /* Apartment model */ 279 COINIT_MULTITHREADED = 0x0, /* OLE calls objects on any thread */ 280 COINIT_DISABLE_OLE1DDE = 0x4, /* Don't use DDE for Ole1 support */ 281 COINIT_SPEED_OVER_MEMORY = 0x8 /* Trade memory for speed */ 282 } COINIT; 283 284 _Check_return_ HRESULT WINAPI CoInitialize(_In_opt_ LPVOID lpReserved); 285 286 _Check_return_ 287 HRESULT 288 WINAPI 289 CoInitializeEx( 290 _In_opt_ LPVOID lpReserved, 291 _In_ DWORD dwCoInit); 292 293 void WINAPI CoUninitialize(void); 294 DWORD WINAPI CoGetCurrentProcess(void); 295 HRESULT WINAPI CoGetCurrentLogicalThreadId(_Out_ GUID *id); 296 HRESULT WINAPI CoGetApartmentType(_Out_ APTTYPE *type, _Out_ APTTYPEQUALIFIER *qualifier); 297 298 HINSTANCE WINAPI CoLoadLibrary(_In_ LPOLESTR lpszLibName, _In_ BOOL bAutoFree); 299 void WINAPI CoFreeAllLibraries(void); 300 void WINAPI CoFreeLibrary(_In_ HINSTANCE hLibrary); 301 void WINAPI CoFreeUnusedLibraries(void); 302 303 void 304 WINAPI 305 CoFreeUnusedLibrariesEx( 306 _In_ DWORD dwUnloadDelay, 307 _In_ DWORD dwReserved); 308 309 _Check_return_ 310 HRESULT 311 WINAPI 312 CoCreateInstance( 313 _In_ REFCLSID rclsid, 314 _In_opt_ LPUNKNOWN pUnkOuter, 315 _In_ DWORD dwClsContext, 316 _In_ REFIID iid, 317 _Outptr_ _At_(*ppv, _Post_readable_size_(_Inexpressible_(varies))) LPVOID *ppv); 318 319 _Check_return_ 320 HRESULT 321 WINAPI 322 CoCreateInstanceEx( 323 _In_ REFCLSID rclsid, 324 _In_opt_ LPUNKNOWN pUnkOuter, 325 _In_ DWORD dwClsContext, 326 _In_opt_ COSERVERINFO *pServerInfo, 327 _In_ ULONG cmq, 328 _Inout_updates_(cmq) MULTI_QI *pResults); 329 330 _Check_return_ 331 HRESULT 332 WINAPI 333 CoGetInstanceFromFile( 334 _In_opt_ COSERVERINFO *pServerInfo, 335 _In_opt_ CLSID *pClsid, 336 _In_opt_ IUnknown *punkOuter, 337 _In_ DWORD dwClsCtx, 338 _In_ DWORD grfMode, 339 _In_ _Null_terminated_ OLECHAR *pwszName, 340 _In_ DWORD dwCount, 341 _Inout_updates_(dwCount) MULTI_QI *pResults); 342 343 _Check_return_ 344 HRESULT 345 WINAPI 346 CoGetInstanceFromIStorage( 347 _In_opt_ COSERVERINFO *pServerInfo, 348 _In_opt_ CLSID *pClsid, 349 _In_opt_ IUnknown *punkOuter, 350 _In_ DWORD dwClsCtx, 351 _In_ IStorage *pstg, 352 _In_ DWORD dwCount, 353 _Inout_updates_(dwCount) MULTI_QI *pResults); 354 355 _Check_return_ 356 HRESULT 357 WINAPI 358 CoGetMalloc( 359 _In_ DWORD dwMemContext, 360 _Outptr_ LPMALLOC *lpMalloc); 361 362 _Ret_opt_ 363 _Post_writable_byte_size_(size) 364 __drv_allocatesMem(Mem) 365 _Check_return_ 366 LPVOID 367 WINAPI 368 CoTaskMemAlloc(_In_ SIZE_T size) __WINE_ALLOC_SIZE(1); 369 370 void 371 WINAPI 372 CoTaskMemFree( 373 _In_opt_ __drv_freesMem(Mem) _Post_invalid_ LPVOID ptr); 374 375 _Ret_opt_ 376 _Post_writable_byte_size_(size) 377 _When_(size > 0, __drv_allocatesMem(Mem) _Check_return_) 378 LPVOID 379 WINAPI 380 CoTaskMemRealloc( 381 _In_opt_ __drv_freesMem(Mem) _Post_invalid_ LPVOID ptr, 382 _In_ SIZE_T size); 383 384 HRESULT WINAPI CoRegisterMallocSpy(_In_ LPMALLOCSPY pMallocSpy); 385 HRESULT WINAPI CoRevokeMallocSpy(void); 386 387 _Check_return_ HRESULT WINAPI CoGetContextToken(_Out_ ULONG_PTR *token); 388 389 /* class registration flags; passed to CoRegisterClassObject */ 390 typedef enum tagREGCLS 391 { 392 REGCLS_SINGLEUSE = 0, 393 REGCLS_MULTIPLEUSE = 1, 394 REGCLS_MULTI_SEPARATE = 2, 395 REGCLS_SUSPENDED = 4, 396 REGCLS_SURROGATE = 8 397 } REGCLS; 398 399 _Check_return_ 400 HRESULT 401 WINAPI 402 CoGetClassObject( 403 _In_ REFCLSID rclsid, 404 _In_ DWORD dwClsContext, 405 _In_opt_ COSERVERINFO *pServerInfo, 406 _In_ REFIID iid, 407 _Outptr_ LPVOID *ppv); 408 409 _Check_return_ 410 HRESULT 411 WINAPI 412 CoRegisterClassObject( 413 _In_ REFCLSID rclsid, 414 _In_ LPUNKNOWN pUnk, 415 _In_ DWORD dwClsContext, 416 _In_ DWORD flags, 417 _Out_ LPDWORD lpdwRegister); 418 419 _Check_return_ 420 HRESULT 421 WINAPI 422 CoRevokeClassObject( 423 _In_ DWORD dwRegister); 424 425 _Check_return_ 426 HRESULT 427 WINAPI 428 CoGetPSClsid( 429 _In_ REFIID riid, 430 _Out_ CLSID *pclsid); 431 432 _Check_return_ 433 HRESULT 434 WINAPI 435 CoRegisterPSClsid( 436 _In_ REFIID riid, 437 _In_ REFCLSID rclsid); 438 439 _Check_return_ HRESULT WINAPI CoRegisterSurrogate(_In_ LPSURROGATE pSurrogate); 440 _Check_return_ HRESULT WINAPI CoSuspendClassObjects(void); 441 _Check_return_ HRESULT WINAPI CoResumeClassObjects(void); 442 ULONG WINAPI CoAddRefServerProcess(void); 443 ULONG WINAPI CoReleaseServerProcess(void); 444 445 /* marshalling */ 446 447 _Check_return_ 448 HRESULT 449 WINAPI 450 CoCreateFreeThreadedMarshaler( 451 _In_opt_ LPUNKNOWN punkOuter, 452 _Outptr_ LPUNKNOWN *ppunkMarshal); 453 454 _Check_return_ 455 HRESULT 456 WINAPI 457 CoGetInterfaceAndReleaseStream( 458 _In_ LPSTREAM pStm, 459 _In_ REFIID iid, 460 _Outptr_ LPVOID *ppv); 461 462 _Check_return_ 463 HRESULT 464 WINAPI 465 CoGetMarshalSizeMax( 466 _Out_ ULONG *pulSize, 467 _In_ REFIID riid, 468 _In_ LPUNKNOWN pUnk, 469 _In_ DWORD dwDestContext, 470 _In_opt_ LPVOID pvDestContext, 471 _In_ DWORD mshlflags); 472 473 _Check_return_ 474 HRESULT 475 WINAPI 476 CoGetStandardMarshal( 477 _In_ REFIID riid, 478 _In_ LPUNKNOWN pUnk, 479 _In_ DWORD dwDestContext, 480 _In_opt_ LPVOID pvDestContext, 481 _In_ DWORD mshlflags, 482 _Outptr_ LPMARSHAL *ppMarshal); 483 484 HRESULT WINAPI CoMarshalHresult(_In_ LPSTREAM pstm, _In_ HRESULT hresult); 485 486 _Check_return_ 487 HRESULT 488 WINAPI 489 CoMarshalInterface( 490 _In_ LPSTREAM pStm, 491 _In_ REFIID riid, 492 _In_ LPUNKNOWN pUnk, 493 _In_ DWORD dwDestContext, 494 _In_opt_ LPVOID pvDestContext, 495 _In_ DWORD mshlflags); 496 497 _Check_return_ 498 HRESULT 499 WINAPI 500 CoMarshalInterThreadInterfaceInStream( 501 _In_ REFIID riid, 502 _In_ LPUNKNOWN pUnk, 503 _Outptr_ LPSTREAM *ppStm); 504 505 _Check_return_ HRESULT WINAPI CoReleaseMarshalData(_In_ LPSTREAM pStm); 506 507 _Check_return_ 508 HRESULT 509 WINAPI 510 CoDisconnectObject( 511 _In_ LPUNKNOWN lpUnk, 512 _In_ DWORD reserved); 513 514 HRESULT WINAPI CoUnmarshalHresult(_In_ LPSTREAM pstm, _Out_ HRESULT *phresult); 515 516 _Check_return_ 517 HRESULT 518 WINAPI 519 CoUnmarshalInterface( 520 _In_ LPSTREAM pStm, 521 _In_ REFIID riid, 522 _Outptr_ LPVOID *ppv); 523 524 _Check_return_ 525 HRESULT 526 WINAPI 527 CoLockObjectExternal( 528 _In_ LPUNKNOWN pUnk, 529 _In_ BOOL fLock, 530 _In_ BOOL fLastUnlockReleases); 531 532 BOOL WINAPI CoIsHandlerConnected(_In_ LPUNKNOWN pUnk); 533 534 /* security */ 535 536 _Check_return_ 537 HRESULT 538 WINAPI 539 CoInitializeSecurity( 540 _In_opt_ PSECURITY_DESCRIPTOR pSecDesc, 541 _In_ LONG cAuthSvc, 542 _In_reads_opt_(cAuthSvc) SOLE_AUTHENTICATION_SERVICE *asAuthSvc, 543 _In_opt_ void *pReserved1, 544 _In_ DWORD dwAuthnLevel, 545 _In_ DWORD dwImpLevel, 546 _In_opt_ void *pReserved2, 547 _In_ DWORD dwCapabilities, 548 _In_opt_ void *pReserved3); 549 550 _Check_return_ 551 HRESULT 552 WINAPI 553 CoGetCallContext( 554 _In_ REFIID riid, 555 _Outptr_ void **ppInterface); 556 557 _Check_return_ 558 HRESULT 559 WINAPI 560 CoSwitchCallContext( 561 _In_opt_ IUnknown *pContext, 562 _Outptr_ IUnknown **ppOldContext); 563 564 _Check_return_ 565 HRESULT 566 WINAPI 567 CoQueryAuthenticationServices( 568 _Out_ DWORD *pcAuthSvc, 569 _Outptr_result_buffer_(*pcAuthSvc) SOLE_AUTHENTICATION_SERVICE **asAuthSvc); 570 571 _Check_return_ 572 HRESULT 573 WINAPI 574 CoQueryProxyBlanket( 575 _In_ IUnknown *pProxy, 576 _Out_opt_ DWORD *pwAuthnSvc, 577 _Out_opt_ DWORD *pAuthzSvc, 578 _Outptr_opt_ OLECHAR **pServerPrincName, 579 _Out_opt_ DWORD *pAuthnLevel, 580 _Out_opt_ DWORD *pImpLevel, 581 _Out_opt_ RPC_AUTH_IDENTITY_HANDLE *pAuthInfo, 582 _Out_opt_ DWORD *pCapabilities); 583 584 _Check_return_ 585 HRESULT 586 WINAPI 587 CoSetProxyBlanket( 588 _In_ IUnknown *pProxy, 589 _In_ DWORD dwAuthnSvc, 590 _In_ DWORD dwAuthzSvc, 591 _In_opt_ OLECHAR *pServerPrincName, 592 _In_ DWORD dwAuthnLevel, 593 _In_ DWORD dwImpLevel, 594 _In_opt_ RPC_AUTH_IDENTITY_HANDLE pAuthInfo, 595 _In_ DWORD dwCapabilities); 596 597 _Check_return_ 598 HRESULT 599 WINAPI CoCopyProxy( 600 _In_ IUnknown *pProxy, 601 _Outptr_ IUnknown **ppCopy); 602 603 _Check_return_ HRESULT WINAPI CoImpersonateClient(void); 604 605 _Check_return_ 606 HRESULT 607 WINAPI 608 CoQueryClientBlanket( 609 _Out_opt_ DWORD *pAuthnSvc, 610 _Out_opt_ DWORD *pAuthzSvc, 611 _Outptr_opt_ OLECHAR **pServerPrincName, 612 _Out_opt_ DWORD *pAuthnLevel, 613 _Out_opt_ DWORD *pImpLevel, 614 _Outptr_opt_ RPC_AUTHZ_HANDLE *pPrivs, 615 _Inout_opt_ DWORD *pCapabilities); 616 617 _Check_return_ HRESULT WINAPI CoRevertToSelf(void); 618 619 /* misc */ 620 621 _Check_return_ 622 HRESULT 623 WINAPI 624 CoGetTreatAsClass( 625 _In_ REFCLSID clsidOld, 626 _Out_ LPCLSID pClsidNew); 627 628 _Check_return_ 629 HRESULT 630 WINAPI 631 CoTreatAsClass( 632 _In_ REFCLSID clsidOld, 633 _In_ REFCLSID clsidNew); 634 635 HRESULT 636 WINAPI 637 CoAllowSetForegroundWindow( 638 _In_ IUnknown *pUnk, 639 _In_opt_ LPVOID lpvReserved); 640 641 _Check_return_ 642 HRESULT 643 WINAPI 644 CoGetObjectContext( 645 _In_ REFIID riid, 646 _Outptr_ LPVOID *ppv); 647 648 _Check_return_ 649 HRESULT 650 WINAPI 651 CoRegisterInitializeSpy( 652 _In_ IInitializeSpy *spy, 653 _Out_ ULARGE_INTEGER *cookie); 654 655 _Check_return_ 656 HRESULT 657 WINAPI 658 CoRevokeInitializeSpy( 659 _In_ ULARGE_INTEGER cookie); 660 661 _Check_return_ HRESULT WINAPI CoCreateGuid(_Out_ GUID *pguid); 662 BOOL WINAPI CoIsOle1Class(_In_ REFCLSID rclsid); 663 664 BOOL 665 WINAPI 666 CoDosDateTimeToFileTime( 667 _In_ WORD nDosDate, 668 _In_ WORD nDosTime, 669 _Out_ FILETIME *lpFileTime); 670 671 BOOL 672 WINAPI 673 CoFileTimeToDosDateTime( 674 _In_ FILETIME *lpFileTime, 675 _Out_ WORD *lpDosDate, 676 _Out_ WORD *lpDosTime); 677 678 HRESULT WINAPI CoFileTimeNow(_Out_ FILETIME *lpFileTime); 679 680 _Check_return_ 681 HRESULT 682 WINAPI 683 CoRegisterMessageFilter( 684 _In_opt_ LPMESSAGEFILTER lpMessageFilter, 685 _Outptr_opt_result_maybenull_ LPMESSAGEFILTER *lplpMessageFilter); 686 687 HRESULT 688 WINAPI 689 CoRegisterChannelHook( 690 _In_ REFGUID ExtensionGuid, 691 _In_ IChannelHook *pChannelHook); 692 693 typedef enum tagCOWAIT_FLAGS 694 { 695 COWAIT_DEFAULT = 0x00000000, 696 COWAIT_WAITALL = 0x00000001, 697 COWAIT_ALERTABLE = 0x00000002, 698 COWAIT_INPUTAVAILABLE = 0x00000004 699 } COWAIT_FLAGS; 700 701 _Check_return_ 702 HRESULT 703 WINAPI 704 CoWaitForMultipleHandles( 705 _In_ DWORD dwFlags, 706 _In_ DWORD dwTimeout, 707 _In_ ULONG cHandles, 708 _In_reads_(cHandles) LPHANDLE pHandles, 709 _Out_ LPDWORD lpdwindex); 710 711 /***************************************************************************** 712 * GUID API 713 */ 714 715 _Check_return_ 716 HRESULT 717 WINAPI 718 StringFromCLSID( 719 _In_ REFCLSID id, 720 _Outptr_ LPOLESTR*); 721 722 _Check_return_ 723 HRESULT 724 WINAPI 725 CLSIDFromString( 726 _In_ LPCOLESTR, 727 _Out_ LPCLSID); 728 729 _Check_return_ 730 HRESULT 731 WINAPI 732 CLSIDFromProgID( 733 _In_ LPCOLESTR progid, 734 _Out_ LPCLSID riid); 735 736 _Check_return_ 737 HRESULT 738 WINAPI 739 ProgIDFromCLSID( 740 _In_ REFCLSID clsid, 741 _Outptr_ LPOLESTR *lplpszProgID); 742 743 _Check_return_ 744 INT 745 WINAPI 746 StringFromGUID2( 747 _In_ REFGUID id, 748 _Out_writes_to_(cmax, return) LPOLESTR str, 749 _In_ INT cmax); 750 751 _Check_return_ 752 HRESULT 753 WINAPI 754 IIDFromString( 755 _In_ LPCOLESTR lpsz, 756 _Out_ LPIID lpiid); 757 758 /***************************************************************************** 759 * COM Server dll - exports 760 */ 761 762 _Check_return_ 763 HRESULT 764 WINAPI 765 DllGetClassObject( 766 _In_ REFCLSID rclsid, 767 _In_ REFIID riid, 768 _Outptr_ LPVOID *ppv) DECLSPEC_HIDDEN; 769 770 HRESULT WINAPI DllCanUnloadNow(void) DECLSPEC_HIDDEN; 771 772 /* shouldn't be here, but is nice for type checking */ 773 #ifdef __WINESRC__ 774 HRESULT WINAPI DllRegisterServer(void) DECLSPEC_HIDDEN; 775 HRESULT WINAPI DllUnregisterServer(void) DECLSPEC_HIDDEN; 776 #endif 777 778 779 /***************************************************************************** 780 * Data Object 781 */ 782 783 HRESULT 784 WINAPI 785 CreateDataAdviseHolder( 786 _Outptr_ LPDATAADVISEHOLDER *ppDAHolder); 787 788 HRESULT 789 WINAPI 790 CreateDataCache( 791 _In_opt_ LPUNKNOWN pUnkOuter, 792 _In_ REFCLSID rclsid, 793 _In_ REFIID iid, 794 _Out_ LPVOID *ppv); 795 796 /***************************************************************************** 797 * Moniker API 798 */ 799 800 _Check_return_ 801 HRESULT 802 WINAPI 803 BindMoniker( 804 _In_ LPMONIKER pmk, 805 _In_ DWORD grfOpt, 806 _In_ REFIID iidResult, 807 _Outptr_ LPVOID *ppvResult); 808 809 _Check_return_ 810 HRESULT 811 WINAPI 812 CoGetObject( 813 _In_ LPCWSTR pszName, 814 _In_opt_ BIND_OPTS *pBindOptions, 815 _In_ REFIID riid, 816 _Outptr_ void **ppv); 817 818 _Check_return_ HRESULT WINAPI CreateAntiMoniker(_Outptr_ LPMONIKER *ppmk); 819 820 _Check_return_ 821 HRESULT 822 WINAPI 823 CreateBindCtx( 824 _In_ DWORD reserved, 825 _Outptr_ LPBC *ppbc); 826 827 _Check_return_ 828 HRESULT 829 WINAPI 830 CreateClassMoniker( 831 _In_ REFCLSID rclsid, 832 _Outptr_ LPMONIKER *ppmk); 833 834 _Check_return_ 835 HRESULT 836 WINAPI 837 CreateFileMoniker( 838 _In_ LPCOLESTR lpszPathName, 839 _Outptr_ LPMONIKER *ppmk); 840 841 _Check_return_ 842 HRESULT 843 WINAPI 844 CreateGenericComposite( 845 _In_opt_ LPMONIKER pmkFirst, 846 _In_opt_ LPMONIKER pmkRest, 847 _Outptr_ LPMONIKER *ppmkComposite); 848 849 _Check_return_ 850 HRESULT 851 WINAPI 852 CreateItemMoniker( 853 _In_ LPCOLESTR lpszDelim, 854 _In_ LPCOLESTR lpszItem, 855 _Outptr_ LPMONIKER *ppmk); 856 857 _Check_return_ 858 HRESULT 859 WINAPI 860 CreateObjrefMoniker( 861 _In_opt_ LPUNKNOWN punk, 862 _Outptr_ LPMONIKER *ppmk); 863 864 _Check_return_ 865 HRESULT 866 WINAPI 867 CreatePointerMoniker( 868 _In_opt_ LPUNKNOWN punk, 869 _Outptr_ LPMONIKER *ppmk); 870 871 _Check_return_ 872 HRESULT 873 WINAPI 874 GetClassFile( 875 _In_ LPCOLESTR filePathName, 876 _Out_ CLSID *pclsid); 877 878 _Check_return_ 879 HRESULT 880 WINAPI 881 GetRunningObjectTable( 882 _In_ DWORD reserved, 883 _Outptr_ LPRUNNINGOBJECTTABLE *pprot); 884 885 _Check_return_ 886 HRESULT 887 WINAPI 888 MkParseDisplayName( 889 _In_ LPBC pbc, 890 _In_ LPCOLESTR szUserName, 891 _Out_ ULONG *pchEaten, 892 _Outptr_ LPMONIKER *ppmk); 893 894 _Check_return_ 895 HRESULT 896 WINAPI 897 MonikerCommonPrefixWith( 898 _In_ IMoniker *pmkThis, 899 _In_ IMoniker *pmkOther, 900 _Outptr_ IMoniker **ppmkCommon); 901 902 _Check_return_ 903 HRESULT 904 WINAPI 905 MonikerRelativePathTo( 906 _In_ LPMONIKER pmkSrc, 907 _In_ LPMONIKER pmkDest, 908 _Outptr_ LPMONIKER *ppmkRelPath, 909 _In_ BOOL dwReserved); 910 911 /***************************************************************************** 912 * Storage API 913 */ 914 #define STGM_DIRECT 0x00000000 915 #define STGM_TRANSACTED 0x00010000 916 #define STGM_SIMPLE 0x08000000 917 #define STGM_READ 0x00000000 918 #define STGM_WRITE 0x00000001 919 #define STGM_READWRITE 0x00000002 920 #define STGM_SHARE_DENY_NONE 0x00000040 921 #define STGM_SHARE_DENY_READ 0x00000030 922 #define STGM_SHARE_DENY_WRITE 0x00000020 923 #define STGM_SHARE_EXCLUSIVE 0x00000010 924 #define STGM_PRIORITY 0x00040000 925 #define STGM_DELETEONRELEASE 0x04000000 926 #define STGM_CREATE 0x00001000 927 #define STGM_CONVERT 0x00020000 928 #define STGM_FAILIFTHERE 0x00000000 929 #define STGM_NOSCRATCH 0x00100000 930 #define STGM_NOSNAPSHOT 0x00200000 931 #define STGM_DIRECT_SWMR 0x00400000 932 933 #define STGFMT_STORAGE 0 934 #define STGFMT_FILE 3 935 #define STGFMT_ANY 4 936 #define STGFMT_DOCFILE 5 937 938 typedef struct tagSTGOPTIONS 939 { 940 USHORT usVersion; 941 USHORT reserved; 942 ULONG ulSectorSize; 943 const WCHAR* pwcsTemplateFile; 944 } STGOPTIONS; 945 946 _Check_return_ 947 HRESULT 948 WINAPI 949 StringFromIID( 950 _In_ REFIID rclsid, 951 _Outptr_ LPOLESTR *lplpsz); 952 953 _Check_return_ 954 HRESULT 955 WINAPI 956 StgCreateDocfile( 957 _In_opt_ _Null_terminated_ LPCOLESTR pwcsName, 958 _In_ DWORD grfMode, 959 _Reserved_ DWORD reserved, 960 _Outptr_ IStorage **ppstgOpen); 961 962 _Check_return_ 963 HRESULT 964 WINAPI 965 StgCreateStorageEx( 966 _In_opt_ _Null_terminated_ const WCHAR*, 967 _In_ DWORD, 968 _In_ DWORD, 969 _In_ DWORD, 970 _Inout_opt_ STGOPTIONS*, 971 _In_opt_ void*, 972 _In_ REFIID, 973 _Outptr_ void**); 974 975 _Check_return_ 976 HRESULT 977 WINAPI 978 StgIsStorageFile( 979 _In_ _Null_terminated_ LPCOLESTR fn); 980 981 _Check_return_ 982 HRESULT 983 WINAPI 984 StgIsStorageILockBytes( 985 _In_ ILockBytes *plkbyt); 986 987 _Check_return_ 988 HRESULT 989 WINAPI 990 StgOpenStorage( 991 _In_opt_ _Null_terminated_ const OLECHAR *pwcsName, 992 _In_opt_ IStorage *pstgPriority, 993 _In_ DWORD grfMode, 994 _In_opt_z_ SNB snbExclude, 995 _In_ DWORD reserved, 996 _Outptr_ IStorage **ppstgOpen); 997 998 _Check_return_ 999 HRESULT 1000 WINAPI 1001 StgOpenStorageEx( 1002 _In_ _Null_terminated_ const WCHAR *pwcwName, 1003 _In_ DWORD grfMode, 1004 _In_ DWORD stgfmt, 1005 _In_ DWORD grfAttrs, 1006 _Inout_opt_ STGOPTIONS *pStgOptions, 1007 _In_opt_ void *reserved, 1008 _In_ REFIID riid, 1009 _Outptr_ void **ppObjectOpen); 1010 1011 _Check_return_ 1012 HRESULT 1013 WINAPI 1014 StgCreateDocfileOnILockBytes( 1015 _In_ ILockBytes *plkbyt, 1016 _In_ DWORD grfMode, 1017 _In_ DWORD reserved, 1018 _Outptr_ IStorage **ppstgOpen); 1019 1020 _Check_return_ 1021 HRESULT 1022 WINAPI 1023 StgOpenStorageOnILockBytes( 1024 _In_ ILockBytes *plkbyt, 1025 _In_opt_ IStorage *pstgPriority, 1026 _In_ DWORD grfMode, 1027 _In_opt_z_ SNB snbExclude, 1028 _Reserved_ DWORD reserved, 1029 _Outptr_ IStorage **ppstgOpen); 1030 1031 _Check_return_ 1032 HRESULT 1033 WINAPI 1034 StgSetTimes( 1035 _In_ _Null_terminated_ OLECHAR const *lpszName, 1036 _In_opt_ FILETIME const *pctime, 1037 _In_opt_ FILETIME const *patime, 1038 _In_opt_ FILETIME const *pmtime); 1039 1040 #ifdef __cplusplus 1041 } 1042 #endif 1043 1044 #ifndef __WINESRC__ 1045 # include <urlmon.h> 1046 #endif 1047 #include <propidl.h> 1048 1049 #ifndef __WINESRC__ 1050 1051 #define FARSTRUCT 1052 #define HUGEP 1053 1054 #define WINOLEAPI STDAPI 1055 #define WINOLEAPI_(type) STDAPI_(type) 1056 1057 #endif /* __WINESRC__ */ 1058 1059 #endif /* _OBJBASE_H_ */ 1060