Esempio n. 1
0
        public void LoadUserData(UserData_v3 sUser, Program program, UserData user)
        {
            if (sUser == null)
            {
                return;
            }
            user.OnLoadedScript = sUser.OnLoadedScript;
            if (sUser.Processor != null)
            {
                program.User.Processor = sUser.Processor.Name;
                if (program.Architecture == null && !string.IsNullOrEmpty(program.User.Processor))
                {
                    program.Architecture = Services.RequireService <IConfigurationService>().GetArchitecture(program.User.Processor);
                }
                //program.Architecture.LoadUserOptions();       //$TODO
            }
            if (sUser.Procedures != null)
            {
                user.Procedures = sUser.Procedures
                                  .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 (sUser.PlatformOptions != null)
            {
                program.User.Environment = sUser.PlatformOptions.Name;
                program.Platform.LoadUserOptions(XmlOptions.LoadIntoDictionary(sUser.PlatformOptions.Options));
            }
            if (sUser.GlobalData != null)
            {
                user.Globals = sUser.GlobalData
                               .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);
            }

            if (sUser.Heuristics != null)
            {
                user.Heuristics.UnionWith(sUser.Heuristics.Select(h => h.Name));
            }
            program.EnvironmentMetadata = project.LoadedMetadata;
        }
Esempio n. 2
0
 private Address LoadAddress(UserData_v3 user)
 {
     if (user == null || user.LoadAddress == null || user.Processor == null ||
         user.Processor.Name == null)
         return null;
     var arch = Services.RequireService<IConfigurationService>()
         .GetArchitecture(user.Processor.Name);
     if (arch == null)
         return null;
     if (!arch.TryParseAddress(user.LoadAddress, out Address addr))
         return null;
     return addr;
 }
Esempio n. 3
0
        public void LoadUserData(UserData_v3 sUser, Program program, UserData user)
        {
            if (sUser == null)
            {
                return;
            }
            user.OnLoadedScript = sUser.OnLoadedScript;
            if (sUser.Processor != null)
            {
                program.User.Processor = sUser.Processor.Name;
                if (program.Architecture == null && !string.IsNullOrEmpty(program.User.Processor))
                {
                    program.Architecture = Services.RequireService <IConfigurationService>().GetArchitecture(program.User.Processor !);
                }
                //program.Architecture.LoadUserOptions();       //$TODO
            }
            if (sUser.Procedures != null)
            {
                user.Procedures = sUser.Procedures
                                  .Select(sup => LoadUserProcedure_v1(program, sup))
                                  .Where(kv => kv.Key != null)
                                  .ToSortedList(kv => kv.Key, kv => kv.Value);
            }

            if (sUser.PlatformOptions != null)
            {
                program.User.Environment = sUser.PlatformOptions.Name;
                program.Platform.LoadUserOptions(XmlOptions.LoadIntoDictionary(sUser.PlatformOptions.Options, StringComparer.OrdinalIgnoreCase));
            }
            if (sUser.GlobalData != null)
            {
                user.Globals = sUser.GlobalData
                               .Select(sud =>
                {
                    program.Architecture !.TryParseAddress(sud.Address, out Address addr);
                    return(new KeyValuePair <Address, GlobalDataItem_v2>(
                               addr,
                               sud));
                })
                               .Where(kv => kv.Key != null)
                               .ToSortedList(kv => kv.Key, kv => kv.Value);
            }

            if (sUser.Heuristics != null)
            {
                user.Heuristics.UnionWith(sUser.Heuristics.Select(h => h.Name));
            }
            // Backwards compatibility: older versions used single file policy.
            program.User.OutputFilePolicy = Program.SingleFilePolicy;
            program.EnvironmentMetadata   = project.LoadedMetadata;
        }
Esempio n. 4
0
 private Address LoadAddress(UserData_v3 user)
 {
     if (user == null || user.LoadAddress == null || user.Processor == null)
     {
         return(null);
     }
     if (!Services.RequireService <IConfigurationService>()
         .GetArchitecture(user.Processor.Name)
         .TryParseAddress(user.LoadAddress, out Address addr))
     {
         return(null);
     }
     return(addr);
 }
Esempio n. 5
0
 public DecompilerInput_v3()
 {
     User = new UserData_v3();
 }
Esempio n. 6
0
        public void LoadUserData(UserData_v3 sUser, Program program, UserData user)
        {
            if (sUser == null)
            {
                return;
            }
            user.OnLoadedScript = sUser.OnLoadedScript;
            if (sUser.Processor != null)
            {
                program.User.Processor = sUser.Processor.Name;
                if (program.Architecture == null && !string.IsNullOrEmpty(program.User.Processor))
                {
                    program.Architecture = Services.RequireService <IConfigurationService>().GetArchitecture(program.User.Processor);
                }
                //program.Architecture.LoadUserOptions();       //$TODO
            }
            if (sUser.Procedures != null)
            {
                user.Procedures = sUser.Procedures
                                  .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 (sUser.PlatformOptions != null)
            {
                program.User.Environment = sUser.PlatformOptions.Name;
                program.Platform.LoadUserOptions(LoadWeaklyTypedOptions(sUser.PlatformOptions.Options));
            }
            if (sUser.GlobalData != null)
            {
                user.Globals = sUser.GlobalData
                               .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);
            }
            var tlDeser = CreateTypeLibraryDeserializer();

            foreach (var kv in user.Globals)
            {
                var dt   = kv.Value.DataType.Accept(tlDeser);
                var item = new ImageMapItem((uint)dt.Size)
                {
                    Address  = kv.Key,
                    DataType = dt,
                    Name     = kv.Value.Name,
                };

                if (item.Size > 0)
                {
                    program.ImageMap.AddItemWithSize(kv.Key, item);
                }
                else
                {
                    program.ImageMap.AddItem(kv.Key, item);
                }
                //$BUGBUG: what about x86 segmented binaries?
                int offset = (int)kv.Key.ToLinear();
                program.GlobalFields.Fields.Add(offset, dt, kv.Value.Name);
            }

            if (sUser.Heuristics != null)
            {
                user.Heuristics.UnionWith(sUser.Heuristics.Select(h => h.Name));
            }
            program.EnvironmentMetadata = project.LoadedMetadata;
        }