Esempio n. 1
0
 private Program LoadProgram(Dictionary <string, object> pArgs, LoadDetails loadDetails)
 {
     if (pArgs.ContainsKey("--data"))
     {
         var hexBytes = (string)pArgs["--data"];
         var image    = BytePattern.FromHexBytes(hexBytes).ToArray();
         return(decompiler.LoadRawImage(image, loadDetails));
     }
     else
     {
         return(decompiler.LoadRawImage((string)pArgs["filename"], loadDetails));
     }
 }
Esempio n. 2
0
        private void DecompileRawImage(Dictionary <string, object> pArgs)
        {
            try
            {
                var arch = config.GetArchitecture((string)pArgs["--arch"]);
                if (arch == null)
                {
                    throw new ApplicationException(string.Format("Unknown architecture {0}", pArgs["--arch"]));
                }

                object sEnv;
                pArgs.TryGetValue("--env", out sEnv);

                Address addrBase;
                object  oAddrEntry;
                if (!arch.TryParseAddress((string)pArgs["--base"], out addrBase))
                {
                    throw new ApplicationException(string.Format("'{0}' doesn't appear to be a valid address.", pArgs["--base"]));
                }
                pArgs.TryGetValue("--entry", out oAddrEntry);

                object sLoader;
                pArgs.TryGetValue("--loader", out sLoader);
                var state   = CreateInitialState(arch, pArgs);
                var program = decompiler.LoadRawImage((string)pArgs["filename"], new LoadDetails
                {
                    LoaderName       = (string)sLoader,
                    ArchitectureName = (string)pArgs["--arch"],
                    PlatformName     = (string)sEnv,
                    LoadAddress      = (string)pArgs["--base"],
                    EntryPoint       = new EntryPointElement {
                        Address = (string)oAddrEntry
                    }
                });
                object oHeur;
                if (pArgs.TryGetValue("heuristics", out oHeur))
                {
                    decompiler.Project.Programs[0].User.Heuristics = ((string[])oHeur).ToSortedSet();
                }
                decompiler.ScanPrograms();
                decompiler.AnalyzeDataFlow();
                decompiler.ReconstructTypes();
                decompiler.StructureProgram();
                decompiler.WriteDecompilerProducts();
            }
            catch (Exception ex)
            {
                diagnosticSvc.Error(ex, "An error occurred during decompilation.");
            }
        }