Processor architecture definition for the Intel x86 family. Currently supported processors are 8086/7, 80186/7, 80286/7, 80386/7, 80486, and Pentium. Also, beginning support for x86-64
Inheritance: IProcessorArchitecture
Esempio n. 1
0
 public void Setup()
 {
     mr = new MockRepository();
     var services = mr.Stub<IServiceProvider>();
     var tlSvc = mr.Stub<ITypeLibraryLoaderService>();
     var configSvc = mr.StrictMock<IConfigurationService>();
     var win32env = new OperatingEnvironmentElement
     {
         TypeLibraries = 
         {
             new TypeLibraryElement {  Name= "msvcrt.xml" },
             new TypeLibraryElement {  Name= "windows32.xml" },
         }
     };
     configSvc.Stub(c => c.GetEnvironment("win32")).Return(win32env);
     configSvc.Stub(c => c.GetPath(null)).IgnoreArguments()
         .Do(new Func<string, string>(s => s));
     services.Stub(s => s.GetService(typeof(ITypeLibraryLoaderService))).Return(tlSvc);
     services.Stub(s => s.GetService(typeof(IConfigurationService))).Return(configSvc);
     tlSvc.Stub(t => t.LoadLibrary(null, null)).IgnoreArguments()
         .Do(new Func<IProcessorArchitecture, string, TypeLibrary>((a, n) =>
         {
             var lib = TypeLibrary.Load(a, Path.ChangeExtension(n, ".xml"));
             return lib;
         }));
     services.Replay();
     tlSvc.Replay();
     configSvc.Replay();
     arch = new IntelArchitecture(ProcessorMode.Protected32);
     win32 = new Reko.Environments.Win32.Win32Platform(services, arch);
 }
Esempio n. 2
0
        public SerializedSignatureTests()
		{
            this.sc = new ServiceContainer();
            this.sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
			this.arch = new X86ArchitectureReal();
            this.platform = new MsdosPlatform(sc, arch);
		}
Esempio n. 3
0
		public X86TextAssembler(IServiceProvider services, IntelArchitecture arch)
		{
            this.services = services;
            this.entryPoints = new List<ImageSymbol>();
            this.ImageSymbols = new List<ImageSymbol>();
            this.arch = arch;
        }
Esempio n. 4
0
		public void SetUp()
		{
            var arch = new IntelArchitecture(ProcessorMode.Real);
            prog = new Program() { Architecture = arch };
            asm = new X86TextAssembler(arch);
			configFile = null;
		}
Esempio n. 5
0
		public void Setup()
		{
            this.sc = new ServiceContainer();
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            arch = new IntelArchitecture(ProcessorMode.Real);
            asm = new X86TextAssembler(sc, arch);
        }
Esempio n. 6
0
        public void Dec_LoadCallSignatures()
        {
            var arch = new IntelArchitecture(ProcessorMode.Real);
            Program program = new Program {
                Architecture = arch,
                Platform = new MsdosPlatform(null, arch)
            };
            decompiler.Project = new Project
            {
                Programs = { program },
            };
            List<SerializedCall_v1> al = new List<SerializedCall_v1>();
            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"),
                }
            };
            al.Add(new SerializedCall_v1(Address.SegPtr(0x0C32, 0x3200), sig));
            var sigs = decompiler.LoadCallSignatures(program, al);

            ProcedureSignature ps = sigs[Address.SegPtr(0x0C32, 0x3200)];
            Assert.IsNotNull(ps, "Expected a call signature for address");
        }
 public void Setup()
 {
     var sc = new ServiceContainer();
     sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
     var arch = new IntelArchitecture(ProcessorMode.Real);
     this.platform = new MsdosPlatform(sc, arch);
 }
 public void Setup()
 {
     mr = new MockRepository();
     mockFactory = new MockFactory(mr);
     arch = new IntelArchitecture(ProcessorMode.Protected32);
     platform = new Win32Platform(null, arch);
 }
 public void Setup()
 {
     mr = new MockRepository();
     mockFactory = new MockFactory(mr);
     arch = new X86ArchitectureFlat32();
     platform = new Win32Platform(null, arch);
 }
