private TS_UD_CS_CORE ParseTsUdCsCore(byte[] data, ref int currentIndex, int length)
{
int endIndex = currentIndex + length - 1;
TS_UD_CS_CORE coreData = new TS_UD_CS_CORE();
coreData.header.type = (TS_UD_HEADER_type_Values)ParseUInt16(data, ref currentIndex, false);
coreData.header.length = ParseUInt16(data, ref currentIndex, false);
coreData.version = (version_Values)ParseUInt32(data, ref currentIndex, false);
coreData.desktopWidth = ParseUInt16(data, ref currentIndex, false);
coreData.desktopHeight = ParseUInt16(data, ref currentIndex, false);
coreData.colorDepth = (colorDepth_Values)ParseUInt16(data, ref currentIndex, false);
coreData.SASSequence = ParseUInt16(data, ref currentIndex, false);
coreData.keyboardLayout = ParseUInt32(data, ref currentIndex, false);
coreData.clientBuild = ParseUInt32(data, ref currentIndex, false);
coreData.clientName = ParseString(data, ref currentIndex, 32);
coreData.keyboardType = (keyboardType_Values)ParseUInt32(data, ref currentIndex, false);
coreData.keyboardSubType = ParseUInt32(data, ref currentIndex, false);
coreData.keyboardFunctionKey = ParseUInt32(data, ref currentIndex, false);
coreData.imeFileName = ParseString(data, ref currentIndex, 64);
//below fields are optional fields, verify the length before parsing.
if(currentIndex < endIndex)
coreData.postBeta2ColorDepth = new UInt16Class(ParseUInt16(data, ref currentIndex, false));
if (currentIndex < endIndex)
coreData.clientProductId = new UInt16Class(ParseUInt16(data, ref currentIndex, false));
if (currentIndex < endIndex)
coreData.serialNumber = new UInt32Class(ParseUInt32(data, ref currentIndex, false));
if (currentIndex < endIndex)
coreData.highColorDepth = new UInt16Class(ParseUInt16(data, ref currentIndex, false));
if (currentIndex < endIndex)
coreData.supportedColorDepths = new UInt16Class(ParseUInt16(data, ref currentIndex, false));
if (currentIndex < endIndex)
coreData.earlyCapabilityFlags = new UInt16Class(ParseUInt16(data, ref currentIndex, false));
if (currentIndex < endIndex)
coreData.clientDigProductId = ParseString(data, ref currentIndex, 64);
if (currentIndex < endIndex)
coreData.connnectionType = new ByteClass(ParseByte(data, ref currentIndex));
if (currentIndex < endIndex)
coreData.pad1octets = new ByteClass(ParseByte(data, ref currentIndex));
if (currentIndex < endIndex)
coreData.serverSelectedProtocol = new UInt32Class(ParseUInt32(data, ref currentIndex, false));
if (currentIndex < endIndex)
coreData.desktopPhysicalWidth = new UInt32Class(ParseUInt32(data, ref currentIndex, false));
if (currentIndex < endIndex)
coreData.desktopPhysicalHeight = new UInt32Class(ParseUInt32(data, ref currentIndex, false));
if (currentIndex < endIndex)
coreData.desktopOrientation = (TS_UD_CS_CORE_desktopOrientation_values)ParseUInt16(data, ref currentIndex, false);
if (currentIndex < endIndex)
coreData.desktopScaleFactor = new UInt32Class(ParseUInt32(data, ref currentIndex, false));
if (currentIndex < endIndex)
coreData.deviceScaleFactor = new UInt32Class(ParseUInt32(data, ref currentIndex, false));
return coreData;
}