This packet is embedded into Server Core Capability Request and Client Core Capability Response messages. It describes nondevice-specific capabilities.
file:///D:/programs/RFSPAC/XML-RDPEFS/_rfc_ms-rdpefs2_2_2_7_1.xml
상속: CAPABILITY_SET
        /// <summary>
        /// Create Server Core Capability Request packet.
        /// </summary>
        /// <returns>Server Core Capability Request packet.</returns>
        public static DR_CORE_CAPABILITY_REQ CreateServerCoreCapabilityRequest()
        {
            DR_CORE_CAPABILITY_REQ request = new DR_CORE_CAPABILITY_REQ();
            request.Header = new RDPDR_HEADER();
            request.Header.Component = Component_Values.RDPDR_CTYP_CORE;
            request.Header.PacketId = PacketId_Values.PAKID_CORE_SERVER_CAPABILITY;
            request.numCapabilities = 5;
            request.Padding = 0;

            List<CAPABILITY_SET> capabilitySet = new List<CAPABILITY_SET>();

            GENERAL_CAPS_SET generalCapability = new GENERAL_CAPS_SET();
            generalCapability.Header = new CAPABILITY_HEADER();
            generalCapability.Header.CapabilityType = CapabilityType_Values.CAP_GENERAL_TYPE;
            generalCapability.Header.CapabilityLength = 44;
            generalCapability.Header.Version = CAPABILITY_VERSION.V1;
            generalCapability.osType = osType_Values.OS_TYPE_UNKNOWN;
            generalCapability.osVersion = osVersion_Values.V1;
            generalCapability.protocolMajorVersion = protocolMajorVersion_Values.V1;
            generalCapability.protocolMinorVersion = 0x000C;
            generalCapability.ioCode1 = (ioCode1_Values)0x0000FFFF;
            generalCapability.ioCode2 = ioCode2_Values.V1;
            generalCapability.extendedPDU = extendedPDU_Values.RDPDR_DEVICE_REMOVE_PDUS | extendedPDU_Values.RDPDR_CLIENT_DISPLAY_NAME_PDU;
            generalCapability.extraFlags1 = extraFlags1_Values.ENABLE_ASYNCIO;
            generalCapability.extraFlags2 = extraFlags2_Values.V1;
            generalCapability.SpecialTypeDeviceCap = 2;
            capabilitySet.Add(generalCapability);

            PRINTER_CAPS_SET printerCapability = new PRINTER_CAPS_SET();
            printerCapability.Header = new CAPABILITY_HEADER();
            printerCapability.Header.CapabilityType = CapabilityType_Values.CAP_PRINTER_TYPE;
            printerCapability.Header.CapabilityLength = 8;
            printerCapability.Header.Version = CAPABILITY_VERSION.V1;
            capabilitySet.Add(printerCapability);

            PORT_CAPS_SET portCapability = new PORT_CAPS_SET();
            portCapability.Header = new CAPABILITY_HEADER();
            portCapability.Header.CapabilityType = CapabilityType_Values.CAP_PORT_TYPE;
            portCapability.Header.CapabilityLength = 8;
            portCapability.Header.Version = CAPABILITY_VERSION.V1;
            capabilitySet.Add(portCapability);

            DRIVE_CAPS_SET driveCapability = new DRIVE_CAPS_SET();
            driveCapability.Header = new CAPABILITY_HEADER();
            driveCapability.Header.CapabilityType = CapabilityType_Values.CAP_DRIVE_TYPE;
            driveCapability.Header.CapabilityLength = 8;
            driveCapability.Header.Version = CAPABILITY_VERSION.V2;
            capabilitySet.Add(driveCapability);

            SMARTCARD_CAPS_SET smartcardCapability = new SMARTCARD_CAPS_SET();
            smartcardCapability.Header = new CAPABILITY_HEADER();
            smartcardCapability.Header.CapabilityType = CapabilityType_Values.CAP_SMARTCARD_TYPE;
            smartcardCapability.Header.CapabilityLength = 8;
            smartcardCapability.Header.Version = CAPABILITY_VERSION.V1;
            capabilitySet.Add(smartcardCapability);

            request.CapabilityMessage = capabilitySet.ToArray();
            return request;
        }
        /// <summary>
        /// Decode Client Core Capability Response packet
        /// </summary>
        /// <param name="data">Packet data</param>
        /// <returns>Client Core Capability Response packet</returns>
        public static DR_CORE_CAPABILITY_RSP DecodeClientCoreCapabilityRSP(byte[] data)
        {
            int index = 0;
            DR_CORE_CAPABILITY_RSP packet = new DR_CORE_CAPABILITY_RSP();
            packet.Header = DecodeRdpdrHeader(data, ref index, false);
            packet.numCapabilities = ParseUInt16(data, ref index, false);
            packet.Padding = ParseUInt16(data, ref index, false);

            List<CAPABILITY_SET> capbilityList = new List<CAPABILITY_SET>();

            while (index + 8 <= data.Length)
            {
                CAPABILITY_HEADER header = DecodeCapabilityHeader(data, ref index, false);
                if (header.CapabilityType == CapabilityType_Values.CAP_GENERAL_TYPE)
                {
                    int originalIndex = index;
                    GENERAL_CAPS_SET capSet = new GENERAL_CAPS_SET();
                    capSet.Header = header;
                    capSet.osType = (osType_Values)ParseUInt32(data, ref index, false);
                    capSet.osVersion = (osVersion_Values)ParseUInt32(data, ref index, false);
                    capSet.protocolMajorVersion = (protocolMajorVersion_Values)ParseUInt16(data, ref index, false);
                    capSet.protocolMinorVersion = ParseUInt16(data, ref index, false);
                    capSet.ioCode1 = (ioCode1_Values)ParseUInt32(data, ref index, false);
                    capSet.ioCode2 = (ioCode2_Values)ParseUInt32(data, ref index, false);
                    capSet.extendedPDU = (extendedPDU_Values)ParseUInt32(data, ref index, false);
                    capSet.extraFlags1 = (extraFlags1_Values)ParseUInt32(data, ref index, false);
                    capSet.extraFlags2 = (extraFlags2_Values)ParseUInt32(data, ref index, false);
                    capSet.SpecialTypeDeviceCap = ParseUInt32(data, ref index, false);
                    index = originalIndex + header.CapabilityLength;
                    capbilityList.Add(capSet);
                }
                else if (header.CapabilityType == CapabilityType_Values.CAP_PRINTER_TYPE)
                {
                    PRINTER_CAPS_SET capSet = new PRINTER_CAPS_SET();
                    capSet.Header = header;
                    capbilityList.Add(capSet);
                }
                else if (header.CapabilityType == CapabilityType_Values.CAP_DRIVE_TYPE)
                {
                    DRIVE_CAPS_SET capSet = new DRIVE_CAPS_SET();
                    capSet.Header = header;
                    capbilityList.Add(capSet);
                }
                else if (header.CapabilityType == CapabilityType_Values.CAP_PORT_TYPE)
                {
                    PORT_CAPS_SET capSet = new PORT_CAPS_SET();
                    capSet.Header = header;
                    capbilityList.Add(capSet);
                }
                else if (header.CapabilityType == CapabilityType_Values.CAP_SMARTCARD_TYPE)
                {
                    SMARTCARD_CAPS_SET capSet = new SMARTCARD_CAPS_SET();
                    capSet.Header = header;
                    capbilityList.Add(capSet);
                }
                else
                {
                    return null;
                }
            }
            packet.CapabilityMessage = capbilityList.ToArray();

            return packet;
        }