示例#1
0
        public ConditionCodeEliminator(SsaState ssa, IPlatform arch)
		{
            this.ssa=ssa;
			this.ssaIds = ssa.Identifiers;
            this.platform = arch;
            this.m = new ExpressionEmitter();
		}
示例#2
0
  public XmlConverter(TextReader rdr, XmlWriter writer, IPlatform platform)
  {
      this.rdr = rdr;
      this.writer = writer;
      this.platform = platform;
      this.parserState = new ParserState();
 }
示例#3
0
        public ExePackLoader(IServiceProvider services, string filename, byte[] imgRaw)
            : base(services, filename, imgRaw)
        {
            var cfgSvc = services.RequireService<IConfigurationService>();
            arch = cfgSvc.GetArchitecture("x86-real-16");
            platform =cfgSvc.GetEnvironment("ms-dos")
                .Load(Services, arch);

            var exe = new ExeImageLoader(services, filename, imgRaw);
            this.exeHdrSize = (uint)(exe.e_cparHeader * 0x10U);
            this.hdrOffset = (uint)(exe.e_cparHeader + exe.e_cs) * 0x10U;
            ImageReader rdr = new LeImageReader(RawImage, hdrOffset);
            this.ip = rdr.ReadLeUInt16();
            this.cs = rdr.ReadLeUInt16();
            rdr.ReadLeUInt16();
            this.cbExepackHeader = rdr.ReadLeUInt16();
            this.sp = rdr.ReadLeUInt16();
            this.ss = rdr.ReadLeUInt16();
            this.cpUncompressed = rdr.ReadLeUInt16();

            int offset = ExePackHeaderOffset(exe);
            if (MemoryArea.CompareArrays(imgRaw, offset, signature, signature.Length))
            {
                relocationsOffset = 0x012D;
            }
            else if (MemoryArea.CompareArrays(imgRaw, offset, signature2, signature2.Length))
            {
                relocationsOffset = 0x0125;
            }
            else
                throw new ApplicationException("Not a recognized EXEPACK image.");
        }
示例#4
0
 public void Setup()
 {
     var sc = new ServiceContainer();
     sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
     var arch = new X86ArchitectureReal();
     this.platform = new MsdosPlatform(sc, arch);
 }
示例#5
0
 public Program(LoadedImage image, ImageMap imageMap, IProcessorArchitecture arch, IPlatform platform) : this()
 {
     this.Image = image;
     this.ImageMap = imageMap;
     this.Architecture = arch;
     this.Platform = platform;
 }
 public void Setup()
 {
     var sc = new ServiceContainer();
     sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
     var arch = new IntelArchitecture(ProcessorMode.Real);
     this.platform = new MsdosPlatform(sc, arch);
 }
示例#7
0
 public TypeLibrary Load(IPlatform platform, string module, TypeLibrary dstLib)
 {
     this.platform = platform;
     this.tlLoader = new TypeLibraryDeserializer(platform, true, dstLib);
     this.moduleName = module;
     tlLoader.SetModuleName(module);
     for (;;)
     {
         var tok = Peek();
         if (tok.Type == TokenType.EOF)
             break;
         if (PeekAndDiscard(TokenType.NL))
             continue;
         var line =  ParseLine();
         if (line != null)
         {
             if (line.Item1.HasValue)
             {
                 tlLoader.LoadService(line.Item1.Value, line.Item2);
             }
             else
             {
                 tlLoader.LoadService(line.Item2.Name, line.Item2);
             }
         }
     }
     return dstLib;
 }
示例#8
0
文件: Program.cs 项目: relaxar/reko
 public Program(SegmentMap segmentMap, IProcessorArchitecture arch, IPlatform platform) : this()
 {
     this.SegmentMap = segmentMap;
     this.ImageMap = segmentMap.CreateImageMap();
     this.Architecture = arch;
     this.Platform = platform;
 }
