public Program VisitInputFile(string projectFilePath, DecompilerInput_v5 sInput) { //$REVIEW: make this null //if (sInput.Filename == null) // return null; var binAbsPath = ConvertToAbsolutePath(projectFilePath, sInput.Filename) !; var sUser = sInput.User ?? new UserData_v4 { ExtractResources = true, OutputFilePolicy = Program.SingleFilePolicy, }; var address = LoadAddress(sUser, this.arch !); Program program = LoadProgram(projectFilePath, sInput); LoadUserData(sUser, program, program.User, projectFilePath); program.Filename = binAbsPath; program.DisassemblyDirectory = ConvertToAbsolutePath(projectFilePath, sInput.DisassemblyDirectory) !; program.SourceDirectory = ConvertToAbsolutePath(projectFilePath, sInput.SourceDirectory) !; program.IncludeDirectory = ConvertToAbsolutePath(projectFilePath, sInput.IncludeDirectory) !; program.ResourcesDirectory = ConvertToAbsolutePath(projectFilePath, sInput.ResourcesDirectory) !; program.EnsureDirectoryNames(program.Filename); program.User.LoadAddress = address; ProgramLoaded?.Fire(this, new ProgramEventArgs(program)); return(program); }
public Program VisitInputFile(string projectFilePath, DecompilerInput_v5 sInput) { //$REVIEW: make this null //if (sInput.Filename == null) // return null; var binAbsPath = ConvertToAbsolutePath(projectFilePath, sInput.Filename) !; var bytes = loader.LoadImageBytes(binAbsPath, 0); var sUser = sInput.User ?? new UserData_v4 { ExtractResources = true, OutputFilePolicy = Program.SingleFilePolicy, }; var address = LoadAddress(sUser, this.arch); var archOptions = XmlOptions.LoadIntoDictionary(sUser.Processor?.Options, StringComparer.OrdinalIgnoreCase); Program program; if (!string.IsNullOrEmpty(sUser.Loader)) { // The presence of an explicit loader name prompts us to // use the LoadRawImage path. var archName = sUser.Processor?.Name; var platform = sUser.PlatformOptions?.Name; program = loader.LoadRawImage(binAbsPath, bytes, address, new LoadDetails { LoaderName = sUser.Loader, ArchitectureName = archName, ArchitectureOptions = archOptions, PlatformName = platform, LoadAddress = sUser.LoadAddress, }); } else { program = loader.LoadExecutable(binAbsPath, bytes, sUser.Loader, address) ?? new Program(); // A previous save of the project was able to read the file, // but now we can't... } LoadUserData(sUser, program, program.User, projectFilePath); program.Filename = binAbsPath; program.DisassemblyDirectory = ConvertToAbsolutePath(projectFilePath, sInput.DisassemblyDirectory); program.SourceDirectory = ConvertToAbsolutePath(projectFilePath, sInput.SourceDirectory); program.IncludeDirectory = ConvertToAbsolutePath(projectFilePath, sInput.IncludeDirectory); program.ResourcesDirectory = ConvertToAbsolutePath(projectFilePath, sInput.ResourcesDirectory); program.EnsureDirectoryNames(program.Filename); program.User.LoadAddress = address; ProgramLoaded?.Fire(this, new ProgramEventArgs(program)); return(program); }
public Program VisitInputFile(string projectFilePath, DecompilerInput_v4 sInput) { var binAbsPath = ConvertToAbsolutePath(projectFilePath, sInput.Filename); var bytes = loader.LoadImageBytes(ConvertToAbsolutePath(projectFilePath, sInput.Filename), 0); var sUser = sInput.User; var address = LoadAddress(sUser, this.arch); Program program; if (address != null && sUser.Processor != null && (sUser.PlatformOptions == null || sUser.PlatformOptions.Name != null)) { var arch = sUser.Processor.Name; var platform = sUser.PlatformOptions?.Name; program = loader.LoadRawImage(binAbsPath, bytes, address, new LoadDetails { LoaderName = sUser.Loader, ArchitectureName = arch, PlatformName = platform, LoadAddress = sUser.LoadAddress, }); } else { program = loader.LoadExecutable(binAbsPath, bytes, sUser.Loader, address); } program.Filename = binAbsPath; program.DisassemblyFilename = ConvertToAbsolutePath(projectFilePath, sInput.DisassemblyFilename); program.IntermediateFilename = ConvertToAbsolutePath(projectFilePath, sInput.IntermediateFilename); program.OutputFilename = ConvertToAbsolutePath(projectFilePath, sInput.OutputFilename); program.TypesFilename = ConvertToAbsolutePath(projectFilePath, sInput.TypesFilename); program.GlobalsFilename = ConvertToAbsolutePath(projectFilePath, sInput.GlobalsFilename); program.EnsureFilenames(program.Filename); LoadUserData(sUser, program, program.User); program.User.LoadAddress = address; ProgramLoaded.Fire(this, new ProgramEventArgs(program)); return(program); }
public Program VisitInputFile(string projectFilePath, DecompilerInput_v3 sInput) { var binAbsPath = ConvertToAbsolutePath(projectFilePath, sInput.Filename); var bytes = loader.LoadImageBytes(binAbsPath, 0); var sUser = sInput.User; var address = LoadAddress(sUser); Program program; if (sUser.Processor != null && (sUser.PlatformOptions == null || sUser.PlatformOptions.Name != null)) { var arch = sUser.Processor.Name; var platform = sUser.PlatformOptions?.Name; program = loader.LoadRawImage(binAbsPath, bytes, address, new LoadDetails { ArchitectureName = arch, PlatformName = platform, LoadAddress = sUser.LoadAddress, }); } else { program = loader.LoadExecutable(sInput.Filename, bytes, null, address) ?? new Program(); // A previous save of the project was able to read the file, // but now we can't... } this.platform = program.Platform; program.Filename = ConvertToAbsolutePath(projectFilePath, sInput.Filename); program.DisassemblyDirectory = ConvertToAbsolutePath(projectFilePath, Path.GetDirectoryName(sInput.DisassemblyFilename)); program.SourceDirectory = ConvertToAbsolutePath(projectFilePath, Path.GetDirectoryName(sInput.OutputFilename)); program.IncludeDirectory = ConvertToAbsolutePath(projectFilePath, Path.GetDirectoryName(sInput.TypesFilename)); program.EnsureDirectoryNames(program.Filename); LoadUserData(sUser, program, program.User); ProgramLoaded?.Fire(this, new ProgramEventArgs(program)); return(program); }
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); }