상속: IntelArchitecture
예제 #1
0
 public void Setup()
 {
     var sc = new ServiceContainer();
     sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
     var arch = new X86ArchitectureReal();
     this.platform = new MsdosPlatform(sc, arch);
 }
예제 #2
0
        public void Dec_LoadCallSignatures()
        {
            var arch = new X86ArchitectureReal();
            Program program = new Program { 
                Architecture = arch,
                Platform = new MsdosPlatform(sc, arch)
            };
            decompiler.Project = new Project
            {
                Programs = { program },
            };
            SerializedSignature sig = new SerializedSignature();
            sig.Arguments = new Argument_v1[] {
			    new Argument_v1 {
			        Kind = new Register_v1("ds")
                },
                new Argument_v1 {
			        Kind = new Register_v1("bx"),
                }
            };
            var al = new List<SerializedCall_v1> {
                new SerializedCall_v1(Address.SegPtr(0x0C32, 0x3200), sig)
            };
            var sigs = decompiler.LoadCallSignatures(program, al);

            FunctionType ps = sigs[Address.SegPtr(0x0C32, 0x3200)];
            Assert.IsNotNull(ps, "Expected a call signature for address");
        }
예제 #3
0
		public void TestGrfWithOneBit()
		{
			IProcessorArchitecture arch = new X86ArchitectureReal();
			SignatureBuilder sb = new SignatureBuilder(null, arch);
            sb.AddFlagGroupReturnValue((uint) FlagM.CF, arch.CreateFrame());
			FunctionType sig = sb.BuildSignature();
			Assert.AreEqual("bool", sig.ReturnValue.DataType.ToString());
		}
예제 #4
0
파일: RewriterTests.cs 프로젝트: uxmal/reko
		public void SetUp()
		{
            var arch = new X86ArchitectureReal();
            program = new Program() { Architecture = arch };
            sc = new ServiceContainer();
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            asm = new X86TextAssembler(sc, arch);
			configFile = null;
		}
예제 #5
0
		protected Program RewriteProgramMsdos(string sourceFilename, Address addrBase)
		{
            var sc = new ServiceContainer();
            sc.AddService<IConfigurationService>(new FakeDecompilerConfiguration());
            var ldr = new Loader(sc);
            var arch = new X86ArchitectureReal();

            program = ldr.AssembleExecutable(
                FileUnitTester.MapTestPath(sourceFilename),
                new X86TextAssembler(arch) { Platform = new MsdosPlatform(null, arch) },
                addrBase);
            return RewriteProgram();
		}
예제 #6
0
        public void X86St_Simple()
        {
            var arch = new X86ArchitectureReal();

            X86State st = new X86State(arch);
            st.SetRegister(Registers.cs, Constant.Word16(0xC00));
            st.SetRegister(Registers.ax, Constant.Word16(0x1234));
            Assert.IsTrue(!st.GetRegister(Registers.bx).IsValid);
            Assert.IsTrue(st.GetRegister(Registers.ax).IsValid);
            Assert.IsTrue(st.GetRegister(Registers.al).IsValid);
            Assert.AreEqual(0x34, st.GetRegister(Registers.al).ToUInt32());
            Assert.IsTrue(st.GetRegister(Registers.ah).IsValid);
            Assert.AreEqual(0x12, st.GetRegister(Registers.ah).ToUInt32());
        }
		private Program AssembleFile(string sourceFile, Address addr)
		{
            var ldr = new Loader(new ServiceContainer());
            var arch = new X86ArchitectureReal();
            Program program = ldr.AssembleExecutable(
                 FileUnitTester.MapTestPath(sourceFile),
                 new X86TextAssembler(sc, arch),
                addr);
            var project = new Project { Programs = { program } };
			var scan = new Scanner(program, new Dictionary<Address, ProcedureSignature>(), new ImportResolver(project), null);
			foreach (EntryPoint ep in program.EntryPoints)
			{
				scan.EnqueueEntryPoint(ep);
			}
			scan.ScanImage();
			return program;
		}
예제 #8
0
		public void PsigArguments()
		{
			using (FileUnitTester fut = new FileUnitTester("Core/PsigArguments.txt"))
			{
				IntelArchitecture arch = new X86ArchitectureReal();
				uint f = (uint)(FlagM.CF|FlagM.ZF);
				Identifier argF = new Identifier(arch.GrfToString(f), PrimitiveType.Bool, new FlagGroupStorage(Registers.eflags, f, "CZ", PrimitiveType.Byte));
				Identifier argR = new Identifier(Registers.ax.Name, Registers.ax.DataType, Registers.ax);
				
				argF.Write(true, fut.TextWriter);
				fut.TextWriter.WriteLine();
				argR.Write(true, fut.TextWriter);
				fut.TextWriter.WriteLine();

				fut.AssertFilesEqual();
			}
		}
