/*++

Copyright (c) 1995 Microsoft Corporation

Module Name:

    qmrt.idl

Abstract:


Author:

    Erez Haba (erezh) 10-Jan-96

Revision History:
--*/

import "mqtypes.idl";

[
uuid(fdb3a030-065f-11d1-bb9b-00a024ea5525),
version(1.0),
pointer_default(unique)
]
interface qmcomm
{

#include "qformat.h"

cpp_quote("#ifndef __transact_h__")
cpp_quote("#ifndef __xactdefs_h__")
cpp_quote("#define __xactdefs_h__")
#include "xactdefs.h"
cpp_quote("#endif")
cpp_quote("#endif")


//
// Transfer Buffer definition.
// These structures are used only for backwards compatibility with MSMQ
// dependent client 1.0 and 2.0.  (ShaiK, 11-May-2000)
//

struct CACCreateRemoteCursor {
	//
	//  Parameters for creating a remote cursor.
	//
    //  CACCreateLocalCursor (in acdef.h) defines parameters for creating a
	//  local cursor.
	//
	ULONG hCursor;
	ULONG srv_hACQueue;
	ULONG cli_pQMQueue;

};


enum TRANSFER_TYPE {
    CACTB_SEND = 0,
    CACTB_RECEIVE,
    CACTB_CREATECURSOR,
};


struct CACTransferBufferV1 {
    //
	// This structure is used by MSMQ 1.0 dependent clients.
	//

    ULONG uTransferType;
    [switch_is(uTransferType)]

    union {

        [case(CACTB_SEND)]
        struct {
            //
            //  MQSendMessage parameters
            //
            struct QUEUE_FORMAT* pAdminQueueFormat;
            struct QUEUE_FORMAT* pResponseQueueFormat;
        } Send;

        [case(CACTB_RECEIVE)]
        struct {
            //
            //  MQReceiveMessage parameters
            //

            ULONG RequestTimeout;
            ULONG Action;
            ULONG Asynchronous;
            ULONG Cursor;

            //
            // Important note:
            // In the following xxxFormatName properties, the value
            // "ulxxxFormatNameLen" is the size of the buffer on input.
            // This value MUST NOT be changed by the driver or QM. This
            // value tell the RPC run-time how many bytes to transfer
            // across process/machine boundaries.
            // The value "pulxxxFormatNameLenProp" is the property passed
            // by caller. This value IS changed and returned to caller to
            // indicate the length of the string.
            //
            ULONG   ulResponseFormatNameLen ;
            [size_is(,ulResponseFormatNameLen)]
            WCHAR** ppResponseFormatName;
            ULONG*  pulResponseFormatNameLenProp;

            ULONG   ulAdminFormatNameLen ;
            [size_is(,ulAdminFormatNameLen)]
            WCHAR** ppAdminFormatName;
            ULONG*  pulAdminFormatNameLenProp;

            ULONG   ulDestFormatNameLen;
            [size_is(,ulDestFormatNameLen)]
            WCHAR** ppDestFormatName;
            ULONG*  pulDestFormatNameLenProp;

            ULONG   ulOrderingFormatNameLen;
            [size_is(,ulOrderingFormatNameLen)]
            WCHAR** ppOrderingFormatName;
            ULONG*  pulOrderingFormatNameLenProp;
        } Receive;

        [case(CACTB_CREATECURSOR)]
        struct CACCreateRemoteCursor CreateCursor;
    };

    //
    //  Message properties pointers
    //
    USHORT* pClass;
    OBJECTID** ppMessageID;

    //
    //  BUGBUG: 20 must match PROPID_M_CORRELATIONID_SIZE
    //
    [size_is(,20), length_is(,20)]
    UCHAR** ppCorrelationID;

    ULONG* pSentTime;
    ULONG* pArrivedTime;
    UCHAR* pPriority;
    UCHAR* pDelivery;
    UCHAR* pAcknowledge;
    UCHAR* pAuditing;
    ULONG* pApplicationTag;

	[size_is(,ulAllocBodyBufferInBytes),
	length_is(,ulBodyBufferSizeInBytes)]
    UCHAR** ppBody;
    ULONG ulBodyBufferSizeInBytes;
    ULONG ulAllocBodyBufferInBytes;
    ULONG* pBodySize;