Esempio n. 10
0
 public OperandRewriter(IntelArchitecture arch, ExpressionEmitter emitter, Frame frame, IRewriterHost host)
 {
     this.arch = arch;
     this.m = emitter;
     this.frame = frame;
     this.host = host;
 }
Esempio n. 11
0
		public void MspRealModeServices()
		{
            mr.ReplayAll();
			IntelArchitecture arch = new IntelArchitecture(ProcessorMode.Real);
			IPlatform platform = new MsdosPlatform(sc, arch);

			var state = arch.CreateProcessorState();
			state.SetRegister(Registers.ah, Constant.Byte(0x3E));
			SystemService svc = platform.FindService(0x21, state);
			Assert.AreEqual("msdos_close_file", svc.Name);
			Assert.AreEqual(1, svc.Signature.Parameters.Length);
			Assert.IsFalse(svc.Characteristics.Terminates, "close() shouldn't terminate program");

			state.SetRegister(Registers.ah, Constant.Byte(0x4C));
			svc = platform.FindService(0x21, state);
			Assert.AreEqual("msdos_terminate", svc.Name);
			Assert.AreEqual(1, svc.Signature.Parameters.Length);
			Assert.IsTrue(svc.Characteristics.Terminates, "terminate() should terminate program");

			state.SetRegister(Registers.ah, Constant.Byte(0x2F));
			svc = platform.FindService(0x21, state);
			Assert.AreEqual("msdos_get_disk_transfer_area_address", svc.Name);
			Assert.AreEqual(0, svc.Signature.Parameters.Length);
			SequenceStorage seq = (SequenceStorage) svc.Signature.ReturnValue.Storage;
			Assert.AreEqual("es", seq.Head.Name);
			Assert.AreEqual("bx", seq.Tail.Name);
		}
Esempio n. 12
0
		public X86State(X86State st) : base(st)
		{
            arch = st.arch;
            FpuStackItems = st.FpuStackItems;
            regs = (ulong[])st.regs.Clone();
			valid = (bool []) st.valid.Clone();
		}
Esempio n. 13
0
 private void BuildTest16(Action<X86Assembler> asmProg)
 {
     sc = new ServiceContainer();
     sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
     arch = new X86ArchitectureReal();
     BuildTest(Address.SegPtr(0x0C00, 0x0000), new MsdosPlatform(sc, arch), asmProg);
 }
Esempio n. 14
0
 public void Setup()
 {
     repository = new MockRepository();
     sc = new ServiceContainer();
     arch = new IntelArchitecture(ProcessorMode.Protected32);
     dcSvc = repository.StrictMock<IConfigurationService>();
 }
Esempio n. 15
0
 public void Setup()
 {
     mr = new MockRepository();
     this.services = mr.Stub<IServiceProvider>();
     var tlSvc = new TypeLibraryLoaderServiceImpl(services);
     var configSvc = mr.StrictMock<IConfigurationService>();
     var win32env = new OperatingEnvironmentElement
     {
         TypeLibraries = 
         {
             new TypeLibraryElement {  Name= "msvcrt.xml" },
             new TypeLibraryElement {  Name= "windows32.xml" },
         }
     };
     configSvc.Stub(c => c.GetEnvironment("win32")).Return(win32env);
     configSvc.Stub(c => c.GetInstallationRelativePath(null)).IgnoreArguments()
         .Do(new Func<string[], string>(s => string.Join("/", s)));
     services.Stub(s => s.GetService(typeof(ITypeLibraryLoaderService))).Return(tlSvc);
     services.Stub(s => s.GetService(typeof(IConfigurationService))).Return(configSvc);
     services.Stub(s => s.GetService(typeof(DecompilerEventListener))).Return(new FakeDecompilerEventListener());
     services.Stub(s => s.GetService(typeof(CancellationTokenSource))).Return(null);
     services.Stub(s => s.GetService(typeof(IFileSystemService))).Return(new FileSystemServiceImpl());
     services.Stub(s => s.GetService(typeof(IDiagnosticsService))).Return(new FakeDiagnosticsService());
     services.Replay();
     configSvc.Replay();
     arch = new X86ArchitectureFlat32();
     win32 = new Reko.Environments.Windows.Win32Platform(services, arch);
 }