示例#9
0
        public ExternalProcedure ResolveProcedure(string moduleName, string importName, IPlatform platform)
        {
            foreach (var program in project.Programs)
            {
                ModuleDescriptor mod;
                if (!program.Metadata.Modules.TryGetValue(moduleName, out mod))
                    continue;

                SystemService svc;
                if (mod.ServicesByName.TryGetValue(importName, out svc))
                {
                    return new ExternalProcedure(svc.Name, svc.Signature, svc.Characteristics);
                }
            }

            foreach (var program in project.Programs)
            {
                ProcedureSignature sig;
                if (program.Metadata.Signatures.TryGetValue(importName, out sig))
                {
                    return new ExternalProcedure(importName, sig);
                }
            }

            return platform.LookupProcedureByName(moduleName, importName);
        }
        // ctor

        /// <summary>
        /// Initializes a new instance of the <see cref="DataManager"/> class.
        /// </summary>
        /// <param name="platform">The platform.</param>
        public DataManager(IPlatform platform)
        {
            _platform = platform;
            AppService = new AppService();

            _current = this;
        }
示例#11
0
        public IPlatform CreatePlatform()
        {
            if (platform != null)
                return platform;

            platform = mr.Stub<IPlatform>();

            platform.Stub(p => p.Name).Return("TestPlatform");
            platform.Stub(p => p.PointerType).Return(PrimitiveType.Pointer32);
            platform.Stub(p => p.GetByteSizeFromCBasicType(CBasicType.Char)).Return(1);
            platform.Stub(p => p.GetByteSizeFromCBasicType(CBasicType.Short)).Return(2);
            platform.Stub(p => p.GetByteSizeFromCBasicType(CBasicType.Int)).Return(4);
            platform.Stub(p => p.GetByteSizeFromCBasicType(CBasicType.Long)).Return(4);
            platform.Stub(p => p.GetByteSizeFromCBasicType(CBasicType.LongLong)).Return(8);
            platform.Stub(p => p.GetByteSizeFromCBasicType(CBasicType.Float)).Return(4);
            platform.Stub(p => p.GetByteSizeFromCBasicType(CBasicType.Double)).Return(8);
            platform.Stub(p => p.GetByteSizeFromCBasicType(CBasicType.LongDouble)).Return(8);
            platform.Stub(p => p.GetByteSizeFromCBasicType(CBasicType.Int64)).Return(8);
            platform.Stub(p => p.CreateMetadata()).Do(new Func<TypeLibrary>(() => this.platformMetadata.Clone()));
            var arch = new X86ArchitectureFlat32();
            platform.Stub(p => p.Architecture).Return(arch);
            platform.Stub(p => p.DefaultCallingConvention).Return("__cdecl");

            platform.Stub(s => s.CreateProcedureSerializer(null, null)).IgnoreArguments().Do(
                new Func<ISerializedTypeVisitor<DataType>, string, ProcedureSerializer>((tlDeser, dc) =>
                    new X86ProcedureSerializer(arch, tlDeser, dc)
                )
            );
            platform.Stub(p => p.SaveUserOptions()).Return(null);

            platform.Replay();
            return platform;
        }
示例#12
0
        public ExternalProcedure ResolveProcedure(string moduleName, string importName, IPlatform platform)
        {
            if (!string.IsNullOrEmpty(moduleName))
            {
                foreach (var program in project.Programs)
                {
                    ModuleDescriptor mod;
                    if (!program.EnvironmentMetadata.Modules.TryGetValue(moduleName, out mod))
                        continue;

                    SystemService svc;
                    if (mod.ServicesByName.TryGetValue(importName, out svc))
                    {
                        return new ExternalProcedure(svc.Name, svc.Signature, svc.Characteristics);
                    }
                }
            }

            foreach (var program in project.Programs)
            {
                FunctionType sig;
                if (program.EnvironmentMetadata.Signatures.TryGetValue(importName, out sig))
                {
                    var chr = platform.LookupCharacteristicsByName(importName);
                    if (chr != null)
                        return new ExternalProcedure(importName, sig, chr);
                    else
                        return new ExternalProcedure(importName, sig);
                }
            }

            return platform.LookupProcedureByName(moduleName, importName);
        }
