Beispiel #1
0
 public RekoConfigurationService(RekoConfiguration_v1 config)
 {
     this.loaders       = LoadCollection(config.Loaders, LoadLoaderConfiguration);
     this.sigFiles      = LoadCollection(config.SignatureFiles, LoadSignatureFile);
     this.architectures = LoadCollection(config.Architectures, LoadArchitecture);
     this.opEnvs        = LoadCollection(config.Environments, LoadEnvironment);
     this.asms          = LoadCollection(config.Assemblers, LoadAssembler);
     this.rawFiles      = LoadCollection(config.RawFiles, LoadRawFile);
     this.uiPreferences = new UiPreferencesConfiguration();
     if (config.UiPreferences != null)
     {
         this.uiPreferences.Styles =
             LoadCollection(config.UiPreferences.Styles, LoadUiStyle);
     }
     ;
 }
 public RekoConfigurationService(IServiceProvider services, RekoConfiguration_v1 config)
 {
     this.services      = services;
     this.loaders       = LoadCollection(config.Loaders, LoadLoaderConfiguration);
     this.sigFiles      = LoadCollection(config.SignatureFiles, LoadSignatureFile);
     this.architectures = LoadCollection(config.Architectures, LoadArchitecture);
     this.opEnvs        = LoadCollection(config.Environments, LoadEnvironment);
     this.symSources    = LoadCollection(config.SymbolSources, LoadSymbolSource);
     this.rawFiles      = LoadCollection(config.RawFiles, LoadRawFile);
     this.uiPreferences = new UiPreferencesConfiguration();
     if (config.UiPreferences != null)
     {
         this.uiPreferences.Styles =
             LoadCollection(config.UiPreferences.Styles, LoadUiStyle);
     }
     ;
 }