Esempio n. 16
0
		public void Setup()
		{
            var arch = new IntelArchitecture(ProcessorMode.Protected32);
			f = arch.CreateFrame();
            liveness = new IdentifierLiveness(arch);
			isLiveHelper = new RegisterLiveness.IsLiveHelper(arch);
		}
Esempio n. 17
0
 public void Setup()
 {
     mr = new MockRepository();
     arch = new X86ArchitectureFlat32();
     importReferences = new Dictionary<Address, ImportReference>();
     sc = new ServiceContainer();
     sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
 }
Esempio n. 18
0
 public X86Emulator(IntelArchitecture arch, LoadedImage loadedImage, IPlatformEmulator envEmulator)
 {
     this.arch = arch;
     this.img = loadedImage;
     this.Registers = new ulong[40];
     this.Valid = new bool[40];
     this.envEmulator = envEmulator;
 }
Esempio n. 19
0
		public void Setup()
		{
            arch = new IntelArchitecture(ProcessorMode.Real);
			f = new Frame(PrimitiveType.Word16);
			argOff = f.EnsureStackArgument(4, PrimitiveType.Word16);
			argSeg = f.EnsureStackArgument(6, PrimitiveType.SegmentSelector);
			arg_alias = f.EnsureStackArgument(4, PrimitiveType.Pointer32);
		}
Esempio n. 20
0
 private X86Assembler Create16bitAssembler()
 {
     arch = arch16;
     baseAddr = baseAddr16;
     var asm = new X86Assembler(arch, baseAddr16, new List<EntryPoint>());
     host = new RewriterHost(asm.ImportReferences);
     return asm;
 }
Esempio n. 21
0
 public void Fstsw_Setup()
 {
     arch = new IntelArchitecture(ProcessorMode.Protected32);
     asm = new X86Assembler(arch, Address.Ptr32(0x10000), new List<EntryPoint>());
     Procedure proc = new Procedure("test", arch.CreateFrame());
     orw = new OperandRewriter32(arch, proc.Frame, null);
     emitter = new ProcedureBuilder();
 }
Esempio n. 22
0
 public void TestGrfWithOneBit()
 {
     IProcessorArchitecture arch = new IntelArchitecture(ProcessorMode.Real);
     SignatureBuilder sb = new SignatureBuilder(null, arch);
     sb.AddFlagGroupReturnValue((uint) FlagM.CF, arch.CreateFrame());
     ProcedureSignature sig = sb.BuildSignature();
     Assert.AreEqual("bool", sig.ReturnValue.DataType.ToString());
 }
Esempio n. 23
0
 public X86Emulator(IntelArchitecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator)
 {
     this.arch = arch;
     this.map = segmentMap;
     this.Registers = new ulong[40];
     this.Valid = new bool[40];
     this.envEmulator = envEmulator;
 }
Esempio n. 24
0
 public void Fstsw_Setup()
 {
     arch = new X86ArchitectureFlat32();
     asm = new X86Assembler(null, new DefaultPlatform(null, new X86ArchitectureFlat32()), Address.Ptr32(0x10000), new List<ImageSymbol>());
     Procedure proc = new Procedure("test", arch.CreateFrame());
     orw = new OperandRewriter32(arch, proc.Frame, null);
     emitter = new ProcedureBuilder();
 }
