Пример #1
0
        /// <summary>
        /// Constructor from a type 1 serialized buffer.
        /// </summary>
        /// <param name="encoded">The type 1 serialized encoded buffer.</param>
        public NdrPickledType(byte[] encoded)
        {
            BinaryReader reader = new BinaryReader(new MemoryStream(encoded));

            if (reader.ReadByte() != 1)
            {
                throw new ArgumentException("Only support version 1 serialization");
            }
            if (reader.ReadByte() != 0x10)
            {
                throw new ArgumentException("Only support little-endian NDR data.");
            }
            if (reader.ReadInt16() != 8)
            {
                throw new ArgumentException("Unexpected header length");
            }
            // Padding.
            reader.ReadInt32();
            int length = reader.ReadInt32();

            // Padding.
            reader.ReadInt32();
            Data = reader.ReadAllBytes(length);
            DataRepresentation = new NdrDataRepresentation()
            {
                IntegerRepresentation       = NdrIntegerRepresentation.LittleEndian,
                CharacterRepresentation     = NdrCharacterRepresentation.ASCII,
                FloatingPointRepresentation = NdrFloatingPointRepresentation.IEEE
            };
        }
 public NdrUnmarshalBuffer(byte[] buffer, IEnumerable <NtObject> handles, NdrDataRepresentation data_represenation)
 {
     _stm            = new MemoryStream(buffer);
     _reader         = new BinaryReader(_stm, Encoding.Unicode);
     _handles        = new DisposableList <NtObject>(handles);
     _deferred_reads = new Queue <Action>();
     CheckDataRepresentation(data_represenation);
 }
 internal static void CheckDataRepresentation(NdrDataRepresentation data_represenation)
 {
     if (data_represenation.IntegerRepresentation != NdrIntegerRepresentation.LittleEndian ||
         data_represenation.FloatingPointRepresentation != NdrFloatingPointRepresentation.IEEE ||
         data_represenation.CharacterRepresentation != NdrCharacterRepresentation.ASCII)
     {
         throw new ArgumentException("Unsupported NDR data representation");
     }
 }
Пример #4
0
 internal NdrPickledType(byte[] data, NdrDataRepresentation data_representation)
 {
     DataRepresentation = data_representation;
     if (DataRepresentation.CharacterRepresentation != NdrCharacterRepresentation.ASCII ||
         DataRepresentation.FloatingPointRepresentation != NdrFloatingPointRepresentation.IEEE)
     {
         throw new ArgumentException("Invalid data representation for type 1 serialized buffer");
     }
     Data = data;
 }
Пример #5
0
 public NdrMarshalBuffer(NdrDataRepresentation data_representation)
 {
     _stm             = new MemoryStream();
     _writer          = new BinaryWriter(_stm, Encoding.Unicode);
     _handles         = new List <NtObject>();
     _referent        = 0x20000;
     _deferred_writes = new NdrDeferralStack();
     NdrUnmarshalBuffer.CheckDataRepresentation(data_representation);
     DataRepresentation = data_representation;
 }