예제 #9
0
		private Program AssembleFile(string sourceFile, Address addr)
		{
            var ldr = new Loader(new ServiceContainer());
            var arch = new X86ArchitectureReal();
            Program program = ldr.AssembleExecutable(
                 FileUnitTester.MapTestPath(sourceFile),
                 new X86TextAssembler(sc, arch),
                addr);
            var project = new Project { Programs = { program } };
			var scan = new Scanner(
                program, 
                new ImportResolver(project, program, null), null);
			foreach (ImageSymbol ep in program.EntryPoints.Values)
			{
				scan.EnqueueImageSymbol(ep, true);
			}
			scan.ScanImage();
			return program;
		}
예제 #10
0
        protected Program RewriteProgramMsdos(string sourceFilename, Address addrBase)
		{
            var cfgSvc = MockRepository.GenerateStub<IConfigurationService>();
            var env = MockRepository.GenerateStub<OperatingEnvironment>();
            var tlSvc = MockRepository.GenerateStub<ITypeLibraryLoaderService>();
            cfgSvc.Stub(c => c.GetEnvironment("ms-dos")).Return(env);
            cfgSvc.Stub(c => c.GetSignatureFiles()).Return(new List<SignatureFile>());
            env.Stub(e => e.TypeLibraries).Return(new List<ITypeLibraryElement>());
            env.Stub(e => e.CharacteristicsLibraries).Return(new List<ITypeLibraryElement>());
            sc = new ServiceContainer();
            sc.AddService<IConfigurationService>(cfgSvc);
            sc.AddService<DecompilerHost>(new FakeDecompilerHost());
            sc.AddService<DecompilerEventListener>(new FakeDecompilerEventListener());
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            sc.AddService<ITypeLibraryLoaderService>(tlSvc);
            var ldr = new Loader(sc);
            var arch = new X86ArchitectureReal();

            program = ldr.AssembleExecutable(
                FileUnitTester.MapTestPath(sourceFilename),
                new X86TextAssembler(sc, arch) { Platform = new MsdosPlatform(sc, arch) },
                addrBase);
            return RewriteProgram();
		}
예제 #11
0
 private void BuildTest16(Action<X86Assembler> m)
 {
     var arch = new X86ArchitectureReal();
     BuildTest(arch, Address.SegPtr(0x0C00, 0x000), new MsdosPlatform(sc, arch), m);
 }
예제 #12
0
 protected static Program RewriteMsdosAssembler(string relativePath, string configFile)
 {
     var arch = new X86ArchitectureReal();
     var sc = new ServiceContainer();
     var cfgSvc = MockRepository.GenerateStub<IConfigurationService>();
     var env = MockRepository.GenerateStub<OperatingEnvironment>();
     var tlSvc = MockRepository.GenerateStub<ITypeLibraryLoaderService>();
     cfgSvc.Stub(c => c.GetEnvironment("ms-dos")).Return(env);
     cfgSvc.Replay();
     env.Stub(e => e.TypeLibraries).Return(new List<ITypeLibraryElement>());
     env.Stub(e => e.CharacteristicsLibraries).Return(new List<ITypeLibraryElement>());
     env.Replay();
     tlSvc.Replay();
     sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
     sc.AddService<IConfigurationService>(cfgSvc);
     sc.AddService<ITypeLibraryLoaderService>(tlSvc);
     Program program;
     Assembler asm = new X86TextAssembler(sc, arch);
     using (var rdr = new StreamReader(FileUnitTester.MapTestPath(relativePath)))
     {
         program = asm.Assemble(Address.SegPtr(0xC00, 0), rdr);
         program.Platform = new MsdosPlatform(sc, program.Architecture);
     }
     Rewrite(program, asm, configFile);
     return program;
 }
예제 #13
0
		public void AsFragment()
		{
			 AssembleFragment(
@"		.i86
hello	proc
		mov	ax,0x30
		mov	bx,0x40
hello	endp
");
            var segment = program.SegmentMap.Segments.Values.First();
			using (FileUnitTester fut = new FileUnitTester("Intel/AsFragment.txt"))
			{
				var arch = new X86ArchitectureReal();
				var d = new Dumper(arch);
				d.DumpData(program.SegmentMap, segment.Address, segment.ContentSize, new TextFormatter(fut.TextWriter));
				fut.AssertFilesEqual();
			}
		}
예제 #14
0
파일: AliasTests.cs 프로젝트: relaxar/reko
 public void Setup()
 {
     var arch = new X86ArchitectureReal();
     proc = Procedure.Create("foo", Address.Ptr32(0x100), arch.CreateFrame());
     alias = new Aliases(proc, arch);
 }
예제 #15
0
 private void Given_MsdosPlatform()
 {
     this.arch = new X86ArchitectureReal();
     this.platform = new MsdosPlatform(sc, arch);
 }