Esempio n. 25
0
 public void Setup()
 {
     mr = new MockRepository();
     arch = new IntelArchitecture(ProcessorMode.Protected32);
     importReferences = new Dictionary<Address, ImportReference>();
     sc = new ServiceContainer();
     sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
 }
Esempio n. 26
0
		public void IaCreate()
		{
			arch = new X86ArchitectureReal();
			Assert.AreEqual(PrimitiveType.Word16, arch.WordWidth);
			arch = new X86ArchitectureFlat32();
			Assert.AreEqual(PrimitiveType.Word32, arch.WordWidth);
            arch = new X86ArchitectureProtected16();
			Assert.AreEqual(PrimitiveType.Word16, arch.WordWidth);
		}
Esempio n. 27
0
 public X86RewriterTests()
 {
     arch16 = new IntelArchitecture(ProcessorMode.Real);
     arch32 = new IntelArchitecture(ProcessorMode.Protected32);
     arch64 = new IntelArchitecture(ProcessorMode.Protected64);
     baseAddr16 = Address.SegPtr(0x0C00, 0x0000);
     baseAddr32 = Address.Ptr32(0x10000000);
     baseAddr64 = Address.Ptr64(0x140000000ul);
 }
Esempio n. 28
0
 public X86RewriterTests()
 {
     arch16 = new X86ArchitectureReal();
     arch32 = new X86ArchitectureFlat32();
     arch64 = new X86ArchitectureFlat64();
     baseAddr16 = Address.SegPtr(0x0C00, 0x0000);
     baseAddr32 = Address.Ptr32(0x10000000);
     baseAddr64 = Address.Ptr64(0x140000000ul);
 }
Esempio n. 29
0
 public void IaCreate()
 {
     arch = new IntelArchitecture(ProcessorMode.Real);
     Assert.AreEqual(PrimitiveType.Word16, arch.WordWidth);
     arch = new IntelArchitecture(ProcessorMode.Protected32);
     Assert.AreEqual(PrimitiveType.Word32, arch.WordWidth);
     arch = new IntelArchitecture(ProcessorMode.ProtectedSegmented);
     Assert.AreEqual(PrimitiveType.Word16, arch.WordWidth);
 }
Esempio n. 30
0
		public void SetUp()
		{
            var arch = new IntelArchitecture(ProcessorMode.Real);
            program = new Program() { Architecture = arch };
            sc = new ServiceContainer();
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            asm = new X86TextAssembler(sc, arch);
			configFile = null;
		}
Esempio n. 31
0
 public X86Rewriter(
     IntelArchitecture arch,
     IRewriterHost host,
     X86State state,
     EndianImageReader rdr,
     IStorageBinder binder)
 {
     this.arch   = arch;
     this.host   = host ?? throw new ArgumentNullException("host");
     this.state  = state;
     this.rdr    = rdr;
     this.binder = binder;
     this.dasm   = new LookaheadEnumerator <X86Instruction>(arch.CreateDisassemblerImpl(rdr));
 }
Esempio n. 32
0
 public X86Rewriter(
     IntelArchitecture arch,
     IRewriterHost host,
     X86State state,
     ImageReader rdr,
     Frame frame)
 {
     if (host == null)
     {
         throw new ArgumentNullException("host");
     }
     this.arch  = arch;
     this.host  = host;
     this.frame = frame;
     this.state = state;
     this.dasm  = new LookaheadEnumerator <X86Instruction>(arch.CreateDisassemblerImpl(rdr));
 }
Esempio n. 33
0
        public Constant GetFlagGroup(uint mask)
        {
            bool sigle = IntelArchitecture.IsSingleBit(mask);

            if ((mask & validFlags) == mask)
            {
                if (sigle)
                {
                    return(Constant.Bool((flags & mask) != 0));
                }
                else
                {
                    return(Constant.Byte((byte)(flags & mask)));
                }
            }
            else
            {
                return(Constant.Invalid);
            }
        }
