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"); } }
public void LoadUserData(UserData_v3 sUser, Program program, UserData user) { if (sUser == null) return; user.OnLoadedScript = sUser.OnLoadedScript; 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.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.PlatformOptions != null) { program.User.Environment = sUser.PlatformOptions.Name; if (program.Platform is DefaultPlatform && !string.IsNullOrEmpty(program.User.Environment)) { program.Platform = services.RequireService<IConfigurationService>() .GetEnvironment(program.User.Environment) .Load(services, program.Architecture); } program.Platform.LoadUserOptions(LoadPlatformOptions(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); } 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); } } if (sUser.Heuristics != null) { user.Heuristics.UnionWith(sUser.Heuristics.Select(h => h.Name)); } }