The TS_LOGON_INFO_FIELD is used to encapsulate extended logon information field data of variable length.
file:///C:/ts_dev/TestSuites/MS-RDPBCGR/TestSuite/Src/TD/latest_XMLS_16may/RDPBCGR/ _rfc_ms-rdpbcgr2_1_8_3_1_1_3_1.xml
        /// <summary>
        /// Parse TS_LOGON_INFO_FIELD array
        /// (parser index is updated according to parsed length)
        /// </summary>
        /// <param name="data">data to be parsed</param>
        /// <param name="currentIndex">current parser index</param>
        /// <param name="presentFlag">fields present flag</param>
        /// <returns>TS_LOGON_INFO_FIELD array</returns>
        private TS_LOGON_INFO_FIELD[] ParseTsLogonInfoFields(
            byte[] data,
            ref int currentIndex,
            FieldsPresent_Values presentFlag)
        {
            // list to save info field(s)
            List<TS_LOGON_INFO_FIELD> list = new List<TS_LOGON_INFO_FIELD>();

            // Auto reconnect field (optional)
            if (IsFlagExist((uint)presentFlag, (uint)FieldsPresent_Values.LOGON_EX_AUTORECONNECTCOOKIE))
            {
                TS_LOGON_INFO_FIELD autoReconnectField = new TS_LOGON_INFO_FIELD();
                autoReconnectField.cbFieldData = ParseUInt32(data, ref currentIndex, false);
                autoReconnectField.FieldData = ParseArcScPrivatePacket(data, ref currentIndex);
                list.Add(autoReconnectField);
            }

            // Logon error info field (optional)
            if (IsFlagExist((uint)presentFlag, (uint)FieldsPresent_Values.LOGON_EX_LOGONERRORS))
            {
                TS_LOGON_INFO_FIELD logonErrorField = new TS_LOGON_INFO_FIELD();
                logonErrorField.cbFieldData = ParseUInt32(data, ref currentIndex, false);
                logonErrorField.FieldData = ParseTsLogonErrorsInfo(data, ref currentIndex);
                list.Add(logonErrorField);
            }

            // copy fields to array
            TS_LOGON_INFO_FIELD[] fields = new TS_LOGON_INFO_FIELD[list.Count];
            for (int i = 0; i < list.Count; ++i)
            {
                fields[i] = list[i];
            }
            return fields;
        }
Пример #2
0
        /// <summary>
        /// Create an instance of the class that is identical to the current PDU. 
        /// </summary>
        /// <returns>The new instance.</returns>
        public override StackPacket Clone()
        {
            Server_Save_Session_Info_Pdu cloneServerSaveSessionInfo = new Server_Save_Session_Info_Pdu();

            cloneServerSaveSessionInfo.commonHeader = commonHeader.Clone();
            cloneServerSaveSessionInfo.saveSessionInfoPduData = saveSessionInfoPduData;

            if (cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData.GetType()
                == typeof(TS_LOGON_INFO_VERSION_2))
            {
                TS_LOGON_INFO_VERSION_2 version2 =
                    (TS_LOGON_INFO_VERSION_2)cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData;
                version2.Pad = RdpbcgrUtility.CloneByteArray(version2.Pad);
                cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData = version2;
            }
            else if (cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData.GetType()
                == typeof(TS_PLAIN_NOTIFY))
            {
                TS_PLAIN_NOTIFY notify = (TS_PLAIN_NOTIFY)cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData;
                notify.Pad = RdpbcgrUtility.CloneByteArray(notify.Pad);
                cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData = notify;
            }
            else if (cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData.GetType()
                == typeof(TS_LOGON_INFO_EXTENDED))
            {
                TS_LOGON_INFO_EXTENDED extended =
                    (TS_LOGON_INFO_EXTENDED)cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData;
                extended.Pad = RdpbcgrUtility.CloneByteArray(extended.Pad);

                TS_LOGON_INFO_EXTENDED srcInfo = (TS_LOGON_INFO_EXTENDED)saveSessionInfoPduData.infoData;
                if (srcInfo.LogonFields != null)
                {
                    TS_LOGON_INFO_FIELD[] logonFields = new TS_LOGON_INFO_FIELD[srcInfo.LogonFields.Length];
                    for (int i = 0; i < srcInfo.LogonFields.Length; ++i)
                    {
                        logonFields[i] = srcInfo.LogonFields[i];
                        if (srcInfo.LogonFields[i].FieldData != null)
                        {
                            if (srcInfo.LogonFields[i].FieldData.GetType() == typeof(TS_LOGON_ERRORS_INFO))
                            {
                                logonFields[i].FieldData = new TS_LOGON_ERRORS_INFO();
                                ((TS_LOGON_ERRORS_INFO)logonFields[i].FieldData).ErrorNotificationData =
                                    ((TS_LOGON_ERRORS_INFO)srcInfo.LogonFields[i].FieldData).ErrorNotificationData;
                                ((TS_LOGON_ERRORS_INFO)logonFields[i].FieldData).ErrorNotificationType =
                                    ((TS_LOGON_ERRORS_INFO)srcInfo.LogonFields[i].FieldData).ErrorNotificationType;
                            }
                            else if (srcInfo.LogonFields[i].FieldData.GetType() == typeof(ARC_SC_PRIVATE_PACKET))
                            {
                                logonFields[i].FieldData = new ARC_SC_PRIVATE_PACKET();
                                ((ARC_SC_PRIVATE_PACKET)logonFields[i].FieldData).cbLen =
                                    ((ARC_SC_PRIVATE_PACKET)srcInfo.LogonFields[i].FieldData).cbLen;
                                ((ARC_SC_PRIVATE_PACKET)logonFields[i].FieldData).LogonId =
                                    ((ARC_SC_PRIVATE_PACKET)srcInfo.LogonFields[i].FieldData).LogonId;
                                ((ARC_SC_PRIVATE_PACKET)logonFields[i].FieldData).Version =
                                    ((ARC_SC_PRIVATE_PACKET)srcInfo.LogonFields[i].FieldData).Version;
                                ((ARC_SC_PRIVATE_PACKET)logonFields[i].FieldData).ArcRandomBits =
                                    RdpbcgrUtility.CloneByteArray(
                                    ((ARC_SC_PRIVATE_PACKET)srcInfo.LogonFields[i].FieldData).ArcRandomBits);
                            }
                        }
                    }

                    extended.LogonFields = logonFields;
                    cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData = extended;
                }
            }

            return cloneServerSaveSessionInfo;
        }