示例#13
0
		public SystemService Build(IPlatform platform, TypeLibrary library)
		{
			SystemService svc = new SystemService();
			svc.Name = Name;
			svc.SyscallInfo = new SyscallInfo();
            svc.SyscallInfo.Vector = SyscallInfo != null
                ? Convert.ToInt32(SyscallInfo.Vector, 16)
                : this.Ordinal;
            if (SyscallInfo != null)
            {
                if (SyscallInfo.RegisterValues != null)
                {
                    svc.SyscallInfo.RegisterValues = new RegValue[SyscallInfo.RegisterValues.Length];
                    for (int i = 0; i < SyscallInfo.RegisterValues.Length; ++i)
                    {
                        svc.SyscallInfo.RegisterValues[i] = new RegValue
                        {
                            Register = platform.Architecture.GetRegister(SyscallInfo.RegisterValues[i].Register),
                            Value = Convert.ToInt32(SyscallInfo.RegisterValues[i].Value, 16),
                        };
                    }
                }
            }
			if (svc.SyscallInfo.RegisterValues == null)
			{
				svc.SyscallInfo.RegisterValues = new RegValue[0];
			}
            TypeLibraryDeserializer loader = new TypeLibraryDeserializer(platform, true, library);
			var sser = platform.CreateProcedureSerializer(loader, "stdapi");
            svc.Signature = sser.Deserialize(Signature, platform.Architecture.CreateFrame());
			svc.Characteristics = Characteristics != null ? Characteristics : DefaultProcedureCharacteristics.Instance;
			return svc;
		}
示例#14
0
 public void ProcessDeclaration(Decl declaration, IPlatform platform, TypeLibraryDeserializer tldser, SymbolTable symbolTable)
 {
     var types = symbolTable.AddDeclaration(declaration);
     var type = types[0];
     int? vectorOffset = GetVectorOffset(declaration);
     if (vectorOffset.HasValue)
     {
         var ntde = new NamedDataTypeExtractor(platform, declaration.decl_specs, symbolTable);
         foreach (var declarator in declaration.init_declarator_list)
         {
             var nt = ntde.GetNameAndType(declarator.Declarator);
             var ssig = (SerializedSignature)nt.DataType;
             if (ssig.ReturnValue != null)
             {
                 ssig.ReturnValue.Kind = ntde.GetArgumentKindFromAttributes(
                     "returns", declaration.attribute_list);
             }
             var sser = platform.CreateProcedureSerializer(tldser, platform.DefaultCallingConvention);
             var sig = sser.Deserialize(ssig, platform.Architecture.CreateFrame());
             SystemServices.Add(
                 vectorOffset.Value,
                 new SystemService
                 {
                     Name = nt.Name,
                     SyscallInfo = new SyscallInfo
                     {
                         Vector = vectorOffset.Value,
                     },
                     Signature = sig,
                 });
         }
     }
 }
示例#15
0
 private static Task<MobileServiceUser> LoginFacebookAsync(IPlatform mobileClient)
 {
     // use server flow if the service URL has been customized
     return Settings.IsDefaultServiceUrl() ?
         mobileClient.LoginFacebookAsync() :
         mobileClient.LoginAsync(MobileServiceAuthenticationProvider.Facebook);
 }
 public void Setup()
 {
     this.mr = new MockRepository();
     this.mockFactory = new MockFactory(mr);
     this.platform = mockFactory.CreatePlatform();
     this.program = mockFactory.CreateProgram();
 }
示例#17
0
        public PlatformKernel(IPlatform platform)
        {
            var runtimeModule = GetRuntimeModule(platform);
            Load(runtimeModule);

            AddBindingResolver<IDisplay>(DisplayBindingResolver);
        }
示例#18
0
		public DataTypeBuilder(TypeFactory factory, ITypeStore store, IPlatform platform)
		{
			this.store = store;
			this.factory = factory;
			this.unifier = new DataTypeBuilderUnifier(factory, store);
            this.platform = platform;
		}
示例#19
0
文件: Sound.cs 项目: OpenRA/OpenRA
        public Sound(IPlatform platform, SoundSettings soundSettings)
        {
            soundEngine = platform.CreateSound(soundSettings.Device);

            if (soundSettings.Mute)
                MuteAudio();
        }
