//+-------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (c) Microsoft Corporation. All rights reserved.
//
//  File: wtypes.idl
//
//  Contents: This interface definition contains typedefs for remotable
//            data types.
//
//  History:  09-May-96  MikeHill  Updated VARENUM comments.
//            22-May-96  MikeHill  Added FMTID defintions/macros.
//            06-Jun-96  MikeHill  Added CBPCLIPDATA macro.
//
//--------------------------------------------------------------------------

cpp_quote("//+-------------------------------------------------------------------------")
cpp_quote("//")
cpp_quote("//  Microsoft Windows")
cpp_quote("//  Copyright (c) Microsoft Corporation. All rights reserved.")
cpp_quote("//")
cpp_quote("//--------------------------------------------------------------------------")
cpp_quote("#if ( _MSC_VER >= 1020 )")
cpp_quote("#pragma once")
cpp_quote("#endif")

//
// Import definitions of the base types related to the 64b porting effort.
//
import "basetsd.h";
import "guiddef.h";

[ uuid(D3980A60-910C-1068-9341-00DD010F2F1C),
  version(0.1), pointer_default(unique) ]

interface IWinTypes
{

typedef struct tagRemHGLOBAL
{
        long fNullHGlobal;
        unsigned long cbData;
        [size_is(cbData)] byte data[];
} RemHGLOBAL;

typedef struct tagRemHMETAFILEPICT
{
        long        mm;
        long        xExt;
        long        yExt;
        unsigned long cbData;
        [size_is(cbData)] byte data[];
} RemHMETAFILEPICT;


typedef struct tagRemHENHMETAFILE
{
        unsigned long cbData;
        [size_is(cbData)] byte data[];
} RemHENHMETAFILE;

typedef struct tagRemHBITMAP
{
        unsigned long cbData;
        [size_is(cbData)] byte data[];
} RemHBITMAP;

typedef struct tagRemHPALETTE
{
        unsigned long cbData;
        [size_is(cbData)] byte data[];
} RemHPALETTE;

typedef struct tagRemBRUSH
{
        unsigned long cbData;
        [size_is(cbData)] byte data[];
} RemHBRUSH;

cpp_quote("#if !defined(_WIN32) && !defined(_MPPC_)" )
cpp_quote("// The following code is for Win16 only")

cpp_quote("#ifndef WINAPI          // If not included with 3.1 headers...")

cpp_quote("#define FAR             _far")
cpp_quote("#define PASCAL          _pascal")
cpp_quote("#define CDECL           _cdecl")

cpp_quote("#define VOID            void")
cpp_quote("#define WINAPI      FAR PASCAL")
cpp_quote("#define CALLBACK    FAR PASCAL")


cpp_quote("#ifndef FALSE")
cpp_quote("#define FALSE 0")
cpp_quote("#define TRUE 1")
cpp_quote("#endif // !FALSE")

cpp_quote("#ifndef _BYTE_DEFINED")
cpp_quote("#define _BYTE_DEFINED")
typedef byte BYTE;
cpp_quote("#endif // !_BYTE_DEFINED")

cpp_quote("#ifndef _WORD_DEFINED")
cpp_quote("#define _WORD_DEFINED")
typedef unsigned short WORD;
cpp_quote("#endif // !_WORD_DEFINED")

typedef unsigned int UINT;
typedef int  INT;
typedef long BOOL;

cpp_quote("#ifndef _LONG_DEFINED")
cpp_quote("#define _LONG_DEFINED")
typedef long LONG;
cpp_quote("#endif // !_LONG_DEFINED")

cpp_quote("#ifndef _WPARAM_DEFINED")
cpp_quote("#define _WPARAM_DEFINED")
typedef UINT_PTR WPARAM;
cpp_quote("#endif // _WPARAM_DEFINED")

cpp_quote("#ifndef _DWORD_DEFINED")
cpp_quote("#define _DWORD_DEFINED")
typedef unsigned long DWORD;
cpp_quote("#endif // !_DWORD_DEFINED")

cpp_quote("#ifndef _LPARAM_DEFINED")
cpp_quote("#define _LPARAM_DEFINED")
typedef LONG_PTR LPARAM;
cpp_quote("#endif // !_LPARAM_DEFINED")

cpp_quote("#ifndef _LRESULT_DEFINED")
cpp_quote("#define _LRESULT_DEFINED")
typedef LONG_PTR LRESULT;
cpp_quote("#endif // !_LRESULT_DEFINED")

typedef void * HANDLE;
#define DECLARE_WIREM_HANDLE(name)  \
                             typedef [wire_marshal(wire ## name)] void * name
#define DECLARE_HANDLE(name) typedef void * name

DECLARE_HANDLE(HMODULE);
DECLARE_HANDLE(HINSTANCE);
DECLARE_HANDLE(HRGN);
DECLARE_HANDLE(HTASK);
DECLARE_HANDLE(HKEY);

DECLARE_HANDLE(HDESK);

DECLARE_HANDLE(HMF);
DECLARE_HANDLE(HEMF);

DECLARE_HANDLE(HPEN);
DECLARE_HANDLE(HRSRC);
DECLARE_HANDLE(HSTR);
DECLARE_HANDLE(HWINSTA);
DECLARE_HANDLE(HKL);
DECLARE_HANDLE(HGDIOBJ);

typedef HANDLE HDWP;

cpp_quote("#ifndef _HFILE_DEFINED")
cpp_quote("#define _HFILE_DEFINED")
typedef INT HFILE;      /* Polymorphic with C runtime file handle type */
cpp_quote("#endif // !_HFILE_DEFINED")


cpp_quote("#ifndef _LPWORD_DEFINED")
cpp_quote("#define _LPWORD_DEFINED")
typedef WORD *LPWORD;
cpp_quote("#endif // !_LPWORD_DEFINED")


cpp_quote("#ifndef _LPDWORD_DEFINED")
cpp_quote("#define _LPDWORD_DEFINED")
typedef DWORD *LPDWORD;
cpp_quote("#endif // !_LPDWORD_DEFINED")


typedef char CHAR;
typedef [string] CHAR *LPSTR;
typedef [string] const CHAR *LPCSTR;


cpp_quote("#ifndef _WCHAR_DEFINED")
cpp_quote("#define _WCHAR_DEFINED")
typedef wchar_t WCHAR;
typedef WCHAR   TCHAR;
cpp_quote("#endif // !_WCHAR_DEFINED")

typedef [string] WCHAR *LPWSTR;


typedef [string] TCHAR *LPTSTR;

typedef [string] const WCHAR *LPCWSTR;
typedef [string] const TCHAR *LPCTSTR;


cpp_quote("#ifndef _COLORREF_DEFINED")
cpp_quote("#define _COLORREF_DEFINED")
typedef DWORD COLORREF;
cpp_quote("#endif // !_COLORREF_DEFINED")

cpp_quote("#ifndef _LPCOLORREF_DEFINED")
cpp_quote("#define _LPCOLORREF_DEFINED")
typedef DWORD *LPCOLORREF;
cpp_quote("#endif // !_LPCOLORREF_DEFINED")


typedef HANDLE *LPHANDLE;

//typedefs for remotable types from wingdi.h

typedef struct _RECTL
{
    LONG    left;
    LONG    top;
    LONG    right;
    LONG    bottom;
} RECTL, *PRECTL, *LPRECTL;


typedef struct tagPOINT
{
    LONG  x;
    LONG  y;
} POINT, *PPOINT, *LPPOINT;

typedef struct _POINTL
{
    LONG  x;
    LONG  y;
} POINTL, *PPOINTL;


cpp_quote("#ifndef WIN16")
typedef struct tagSIZE
{
    LONG        cx;
    LONG        cy;
} SIZE, *PSIZE, *LPSIZE;
cpp_quote("#else // WIN16")
cpp_quote("typedef struct tagSIZE")
cpp_quote("{")
cpp_quote("    INT cx;")
cpp_quote("    INT cy;")
cpp_quote("} SIZE, *PSIZE, *LPSIZE;")
cpp_quote("#endif // WIN16")


typedef struct tagSIZEL
{
    LONG cx;
    LONG cy;
} SIZEL, *PSIZEL, *LPSIZEL;


cpp_quote("#endif  //WINAPI")
cpp_quote("#endif  //!WIN32 && !MPPC")


cpp_quote("#ifndef _PALETTEENTRY_DEFINED")
cpp_quote("#define _PALETTEENTRY_DEFINED")

typedef struct tagPALETTEENTRY {
    BYTE        peRed;
    BYTE        peGreen;
    BYTE        peBlue;
    BYTE        peFlags;
} PALETTEENTRY, *PPALETTEENTRY, *LPPALETTEENTRY;

cpp_quote("#endif // !_PALETTEENTRY_DEFINED")

// Logical Palette
cpp_quote("#ifndef _LOGPALETTE_DEFINED")
cpp_quote("#define _LOGPALETTE_DEFINED")

typedef struct tagLOGPALETTE {
    WORD        palVersion;
    WORD        palNumEntries;
    [size_is(palNumEntries)] PALETTEENTRY        palPalEntry[];
} LOGPALETTE, *PLOGPALETTE, *LPLOGPALETTE;

cpp_quote("#endif // !_LOGPALETTE_DEFINED")


cpp_quote("#if defined(_WIN32) && !defined(OLE2ANSI)")

typedef WCHAR                   OLECHAR;
typedef [string] OLECHAR       *LPOLESTR;
typedef [string] const OLECHAR *LPCOLESTR;
cpp_quote("#define OLESTR(str) L##str")

cpp_quote("")
cpp_quote("#else")
cpp_quote("")

cpp_quote("typedef char      OLECHAR;")
cpp_quote("typedef LPSTR     LPOLESTR;")
cpp_quote("typedef LPCSTR    LPCOLESTR;")
cpp_quote("#define OLESTR(str) str")

cpp_quote("#endif")


// This block contains types that are normally defined by the nt sdk in WINDEF.H
// but we need them here for definitions that follow in this file.  If WINDEF.H
// hasn't been included then we need to define them now so that WTYPES.H
// will compile.
cpp_quote("#ifndef _WINDEF_")
typedef const RECTL *LPCRECTL;

typedef void * PVOID, * LPVOID;
typedef float   FLOAT;

typedef struct tagRECT
{
    LONG    left;
    LONG    top;
    LONG    right;
    LONG    bottom;
} RECT, *PRECT, *LPRECT;
typedef const RECT *LPCRECT;

cpp_quote("#endif  //_WINDEF_")


typedef unsigned char   UCHAR;
typedef short           SHORT;
typedef unsigned short  USHORT;
typedef DWORD           ULONG;
typedef double          DOUBLE;

cpp_quote("#ifndef _DWORDLONG_")
typedef unsigned __int64 DWORDLONG;
typedef DWORDLONG *PDWORDLONG;
cpp_quote("#endif // !_DWORDLONG_")

cpp_quote("#ifndef _ULONGLONG_")
typedef __int64 LONGLONG;
typedef unsigned __int64 ULONGLONG;
typedef LONGLONG *PLONGLONG;
typedef ULONGLONG *PULONGLONG;
cpp_quote("#endif // _ULONGLONG_")

// just for local wtypes
cpp_quote("#if 0")

typedef struct _LARGE_INTEGER {
    LONGLONG QuadPart;
} LARGE_INTEGER;

typedef LARGE_INTEGER *PLARGE_INTEGER;

typedef struct _ULARGE_INTEGER {
    ULONGLONG QuadPart;
} ULARGE_INTEGER;

// just for local wtypes
cpp_quote("#endif // 0")


cpp_quote("#ifndef _WINBASE_")

cpp_quote("#ifndef _FILETIME_")
cpp_quote("#define _FILETIME_")
typedef struct _FILETIME
{
    DWORD dwLowDateTime;
    DWORD dwHighDateTime;
} FILETIME, *PFILETIME, *LPFILETIME;
cpp_quote("#endif // !_FILETIME")

cpp_quote("#ifndef _SYSTEMTIME_")
cpp_quote("#define _SYSTEMTIME_")
typedef struct _SYSTEMTIME {
    WORD wYear;
    WORD wMonth;
    WORD wDayOfWeek;
    WORD wDay;
    WORD wHour;
    WORD wMinute;
    WORD wSecond;
    WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;

cpp_quote("#endif // !_SYSTEMTIME")

cpp_quote("#ifndef _SECURITY_ATTRIBUTES_")
cpp_quote("#define _SECURITY_ATTRIBUTES_")
typedef struct _SECURITY_ATTRIBUTES {
    DWORD nLength;
    [size_is(nLength)] LPVOID lpSecurityDescriptor;
    BOOL bInheritHandle;
} SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
cpp_quote("#endif // !_SECURITY_ATTRIBUTES_")

cpp_quote("#ifndef SECURITY_DESCRIPTOR_REVISION")

typedef USHORT SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;

typedef PVOID PSID;     // winnt

typedef struct _ACL {
    UCHAR AclRevision;
    UCHAR Sbz1;
    USHORT AclSize;
    USHORT AceCount;
    USHORT Sbz2;
} ACL;
typedef ACL *PACL;

typedef struct _SECURITY_DESCRIPTOR {
    UCHAR Revision;
    UCHAR Sbz1;
    SECURITY_DESCRIPTOR_CONTROL Control;
    PSID Owner;
    PSID Group;
    PACL Sacl;
    PACL Dacl;
} SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;

cpp_quote("#endif // !SECURITY_DESCRIPTOR_REVISION")

cpp_quote("#endif //_WINBASE_")

typedef struct _COAUTHIDENTITY
{
  [size_is(UserLength+1)] USHORT *      User;
  ULONG                                 UserLength;
  [size_is(DomainLength+1)] USHORT *    Domain;
  ULONG                                 DomainLength;
  [size_is(PasswordLength+1)] USHORT *  Password;
  ULONG                                 PasswordLength;
  ULONG                                 Flags;
} COAUTHIDENTITY;

typedef struct _COAUTHINFO
{
    DWORD               dwAuthnSvc;
    DWORD               dwAuthzSvc;
    LPWSTR              pwszServerPrincName;
    DWORD               dwAuthnLevel;
    DWORD               dwImpersonationLevel;
    COAUTHIDENTITY *    pAuthIdentityData;
    DWORD               dwCapabilities;
} COAUTHINFO;

//
// SCODE, HRESULT
//
//
//  Status values are 32 bit values layed out as follows:
//
//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
//  +-+-----------------------------+-------------------------------+
//  |S|       Facility              |               Code            |
//  +-+-----------------------------+-------------------------------+
//
//  where
//
//      S - is the severity code
//
//          0 - Success
//          1 - Error
//
//
//      Facility - is the facility code
//
//      Code - is the facility's status code
//
// SCODE and HRESULT are mktyplib base types.
//
typedef LONG SCODE;
cpp_quote("#ifndef _HRESULT_DEFINED")
cpp_quote("#define _HRESULT_DEFINED")
#if defined(_STRICT_HRESULT)
typedef struct _HRESULT_STRUCT {
        DWORD Data1;
} HRESULT_STRUCT, *PHRESULT_STRUCT;
typedef PHRESULT_STRUCT HRESULT;
#else // defined(_STRICT_HRESULT)
typedef LONG HRESULT;
#endif // defined(_STRICT_HRESULT)
cpp_quote("#endif // !_HRESULT_DEFINED")

typedef SCODE *PSCODE;

cpp_quote("#ifndef __OBJECTID_DEFINED")
cpp_quote("#define __OBJECTID_DEFINED")
cpp_quote("#define _OBJECTID_DEFINED")
typedef struct _OBJECTID     // NOTE!! Order of structure members is important for OFS
{                            // enumeration.
   GUID Lineage;             // Unique for objects copied from same original and copies of.
   unsigned long Uniquifier; // Random, to provide uniqueness within small set with same
} OBJECTID;                  // lineage id.
cpp_quote("#endif // !_OBJECTID_DEFINED")

//The following typedefs are used internally by MIDL.
cpp_quote("#if 0")
    /* MIDL 2.0+ definitions */
    typedef GUID *REFGUID;
    typedef IID *REFIID;
    typedef CLSID *REFCLSID;
    typedef FMTID *REFFMTID;
cpp_quote("#endif // 0")

/************************* Misc types ***********************************/

// Common typdefs used in API paramaters, gleamed from compobj.h

// memory context values; passed to CoGetMalloc
typedef enum tagMEMCTX
{
    MEMCTX_TASK = 1,            // task (private) memory
    MEMCTX_SHARED = 2,          // shared memory (between processes)
    MEMCTX_MACSYSTEM = 3,       // on the mac, the system heap
    // these are mostly for internal use...
    MEMCTX_UNKNOWN = -1,        // unknown context (when asked about it)
    MEMCTX_SAME = -2,           // same context (as some other pointer)
} MEMCTX;


// For IRunningObjectTable::Register
cpp_quote("#ifndef _ROTFLAGS_DEFINED")
cpp_quote("#define _ROTFLAGS_DEFINED")
cpp_quote("#define ROTFLAGS_REGISTRATIONKEEPSALIVE 0x1")
cpp_quote("#define ROTFLAGS_ALLOWANYCLIENT 0x2")
cpp_quote("#endif // !_ROTFLAGS_DEFINED")

// Maximum size of comparison buffer for IROTData::GetComparisonData
cpp_quote("#ifndef _ROT_COMPARE_MAX_DEFINED")
cpp_quote("#define _ROT_COMPARE_MAX_DEFINED")
cpp_quote("#define ROT_COMPARE_MAX 2048")
cpp_quote("#endif // !_ROT_COMPARE_MAX_DEFINED")


// class context: used to determine what scope and kind of class object to use
// NOTE: this is a bitwise enum
typedef enum tagCLSCTX
{
    CLSCTX_INPROC_SERVER = 0x01,     // server dll (runs in same process as caller)
    CLSCTX_INPROC_HANDLER = 0x02,    // handler dll (runs in same process as caller)
    CLSCTX_LOCAL_SERVER = 0x04,      // server exe (runs on same machine; diff proc)
    CLSCTX_INPROC_SERVER16 = 0x08,   // 16-bit server dll (runs in same process as caller)
    CLSCTX_REMOTE_SERVER = 0x10,     // remote server exe (runs on different machine)
    CLSCTX_INPROC_HANDLER16 = 0x20,  // 16-bit handler dll (runs in same process as caller)
    CLSCTX_RESERVED1 = 0x40,         // formerly INPROC_SERVERX86, deprectated
    CLSCTX_RESERVED2 = 0x80,         // formerly INPROC_HANDLERX86, deprectated
    CLSCTX_RESERVED3 = 0x100,        // formerly ESERVER_HANDLER, deprecated
    CLSCTX_RESERVED4 = 0x200,        // reserved
    CLSCTX_NO_CODE_DOWNLOAD = 0x400, // disallow code download from the Directory Service (if any) or the internet   -rahulth
    CLSCTX_RESERVED5 = 0x800,        // formerly NO_WX86_TRANSLATION, deprecated
    CLSCTX_NO_CUSTOM_MARSHAL = 0x1000,
    CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000,
                                     // allow code download from the Directory Service (if any) or the internet
    CLSCTX_NO_FAILURE_LOG = 0x4000,  // do not log messages about activation failure (should one occur) to Event Log
    CLSCTX_DISABLE_AAA   = 0x8000,   // Disable activate-as-activator capability for this activation only
    CLSCTX_ENABLE_AAA   = 0x10000,   // Enable activate-as-activator capability for this activation only
    CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000    // Begin this activation from the default context of the current apartment
 } CLSCTX;


// marshaling flags; passed to CoMarshalInterface
typedef enum tagMSHLFLAGS
{
    MSHLFLAGS_NORMAL = 0,       // normal marshaling via proxy/stub
    MSHLFLAGS_TABLESTRONG = 1,  // keep object alive; must explicitly release
    MSHLFLAGS_TABLEWEAK = 2,    // doesn't hold object alive; still must release
    MSHLFLAGS_NOPING = 4,       // remote clients dont 'ping' to keep objects alive
    MSHLFLAGS_RESERVED1 = 8,    // reserved
    MSHLFLAGS_RESERVED2 = 16,   // reserved
    MSHLFLAGS_RESERVED3 = 32,   // reserved
    MSHLFLAGS_RESERVED4 = 64    // reserved
} MSHLFLAGS;


// marshal context: determines the destination context of the marshal operation
typedef enum tagMSHCTX
{
    MSHCTX_LOCAL = 0,           // unmarshal context is local (eg.shared memory)
    MSHCTX_NOSHAREDMEM = 1,     // unmarshal context has no shared memory access
    MSHCTX_DIFFERENTMACHINE = 2,// unmarshal context is on a different machine
    MSHCTX_INPROC = 3,          // unmarshal context is on different thread
    MSHCTX_CROSSCTX = 4         // unmarshal context is on different context
} MSHCTX;


//
// Common typedefs for paramaters used in data view API's, gleamed
// from dvobj.h
//

// Data/View aspect; specifies the desired aspect of the object when
// drawing or getting data.
typedef enum tagDVASPECT
{
    DVASPECT_CONTENT = 1,
    DVASPECT_THUMBNAIL = 2,
    DVASPECT_ICON = 4,
    DVASPECT_DOCPRINT = 8
} DVASPECT;

/****** Storage types *************************************************/


/* Storage commit types */
typedef enum tagSTGC
{
    STGC_DEFAULT        = 0,
    STGC_OVERWRITE      = 1,
    STGC_ONLYIFCURRENT  = 2,
    STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 4,
    STGC_CONSOLIDATE    = 8
} STGC;


typedef enum tagSTGMOVE
{
    STGMOVE_MOVE    = 0,
    STGMOVE_COPY    = 1,
    STGMOVE_SHALLOWCOPY = 2
} STGMOVE;

typedef enum tagSTATFLAG
{
    STATFLAG_DEFAULT = 0,
    STATFLAG_NONAME = 1,
    STATFLAG_NOOPEN = 2
} STATFLAG;


typedef [context_handle] void *HCONTEXT;

/****** Critical Section Wrappers ***********************************/


/* if not already picked up from olenls.h */
cpp_quote("#ifndef _LCID_DEFINED")
cpp_quote("#define _LCID_DEFINED")
typedef DWORD LCID;
cpp_quote("#endif // !_LCID_DEFINED")

cpp_quote("#ifndef _LANGID_DEFINED")
cpp_quote("#define _LANGID_DEFINED")
typedef USHORT LANGID;
cpp_quote("#endif // !_LANGID_DEFINED")


// #######################################################################
//
//  User marshal support for Windows data types.

//
//  Frequently used helpers: sized blobs
//
//      Never put [user_marshal] or [wire_marshal] on the helpers directly.
//

// Simple blobs.

typedef struct _BYTE_BLOB {
                        unsigned long   clSize;
    [size_is(clSize)]   byte            abData[];
} BYTE_BLOB;

typedef [unique] BYTE_BLOB * UP_BYTE_BLOB;

typedef struct _WORD_BLOB {
                        unsigned long   clSize;
    [size_is(clSize)]   unsigned short  asData[];
} WORD_BLOB;

typedef [unique] WORD_BLOB * UP_WORD_BLOB;

typedef struct _DWORD_BLOB {
                        unsigned long   clSize;
    [size_is(clSize)]   unsigned long   alData[];
} DWORD_BLOB;

typedef [unique] DWORD_BLOB * UP_DWORD_BLOB;

// Flagged blobs.

typedef struct _FLAGGED_BYTE_BLOB {
                        unsigned long   fFlags;
                        unsigned long   clSize;
    [size_is(clSize)]   byte            abData[];
} FLAGGED_BYTE_BLOB;

typedef [unique] FLAGGED_BYTE_BLOB * UP_FLAGGED_BYTE_BLOB;

typedef struct _FLAGGED_WORD_BLOB {
                        unsigned long   fFlags;
                        unsigned long   clSize;
    [size_is(clSize)]   unsigned short  asData[];
} FLAGGED_WORD_BLOB;

typedef [unique] FLAGGED_WORD_BLOB * UP_FLAGGED_WORD_BLOB;

// Frequently used helpers with sized pointers.

typedef struct _BYTE_SIZEDARR {
                        unsigned long   clSize;
    [size_is(clSize)]   byte     *      pData ;
} BYTE_SIZEDARR;

typedef struct _SHORT_SIZEDARR {
                        unsigned long   clSize;
    [size_is(clSize)]   unsigned short* pData ;
} WORD_SIZEDARR;

typedef struct _LONG_SIZEDARR {
                        unsigned long   clSize;
    [size_is(clSize)]   unsigned long * pData ;
} DWORD_SIZEDARR;

typedef struct _HYPER_SIZEDARR {
                        unsigned long   clSize;
    [size_is(clSize)]   hyper         * pData ;
} HYPER_SIZEDARR;


// #########################################################################
//
//   Constants for the call context
//

const unsigned long WDT_INPROC_CALL   = 0x48746457;
const unsigned long WDT_REMOTE_CALL   = 0x52746457;
const unsigned long WDT_INPROC64_CALL = 0x50746457;


// #########################################################################
//
//  CLIPFORMAT
//

typedef union _userCLIPFORMAT switch(long fContext) u
{
    case WDT_INPROC_CALL:            DWORD     dwValue;
    case WDT_REMOTE_CALL:   [string] wchar_t * pwszName;
} userCLIPFORMAT;

typedef [unique] userCLIPFORMAT *  wireCLIPFORMAT;

typedef [wire_marshal(wireCLIPFORMAT)] WORD  CLIPFORMAT;


// #########################################################################
//
//  Good for most of the gdi handles.

typedef union _GDI_NONREMOTE switch( long fContext ) u
{
    case WDT_INPROC_CALL:   long        hInproc;
    case WDT_REMOTE_CALL:   DWORD_BLOB *hRemote;
} GDI_NONREMOTE;

// #########################################################################
//
//  HGLOBAL
//
// A global may be Null or may be non-NULL with 0 length.

typedef union _userHGLOBAL switch( long fContext ) u
{
    case WDT_INPROC_CALL:   long                    hInproc;
    case WDT_REMOTE_CALL:   FLAGGED_BYTE_BLOB *     hRemote;
    case WDT_INPROC64_CALL: __int64                 hInproc64;
} userHGLOBAL;

typedef [unique] userHGLOBAL       * wireHGLOBAL;

// #########################################################################
//
//  HMETAFILE
//

typedef union _userHMETAFILE switch( long fContext ) u
{
    case WDT_INPROC_CALL:   long            hInproc;
    case WDT_REMOTE_CALL:   BYTE_BLOB *     hRemote;
    case WDT_INPROC64_CALL: __int64         hInproc64;
} userHMETAFILE;

// #########################################################################
//
//  HMETAFILEPICT
//
typedef struct _remoteMETAFILEPICT
{
    long            mm;
    long            xExt;
    long            yExt;
    userHMETAFILE * hMF;
} remoteMETAFILEPICT;

typedef union _userHMETAFILEPICT switch( long fContext ) u
{
    case WDT_INPROC_CALL:   long                hInproc;
    case WDT_REMOTE_CALL:   remoteMETAFILEPICT* hRemote;
    case WDT_INPROC64_CALL: __int64             hInproc64;
} userHMETAFILEPICT;

// #########################################################################
//
//  HENHMETAFILE
//

typedef union _userHENHMETAFILE switch( long fContext ) u
{
    case WDT_INPROC_CALL:   long            hInproc;
    case WDT_REMOTE_CALL:   BYTE_BLOB *     hRemote;
    case WDT_INPROC64_CALL: __int64         hInproc64;
} userHENHMETAFILE;

// #########################################################################
//
//  HBITMAP
//

// RemHBITMAP was just a byte blob, but the whole bitmap structure was copied
// at the beginning of the buffer.

// So, we take BITMAP fields from wingdi.x

typedef struct _userBITMAP
{
    LONG            bmType;
    LONG            bmWidth;
    LONG            bmHeight;
    LONG            bmWidthBytes;
    WORD            bmPlanes;
    WORD            bmBitsPixel;
    ULONG                       cbSize;
    [size_is(cbSize)]   byte    pBuffer[];
} userBITMAP;


typedef union _userHBITMAP switch( long fContext ) u
{
    case WDT_INPROC_CALL:   long            hInproc;
    case WDT_REMOTE_CALL:   userBITMAP *    hRemote;
    case WDT_INPROC64_CALL: __int64         hInproc64;
} userHBITMAP;

// #########################################################################
//
//  HPALETTE
//

// PALETTEENTRY is in wingdi.x, it is a struct with 4 bytes.
// LOGPALETTE   is in wingdi.x, it is a conf struct with paletteentries and
//                                    a version field

typedef union _userHPALETTE switch( long fContext ) u
{
    case WDT_INPROC_CALL:   long            hInproc;
    case WDT_REMOTE_CALL:   LOGPALETTE *    hRemote;
    case WDT_INPROC64_CALL: __int64         hInproc64;
} userHPALETTE;

// #########################################################################
//
//  Handles passed locally as longs.
//

typedef union _RemotableHandle switch( long fContext ) u
{
    case WDT_INPROC_CALL:   long   hInproc;
    case WDT_REMOTE_CALL:   long   hRemote;
} RemotableHandle;

typedef [unique] RemotableHandle * wireHWND;
typedef [unique] RemotableHandle * wireHMENU;
typedef [unique] RemotableHandle * wireHACCEL;
typedef [unique] RemotableHandle * wireHBRUSH;
typedef [unique] RemotableHandle * wireHFONT;
typedef [unique] RemotableHandle * wireHDC;
typedef [unique] RemotableHandle * wireHICON;


cpp_quote("#if 0")
#ifndef _MIDL_DECLARE_WIREM_HANDLE
DECLARE_WIREM_HANDLE( HWND );
DECLARE_WIREM_HANDLE( HMENU );
DECLARE_WIREM_HANDLE( HACCEL );
DECLARE_WIREM_HANDLE( HBRUSH );
DECLARE_WIREM_HANDLE( HFONT );
DECLARE_WIREM_HANDLE( HDC );
DECLARE_WIREM_HANDLE( HICON );
#endif

cpp_quote("#ifndef _HCURSOR_DEFINED")
cpp_quote("#define _HCURSOR_DEFINED")
typedef HICON HCURSOR;      /* HICONs & HCURSORs are polymorphic */
cpp_quote("#endif // !_HCURSOR_DEFINED")

cpp_quote("#endif //0")

cpp_quote("#ifndef _TEXTMETRIC_DEFINED")
cpp_quote("#define _TEXTMETRIC_DEFINED")
typedef struct tagTEXTMETRICW {
    LONG  tmHeight;
    LONG  tmAscent;
    LONG  tmDescent;
    LONG  tmInternalLeading;
    LONG  tmExternalLeading;
    LONG  tmAveCharWidth;
    LONG  tmMaxCharWidth;
    LONG  tmWeight;
    LONG  tmOverhang;
    LONG  tmDigitizedAspectX;
    LONG  tmDigitizedAspectY;
    WCHAR tmFirstChar;
    WCHAR tmLastChar;
    WCHAR tmDefaultChar;
    WCHAR tmBreakChar;
    BYTE  tmItalic;
    BYTE  tmUnderlined;
    BYTE  tmStruckOut;
    BYTE  tmPitchAndFamily;
    BYTE  tmCharSet;
} TEXTMETRICW, *PTEXTMETRICW, *LPTEXTMETRICW;
cpp_quote("#endif // !_TEXTMETRIC_DEFINED")


cpp_quote("#ifndef _WIN32           // The following code is for Win16 only")
cpp_quote("#ifndef WINAPI          // If not included with 3.1 headers...")

// Message structure

typedef struct tagMSG {
    HWND        hwnd;
    UINT        message;
    WPARAM      wParam;
    LPARAM      lParam;
    DWORD       time;
    POINT       pt;
} MSG, *PMSG, *NPMSG, *LPMSG;
cpp_quote("#endif // _WIN32")
cpp_quote("#endif // WINAPI")

typedef [unique] userHBITMAP      * wireHBITMAP;
typedef [unique] userHPALETTE     * wireHPALETTE;
typedef [unique] userHENHMETAFILE * wireHENHMETAFILE;
typedef [unique] userHMETAFILE    * wireHMETAFILE;
typedef [unique] userHMETAFILEPICT* wireHMETAFILEPICT;

cpp_quote("#if 0")
DECLARE_WIREM_HANDLE( HGLOBAL );
typedef HGLOBAL HLOCAL;
DECLARE_WIREM_HANDLE( HBITMAP );
DECLARE_WIREM_HANDLE( HPALETTE );
DECLARE_WIREM_HANDLE( HENHMETAFILE );
DECLARE_WIREM_HANDLE( HMETAFILE );
cpp_quote("#endif //0")

DECLARE_WIREM_HANDLE( HMETAFILEPICT );

}

// #########################################################################
//

cpp_quote("#if ( _MSC_VER >= 800 )")
cpp_quote("#if _MSC_VER >= 1200")
cpp_quote("#pragma warning(push)")
cpp_quote("#endif")
cpp_quote("#pragma warning(disable:4201)")
cpp_quote("#endif")

typedef double DATE;

/* This is a helper struct for use in handling currency. */
cpp_quote("#ifndef _tagCY_DEFINED")
cpp_quote("#define _tagCY_DEFINED")
cpp_quote("#define _CY_DEFINED")

cpp_quote("#if 0")

cpp_quote("/* the following isn't the real definition of CY, but it is */")
cpp_quote("/* what RPC knows how to remote */")
typedef struct tagCY {
    LONGLONG    int64;
} CY;

cpp_quote("#else /* 0 */")

cpp_quote("/* real definition that makes the C++ compiler happy */")
cpp_quote("typedef union tagCY {")
cpp_quote("    struct {")
cpp_quote("#ifdef _MAC")
cpp_quote("        long      Hi;")
cpp_quote("        long Lo;")
cpp_quote("#else")
cpp_quote("        unsigned long Lo;")
cpp_quote("        long      Hi;")
cpp_quote("#endif")
cpp_quote("    };")
cpp_quote("    LONGLONG int64;")
cpp_quote("} CY;")

cpp_quote("#endif /* 0 */")

cpp_quote("#endif /* _tagCY_DEFINED */")

typedef CY *LPCY;

cpp_quote("#if 0 /* _tagDEC_DEFINED */")
cpp_quote("/* The following isn't the real definition of Decimal type, */")
cpp_quote("/* but it is what RPC knows how to remote */")

typedef struct tagDEC {
    USHORT wReserved;
    BYTE  scale;
    BYTE  sign;
    ULONG Hi32;
    ULONGLONG Lo64;
} DECIMAL;

cpp_quote("#else /* _tagDEC_DEFINED */")

cpp_quote("/* real definition that makes the C++ compiler happy */")
cpp_quote("typedef struct tagDEC {")
cpp_quote("    USHORT wReserved;")
cpp_quote("    union {")
cpp_quote("        struct {")
cpp_quote("            BYTE scale;")
cpp_quote("            BYTE sign;")
cpp_quote("        };")
cpp_quote("        USHORT signscale;")
cpp_quote("    };")
cpp_quote("    ULONG Hi32;")
cpp_quote("    union {")
cpp_quote("        struct {")
cpp_quote("#ifdef _MAC")
cpp_quote("            ULONG Mid32;")
cpp_quote("            ULONG Lo32;")
cpp_quote("#else")
cpp_quote("            ULONG Lo32;")
cpp_quote("            ULONG Mid32;")
cpp_quote("#endif")
cpp_quote("        };")
cpp_quote("        ULONGLONG Lo64;")
cpp_quote("    };")
cpp_quote("} DECIMAL;")

cpp_quote("#define DECIMAL_NEG ((BYTE)0x80)")
cpp_quote("#define DECIMAL_SETZERO(dec) \\")
cpp_quote("        {(dec).Lo64 = 0; (dec).Hi32 = 0; (dec).signscale = 0;}")

cpp_quote("#endif /* _tagDEC_DEFINED */")

typedef DECIMAL *LPDECIMAL;

cpp_quote("#if ( _MSC_VER >= 800 )")
cpp_quote("#if _MSC_VER >= 1200")
cpp_quote("#pragma warning(pop)")
cpp_quote("#else")
cpp_quote("#pragma warning(default:4201)")
cpp_quote("#endif")
cpp_quote("#endif")

/* IDL declarations for BSTR how to transmit them */
//
typedef [unique] FLAGGED_WORD_BLOB * wireBSTR;
typedef [wire_marshal( wireBSTR )] OLECHAR *  BSTR;
typedef BSTR * LPBSTR;

cpp_quote("/* 0 == FALSE, -1 == TRUE */")
typedef short VARIANT_BOOL;
cpp_quote("#if !__STDC__ && (_MSC_VER <= 1000)")
cpp_quote("/* For backward compatibility */")
typedef VARIANT_BOOL _VARIANT_BOOL;
cpp_quote("#else")
cpp_quote("/* ANSI C/C++ reserve bool as keyword */")
cpp_quote("#define _VARIANT_BOOL    /##/")
cpp_quote("#endif")
typedef boolean BOOLEAN;

cpp_quote("/* The BSTRBLOB structure is used by some implementations */")
cpp_quote("/* of the IPropertyStorage interface when marshaling BSTRs */")
cpp_quote("/* on systems which don't support BSTR marshaling. */")

cpp_quote("#ifndef _tagBSTRBLOB_DEFINED")
cpp_quote("#define _tagBSTRBLOB_DEFINED")
typedef struct tagBSTRBLOB
{
                          ULONG   cbSize;
    [size_is(cbSize)]     BYTE    *pData;
} BSTRBLOB, *LPBSTRBLOB;
cpp_quote("#endif")

cpp_quote("#define VARIANT_TRUE ((VARIANT_BOOL)-1)")
cpp_quote("#define VARIANT_FALSE ((VARIANT_BOOL)0)")

cpp_quote("#ifndef _tagBLOB_DEFINED")
cpp_quote("#define _tagBLOB_DEFINED")
cpp_quote("#define _BLOB_DEFINED")
cpp_quote("#define _LPBLOB_DEFINED")
typedef struct tagBLOB {
    ULONG cbSize;
    [size_is(cbSize)]
    BYTE  *pBlobData;
} BLOB, * LPBLOB;
cpp_quote("#endif")

typedef struct tagCLIPDATA {
    ULONG cbSize;       // count that includes sizeof(ulClipFmt)
    long ulClipFmt;     // long to keep alignment
    [size_is(cbSize-4)]
    BYTE * pClipData;   // cbSize-sizeof(ULONG) bytes of data in clipboard format
} CLIPDATA;

cpp_quote("// Macro to calculate the size of the above pClipData")
cpp_quote("#define CBPCLIPDATA(clipdata)    ( (clipdata).cbSize - sizeof((clipdata).ulClipFmt) )")


typedef unsigned short VARTYPE;

// #########################################################################
//
//  VARTYPE
//
// #########################################################################


cpp_quote("/*")
cpp_quote(" * VARENUM usage key,")
cpp_quote(" *")
cpp_quote(" * * [V] - may appear in a VARIANT")
cpp_quote(" * * [T] - may appear in a TYPEDESC")
cpp_quote(" * * [P] - may appear in an OLE property set")
cpp_quote(" * * [S] - may appear in a Safe Array")
cpp_quote(" *")
cpp_quote(" *")
cpp_quote(" *  VT_EMPTY            [V]   [P]     nothing")
cpp_quote(" *  VT_NULL             [V]   [P]     SQL style Null")
cpp_quote(" *  VT_I2               [V][T][P][S]  2 byte signed int")
cpp_quote(" *  VT_I4               [V][T][P][S]  4 byte signed int")
cpp_quote(" *  VT_R4               [V][T][P][S]  4 byte real")
cpp_quote(" *  VT_R8               [V][T][P][S]  8 byte real")
cpp_quote(" *  VT_CY               [V][T][P][S]  currency")
cpp_quote(" *  VT_DATE             [V][T][P][S]  date")
cpp_quote(" *  VT_BSTR             [V][T][P][S]  OLE Automation string")
cpp_quote(" *  VT_DISPATCH         [V][T]   [S]  IDispatch *")
cpp_quote(" *  VT_ERROR            [V][T][P][S]  SCODE")
cpp_quote(" *  VT_BOOL             [V][T][P][S]  True=-1, False=0")
cpp_quote(" *  VT_VARIANT          [V][T][P][S]  VARIANT *")
cpp_quote(" *  VT_UNKNOWN          [V][T]   [S]  IUnknown *")
cpp_quote(" *  VT_DECIMAL          [V][T]   [S]  16 byte fixed point")
cpp_quote(" *  VT_RECORD           [V]   [P][S]  user defined type")
cpp_quote(" *  VT_I1               [V][T][P][s]  signed char")
cpp_quote(" *  VT_UI1              [V][T][P][S]  unsigned char")
cpp_quote(" *  VT_UI2              [V][T][P][S]  unsigned short")
cpp_quote(" *  VT_UI4              [V][T][P][S]  unsigned long")
cpp_quote(" *  VT_I8                  [T][P]     signed 64-bit int")
cpp_quote(" *  VT_UI8                 [T][P]     unsigned 64-bit int")
cpp_quote(" *  VT_INT              [V][T][P][S]  signed machine int")
cpp_quote(" *  VT_UINT             [V][T]   [S]  unsigned machine int")
cpp_quote(" *  VT_INT_PTR             [T]        signed machine register size width")
cpp_quote(" *  VT_UINT_PTR            [T]        unsigned machine register size width")
cpp_quote(" *  VT_VOID                [T]        C style void")
cpp_quote(" *  VT_HRESULT             [T]        Standard return type")
cpp_quote(" *  VT_PTR                 [T]        pointer type")
cpp_quote(" *  VT_SAFEARRAY           [T]        (use VT_ARRAY in VARIANT)")
cpp_quote(" *  VT_CARRAY              [T]        C style array")
cpp_quote(" *  VT_USERDEFINED         [T]        user defined type")
cpp_quote(" *  VT_LPSTR               [T][P]     null terminated string")
cpp_quote(" *  VT_LPWSTR              [T][P]     wide null terminated string")
cpp_quote(" *  VT_FILETIME               [P]     FILETIME")
cpp_quote(" *  VT_BLOB                   [P]     Length prefixed bytes")
cpp_quote(" *  VT_STREAM                 [P]     Name of the stream follows")
cpp_quote(" *  VT_STORAGE                [P]     Name of the storage follows")
cpp_quote(" *  VT_STREAMED_OBJECT        [P]     Stream contains an object")
cpp_quote(" *  VT_STORED_OBJECT          [P]     Storage contains an object")
cpp_quote(" *  VT_VERSIONED_STREAM       [P]     Stream with a GUID version")
cpp_quote(" *  VT_BLOB_OBJECT            [P]     Blob contains an object ")
cpp_quote(" *  VT_CF                     [P]     Clipboard format")
cpp_quote(" *  VT_CLSID                  [P]     A Class ID")
cpp_quote(" *  VT_VECTOR                 [P]     simple counted array")
cpp_quote(" *  VT_ARRAY            [V]           SAFEARRAY*")
cpp_quote(" *  VT_BYREF            [V]           void* for local use")
cpp_quote(" *  VT_BSTR_BLOB                      Reserved for system use")
cpp_quote(" */")

enum VARENUM
{
    VT_EMPTY           = 0,
    VT_NULL            = 1,
    VT_I2              = 2,
    VT_I4              = 3,
    VT_R4              = 4,
    VT_R8              = 5,
    VT_CY              = 6,
    VT_DATE            = 7,
    VT_BSTR            = 8,
    VT_DISPATCH        = 9,
    VT_ERROR           = 10,
    VT_BOOL            = 11,
    VT_VARIANT         = 12,
    VT_UNKNOWN         = 13,
    VT_DECIMAL         = 14,
// VBA reserves 15 for future use
    VT_I1              = 16,
    VT_UI1             = 17,
    VT_UI2             = 18,
    VT_UI4             = 19,
    VT_I8              = 20,
    VT_UI8             = 21,
    VT_INT             = 22,
    VT_UINT            = 23,
    VT_VOID            = 24,
    VT_HRESULT         = 25,
    VT_PTR             = 26,
    VT_SAFEARRAY       = 27,
    VT_CARRAY          = 28,
    VT_USERDEFINED     = 29,
    VT_LPSTR           = 30,
    VT_LPWSTR          = 31,
// VBA reserves 32-35 for future use
    VT_RECORD          = 36,
	VT_INT_PTR         = 37,
	VT_UINT_PTR        = 38,	

    VT_FILETIME        = 64,
    VT_BLOB            = 65,
    VT_STREAM          = 66,
    VT_STORAGE         = 67,
    VT_STREAMED_OBJECT = 68,
    VT_STORED_OBJECT   = 69,
    VT_BLOB_OBJECT     = 70,
    VT_CF              = 71,
    VT_CLSID           = 72,
    VT_VERSIONED_STREAM= 73,

    VT_BSTR_BLOB       = 0x0fff,

    VT_VECTOR          = 0x1000,
    VT_ARRAY           = 0x2000,
    VT_BYREF           = 0x4000,
    VT_RESERVED        = 0x8000,

    VT_ILLEGAL         = 0xffff,
    VT_ILLEGALMASKED   = 0x0fff,
    VT_TYPEMASK        = 0x0fff
};


// Property stuff
typedef ULONG PROPID;

// Access Control - ntseapi.h
cpp_quote( "#ifndef SID_IDENTIFIER_AUTHORITY_DEFINED" )
cpp_quote( "#define SID_IDENTIFIER_AUTHORITY_DEFINED" )
typedef struct _SID_IDENTIFIER_AUTHORITY {
    UCHAR Value[6];
} SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
cpp_quote( "#endif" )

cpp_quote( "#ifndef SID_DEFINED" )
cpp_quote( "#define SID_DEFINED" )
typedef struct _SID {
   BYTE Revision;
   BYTE SubAuthorityCount;
   SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
   [size_is(SubAuthorityCount)] ULONG SubAuthority[*];
} SID, *PISID;

typedef struct _SID_AND_ATTRIBUTES {
    SID * Sid;
    DWORD Attributes;
    } SID_AND_ATTRIBUTES, * PSID_AND_ATTRIBUTES;
cpp_quote( "#endif" )


// Class Store types

//
// Platform/Architecture Definition
//
    typedef struct tagCSPLATFORM
    {
        DWORD dwPlatformId;     // This is the OS Platform
        DWORD dwVersionHi;      // Major Version of OS
        DWORD dwVersionLo;      // Minor Version of OS
        DWORD dwProcessorArch;  // This is the Processor Architecure
    } CSPLATFORM;

//
// Query Context Structure
// This contains a list of attributes used to look up a class implementation
//
    typedef struct tagQUERYCONTEXT {
          DWORD      dwContext;         // Execution context
          CSPLATFORM Platform;          // Client Platform/Architecture
          LCID       Locale;            // Locale ID
          DWORD      dwVersionHi;       // Low Version number
          DWORD      dwVersionLo;       // Hi Version number
    } QUERYCONTEXT;


//
// Class Specifier structure
// All means of mapping to a Class ID
// (Union of CLSID, File Extension, ProgId, MimeType, File Ext)
//

    typedef [v1_enum] enum tagTYSPEC {
        TYSPEC_CLSID,
        TYSPEC_FILEEXT,
        TYSPEC_MIMETYPE,
        TYSPEC_FILENAME,
        TYSPEC_PROGID,
        TYSPEC_PACKAGENAME,
        TYSPEC_OBJECTID
    } TYSPEC;

    typedef union switch(DWORD tyspec)
        {
        case TYSPEC_CLSID:
            CLSID   clsid;
        case TYSPEC_FILEEXT:
            LPOLESTR pFileExt;
        case TYSPEC_MIMETYPE:
            LPOLESTR pMimeType;
        case TYSPEC_PROGID:
            LPOLESTR pProgId;
        case TYSPEC_FILENAME:
            LPOLESTR pFileName;
        case TYSPEC_PACKAGENAME:
            struct {
            LPOLESTR pPackageName;
            GUID     PolicyId;
            } ByName;
        case TYSPEC_OBJECTID:
            struct {
            GUID     ObjectId;
            GUID     PolicyId;
            } ByObjectId;
    } uCLSSPEC;




