Exemplo n.º 1
0
 private void LoadUserData(DecompilerInput_v2 sInput, Program program, UserData user)
 {
     if (sInput.UserProcedures != null)
     {
         user.Procedures = sInput.UserProcedures
                 .Select(sup =>
                 {
                     Address addr;
                     program.Architecture.TryParseAddress(sup.Address, out addr);
                     return new KeyValuePair<Address, Procedure_v1>(addr, sup);
                 })
                 .Where(kv => kv.Key != null)
                 .ToSortedList(kv => kv.Key, kv => kv.Value);
     }
     if (sInput.UserGlobalData != null)
     {
         user.Globals = sInput.UserGlobalData
             .Select(sud =>
             {
                 Address addr;
                 program.Architecture.TryParseAddress(sud.Address, out addr);
                 return new KeyValuePair<Address, GlobalDataItem_v2>(
                     addr,
                     sud);
             })
             .Where(kv => kv.Key != null)
            .ToSortedList(kv => kv.Key, kv => kv.Value);
     }
     foreach (var kv in user.Globals)
     {
         var dt = kv.Value.DataType.BuildDataType(program.TypeFactory);
         var item = new ImageMapItem((uint)dt.Size)
         {
             Address = kv.Key,
             DataType = dt,
         };
         if (item.Size > 0)
         {
             program.ImageMap.AddItemWithSize(kv.Key, item);
         }
         else
         {
             program.ImageMap.AddItem(kv.Key, item);
         }
     }
     user.OnLoadedScript = sInput.OnLoadedScript;
     if (sInput.Options != null)
     {
         program.User.Heuristics.Add("shingle");
     }
 }
Exemplo n.º 2
0
 public Program VisitInputFile(DecompilerInput_v2 sInput)
 {
     var bytes = loader.LoadImageBytes(sInput.Filename, 0);
     var program = loader.LoadExecutable(sInput.Filename, bytes, null);
     program.Filename = sInput.Filename;
     if (sInput.UserProcedures != null)
     {
         program.UserProcedures = sInput.UserProcedures
                 .Select(sup =>{
                     Address addr;
                     program.Architecture.TryParseAddress(sup.Address, out addr);
                     return new KeyValuePair<Address, Procedure_v1>(addr, sup);
                 })
                 .Where(kv => kv.Key != null)
                 .ToSortedList(kv => kv.Key, kv => kv.Value);
     }
     if (sInput.UserGlobalData != null)
     {
         program.UserGlobalData = sInput.UserGlobalData
             .Select(sud =>
             {
                 Address addr;
                 program.Architecture.TryParseAddress(sud.Address, out addr);
                 return new KeyValuePair<Address, GlobalDataItem_v2>(
                     addr,
                     sud);
             })
             .Where(kv => kv.Key != null)
            .ToSortedList(kv => kv.Key, kv => kv.Value);
     }
     foreach (var kv in program.UserGlobalData)
     {
         var dt = kv.Value.DataType.BuildDataType(program.TypeFactory);
         var item = new ImageMapItem((uint)dt.Size)
          {
             Address = kv.Key,
             DataType = dt,
         };
         if (item.Size > 0)
         {
             program.ImageMap.AddItemWithSize(kv.Key, item);
         }
         else 
         {
             program.ImageMap.AddItem(kv.Key, item);
         }
     }
     program.DisassemblyFilename = sInput.DisassemblyFilename;
     program.IntermediateFilename = sInput.IntermediateFilename;
     program.OutputFilename = sInput.OutputFilename;
     program.TypesFilename = sInput.TypesFilename;
     program.GlobalsFilename = sInput.GlobalsFilename;
     program.EnsureFilenames(sInput.Filename);
     program.OnLoadedScript = sInput.OnLoadedScript;
     if (sInput.Options != null)
     {
         program.Options.HeuristicScanning = sInput.Options.HeuristicScanning;
     }
     ProgramLoaded.Fire(this, new ProgramEventArgs(program));
     return program;
 }
Exemplo n.º 3
0
        public Program VisitInputFile(DecompilerInput_v2 sInput)
        {
            var bytes = loader.LoadImageBytes(sInput.Filename, 0);
            var program = loader.LoadExecutable(sInput.Filename, bytes, null);
            program.Filename = sInput.Filename;
            LoadUserData(sInput, program, program.User);

            program.DisassemblyFilename = sInput.DisassemblyFilename;
            program.IntermediateFilename = sInput.IntermediateFilename;
            program.OutputFilename = sInput.OutputFilename;
            program.TypesFilename = sInput.TypesFilename;
            program.GlobalsFilename = sInput.GlobalsFilename;
            program.EnsureFilenames(sInput.Filename);
            ProgramLoaded.Fire(this, new ProgramEventArgs(program));
            return program;
        }