示例#20
0
        private void BuildTest(Address addrBase, IPlatform platform , Action<X86Assembler> asmProg)
        {
            var sc = new ServiceContainer();
            sc.AddService<DecompilerEventListener>(new FakeDecompilerEventListener());
            sc.AddService<DecompilerHost>(new FakeDecompilerHost());
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            var entryPoints = new List<EntryPoint>();
            var asm = new X86Assembler(sc, platform, addrBase, entryPoints);
            asmProg(asm);

            var lr = asm.GetImage();
            program = new Program(
                lr.Image,
                lr.ImageMap,
                arch,
                platform);
            var project = new Project { Programs = { program } };
            scanner = new Scanner(
                program,
                new Dictionary<Address, ProcedureSignature>(),
                new ImportResolver(project),
                sc);
            scanner.EnqueueEntryPoint(new EntryPoint(addrBase, arch.CreateProcessorState()));
            scanner.ScanImage();
        }
示例#21
0
 private void Given_Platform(IPlatform platform)
 {
     this.oe = mr.Stub<OperatingEnvironment>();
     this.platform = platform;
     this.cfgSvc.Stub(c => c.GetEnvironment("testOS")).Return(oe);
     oe.Stub(e => e.Load(sc, null)).IgnoreArguments().Return(platform);
 }
示例#22
0
 private void Given_TestOS()
 {
     this.oe = mr.Stub<OperatingEnvironment>();
     this.platform = mr.Stub<IPlatform>();
     this.cfgSvc.Stub(c => c.GetEnvironment("testOS")).Return(oe);
     oe.Stub(e => e.Load(sc, null)).IgnoreArguments().Return(platform);
     this.platform.Stub(p => p.CreateMetadata()).Return(new TypeLibrary());
 }
示例#23
0
		public MsdosImageLoader(IServiceProvider services, string filename, ExeImageLoader exe) : base(services, filename, exe.RawImage)
		{
			this.exe = exe;
            var cfgSvc = services.RequireService<IConfigurationService>();
            this.arch = cfgSvc.GetArchitecture("x86-real-16");
            this.platform = cfgSvc.GetEnvironment("ms-dos")
                .Load(services, arch);
		}
示例#24
0
 public static void Initialize(IPlatform platform)
 {
     if( null != Kernel )
     {
         throw new ArgumentException("Kernel has already been initialized");
     }
     Kernel = new PlatformKernel(platform);
 }
示例#25
0
 public override TypeLibrary Load(IPlatform platform, TypeLibrary dstLib)
 {
     var ser = SerializedLibrary.CreateSerializer();
     var slib = (SerializedLibrary) ser.Deserialize(stream);
     var tldser = new TypeLibraryDeserializer(platform, true, dstLib);
     var tlib = tldser.Load(slib);
     return tlib;
 }
示例#26
0
		public MsdosImageLoader(IServiceProvider services, string filename, ExeImageLoader exe) : base(services, filename, exe.RawImage)
		{
			this.exe = exe;
            this.arch = new IntelArchitecture(ProcessorMode.Real);
            this.platform = this.platform = services.RequireService<IConfigurationService>()
                .GetEnvironment("ms-dos")
                .Load(services, arch);
		}
        public UserAgentBuilder(IPlatform platformInfo, ISdk sdkInfo, ISourceLanguage language)
        {
            this.platform = platformInfo;
            this.sdk = sdkInfo;
            this.language = language;

            this.userAgentValue = new Lazy<string>(() => this.Generate());
        }
示例#28
0
		public LzExeUnpacker(IServiceProvider services, ExeImageLoader exe, string filename, byte [] rawImg) : base(services, filename, rawImg)
		{
            this.arch = new IntelArchitecture(ProcessorMode.Real);
            this.platform = services.RequireService<IConfigurationService>()
                .GetEnvironment("ms-dos")
                .Load(services, arch);
            Validate(exe);
		}
示例#29
0
 public override Identifier ResolveImportedGlobal(
     IImportResolver resolver,
     IPlatform platform,
     AddressContext ctx)
 {
     var global = resolver.ResolveGlobal(ModuleName, ImportName, platform);
     return global;
 }
示例#30
0
 public override Program LinkObject(IPlatform platform, Address addrLoad, byte[] rawImage)
 {
     var segments = ComputeSegmentSizes();
     var imageMap = CreateSegments(addrLoad, segments);
     var program = new Program(imageMap, platform.Architecture, platform);
     LoadExternalProcedures(program.InterceptedCalls);;
     return program;
 }