Beispiel #1
0
		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();
			}
		}
Beispiel #2
0
		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();
			}	
		}
Beispiel #3
0
		public void AsFragment()
		{
			var program = asm.AssembleFragment(
				Address.SegPtr(0xC00, 0),
@"		.i86
hello	proc
		mov	ax,0x30
		mov	bx,0x40
hello	endp
");
            LoadedImage img = program.Image;
			using (FileUnitTester fut = new FileUnitTester("Intel/AsFragment.txt"))
			{
				var arch = new IntelArchitecture(ProcessorMode.Real);
				var d = new Dumper(arch);
				d.DumpData(img, img.BaseAddress, img.Bytes.Length, fut.TextWriter);
				fut.AssertFilesEqual();
			}
		}
Beispiel #4
0
		public void AsCarryInstructions()
		{
            Program program;
            using (var rdr = new StreamReader(FileUnitTester.MapTestPath("Fragments/carryinsts.asm")))
            {
			    program = asm.Assemble(Address.SegPtr(0xBAC, 0), rdr);
            }
			using (FileUnitTester fut = new FileUnitTester("Intel/AsCarryInstructions.txt"))
			{
				Dumper dump = new Dumper(arch);
				dump.DumpData(program.Image, program.Image.BaseAddress, program.Image.Length, fut.TextWriter);
				fut.AssertFilesEqual();
			}
		}
 /// <summary>
 /// Copies the selected range of bytes into the clipboard.
 /// </summary>
 /// <returns></returns>
 private bool CopySelectionToClipboard()
 {
     AddressRange range;
     if (!TryGetSelectedAddressRange(out range))
         return true;
     if (control.MemoryView.Focused)
     {
          var decompiler = services.GetService<IDecompilerService>().Decompiler;
          var dumper = new Dumper(decompiler.Project.Programs.First().Architecture);
         var sb = new StringWriter();
         dumper.DumpData(control.MemoryView.ProgramImage, range, sb);
         Clipboard.SetText(sb.ToString());       //$TODO: abstract this.
     }
     return true;
 }