protected static void UpdateLength(RdpPacket packet, string Identifier) { Fixup fixup = RDPClient.m_Fixup[Identifier]; RDPClient.m_Fixup.Remove(Identifier); long position = packet.Position; if (fixup.Length != -1) { long num2 = packet.Position - fixup.Offset; if (num2 != fixup.Length) { throw new Exception("DER Tag length invalid"); } } else { long num3 = packet.Position - (fixup.Offset + 1L); byte[] bytes = BitConverter.GetBytes(num3); packet.Position = fixup.Offset; if (num3 > 0xffffffL) { packet.WriteByte(0x84); packet.InsertByte(bytes[3]); position += 1L; packet.InsertByte(bytes[2]); position += 1L; packet.InsertByte(bytes[1]); position += 1L; packet.InsertByte(bytes[0]); position += 1L; } else if (num3 > 0xffffL) { packet.WriteByte(0x83); packet.InsertByte(bytes[2]); position += 1L; packet.InsertByte(bytes[1]); position += 1L; packet.InsertByte(bytes[0]); position += 1L; } else if (num3 > 0xffL) { packet.WriteByte(130); packet.InsertByte(bytes[1]); position += 1L; packet.InsertByte(bytes[0]); position += 1L; } else if (num3 > 0x7fL) { packet.WriteByte(0x81); packet.InsertByte(bytes[0]); position += 1L; } else { packet.WriteByte(bytes[0]); } packet.Position = position; } }