Esempio n. 34
0
 public override OperandRewriter CreateOperandRewriter(IntelArchitecture arch, ExpressionEmitter m, IStorageBinder binder, IRewriterHost host)
 {
     return(new OperandRewriter64(arch, m, binder, host));
 }
Esempio n. 35
0
 public OperandRewriter64(IntelArchitecture arch, ExpressionEmitter m, IStorageBinder binder, IRewriterHost host) : base(arch, m, binder, host)
 {
 }
Esempio n. 36
0
 public OperandRewriter(IntelArchitecture arch, Frame frame, IRewriterHost host)
 {
     this.arch  = arch;
     this.frame = frame;
     this.host  = host;
 }
Esempio n. 37
0
 public X86ProcedureSerializer(IntelArchitecture arch, ISerializedTypeVisitor <DataType> typeLoader, string defaultCc)
     : base(arch, typeLoader, defaultCc)
 {
 }
 public StringInstructionRewriter(IntelArchitecture arch, OperandRewriter orw)
 {
     this.arch = arch;
     this.orw  = orw;
 }
Esempio n. 39
0
 public X86Protected32Emulator(IntelArchitecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator)
     : base(arch, segmentMap, envEmulator, X86.Registers.eip, X86.Registers.ecx)
 {
 }
Esempio n. 40
0
 public OperandRewriter32(IntelArchitecture arch, ExpressionEmitter m, IStorageBinder frame, IRewriterHost host) : base(arch, m, frame, host)
 {
 }
Esempio n. 41
0
 public override OperandRewriter CreateOperandRewriter(IntelArchitecture arch, Frame frame, IRewriterHost host)
 {
     return(new OperandRewriter64(arch, frame, host));
 }
Esempio n. 42
0
 public abstract OperandRewriter CreateOperandRewriter(IntelArchitecture arch, Frame frame, IRewriterHost host);
Esempio n. 43
0
 public abstract IProcessorEmulator CreateEmulator(IntelArchitecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator);
Esempio n. 44
0
 public X86RealModeEmulator(IntelArchitecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator)
     : base(arch, segmentMap, envEmulator, X86.Registers.ip, X86.Registers.cx)
 {
 }
Esempio n. 45
0
 public OperandRewriter64(IntelArchitecture arch, ExpressionEmitter m, Frame frame, IRewriterHost host) : base(arch, m, frame, host)
 {
 }
Esempio n. 46
0
 public override IProcessorEmulator CreateEmulator(IntelArchitecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator)
 {
     return(new X86Protected32Emulator(arch, segmentMap, envEmulator));
 }
Esempio n. 47
0
 public X86State(IntelArchitecture arch)
 {
     this.arch  = arch;
     this.regs  = new ulong[(int)Registers.Max];
     this.valid = new ulong[(int)Registers.Max];
 }
Esempio n. 48
0
 public abstract OperandRewriter CreateOperandRewriter(IntelArchitecture arch, ExpressionEmitter m, IStorageBinder binder, IRewriterHost host);
Esempio n. 49
0
 public override OperandRewriter CreateOperandRewriter(IntelArchitecture arch, ExpressionEmitter m, Frame frame, IRewriterHost host)
 {
     return(new OperandRewriter32(arch, m, frame, host));
 }
Esempio n. 50
0
 public OperandRewriter64(IntelArchitecture arch, Frame frame, IRewriterHost host) : base(arch, frame, host)
 {
 }
Esempio n. 51
0
 public abstract OperandRewriter CreateOperandRewriter(IntelArchitecture arch, ExpressionEmitter m, Frame frame, IRewriterHost host);
Esempio n. 52
0
 public override IProcessorEmulator CreateEmulator(IntelArchitecture arch, SegmentMap segmentMap, IPlatformEmulator envEmulator)
 {
     throw new NotImplementedException();
 }
Esempio n. 53
0
 public X86State(X86State st) : base(st)
 {
     arch  = st.arch;
     regs  = (ulong[])st.regs.Clone();
     valid = (ulong [])st.valid.Clone();
 }