Beispiel #3
0
        public void RekoCon_Save()
        {
            var rekoCon = new RekoConfiguration_v1
            {
                Loaders = new[]
                {
                    new RekoLoader
                    {
                        MagicNumber = "4D5A",
                        Type = "mzexeloader,mzexeloader"
                    }
                },
                RawFiles = new []
                {
                    new RawFile_v1
                    {
                        Name="ms-dos-com",
                        Description="MS-DOS COM executable",
                        Architecture="x86-real-16",
                        Environment="ms-dos",
                        Base="0C00:0100",
                        Entry = new EntryPoint_v1
                        {
                            Address = "0C00:0100",
                            Name = "MsDosCom_Start",
                        }
                    }
                },
                SignatureFiles = new []
                {
                    new SignatureFile_v1
                    {
                        Filename="IMAGE_FILE_MACHINE_I386.xml",
                        Type ="Reko.Loading.UnpackerSignatureLoader,Reko"
                    }
                },
                Environments = new []
                {
                    new Environment_v1 {
                        Name="elf-neutral",
                        Description ="Unspecified ELF ABI",
                        Type ="Reko.Environments.SysV.SysVPlatform,Reko.Environments.SysV",
                        TypeLibraries = new []
                        {
                            new TypeLibraryReference_v1 { Name="libc.so.xml" },
                        },
                        Characteristics = new []
                        {
                            new TypeLibraryReference_v1 { Name="sysvcharacteristics.xml" }
                        },
                        Heuristics = new PlatformHeuristics_v1
                        {
                            ProcedurePrologs = new []
                            {
                                new BytePattern_v1 {
                                    Bytes = "55 8B EC",
                                    Mask = "FF FF FF"
                                }
                            }
                        }
                    }
                },
                Architectures = new[]
                {
                    new Architecture_v1
                    {
                        Name="x86-real-16",
                        Description = "x86 16-bit Real Mode",
                        Type ="Reko.Arch.X86.X86ArchitectureReal,Reko.Arch.X86"
                    }
                },
                Assemblers = new []
                {
                    new Assembler_v1
                    {
                        Name = "pdp11-mac",
                        Description = "PDP-11 MACRO assembler",
                        Type = "Reko.Assemblers.Pdp11.Pdp11TextAssembler,Reko.Assemblers.Pdp11" 
                    }
                },
                UiPreferences = new RekoUiPreferences
                {
                    Styles = new []
                    {
                        new StyleDefinition_v1
                        {
                          Name="mem", Font="Lucida Console, 9pt"
                        },
                        new StyleDefinition_v1
                        {
                            Name ="mem-code", ForeColor="#000000", BackColor="#FFC0C0"
                        }
                    }
                }
            };

            var ser = new XmlSerializer(rekoCon.GetType());
            var stm = new StringWriter();
            var xml = new FilteringXmlWriter(stm);
            xml.Formatting = Formatting.Indented;
            ser.Serialize(xml, rekoCon);
            var sExp =
            #region Expected
@"<?xml version=""1.0"" encoding=""utf-16""?>
<Reko xmlns=""http://schemata.jklnet.org/Reko/Config/v1"">
  <Loaders>
    <Loader MagicNumber=""4D5A"" Type=""mzexeloader,mzexeloader"" />
  </Loaders>
  <RawFiles>
    <RawFile Name=""ms-dos-com"" Description=""MS-DOS COM executable"" Arch=""x86-real-16"" Env=""ms-dos"" Base=""0C00:0100"">
      <Entry Addr=""0C00:0100"" Name=""MsDosCom_Start"" />
    </RawFile>
  </RawFiles>
  <SignatureFiles>
    <SignatureFile Filename=""IMAGE_FILE_MACHINE_I386.xml"" Type=""Reko.Loading.UnpackerSignatureLoader,Reko"" />
  </SignatureFiles>
  <Environments>
    <Environment Name=""elf-neutral"" Description=""Unspecified ELF ABI"" Type=""Reko.Environments.SysV.SysVPlatform,Reko.Environments.SysV"">
      <TypeLibraries>
        <TypeLibrary Name=""libc.so.xml"" />
      </TypeLibraries>
      <Characteristics>
        <TypeLibrary Name=""sysvcharacteristics.xml"" />
      </Characteristics>
      <Heuristics>
        <ProcedurePrologs>
          <Pattern>
            <Bytes>55 8B EC</Bytes>
            <Mask>FF FF FF</Mask>
          </Pattern>
        </ProcedurePrologs>
      </Heuristics>
    </Environment>
  </Environments>
  <Architectures>
    <Architecture Name=""x86-real-16"" Description=""x86 16-bit Real Mode"" Type=""Reko.Arch.X86.X86ArchitectureReal,Reko.Arch.X86"" />
  </Architectures>
  <Assemblers>
    <Assembler Name=""pdp11-mac"" Description=""PDP-11 MACRO assembler"" Type=""Reko.Assemblers.Pdp11.Pdp11TextAssembler,Reko.Assemblers.Pdp11"" />
  </Assemblers>
  <UiPreferences>
    <Style Name=""mem"" Font=""Lucida Console, 9pt"" />
    <Style Name=""mem-code"" ForeColor=""#000000"" BackColor=""#FFC0C0"" />
  </UiPreferences>
</Reko>";
            #endregion
            Assert.AreEqual(sExp, stm.ToString());
        }
        public RekoConfigurationService(IServiceProvider services, string rekoConfigPath, RekoConfiguration_v1 config)
        {
            var pluginSvc = services.GetService <IPluginLoaderService>();

            if (pluginSvc is null)
            {
                pluginSvc = new PluginLoaderService();
            }
            this.pluginSvc      = pluginSvc;
            this.configFileRoot = Path.GetDirectoryName(rekoConfigPath);
            this.services       = services;
            this.loaders        = LoadCollection(config.Loaders, LoadLoaderConfiguration);
            this.sigFiles       = LoadCollection(config.SignatureFiles, LoadSignatureFile);
            this.architectures  = LoadCollection(config.Architectures, LoadArchitecture);
            this.opEnvs         = LoadCollection(config.Environments, LoadEnvironment);
            this.symSources     = LoadCollection(config.SymbolSources, LoadSymbolSource);
            this.rawFiles       = LoadCollection(config.RawFiles, LoadRawFile);
            this.uiPreferences  = new UiPreferencesConfiguration();
            if (config.UiPreferences != null)
            {
                this.uiPreferences.Styles =
                    LoadCollection(config.UiPreferences.Styles, LoadUiStyle);
            }
            ;
        }