	//
	//  don't use [string] for *ppTitle, it is not
	//  initialized for RPC, thus we say how much to marshul.
	//
	[size_is(,ulTitleBufferSizeInWCHARs),
	length_is(,ulTitleBufferSizeInWCHARs)]
    WCHAR** ppTitle;
    ULONG   ulTitleBufferSizeInWCHARs;
    ULONG*  pulTitleBufferSizeInWCHARs;

    ULONG ulAbsoluteTimeToQueue;
    ULONG* pulRelativeTimeToQueue;

    ULONG ulRelativeTimeToLive;
    ULONG* pulRelativeTimeToLive;

    UCHAR* pTrace;
    ULONG* pulSenderIDType;

    [size_is(,uSenderIDLen)]
    UCHAR** ppSenderID;
    ULONG* pulSenderIDLenProp;

    ULONG* pulPrivLevel;
    ULONG  ulAuthLevel;
    UCHAR* pAuthenticated;
    ULONG* pulHashAlg;
    ULONG* pulEncryptAlg;

    [size_is(,ulSenderCertLen)]
    UCHAR** ppSenderCert;
    ULONG ulSenderCertLen;
    ULONG* pulSenderCertLenProp;

    [size_is(,ulProvNameLen)]
    WCHAR** ppwcsProvName;
    ULONG   ulProvNameLen;
    //
    // on msmq1.0 this was called "pulProvNameLenProp" and it was used only
    // on receive, to get the length of the authentication provider name
    // (PROPID_M_PROV_NAME_LEN). On send, the length was determined by the
    // length of the ppwcsProvName string, using wcslen().
    // On msmq2.0, we add one more signature to the security section. On send,
    // the mqrt determine the length of the "provider name" and pass it to
    // the driver using this property. it's the driver that allocate the
    // packet, using this value. See also phsecure.h
    //
    ULONG*  pulAuthProvNameLenProp;

    ULONG*  pulProvType;
    BOOL    fDefaultProvider;

    [size_is(,ulSymmKeysSize)]
    UCHAR** ppSymmKeys;
    ULONG   ulSymmKeysSize;
    ULONG*  pulSymmKeysSizeProp;

    UCHAR bEncrypted;
    UCHAR bAuthenticated;
    USHORT uSenderIDLen;

    [size_is(,ulSignatureSize)]
    UCHAR** ppSignature;
    //
    // On msmq2.0, the ppSignature buffer may hold both signature: the
    // "legacy" msmq1.0 one and the new (enhanced) signature. First come
    // the msmq1.0 signature, then the new one. If the msmq1.0 signature
    // is not computed, then it's replaced with a zero value dword.
    //
    ULONG   ulSignatureSize;
    ULONG*  pulSignatureSizeProp;

    GUID** ppSrcQMID;

    XACTUOW* pUow;

	[size_is(,ulMsgExtensionBufferInBytes),
	length_is(,ulMsgExtensionBufferInBytes)]
    UCHAR** ppMsgExtension;
    ULONG ulMsgExtensionBufferInBytes;
    ULONG* pMsgExtensionSize;
    GUID** ppConnectorType;
    ULONG* pulBodyType;
    ULONG* pulVersion;

}; //  CACTransferBufferV1


struct CACTransferBufferV2 {
    //
	// This structure is used by MSMQ 2.0 dependent clients.
	//

