protected void RunTest(string sourceFile, string outputFile, Address addrBase) { Program program; using (var rdr = new StreamReader(FileUnitTester.MapTestPath(sourceFile))) { program = asm.Assemble(addrBase, rdr); } foreach (var item in asm.ImportReferences) { program.ImportReferences.Add(item.Key, item.Value); } using (FileUnitTester fut = new FileUnitTester(outputFile)) { Dumper dumper = new Dumper(program.Architecture); dumper.ShowAddresses = true; dumper.ShowCodeBytes = true; dumper.DumpData(program.Image, program.Image.BaseAddress, program.Image.Length, fut.TextWriter); fut.TextWriter.WriteLine(); dumper.DumpAssembler(program.Image, program.Image.BaseAddress, program.Image.BaseAddress + (uint)program.Image.Length, fut.TextWriter); if (program.ImportReferences.Count > 0) { foreach (var de in program.ImportReferences.OrderBy(d => d.Key)) { fut.TextWriter.WriteLine("{0:X8}: {1}", de.Key, de.Value); } } fut.AssertFilesEqual(); } }
private void RenderResult(Program program, string outputFile) { foreach (var item in asm.ImportReferences) { program.ImportReferences.Add(item.Key, item.Value); } using (FileUnitTester fut = new FileUnitTester(outputFile)) { Dumper dumper = new Dumper(program); dumper.ShowAddresses = true; dumper.ShowCodeBytes = true; var mem = program.SegmentMap.Segments.Values.First().MemoryArea; var formatter = new TextFormatter(fut.TextWriter); dumper.DumpData(program.SegmentMap, program.Architecture, mem.BaseAddress, mem.Bytes.Length, formatter); fut.TextWriter.WriteLine(); dumper.DumpAssembler(program.SegmentMap, program.Architecture, mem.BaseAddress, mem.EndAddress, formatter); if (program.ImportReferences.Count > 0) { var list = new SortedList <Address, ImportReference>(program.ImportReferences); foreach (var de in list) { fut.TextWriter.WriteLine("{0}: {1}", de, de.Value); } } fut.AssertFilesEqual(); } }
private void RenderResult(Program prog, string outputFile) { foreach (var item in asm.ImportReferences) { prog.ImportReferences.Add(item.Key, item.Value); } using (FileUnitTester fut = new FileUnitTester(outputFile)) { Dumper dumper = new Dumper(prog.Architecture); dumper.ShowAddresses = true; dumper.ShowCodeBytes = true; dumper.DumpData(prog.Image, prog.Image.BaseAddress, prog.Image.Bytes.Length, fut.TextWriter); fut.TextWriter.WriteLine(); dumper.DumpAssembler(prog.Image, prog.Image.BaseAddress, prog.Image.BaseAddress + prog.Image.Bytes.Length, fut.TextWriter); if (prog.ImportReferences.Count > 0) { var list = new SortedList <Address, ImportReference>(prog.ImportReferences); foreach (var de in list) { fut.TextWriter.WriteLine("{0}: {1}", de, de.Value); } } fut.AssertFilesEqual(); } }
private void RunTest(string sourceFile, string outputFile) { Program program; using (var rdr = new StreamReader(FileUnitTester.MapTestPath(sourceFile))) { program = asm.Assemble(Address.SegPtr(0x0C00, 0), rdr); } using (FileUnitTester fut = new FileUnitTester(outputFile)) { Dumper dump = new Dumper(asm.Architecture); dump.DumpData(program.Image, program.Image.BaseAddress, program.Image.Bytes.Length, fut.TextWriter); fut.TextWriter.WriteLine(); dump.ShowAddresses = true; dump.ShowCodeBytes = true; dump.DumpAssembler(program.Image, program.Image.BaseAddress, program.Image.BaseAddress + program.Image.Bytes.Length, fut.TextWriter); fut.AssertFilesEqual(); } }
private void RunTest(string sourceFile, string outputFile) { Program program; using (var rdr = new StreamReader(FileUnitTester.MapTestPath(sourceFile))) { program = asm.Assemble(Address.SegPtr(0x0C00, 0), rdr); } using (FileUnitTester fut = new FileUnitTester(outputFile)) { Dumper dump = new Dumper(program); var bmem = (ByteMemoryArea)program.SegmentMap.Segments.Values.First().MemoryArea; var formatter = new TextFormatter(fut.TextWriter); dump.DumpData(program.SegmentMap, program.Architecture, bmem.BaseAddress, bmem.Bytes.Length, formatter); fut.TextWriter.WriteLine(); dump.ShowAddresses = true; dump.ShowCodeBytes = true; dump.DumpAssembler(program.SegmentMap, program.Architecture, bmem.BaseAddress, bmem.EndAddress, formatter); fut.AssertFilesEqual(); } }
protected void RunTest(string sourceFile, string outputFile, Address addrBase) { Program program; using (var rdr = new StreamReader(FileUnitTester.MapTestPath(sourceFile))) { program = asm.Assemble(addrBase, rdr); } foreach (var item in asm.ImportReferences) { program.ImportReferences.Add(item.Key, item.Value); } using (FileUnitTester fut = new FileUnitTester(outputFile)) { Dumper dumper = new Dumper(program); dumper.ShowAddresses = true; dumper.ShowCodeBytes = true; foreach (var segment in program.SegmentMap.Segments.Values) { var bmem = (ByteMemoryArea)segment.MemoryArea; var formatter = new TextFormatter(fut.TextWriter); dumper.DumpData(program.SegmentMap, program.Architecture, bmem.BaseAddress, bmem.Length, formatter); fut.TextWriter.WriteLine(); dumper.DumpAssembler(program.SegmentMap, program.Architecture, bmem.BaseAddress, bmem.EndAddress, formatter); if (program.ImportReferences.Count > 0) { foreach (var de in program.ImportReferences.OrderBy(d => d.Key)) { fut.TextWriter.WriteLine("{0:X8}: {1}", de.Key, de.Value); } } } fut.AssertFilesEqual(); } }
private void Disassemble() { try { if (this.arch is null) { return; } if (!arch.TryParseAddress(control.Address.Text, out var addr)) { return; } var bytes = BytePattern.FromHexBytes(control.HexBytes.Text).ToArray(); if (bytes.Length > 0) { var mem = arch.CreateMemoryArea(addr, bytes); var dumper = new Dumper(new Program()) { ShowAddresses = true, ShowCodeBytes = true, }; var sw = new StringWriter(); dumper.DumpAssembler(arch, mem, mem.BaseAddress, bytes.Length, new Core.Output.TextFormatter(sw)); control.Disassembly.Text = sw.ToString(); } else { control.Disassembly.Text = ""; } } catch (Exception ex) { var diagSvc = services.RequireService <IDiagnosticsService>(); diagSvc.Error(ex, "An error occurred during disassembly."); } }