Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpbcgr.RdpbcgrServerDecoder.DecodeControlPDU C# (CSharp) Method

DecodeControlPDU() public method

Decode Control PDU
public DecodeControlPDU ( byte data, byte decryptedUserData, SecurityHeaderType type ) : Microsoft.Protocols.TestTools.StackSdk.StackPacket
data byte data to be parsed
decryptedUserData byte decrypted user data to be parsed
type SecurityHeaderType security header type
return Microsoft.Protocols.TestTools.StackSdk.StackPacket
        public StackPacket DecodeControlPDU(
            byte[] data,
            byte[] decryptedUserData,
            SecurityHeaderType type)
        {
            // data index
            int dataIndex = 0;

            // ControlPDU: commonHeader
            SlowPathPduCommonHeader commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type);

            // user data index
            int userDataIndex = 0;

            // ControlPDU: controlPduData
            TS_CONTROL_PDU controlPduData = ParseTsControlPdu(decryptedUserData, ref userDataIndex);

            // Get pdu by action type
            StackPacket pdu;
            if (controlPduData.action == action_Values.CTRLACTION_COOPERATE)
            {
                // Control PDU - cooperate
                Client_Control_Pdu_Cooperate cooperatePdu = new Client_Control_Pdu_Cooperate();
                cooperatePdu.commonHeader = commonHeader;
                cooperatePdu.controlPduData = controlPduData;
                pdu = cooperatePdu;

                // ETW Provider Dump Message
                if (cooperatePdu.commonHeader.securityHeader != null)
                {
                    // RDP Standard Security
                    string messageName = "RDPBCGR:" + cooperatePdu.GetType().Name;
                    ExtendedLogger.DumpMessage(messageName, RdpbcgrUtility.DumpLevel_Layer3, cooperatePdu.GetType().Name, decryptedUserData);
                }
            }
            else if (controlPduData.action == action_Values.CTRLACTION_REQUEST_CONTROL)
            {
                // Control PDU - granted control
                Client_Control_Pdu_Request_Control requestPdu = new Client_Control_Pdu_Request_Control();
                requestPdu.commonHeader = commonHeader;
                requestPdu.controlPduData = controlPduData;
                pdu = requestPdu;

                // ETW Provider Dump Message
                if (requestPdu.commonHeader.securityHeader != null)
                {
                    // RDP Standard Security
                    string messageName = "RDPBCGR:" + requestPdu.GetType().Name;
                    ExtendedLogger.DumpMessage(messageName, RdpbcgrUtility.DumpLevel_Layer3, requestPdu.GetType().Name, decryptedUserData);
                }
            }
            else
            {
                throw new FormatException(ConstValue.ERROR_MESSAGE_ENUM_UNRECOGNIZED);
            }

            // Check if data length exceeded expectation
            VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED);
            return pdu;
        }
RdpbcgrServerDecoder