public void Rcfg_LoadOperatingEnvironment() { var cfgSvc = new RekoConfigurationService(new RekoConfiguration_v1 { Environments = new [] { new Environment_v1 { Name = "testOS", Description = "Test OS", Heuristics = new PlatformHeuristics_v1 { ProcedurePrologs = new [] { new BytePattern_v1 { Bytes = "55 8B EC", Mask = "FF FF FF", }, new BytePattern_v1 { Bytes = "55 ?? 30" } } } } } }); var env = cfgSvc.GetEnvironment("testOS"); Assert.AreEqual(2, env.Heuristics.ProcedurePrologs.Length); var pattern0 = env.Heuristics.ProcedurePrologs[0]; Assert.AreEqual("55 8B EC", pattern0.Bytes); Assert.AreEqual("FF FF FF", pattern0.Mask); var pattern1 = env.Heuristics.ProcedurePrologs[1]; Assert.AreEqual("55 ?? 30", pattern1.Bytes); Assert.IsNull(pattern1.Mask); }
public void Rcfg_LoadOperatingEnvironment() { var cfgSvc = new RekoConfigurationService(new RekoConfiguration_v1 { Environments = new [] { new Environment_v1 { Name = "testOS", Description = "Test OS", Heuristics = new PlatformHeuristics_v1 { ProcedurePrologs = new [] { new BytePattern_v1 { Bytes = "55 8B EC", Mask = "FF FF FF", }, new BytePattern_v1 { Bytes= "55 ?? 30" } } } } } }); var env = cfgSvc.GetEnvironment("testOS"); Assert.AreEqual(2, env.Heuristics.ProcedurePrologs.Length); var pattern0 = env.Heuristics.ProcedurePrologs[0]; Assert.AreEqual("55 8B EC", pattern0.Bytes); Assert.AreEqual("FF FF FF", pattern0.Mask); var pattern1 = env.Heuristics.ProcedurePrologs[1]; Assert.AreEqual("55 ?? 30", pattern1.Bytes); Assert.IsNull(pattern1.Mask); }
public void Rcfg_LoadOperatingEnvironment() { var sc = new ServiceContainer(); var cfgSvc = new RekoConfigurationService(sc, "reko.config", new RekoConfiguration_v1 { Environments = new [] { new Environment_v1 { Name = "testOS", Description = "Test OS", Heuristics = new PlatformHeuristics_v1 { ProcedurePrologs = new [] { new BytePattern_v1 { Bytes = "55 8B EC", Mask = "FF FF FF", }, new BytePattern_v1 { Bytes = "55 ?? 30" } } }, Architectures = new[] { new PlatformArchitecture_v1 { Name = "testCPU", TypeLibraries = new[] { new TypeLibraryReference_v1 { Name = "lp32.xml", } } } } } } }); var env = cfgSvc.GetEnvironment("testOS"); Assert.AreEqual(2, env.Heuristics.ProcedurePrologs.Length); var pattern0 = env.Heuristics.ProcedurePrologs[0]; Assert.AreEqual("55 8B EC", pattern0.Bytes); Assert.AreEqual("FF FF FF", pattern0.Mask); var pattern1 = env.Heuristics.ProcedurePrologs[1]; Assert.AreEqual("55 ?? 30", pattern1.Bytes); Assert.IsNull(pattern1.Mask); var archs = env.Architectures; Assert.AreEqual(1, archs.Count); Assert.AreEqual("lp32.xml", archs[0].TypeLibraries[0].Name); }
private void DecompileRawImage(DecompilerDriver dec, Dictionary <string, object> pArgs) { var arch = config.GetArchitecture((string)pArgs["--arch"]); if (arch == null) { throw new ApplicationException(string.Format("Unknown architecture {0}", pArgs["--arch"])); } object sEnv; IPlatform platform; if (pArgs.TryGetValue("--env", out sEnv)) { var opEnv = config.GetEnvironment((string)sEnv); if (opEnv == null) { throw new ApplicationException(string.Format("Unknown operating environment {0}", sEnv)); } platform = opEnv.Load(services, arch); } else { platform = new DefaultPlatform(services, arch); } Address addrBase; Address addrEntry; if (!arch.TryParseAddress((string)pArgs["--base"], out addrBase)) { throw new ApplicationException(string.Format("'{0}' doesn't appear to be a valid address.", pArgs["--base"])); } if (pArgs.ContainsKey("--entry")) { if (!arch.TryParseAddress((string)pArgs["--base"], out addrEntry)) { throw new ApplicationException(string.Format("'{0}' doesn't appear to be a valid address.", pArgs["--base"])); } } else { addrEntry = addrBase; } var state = CreateInitialState(arch, pArgs); dec.LoadRawImage((string)pArgs["filename"], (string)pArgs["--arch"], (string)sEnv, addrBase); dec.Project.Programs[0].EntryPoints.Add( addrEntry, new EntryPoint(addrEntry, state)); object oHeur; if (pArgs.TryGetValue("heuristics", out oHeur)) { dec.Project.Programs[0].User.Heuristics = ((string[])oHeur).ToSortedSet(); } dec.ScanPrograms(); dec.AnalyzeDataFlow(); dec.ReconstructTypes(); dec.StructureProgram(); dec.WriteDecompilerProducts(); }