	struct CACTransferBufferV1 old;
    UCHAR* pbFirstInXact;
    UCHAR* pbLastInXact;
    OBJECTID** ppXactID;

}; // CACTransferBufferV2






const ULONG MQQM_QUEUE               = 1;
const ULONG MQQM_QUEUE_LOCAL_PRIVATE = 2;

struct OBJECT_FORMAT {
    DWORD ObjType;
        [switch_is(ObjType)] union
        {
            [case(MQQM_QUEUE)]
                struct QUEUE_FORMAT* pQueueFormat;
        };
};

typedef [context_handle] void* PCTX_OPENREMOTE_HANDLE_TYPE;

typedef [context_handle] void* RPC_QUEUE_HANDLE;
typedef [context_handle] void* RPC_INT_XACT_HANDLE;

/*===========================================================================================
    QMCOMM functions
=============================================================================================*/

HRESULT
R_QMOpenQueue(
    [in]  handle_t       hBind,
	[in]  ULONG          nMqf,
    [in, size_is (nMqf)] struct QUEUE_FORMAT mqf[],
    [in]  DWORD          dwCallingProcessID,
    [in]  DWORD          dwDesiredAccess,
    [in]  DWORD          dwShareMode,
    [in]  DWORD          hRemoteQueue,
    [in, out, ptr] LPWSTR* lplpRemoteQueueName,
    [in]  DWORD*         dwpQueue,
    [out] DWORD*         phQueue,
    [in]  DWORD          dwpRemoteContext
    );

HRESULT
QMGetRemoteQueueName(
    [in]  handle_t                hBind,
    [in]  DWORD                   pQueue,
    [in, out, ptr, string] LPWSTR *lplpRemoteQueueName
    );

HRESULT
QMOpenRemoteQueue(
    [in] handle_t                      hBind,
    [out] PCTX_OPENREMOTE_HANDLE_TYPE  *pphContext,
    [out] DWORD                        *pdwContext,
    [in, unique]  struct QUEUE_FORMAT* pQueueFormat,
    [in]  DWORD                        dwCallingProcessID,
    [in]  DWORD                        dwDesiredAccess,
    [in]  DWORD                        dwShareMode,
    [in]  GUID*                        pLicGuid,
    [in]  DWORD                        dwMQS,
    [out] DWORD                        *dwpQueue,
    [out] DWORD                        *phQueue
    );

void
QMCloseRemoteQueueContext(
    [in, out] PCTX_OPENREMOTE_HANDLE_TYPE  *pphContext
    );

HRESULT
QMCreateRemoteCursor(
    [in]  handle_t                     hBind,
    [in]  struct CACTransferBufferV1 * ptb1,
    [in]  DWORD                        hQueue,
    [out] DWORD *                      phCursor
    );

HRESULT
QMSendMessageInternal(
    [in] handle_t                     hBind,
    [in] struct QUEUE_FORMAT*         pQueueFormat,
    [in] struct CACTransferBufferV1 * ptb1
    );

HRESULT
QMCreateObjectInternal(
    [in] handle_t                                 hBind,
    [in] DWORD                                    dwObjectType,
    [in] LPCWSTR                                  lpwcsPathName,
    [in] DWORD                                    SDSize,
    [in, unique, size_is (SDSize)]  unsigned char *pSecurityDescriptor,
    [in] DWORD                                    cp,
    [in, size_is (cp)]  PROPID                    aProp[],
    [in, size_is (cp)]  PROPVARIANT               apVar[]
    );

cpp_quote("HRESULT")
cpp_quote("QMCreateObject(")
cpp_quote("    /* in */ DWORD dwObjectType,")
cpp_quote("    /* in */ LPCWSTR lpwcsPathName,")
cpp_quote("    /* in */ PSECURITY_DESCRIPTOR pSecurityDescriptor,")
cpp_quote("    /* in */ DWORD cp,")
cpp_quote("    /* in */ PROPID aProp[],")
cpp_quote("    /* in */ PROPVARIANT apVar[]);")

typedef ULONG SECURITY_INFORMATION;

HRESULT
QMSetObjectSecurityInternal(
    [in] handle_t                                 hBind,
    [in] struct OBJECT_FORMAT*                    pObjectFormat,
    [in] SECURITY_INFORMATION                     SecurityInformation,
    [in] DWORD                                    SDSize,
    [in, unique, size_is (SDSize)]  unsigned char *pSecurityDescriptor);

cpp_quote("HRESULT")
cpp_quote("QMSetObjectSecurity(")
cpp_quote("    /* in */ struct OBJECT_FORMAT* pObjectFormat,")
cpp_quote("    /* in */ SECURITY_INFORMATION SecurityInformation,")
cpp_quote("    /* in */ PSECURITY_DESCRIPTOR pSecurityDescriptor);")

HRESULT
QMGetObjectSecurityInternal(
    [in] handle_t                           hBind,
    [in] struct OBJECT_FORMAT*              pObjectFormat,
    [in] SECURITY_INFORMATION               RequestedInformation,
    [out, size_is (nLength)]  unsigned char *pSecurityDescriptor,
    [in, range(0, 524288)] DWORD            nLength,
    [out]  LPDWORD                          lpnLengthNeeded);

cpp_quote("#define QMGetObjectSecurity(hBind, of, si, sd, l , ln) \\")
cpp_quote("    QMGetObjectSecurityInternal(hBind, of, si, (unsigned char *)(sd), l , ln)")

HRESULT
QMDeleteObject(
     [in] handle_t        hBind,
     [in] struct OBJECT_FORMAT*  pObjectFormat);

HRESULT
QMGetObjectProperties(
    [in] handle_t                        hBind,
    [in] struct OBJECT_FORMAT*           pObjectFormat,
    [in] DWORD                           cp,
    [in, size_is (cp )]  PROPID          aProp[],
    [in, out, size_is(cp )]  PROPVARIANT apVar[]);

HRESULT
QMSetObjectProperties(
    [in] handle_t                            hBind,
    [in] struct OBJECT_FORMAT*               pObjectFormat,
    [in] DWORD                               cp,
    [in, unique, size_is (cp )]  PROPID      aProp[],
    [in, unique, size_is(cp )]  PROPVARIANT  apVar[]);


HRESULT
QMObjectPathToObjectFormat(
    [in] handle_t               hBind,
    [in] LPCWSTR                lpwcsPathName,
    [in, out] struct OBJECT_FORMAT     *pObjectFormat);

HRESULT
QMAttachProcess(
    [in] handle_t                      hBind,
    [in] DWORD                         dwProcessId,
    [in, range(0,512)] DWORD           cSid,
    [out, size_is(cSid)] unsigned char *pSid,
    [out] LPDWORD                      cReqSid);

HRESULT
QMGetTmWhereabouts(
    [in]  handle_t                      hBind,
    [in, range(0, 131072)]  DWORD       cbBufSize,
    [out, size_is (cbBufSize)]          UCHAR* pbWhereabouts,
    [out] DWORD                         *pcbWhereabouts);

HRESULT
QMEnlistTransaction(
    [in] handle_t                       hBind,
    [in] XACTUOW*                       pUow,
    [in] DWORD                          cbCookie,
    [in, size_is (cbCookie)]  UCHAR*    pbCookie);

HRESULT
QMEnlistInternalTransaction(
    [in]  handle_t                      hBind,
    [in]  XACTUOW*                      pUow,
    [out] RPC_INT_XACT_HANDLE*          phIntXact
);

HRESULT
QMCommitTransaction(
    [in, out] RPC_INT_XACT_HANDLE*      phIntXact);

HRESULT
QMAbortTransaction(
    [in, out] RPC_INT_XACT_HANDLE*      phIntXact);

HRESULT
rpc_QMOpenQueueInternal(
    [in]  handle_t      hBind,
    [in]  struct QUEUE_FORMAT* pQueueFormat,
    [in]  DWORD         dwDesiredAccess,
    [in]  DWORD         dwShareMode,
    [in]  DWORD         hRemoteQueue,
    [in, out, ptr] LPWSTR*  lplpRemoteQueueName,
    [in]  DWORD*            dwpQueue,
    [in]  GUID*             pLicGuid,
    [in]  LPWSTR            lpClientName,
    [out] DWORD*            pdwQMContext,
    [out] RPC_QUEUE_HANDLE* phQueue,
    [in]  DWORD             dwRemoteProtocol,
    [in]  DWORD             dwpRemoteContext
    );

HRESULT
rpc_ACCloseHandle(
    [in, out] RPC_QUEUE_HANDLE* phQueue
    );

HRESULT
rpc_ACCreateCursor(
    [in] RPC_QUEUE_HANDLE                  hQueue,
    [in, out] struct CACTransferBufferV1 * ptb1
    );

HRESULT
rpc_ACCloseCursor(
    [in] RPC_QUEUE_HANDLE hQueue,
    [in] ULONG hCursor
    );

HRESULT
rpc_ACSetCursorProperties(
    [in] RPC_QUEUE_HANDLE hProxy,
    [in] ULONG hCursor,
    [in] ULONG hRemoteCursor
    );

HRESULT
rpc_ACSendMessage(
    [in] RPC_QUEUE_HANDLE             hQueue,
    [in] struct CACTransferBufferV1 * ptb1,
    [in, out, unique] OBJECTID *      pMessageID
    );

HRESULT
rpc_ACReceiveMessage(
    [in] handle_t                          hBind,
    [in] DWORD                             hQMContext,
    [in, out] struct CACTransferBufferV1 * ptb1
    );

HRESULT
rpc_ACHandleToFormatName(
    [in] RPC_QUEUE_HANDLE hQueue,
    [in] DWORD dwFormatNameRPCBufferLen,
    [in, out, unique,
     size_is(dwFormatNameRPCBufferLen), length_is(dwFormatNameRPCBufferLen)] WCHAR* lpwcsFormatName,
    [in, out] LPDWORD pdwLength
    );

HRESULT
rpc_ACPurgeQueue(
    [in] RPC_QUEUE_HANDLE hQueue
    );

cpp_quote("#define  QueryRemoteQM_MQISServers     1")
cpp_quote("#define  QueryRemoteQM_LongLiveDefault 2")
cpp_quote("#define  QueryRemoteQM_EnterpriseGUID  3")
cpp_quote("#define  QueryRemoteQM_QMVersion       4")
cpp_quote("#define  QueryRemoteQM_ServerQmGUID    5")

HRESULT
QMQueryQMRegistryInternal(
    [in]  handle_t         hBind,
    [in]  DWORD            dwQueryType,
    [out, string] LPWSTR   *lplpMQISServer
    );

HRESULT
QMListInternalQueues(
    [in] handle_t hBind,
    [in, out, unique,
        size_is(,*pdwFormatLen), length_is(,*pdwFormatLen)] WCHAR* *ppFormatName,
    [in, out] LPDWORD pdwFormatLen,
    [in, out, unique,
        size_is(,*pdwDisplayLen), length_is(,*pdwDisplayLen)] WCHAR* *ppDisplayName,
    [in, out] LPDWORD pdwDisplayLen
    );

HRESULT QMCorrectOutSequence(
    [in] handle_t hBind,
        [in] DWORD dwSeqID1,
    [in] DWORD dwSeqID2,
        [in] ULONG ulSeqN
    );

DWORD  QMGetRTQMServerPort( [in] handle_t hBind,
                            [in] DWORD    fIP ) ;

HRESULT
QMGetMsmqServiceName(
    [in]  handle_t                hBind,
    [in, out, ptr, string] LPWSTR *lplpService
    );

HRESULT
QMCreateDSObjectInternal(
    [in] handle_t                                 hBind,
    [in] DWORD                                    dwObjectType,
    [in] LPCWSTR                                  lpwcsPathName,
    [in] DWORD                                    SDSize,
    [in, unique, size_is (SDSize)]  unsigned char *pSecurityDescriptor,
    [in] DWORD                                    cp,
    [in, size_is (cp)]  PROPID                    aProp[],
    [in, size_is (cp)]  PROPVARIANT               apVar[],
    [in, out, unique]   GUID                     *pObjGuid );

cpp_quote("HRESULT")
cpp_quote("QMCreateDSObject(")
cpp_quote("    /* in  */ DWORD dwObjectType,")
cpp_quote("    /* in  */ LPCWSTR lpwcsPathName,")
cpp_quote("    /* in  */ PSECURITY_DESCRIPTOR pSecurityDescriptor,")
cpp_quote("    /* in  */ DWORD cp,")
cpp_quote("    /* in  */ PROPID aProp[],")
cpp_quote("    /* in  */ PROPVARIANT apVar[],")
cpp_quote("    /* out */ GUID       *pGuid);")

}





[
uuid(76d12b80-3467-11d3-91ff-0090272f9ea3),
version(1.0),
pointer_default(unique)
]
interface qmcomm2
{

HRESULT
QMSendMessageInternalEx(
    [in] handle_t                     hBind,
    [in] struct QUEUE_FORMAT* pQueueFormat,
    [in] struct CACTransferBufferV2 * ptb2,
    [in, out, unique] OBJECTID *      pMessageID	
    );

HRESULT
rpc_ACSendMessageEx(
    [in] RPC_QUEUE_HANDLE             hQueue,
    [in] struct CACTransferBufferV2 * ptb2,
    [in, out, unique] OBJECTID *      pMessageID
    );

HRESULT
rpc_ACReceiveMessageEx(
    [in] handle_t                          hBind,
    [in] DWORD                             hQMContext,
    [in, out] struct CACTransferBufferV2 * ptb2
    );

HRESULT
rpc_ACCreateCursorEx(
    [in] RPC_QUEUE_HANDLE                    hQueue,
    [in, out] struct CACCreateRemoteCursor * pcc
    );

}

