/*
* Copyright (C) 1998-1999 Francois Gouget
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Oracle elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#include <rpc.h>
#include <rpcndr.h>
#ifndef _OBJBASE_H_
#define _OBJBASE_H_
/*****************************************************************************
* Macros to define a COM interface
*/
/*
* The goal of the following set of definitions is to provide a way to use the same
* header file definitions to provide both a C interface and a C++ object oriented
* interface to COM interfaces. The type of interface is selected automatically
* depending on the language but it is always possible to get the C interface in C++
* by defining CINTERFACE.
*
* It is based on the following assumptions:
* - all COM interfaces derive from IUnknown, this should not be a problem.
* - the header file only defines the interface, the actual fields are defined
* separately in the C file implementing the interface.
*
* The natural approach to this problem would be to make sure we get a C++ class and
* virtual methods in C++ and a structure with a table of pointer to functions in C.
* Unfortunately the layout of the virtual table is compiler specific, the layout of
* g++ virtual tables is not the same as that of an egcs virtual table which is not the
* same as that generated by Visual C+. There are workarounds to make the virtual tables
* compatible via padding but unfortunately the one which is imposed to the WINE emulator
* by the Windows binaries, i.e. the Visual C++ one, is the most compact of all.
*
* So the solution I finally adopted does not use virtual tables. Instead I use inline
* non virtual methods that dereference the method pointer themselves and perform the call.
*
* Let's take Direct3D as an example:
*
* #define INTERFACE IDirect3D
* DECLARE_INTERFACE_(IDirect3D,IUnknown)
* {
* // *** IUnknown methods *** //
* STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID, void**) PURE;
* STDMETHOD_(ULONG,AddRef)(THIS) PURE;
* STDMETHOD_(ULONG,Release)(THIS) PURE;
* // *** IDirect3D methods *** //
* STDMETHOD(Initialize)(THIS_ REFIID) PURE;
* STDMETHOD(EnumDevices)(THIS_ LPD3DENUMDEVICESCALLBACK, LPVOID) PURE;
* STDMETHOD(CreateLight)(THIS_ LPDIRECT3DLIGHT *, IUnknown *) PURE;
* STDMETHOD(CreateMaterial)(THIS_ LPDIRECT3DMATERIAL *, IUnknown *) PURE;
* STDMETHOD(CreateViewport)(THIS_ LPDIRECT3DVIEWPORT *, IUnknown *) PURE;
* STDMETHOD(FindDevice)(THIS_ LPD3DFINDDEVICESEARCH, LPD3DFINDDEVICERESULT) PURE;
* };
* #undef INTERFACE
*
* #ifdef COBJMACROS
* // *** IUnknown methods *** //
* #define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
* #define IDirect3D_AddRef(p) (p)->lpVtbl->AddRef(p)
* #define IDirect3D_Release(p) (p)->lpVtbl->Release(p)
* // *** IDirect3D methods *** //
* #define IDirect3D_Initialize(p,a) (p)->lpVtbl->Initialize(p,a)
* #define IDirect3D_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevice(p,a,b)
* #define IDirect3D_CreateLight(p,a,b) (p)->lpVtbl->CreateLight(p,a,b)
* #define IDirect3D_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial(p,a,b)
* #define IDirect3D_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport(p,a,b)
* #define IDirect3D_FindDevice(p,a,b) (p)->lpVtbl->FindDevice(p,a,b)
* #endif
*
* Comments:
* - The INTERFACE macro is used in the STDMETHOD macros to define the type of the 'this'
* pointer. Defining this macro here saves us the trouble of having to repeat the interface
* name everywhere. Note however that because of the way macros work, a macro like STDMETHOD
* cannot use 'INTERFACE##_VTABLE' because this would give 'INTERFACE_VTABLE' and not
* 'IDirect3D_VTABLE'.
* - The DECLARE_INTERFACE declares all the structures necessary for the interface. We have to
* explicitly use the interface name for macro expansion reasons again. It defines the list of
* methods that are inheritable from this interface. It must be written manually (rather than
* using a macro to generate the equivalent code) to avoid macro recursion (which compilers
* don't like). It must start with the methods definition of the parent interface so that
* method inheritance works properly.
* - The 'undef INTERFACE' is here to remind you that using INTERFACE in the following macros
* will not work.
* - Finally the set of 'IDirect3D_Xxx' macros is a standard set of macros defined to ease access
* to the interface methods in C. Unfortunately I don't see any way to avoid having to duplicate
* the inherited method definitions there. This time I could have used a trick to use only one
* macro whatever the number of parameters but I preferred to have it work the same way as above.
* - You probably have noticed that we don't define the fields we need to actually implement this
* interface: reference count, pointer to other resources and miscellaneous fields. That's
* because these interfaces are just that: interfaces. They may be implemented more than once, in
* different contexts and sometimes not even in Wine. Thus it would not make sense to impose
* that the interface contains some specific fields.
*
*
* In C this gives:
* typedef struct IDirect3DVtbl IDirect3DVtbl;
* struct IDirect3D {
* IDirect3DVtbl* lpVtbl;
* };
* struct IDirect3DVtbl {
* HRESULT (*QueryInterface)(IDirect3D* me, REFIID riid, LPVOID* ppvObj);
* ULONG (*AddRef)(IDirect3D* me);
* ULONG (*Release)(IDirect3D* me);
* HRESULT (*Initialize)(IDirect3D* me, REFIID a);
* HRESULT (*EnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
* HRESULT (*CreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
* HRESULT (*CreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
* HRESULT (*CreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
* HRESULT (*FindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
* };
*
* #ifdef COBJMACROS
* // *** IUnknown methods *** //
* #define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
* #define IDirect3D_AddRef(p) (p)->lpVtbl->AddRef(p)
* #define IDirect3D_Release(p) (p)->lpVtbl->Release(p)
* // *** IDirect3D methods *** //
* #define IDirect3D_Initialize(p,a) (p)->lpVtbl->Initialize(p,a)
* #define IDirect3D_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevice(p,a,b)
* #define IDirect3D_CreateLight(p,a,b) (p)->lpVtbl->CreateLight(p,a,b)
* #define IDirect3D_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial(p,a,b)
* #define IDirect3D_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport(p,a,b)
* #define IDirect3D_FindDevice(p,a,b) (p)->lpVtbl->FindDevice(p,a,b)
* #endif
*
* Comments:
* the user needs to know to use the interface. Of course the structure we will define to
* implement this interface will have more fields but the first one will match this pointer.
* - The code generated by DECLARE_INTERFACE defines both the structure representing the interface and
* the structure for the jump table.
* - Each method is declared as a pointer to function field in the jump table. The implementation
* will fill this jump table with appropriate values, probably using a static variable, and
* initialize the lpVtbl field to point to this variable.
* - The IDirect3D_Xxx macros then just derefence the lpVtbl pointer and use the function pointer
* corresponding to the macro name. This emulates the behavior of a virtual table and should be
* just as fast.
* - This C code should be quite compatible with the Windows headers both for code that uses COM
* interfaces and for code implementing a COM interface.
*
*
* And in C++ (with gcc's g++):
*
* typedef struct IDirect3D: public IUnknown {
* virtual HRESULT Initialize(REFIID a) = 0;
* virtual HRESULT EnumDevices(LPD3DENUMDEVICESCALLBACK a, LPVOID b) = 0;
* virtual HRESULT CreateLight(LPDIRECT3DLIGHT* a, IUnknown* b) = 0;
* virtual HRESULT CreateMaterial(LPDIRECT3DMATERIAL* a, IUnknown* b) = 0;
* virtual HRESULT CreateViewport(LPDIRECT3DVIEWPORT* a, IUnknown* b) = 0;
* virtual HRESULT FindDevice(LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b) = 0;
* };
*
* Comments:
* - Of course in C++ we use inheritance so that we don't have to duplicate the method definitions.
* - Finally there is no IDirect3D_Xxx macro. These are not needed in C++ unless the CINTERFACE
* macro is defined in which case we would not be here.
*
*
* Implementing a COM interface.
*
* This continues the above example. This example assumes that the implementation is in C.
*
* typedef struct IDirect3DImpl {
* void* lpVtbl;
* // ...
*
* } IDirect3DImpl;
*
* static IDirect3DVtbl d3dvt;
*
* // implement the IDirect3D methods here
*
* int IDirect3D_QueryInterface(IDirect3D* me)
* {
* IDirect3DImpl *This = (IDirect3DImpl *)me;
* // ...
* }
*
* // ...
*
* static IDirect3DVtbl d3dvt = {
* IDirect3D_QueryInterface,
* IDirect3D_Add,
* IDirect3D_Add2,
* IDirect3D_Initialize,
* IDirect3D_SetWidth
* };
*
* Comments:
* - We first define what the interface really contains. This is the IDirect3DImpl structure. The
* first field must of course be the virtual table pointer. Everything else is free.
* - Then we predeclare our static virtual table variable, we will need its address in some
* methods to initialize the virtual table pointer of the returned interface objects.
* - Then we implement the interface methods. To match what has been declared in the header file
* they must take a pointer to an IDirect3D structure and we must cast it to an IDirect3DImpl so
* that we can manipulate the fields.
* - Finally we initialize the virtual table.
*/
#if defined(__cplusplus) && !defined(CINTERFACE)
/* C++ interface */
#define PURE = 0
#define THIS_
#define THIS void
#define interface struct
#define DECLARE_INTERFACE_IID_(iface, ibase, iid) interface DECLSPEC_UUID(iid) DECLSPEC_NOVTABLE iface : public ibase
#define BEGIN_INTERFACE
#define END_INTERFACE
#else /* __cplusplus && !CINTERFACE */
/* C interface */
#define PURE
#define interface struct
#ifdef __WINESRC__
#define CONST_VTABLE
#endif
#ifdef CONST_VTABLE
#define CONST_VTBL const
#else
#define CONST_VTBL
#endif
#define BEGIN_INTERFACE
#define END_INTERFACE
#endif /* __cplusplus && !CINTERFACE */
#ifndef __IRpcStubBuffer_FWD_DEFINED__
#define __IRpcStubBuffer_FWD_DEFINED__
#endif
#endif
#ifndef RC_INVOKED
/* For compatibility only, at least for now */
#include <stdlib.h>
#endif
#include <wtypes.h>
#include <unknwn.h>
#include <objidl.h>
#include <guiddef.h>
#ifndef INITGUID
#include <cguid.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef NONAMELESSSTRUCT
#else
#endif
/*****************************************************************************
* Standard API
*/
typedef enum tagCOINIT
{
} COINIT;
void WINAPI CoUninitialize(void);
void WINAPI CoFreeAllLibraries(void);
void WINAPI CoFreeUnusedLibraries(void);
HRESULT WINAPI CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv);
HRESULT WINAPI CoGetInstanceFromFile(COSERVERINFO* pServerInfo, CLSID* pClsid, IUnknown* punkOuter, DWORD dwClsCtx, DWORD grfMode, OLECHAR* pwszName, DWORD dwCount, MULTI_QI* pResults);
HRESULT WINAPI CoGetInstanceFromIStorage(COSERVERINFO* pServerInfo, CLSID* pClsid, IUnknown* punkOuter, DWORD dwClsCtx, IStorage* pstg, DWORD dwCount, MULTI_QI* pResults);
/* class registration flags; passed to CoRegisterClassObject */
typedef enum tagREGCLS
{
REGCLS_SINGLEUSE = 0,
} REGCLS;
HRESULT WINAPI CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo, REFIID iid, LPVOID *ppv);
HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid,LPUNKNOWN pUnk,DWORD dwClsContext,DWORD flags,LPDWORD lpdwRegister);
/* marshalling */
HRESULT WINAPI CoGetMarshalSizeMax(ULONG* pulSize, REFIID riid, LPUNKNOWN pUnk, DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags);
HRESULT WINAPI CoGetStandardMarshal(REFIID riid, LPUNKNOWN pUnk, DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags, LPMARSHAL* ppMarshal);
HRESULT WINAPI CoMarshalInterface(LPSTREAM pStm, REFIID riid, LPUNKNOWN pUnk, DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags);
/* security */
HRESULT WINAPI CoInitializeSecurity(PSECURITY_DESCRIPTOR pSecDesc, LONG cAuthSvc, SOLE_AUTHENTICATION_SERVICE* asAuthSvc, void* pReserved1, DWORD dwAuthnLevel, DWORD dwImpLevel, void* pReserved2, DWORD dwCapabilities, void* pReserved3);
HRESULT WINAPI CoQueryAuthenticationServices(DWORD* pcAuthSvc, SOLE_AUTHENTICATION_SERVICE** asAuthSvc);
HRESULT WINAPI CoQueryProxyBlanket(IUnknown* pProxy, DWORD* pwAuthnSvc, DWORD* pAuthzSvc, OLECHAR** pServerPrincName, DWORD* pAuthnLevel, DWORD* pImpLevel, RPC_AUTH_IDENTITY_HANDLE* pAuthInfo, DWORD* pCapabilities);
HRESULT WINAPI CoSetProxyBlanket(IUnknown* pProxy, DWORD dwAuthnSvc, DWORD dwAuthzSvc, OLECHAR* pServerPrincName, DWORD dwAuthnLevel, DWORD dwImpLevel, RPC_AUTH_IDENTITY_HANDLE pAuthInfo, DWORD dwCapabilities);
HRESULT WINAPI CoQueryClientBlanket(DWORD* pAuthnSvc, DWORD* pAuthzSvc, OLECHAR** pServerPrincName, DWORD* pAuthnLevel, DWORD* pImpLevel, RPC_AUTHZ_HANDLE* pPrivs, DWORD* pCapabilities);
/* misc */
HRESULT WINAPI CoRegisterMessageFilter(LPMESSAGEFILTER lpMessageFilter,LPMESSAGEFILTER *lplpMessageFilter);
typedef enum tagCOWAIT_FLAGS
{
} COWAIT_FLAGS;
HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags,DWORD dwTimeout,ULONG cHandles,LPHANDLE pHandles,LPDWORD lpdwindex);
/*****************************************************************************
* GUID API
*/
/*****************************************************************************
* COM Server dll - exports
*/
/* shouldn't be here, but is nice for type checking */
#ifdef __WINESRC__
#endif
/*****************************************************************************
* Data Object
*/
/*****************************************************************************
* Moniker API
*/
HRESULT WINAPI CreateGenericComposite(LPMONIKER pmkFirst, LPMONIKER pmkRest, LPMONIKER* ppmkComposite);
HRESULT WINAPI MkParseDisplayName(LPBC pbc, LPCOLESTR szUserName, ULONG * pchEaten, LPMONIKER * ppmk);
HRESULT WINAPI MonikerRelativePathTo(LPMONIKER pmkSrc, LPMONIKER pmkDest, LPMONIKER * ppmkRelPath, BOOL dwReserved);
/*****************************************************************************
* Storage API
*/
#define STGFMT_STORAGE 0
typedef struct tagSTGOPTIONS
{
} STGOPTIONS;
HRESULT WINAPI StgCreateDocfile(LPCOLESTR pwcsName,DWORD grfMode,DWORD reserved,IStorage **ppstgOpen);
HRESULT WINAPI StgOpenStorage(const OLECHAR* pwcsName,IStorage* pstgPriority,DWORD grfMode,SNB snbExclude,DWORD reserved,IStorage**ppstgOpen);
HRESULT WINAPI StgOpenStorageEx(const WCHAR* pwcwName,DWORD grfMode,DWORD stgfmt,DWORD grfAttrs,STGOPTIONS *pStgOptions, void *reserved, REFIID riid, void **ppObjectOpen);
HRESULT WINAPI StgCreateDocfileOnILockBytes(ILockBytes *plkbyt,DWORD grfMode, DWORD reserved, IStorage** ppstgOpen);
HRESULT WINAPI StgOpenStorageOnILockBytes(ILockBytes *plkbyt, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen);
HRESULT WINAPI StgSetTimes( OLECHAR const *lpszName, FILETIME const *pctime, FILETIME const *patime, FILETIME const *pmtime);
#ifdef __cplusplus
}
#endif
#ifndef __WINESRC__
# include <urlmon.h>
#endif
#include <propidl.h>
#ifndef __WINESRC__
#define FARSTRUCT
#define HUGEP
#endif /* __WINESRC__ */
#endif /* _OBJBASE_H_ */