예제 #1
0
        public void ReadFixedZeroFilledString_StreamTooShort()
        {
            var stream = new MemoryStream();
            var reader = new BinaryStreamReader(stream, new byte[20]);

            reader.ReadFixedZeroFilledAsciiString(8);
        }
예제 #2
0
        public void ReadFixedZeroFilledString_A()
        {
            var    reader = new BinaryStreamReader(new MemoryStream(new byte[] { 65 }), new byte[20]);
            string str    = reader.ReadFixedZeroFilledAsciiString(1);

            Assert.AreEqual("A", str);
        }
예제 #3
0
        public void ReadFixedZeroFilledString_0IsEmpty()
        {
            var    reader = new BinaryStreamReader(new MemoryStream(), new byte[20]);
            string str    = reader.ReadFixedZeroFilledAsciiString(0);

            Assert.AreEqual("", str);
        }
예제 #4
0
        public void ShortThenExtend_ReadFixedZeroFilledString_StreamTooShort()
        {
            var stream = new GradualReadMemoryStream(Encoding.ASCII.GetBytes("*ABCD"), 1);
            var reader = new BinaryStreamReader(stream, new byte[20]);

            reader.ReadByte();
            reader.ReadFixedZeroFilledAsciiString(20);
        }
예제 #5
0
        public void ShortThenExtend_ReadFixedZeroFilledString_Alphabet()
        {
            var stream = new GradualReadMemoryStream(Encoding.ASCII.GetBytes("*ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1);
            var reader = new BinaryStreamReader(stream, new byte[20]);

            reader.ReadByte();
            string str = reader.ReadFixedZeroFilledAsciiString(26);

            Assert.AreEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ", str);
        }
예제 #6
0
 static void ReadSectionHeader(BinaryStreamReader reader, SectionHeader section)
 {
     section.Name = reader.ReadFixedZeroFilledAsciiString(SectionHeader.MaximumNameSize);
     section.VirtualSize = reader.ReadUInt32();
     section.VirtualAddress = reader.ReadUInt32();
     section.SizeOfRawData = reader.ReadUInt32();
     section.PointerToRawData = reader.ReadUInt32();
     section.PointerToRelocations = reader.ReadUInt32();
     section.PointerToLinenumbers = reader.ReadUInt32();
     section.NumberOfRelocations = reader.ReadUInt16();
     section.NumberOfLinenumbers = reader.ReadUInt16();
     section.Characteristics = (SectionCharacteristics)reader.ReadUInt32();
 }
예제 #7
0
 public void ReadFixedZeroFilledString_Negative()
 {
     var    reader = new BinaryStreamReader(new MemoryStream(), new byte[20]);
     string str    = reader.ReadFixedZeroFilledAsciiString(-1);
 }
예제 #8
0
 public void ShortThenExtend_ReadFixedZeroFilledString_StreamTooShort()
 {
     var stream = new GradualReadMemoryStream(Encoding.ASCII.GetBytes("*ABCD"), 1);
     var reader = new BinaryStreamReader(stream, new byte[20]);
     reader.ReadByte();
     reader.ReadFixedZeroFilledAsciiString(20);
 }
예제 #9
0
 public void ShortThenExtend_ReadFixedZeroFilledString_Alphabet()
 {
     var stream = new GradualReadMemoryStream(Encoding.ASCII.GetBytes("*ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1);
     var reader = new BinaryStreamReader(stream, new byte[20]);
     reader.ReadByte();
     string str = reader.ReadFixedZeroFilledAsciiString(26);
     Assert.AreEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ", str);
 }
예제 #10
0
 public void ReadFixedZeroFilledString_StreamTooShort()
 {
     var stream = new MemoryStream();
     var reader = new BinaryStreamReader(stream, new byte[20]);
     reader.ReadFixedZeroFilledAsciiString(8);
 }
예제 #11
0
 public void ReadFixedZeroFilledString_Negative()
 {
     var reader = new BinaryStreamReader(new MemoryStream(), new byte[20]);
     string str = reader.ReadFixedZeroFilledAsciiString(-1);
 }
예제 #12
0
 public void ReadFixedZeroFilledString_FilledWithZero()
 {
     var reader = new BinaryStreamReader(new MemoryStream(new byte[1]), new byte[20]);
     string str = reader.ReadFixedZeroFilledAsciiString(1);
     Assert.AreEqual("", str);
 }
예제 #13
0
 public void ReadFixedZeroFilledString_0IsEmpty()
 {
     var reader = new BinaryStreamReader(new MemoryStream(), new byte[20]);
     string str = reader.ReadFixedZeroFilledAsciiString(0);
     Assert.AreEqual("", str);
 }