⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcomshow.cpp

📁 VXWORKS源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    public:	/*****************************************************************	*	* RpcIndentBlock::RpcIndentBlock - Constructor.	*	* Output's the given name and indents it.	*	* RETURNS: None.	* NOMANUAL	*/	RpcIndentBlock (const char * pName) : 	    RpcName (pName, true)	    {	    endOfLine ();	    }	/*****************************************************************	*	* RpcIndentBlock::~RpcIndentBlock - Destructor.	*	* Removes the indentation that the constructor applied.	*	* RETURNS: None.	* NOMANUAL	*/	~RpcIndentBlock ()	    {	    padDown ();	    }    };/* DCE packet classes *//*These classes all have one method called Read which decodes a part of thepacket. */class RpcGUID     {    public:    const GUID * Read (const char * pName)	{	static GUID		value;	value.Data1 = *(DWORD *)ReadBytes (sizeof(DWORD));	value.Data2 = *(USHORT *)ReadBytes (sizeof (USHORT));	value.Data3 = *(USHORT *)ReadBytes (sizeof (USHORT));	memcpy (value.Data4, ReadBytes (8), 8);	FIELD(pName, findGuid (value));	endOfLine ();	return &value;	}    COMMON_VIRTUALS();    };class RpcCnPresSyntaxId : RpcGUID    {    public:    const rpc_cn_pres_syntax_id_t * Read (const char * pName)	{	static rpc_cn_pres_syntax_id_t value;	NAME(pName);	value.id = *RpcGUID::Read ("id");	value.version = ReadULONG ("version");	return &value;	}    COMMON_VIRTUALS();    };class RpcCnPresCtxElem : RpcCnPresSyntaxId    {    public:    void Read (const char * pName)	{	NAME(pName);	BYTE i;	USHORT presCtxId = ReadUSHORT ("presCtxId");    	BYTE count = ReadBYTE ("nTransferSyntaxes");	ReadBYTE ("reserved");	updateCtxTable (presCtxId, 		        RpcCnPresSyntaxId::Read("abstractSyntax")->id,		        getChannelBinding ());	for (i = 0; i < count; i++)	        {		char line [25];		sprintf (line, "transferSyntax [%d]", i);    		RpcCnPresSyntaxId::Read (line);		}    	}    COMMON_VIRTUALS();    };class RpcCnPresCtxList : RpcCnPresCtxElem    {    public:    void Read (const char * pName)	{	NAME(pName);	BYTE	i;    	BYTE	count = ReadBYTE ("numCtxElems");	ReadBYTE ("reserved");	ReadUSHORT ("reserved2");	for (i = 0; i < count; i++)	    RpcCnPresCtxElem::Read ("presCtxElem [1]");    	}    COMMON_VIRTUALS();    };class RpcCnBindHdr : RpcCnPresCtxList    {    public:    void Read (const char * pName)	{	NAME(pName);	ReadUSHORT ("maxTxFrag");	ReadUSHORT ("maxRxFrag");	ReadULONG  ("assocGroupId");	RpcCnPresCtxList::Read ("presCtxList");    	};    COMMON_VIRTUALS();    };class RpcCnPresCtxId    {    public:    USHORT Read (const char * pName)	{    	USHORT presCtxId = ReadUSHORT (pName, true, NULL, false);	output (" - ");	output (getFromCtxTable (presCtxId, getChannelBinding ()));	endOfLine ();	return presCtxId;	}    COMMON_VIRTUALS ();    };class RpcCnResponseHdr : RpcCnPresCtxId    {    public:    void Read (const char * pName)	{	NAME(pName);    	ReadULONG ("allocHint");	RpcCnPresCtxId::Read ("presCtxId");    	ReadBYTE ("alertCount");    	ReadBYTE ("reserved");	}    COMMON_VIRTUALS();    };class RpcCnRequestHdr : RpcGUID, RpcCnPresCtxId    {    public:    void Read (const char * pName)	{	NAME(pName);    	ReadULONG ("allocHint");	RpcCnPresCtxId::Read ("presCtxId");	ReadUSHORT ("methodNum");	if (getFlags () & RPC_CN_FLAGS_OBJECT_UUID)	    {	    RpcGUID::Read ("objectId");	    }	}    COMMON_VIRTUALS();    };class RpcCnPortAny    {    public:    void Read (const char * pName)	{	NAME(pName);    	ReadUSHORT ("len");    	ReadARRAY ("addr", 6);	}    COMMON_VIRTUALS();    };class  RpcCnPresResult : RpcCnPresSyntaxId    {    public:    void Read (const char * pName)	{	NAME(pName);    	ReadUSHORT ("result");    	ReadUSHORT ("reason");	RpcCnPresSyntaxId::Read ("transferSyntax");	}    COMMON_VIRTUALS();    };class RpcCnPresResultList : RpcCnPresResult    {    public:    void Read (const char * pName)	{	NAME(pName);	BYTE 		i;    	BYTE 		numResults = ReadBYTE ("numResults");        ReadBYTE ("reserved");    	ReadUSHORT ("reserved2");	for (i = 0; i < numResults; i++)	    {	    char line [20];	    sprintf (line, "presResult [%d]", i);	    RpcCnPresResult::Read (line);	    }	}    COMMON_VIRTUALS();    };class  RpcCnBindAckHdr : RpcCnPortAny, RpcCnPresResultList    {    public:    void Read (const char * pName)	{	NAME(pName);	ReadUSHORT ("maxTxFrag");	ReadUSHORT ("maxRxFrag");	ReadULONG ("assocGroupId");	RpcCnPortAny::Read ("secAddr");	RpcCnPresResultList::Read ("resultList");	}    COMMON_VIRTUALS();    };class  RpcCnAlterContextRespHdr : RpcCnPresResultList    {    public:    void Read (const char * pName)	{	NAME(pName);    	ReadUSHORT ("maxTxFrag");    	ReadUSHORT ("maxRxFrag");    	ReadULONG  ("assocGroupId");    	ReadUSHORT ("secAddr");    	ReadUSHORT ("pad");	RpcCnPresResultList::Read ("resultList");	}    COMMON_VIRTUALS();    };class RpcCnFaultHdr : RpcCnPresCtxId    {    public:    void Read (const char * pName)	{	NAME(pName);	ReadULONG ("allocHint");	RpcCnPresCtxId::Read ("presCtxId");	ReadBYTE ("alertCount");	ReadBYTE ("reserved");	ReadULONG ("status");	ReadULONG ("reserved2");	}    COMMON_VIRTUALS ();    };class RpcCnBindNakHdr    {    public:    void Read (const char * pName)	{	NAME(pName);	ReadUSHORT ("reason");	ReadBYTE ("numProtocols");	ReadBYTE ("verMajor");	ReadBYTE ("verMinor");	}    COMMON_VIRTUALS ();    };class RpcCnAuth3Hdr    {    public:    void Read (const char * pName)	{        ReadUSHORT ("maxTxFrag");	ReadUSHORT ("maxRxFrag");	}    COMMON_VIRTUALS ();    };class RpcCnBody    {    public:    void Read (const char * pName)	{	NAME(pName);	BYTE *		pBlock;	DWORD		remain;	while ((remain = BytesRemaining ()) > 0)	    {	    DWORD	blockSize = (remain < BLOCK_SIZE)?remain:BLOCK_SIZE;	    DWORD	i;	    pBlock = ReadBytes (blockSize, false);	    /* Dump out numeric */	    output (pBlock [0], true);	    outputSpace ();	    for (i = 1; i < blockSize; i++)		{		output (pBlock [i]);		outputSpace ();		}	    if (blockSize < BLOCK_SIZE)		for (i = blockSize; i < BLOCK_SIZE; i++)		    output ("   ");	    /* Dump out text */	    output ("\t");	    for (i = 0; i < blockSize; i++)		{		if (isprint (pBlock [i]))		    {		    char	line [2];		    sprintf (line, "%c", pBlock [i]);		    PRINT_STR(line);		    }		else		    output (".");		}	    endOfLine ();	    }	endOfLine ();	}    COMMON_VIRTUALS ();    private:    	enum {BLOCK_SIZE = 16};    };class RpcCnCommonHdr : 	RpcCnBindHdr, 	RpcCnBindAckHdr, 	RpcCnAlterContextRespHdr, 	RpcCnRequestHdr, 	RpcCnResponseHdr,	RpcCnFaultHdr,	RpcCnBindNakHdr,	RpcCnAuth3Hdr,	RpcCnBody    {    public:    void Read (const char * pName)	{	NAME(pName);	BYTE	type;	/* Decode common header */	ReadBYTE ("rpcVersion");	ReadBYTE ("rpcMinorVersion");    	type = ReadBYTE ("packetType", rpcCnTypesTable);	setFlags(ReadBYTE ("flags"));	ReadARRAY ("drep", 4);	ReadUSHORT ("fragLen");	ReadUSHORT ("authLen");	ReadULONG ("callId");	/* Decode type header */	switch (type)	    {	    case RPC_CN_PKT_REQUEST:		RpcCnRequestHdr::Read("request");		break;	    case RPC_CN_PKT_RESPONSE:		RpcCnResponseHdr::Read("response");		break;	    case RPC_CN_PKT_FAULT:		RpcCnFaultHdr::Read ("fault");		break;	    case RPC_CN_PKT_BIND:		RpcCnBindHdr::Read ("bind");		break;	    case RPC_CN_PKT_BIND_ACK:		RpcCnBindAckHdr::Read ("bind ack");		break;	    case RPC_CN_PKT_BIND_NAK:		RpcCnBindNakHdr::Read ("bind nak");		break;	    case RPC_CN_PKT_ALTER_CONTEXT:		RpcCnBindHdr::Read ("alter context");		break;	    case RPC_CN_PKT_ALTER_CONTEXT_RESP:		RpcCnAlterContextRespHdr::Read ("alter context resp");		break;	    case RPC_CN_PKT_AUTH3:		RpcCnAuth3Hdr::Read ("auth3");		break;	    case RPC_CN_PKT_SHUTDOWN:	    case RPC_CN_PKT_REMOTE_ALERT:	    case RPC_CN_PKT_ORPHANED:	    default:		/* no body to these packets, just a common hdr */		break;	    }	/* Dump out remaining data */	RpcCnBody::Read ("body");	}    COMMON_VIRTUALS();    };/* Class to encapsulate the data packet */class DataPacket : RpcCnCommonHdr    {    public:    /*************************************************************************    *    * DataPacket::DataPacket - Constructor    *    * This constructor initializes the class, works out the endianess of the     * target for byte swapping and stores a copy of the data buffer.    *    * RETURNS: None.    * NOMANUAL    */    DataPacket 	(	const BYTE * 	pData, 		/* The packet */	DWORD 		length, 	/* The length of the packet */	const char * 	pHost, 		/* The ip address of the end point */	int 		hostPort, 	/* The port on the target */	int		peerPort,	/* The port on the end point */	bool		outbound	/* Direction of connection, */					/* true is outbound */	) : m_hostPort (hostPort),            m_peerPort (peerPort),	    m_outbound (outbound),	    m_pResult (0),	    m_pBinding (0)        {	/* Work out byte swap order */	USHORT	testOrder = 0x1234;	BYTE *	pTestOrder = (BYTE *)(&testOrder);        if (*pTestOrder == 0x12)	    {	    m_byteSwap = true;	    }	else	    {	    m_byteSwap = false;	    }	/* Store data and work out the end of the buffer */	m_pData = pData;	m_pEnd = const_cast<BYTE *>(m_pData) + length;	m_pHost = new char [strlen (pHost) + 1];	strcpy (m_pHost, pHost);	}    /*************************************************************************    *    * DataPacket::~DataPacket - Destructor    *    * Deletes any temp buffers    *    * RETURNS: None.    * NOMANUAL    */    virtual ~DataPacket ()        {	/* Clean up any allocated temp buffer */	if (m_pResult)	    {	    delete [] m_pResult;	    m_pResult = NULL;	    }	if (m_pBinding)	    {	    delete [] m_pBinding;	    m_pBinding = NULL;	    }	delete [] m_pHost;	}    /*************************************************************************    *    * DataPacket::Read - Starts decode of the packet.    *    * This method starts the decode of the packet. It actually just starts a     * new line and then passes the rest of the job to the common header class.    *    * RETURNS: None.    * NOMANUAL    */    void Read 	(	const char * 	pName		/* Name to print out  for this step */	)	{	endOfLine ();	RpcCnCommonHdr::Read (pName);	}    /**************************************************************************    *    * DataPacket::getDesc - Returns the binding ip/port binding for this    * packet.    *    * This method gives a channel binding as a string containing ip and port    * addresses. For outbound bindings it is of the format:    *     ip:host port:peer port    * and for inbound transactions it is of the form:    *     ip:peer port:host port    *    * RETURNS: The ip/port binding for the packet as a string.    * NOMANUAL    */    const char * getDesc ()	{	if (m_pBinding)	    {	    delete [] m_pBinding;	    m_pBinding = NULL;	    }	m_pBinding = new char [strlen (m_pHost) + 50];	if (m_outbound)	    {	    sprintf (m_pBinding,		    "From target port %d to %s port %d",		    m_hostPort, m_pHost, m_peerPort);	    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -