public void HasColonInWrongPlace()
 {
     writer.WriteLine(":");
     writer.Flush();
     parser = new DumpFileParser(stream, "main");
     CollectionAssert.AreEqual(new Byte[] {0xc9}, parser.GetBytes());
 }
 public void HasColonInWrongPlace()
 {
     writer.WriteLine(":");
     writer.Flush();
     parser = new DumpFileParser(stream, "main");
     CollectionAssert.AreEqual(new Byte[] { 0xc9 }, parser.GetBytes());
 }
        public void EmptyLine()
        {
            writer.WriteLine(String.Empty);
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            Assert.IsNull(parser.GetBytes());
        }
        public void LineWithSpaceTab()
        {
            writer.WriteLine(" 8048388:       c7 04 24 10 00 00 00 \tmov    DWORD PTR [esp],0x10");
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            var expectedResult = new Byte[] { 0xc9, 0xc7, 0x04, 0x24, 0x10, 0x00, 0x00, 0x00 };

            CollectionAssert.AreEqual(expectedResult, parser.GetBytes());
        }
        public void LineWithSingleHex()
        {
            writer.WriteLine(" 804837c:       55                      push   ebp");
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            var expectedResult = new Byte[] { 0xc9, 0x55 };

            CollectionAssert.AreEqual(expectedResult, parser.GetBytes());
        }
        public void GetBytesIsNull()
        {
            writer.WriteLine(" 804837f:       55                      push   ebp");
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            Assert.IsNull(parser.GetBytes());
            Assert.AreEqual(0, parser.BaseAddress);
            Assert.AreEqual(0, parser.EntryPointAddress);
        }
        public void GetBytesReturnAllInstructions()
        {
            writer.WriteLine(" 804837d:	c3                   	ret    ");
            writer.WriteLine(" 804837e:	90                   	nop    ");
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            var code = parser.GetBytes();
            CollectionAssert.AreEqual(new Byte[] {0xc9, 0xc3, 0x90}, code);
        }
        public void LineWithMultipleHex()
        {
            writer.WriteLine(" 8048385:       83 ec 10                sub    esp,0x10");
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            var expectedResult = new Byte[] { 0xc9, 0x83, 0xec, 0x10 };

            CollectionAssert.AreEqual(expectedResult, parser.GetBytes());
        }
        public void GetBytesReturnAllInstructions()
        {
            writer.WriteLine(" 804837d:	c3                   	ret    ");
            writer.WriteLine(" 804837e:	90                   	nop    ");
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            var code = parser.GetBytes();

            CollectionAssert.AreEqual(new Byte[] { 0xc9, 0xc3, 0x90 }, code);
        }
        public void ParseNonMain()
        {
            writer.WriteLine(" 804837d:	c3                   	ret    ");
            writer.WriteLine();
            writer.Flush();
            parser = new DumpFileParser(stream, "_start");

            Assert.AreEqual(0x0804837c, parser.BaseAddress);
            Assert.AreEqual(0x0804837c, parser.EntryPointAddress);

            var code = parser.GetBytes();

            Assert.AreEqual(0xc9, code[0]);
        }
        public void MainIsLastFunction()
        {
            writer.WriteLine(" 804837d:	c3                   	ret    ");
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            Assert.AreEqual(0x0804837c, parser.BaseAddress);
            Assert.AreEqual(0x0804837d, parser.EntryPointAddress);

            var code = parser.GetBytes();

            CollectionAssert.AreEqual(new Byte[] { 0xc9, 0xc3 }, code);
            Assert.AreEqual(2, code.Length);
            Assert.AreEqual(0, parser.ExpectedReportItems.Count);
        }
 public void NoLines()
 {
     parser = new DumpFileParser(stream, "main");
     Assert.IsNull(parser.GetBytes());
 }
        public void EmptyLine()
        {
            writer.WriteLine(String.Empty);
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            Assert.IsNull(parser.GetBytes());
        }
        public void GetBytesIsNull()
        {
            writer.WriteLine(" 804837f:       55                      push   ebp");
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            Assert.IsNull(parser.GetBytes());
            Assert.AreEqual(0, parser.BaseAddress);
            Assert.AreEqual(0, parser.EntryPointAddress);
        }
        public void ParseNonMain()
        {
            writer.WriteLine(" 804837d:	c3                   	ret    ");
            writer.WriteLine();
            writer.Flush();
            parser = new DumpFileParser(stream, "_start");

            Assert.AreEqual(0x0804837c, parser.BaseAddress);
            Assert.AreEqual(0x0804837c, parser.EntryPointAddress);

            var code = parser.GetBytes();
            Assert.AreEqual(0xc9, code[0]);
        }
        public void NextLineSkipsBadLines()
        {
            writer.WriteLine("BADLINE");
            writer.WriteLine(" 8048385:       83 ec 10                sub    esp,0x10");
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            var expectedResult = new Byte[] {0xc9, 0x83, 0xec, 0x10};
            CollectionAssert.AreEqual(expectedResult, parser.GetBytes());
        }
        public void MainIsNotLastFunction()
        {
            writer.WriteLine(" 804837d:	c3                   	ret    ");
            writer.WriteLine();
            writer.WriteLine("0804837e <nonmain2>:");
            writer.WriteLine(" 804837e:	90                   	nop  ");
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            Assert.AreEqual(0x0804837c, parser.BaseAddress);
            Assert.AreEqual(0x0804837d, parser.EntryPointAddress);

            var code = parser.GetBytes();
            CollectionAssert.AreEqual(new Byte[] {0xc9, 0xc3, 0x90}, code);
            Assert.AreEqual(3, code.Length);
            Assert.AreEqual(0, parser.ExpectedReportItems.Count);
        }
 public void NoLines()
 {
     parser = new DumpFileParser(stream, "main");
     Assert.IsNull(parser.GetBytes());
 }
        public void LineWithMuchoHex()
        {
            writer.WriteLine(" 8048388:       c7 04 24 10 00 00 00    mov    DWORD PTR [esp],0x10");
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            var expectedResult = new Byte[] {0xc9, 0xc7, 0x04, 0x24, 0x10, 0x00, 0x00, 0x00};
            CollectionAssert.AreEqual(expectedResult, parser.GetBytes());
        }
        public void LineWithSingleHex()
        {
            writer.WriteLine(" 804837c:       55                      push   ebp");
            writer.Flush();
            parser = new DumpFileParser(stream, "main");

            var expectedResult = new Byte[] {0xc9, 0x55};
            CollectionAssert.AreEqual(expectedResult, parser.GetBytes());
        }