mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
GP-4836 cleanup "Executable Format" option usage
This commit is contained in:
parent
5047c00359
commit
ffaa3398ca
14 changed files with 45 additions and 80 deletions
|
@ -31,7 +31,6 @@ import ghidra.app.util.opinion.ElfLoader;
|
|||
import ghidra.pcode.emulate.EmulateExecutionState;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.Instruction;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.exception.NotFoundException;
|
||||
|
@ -61,8 +60,7 @@ public class EmuX86DeobfuscateExampleScript extends GhidraScript {
|
|||
@Override
|
||||
protected void run() throws Exception {
|
||||
|
||||
String format =
|
||||
currentProgram.getOptions(Program.PROGRAM_INFO).getString("Executable Format", null);
|
||||
String format = currentProgram.getExecutableFormat();
|
||||
|
||||
if (currentProgram == null || !currentProgram.getName().startsWith(PROGRAM_NAME) ||
|
||||
!"x86:LE:64:default".equals(currentProgram.getLanguageID().toString()) ||
|
||||
|
|
|
@ -33,7 +33,6 @@ import ghidra.pcode.emulate.EmulateExecutionState;
|
|||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.InsufficientBytesException;
|
||||
import ghidra.program.model.listing.Function;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.exception.NotFoundException;
|
||||
|
@ -64,8 +63,7 @@ public class EmuX86GccDeobfuscateHookExampleScript extends GhidraScript {
|
|||
@Override
|
||||
protected void run() throws Exception {
|
||||
|
||||
String format =
|
||||
currentProgram.getOptions(Program.PROGRAM_INFO).getString("Executable Format", null);
|
||||
String format = currentProgram.getExecutableFormat();
|
||||
|
||||
if (currentProgram == null || !currentProgram.getName().startsWith(PROGRAM_NAME) ||
|
||||
!"x86:LE:64:default".equals(currentProgram.getLanguageID().toString()) ||
|
||||
|
|
|
@ -25,7 +25,6 @@ import ghidra.app.util.bin.format.coff.*;
|
|||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.app.util.opinion.BinaryLoader;
|
||||
import ghidra.framework.cmd.BinaryAnalysisCommand;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.flatapi.FlatProgramAPI;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.data.*;
|
||||
|
@ -46,9 +45,7 @@ public class CoffBinaryAnalysisCommand extends FlatProgramAPI
|
|||
@Override
|
||||
public boolean canApply(Program program) {
|
||||
try {
|
||||
Options options = program.getOptions(Program.PROGRAM_INFO);
|
||||
String format = options.getString("Executable Format", null);
|
||||
if (!BinaryLoader.BINARY_NAME.equals(format)) {
|
||||
if (!BinaryLoader.BINARY_NAME.equals(program.getExecutableFormat())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import ghidra.app.util.bin.format.elf.ElfDynamicType.ElfDynamicValueType;
|
|||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.app.util.opinion.BinaryLoader;
|
||||
import ghidra.framework.cmd.BinaryAnalysisCommand;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.flatapi.FlatProgramAPI;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressOverflowException;
|
||||
|
@ -54,9 +53,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
|
|||
@Override
|
||||
public boolean canApply(Program program) {
|
||||
try {
|
||||
Options options = program.getOptions(Program.PROGRAM_INFO);
|
||||
String format = options.getString("Executable Format", null);
|
||||
if (!BinaryLoader.BINARY_NAME.equals(format)) {
|
||||
if (!BinaryLoader.BINARY_NAME.equals(program.getExecutableFormat())) {
|
||||
return false;
|
||||
}
|
||||
Memory memory = program.getMemory();
|
||||
|
|
|
@ -27,7 +27,6 @@ import ghidra.app.util.bin.format.macho.commands.UnsupportedLoadCommand;
|
|||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.app.util.opinion.BinaryLoader;
|
||||
import ghidra.framework.cmd.BinaryAnalysisCommand;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.flatapi.FlatProgramAPI;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.data.DataType;
|
||||
|
@ -63,9 +62,7 @@ public class MachoBinaryAnalysisCommand extends FlatProgramAPI
|
|||
@Override
|
||||
public boolean canApply(Program program) {
|
||||
try {
|
||||
Options options = program.getOptions(Program.PROGRAM_INFO);
|
||||
String format = options.getString("Executable Format", null);
|
||||
if (!BinaryLoader.BINARY_NAME.equals(format)) {
|
||||
if (!BinaryLoader.BINARY_NAME.equals(program.getExecutableFormat())) {
|
||||
return false;
|
||||
}
|
||||
Memory memory = program.getMemory();
|
||||
|
|
|
@ -19,7 +19,6 @@ import ghidra.app.services.*;
|
|||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.app.util.opinion.ElfLoader;
|
||||
import ghidra.app.util.opinion.MachoLoader;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.util.ExternalSymbolResolver;
|
||||
|
@ -57,8 +56,7 @@ public class ExternalSymbolResolverAnalyzer extends AbstractAnalyzer {
|
|||
return false;
|
||||
}
|
||||
|
||||
Options options = program.getOptions(Program.PROGRAM_INFO);
|
||||
String format = options.getString("Executable Format", null);
|
||||
String format = program.getExecutableFormat();
|
||||
return ElfLoader.ELF_NAME.equals(format) || MachoLoader.MACH_O_NAME.equals(format);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,8 +91,7 @@ public class MachoFunctionStartsAnalyzer extends AbstractAnalyzer {
|
|||
|
||||
@Override
|
||||
public boolean canAnalyze(Program program) {
|
||||
Options options = program.getOptions(Program.PROGRAM_INFO);
|
||||
String format = options.getString("Executable Format", null);
|
||||
String format = program.getExecutableFormat();
|
||||
isDyld = DyldCacheLoader.DYLD_CACHE_NAME.equals(format);
|
||||
return isDyld || MachoLoader.MACH_O_NAME.equals(format);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import ghidra.app.plugin.core.analysis.rust.RustConstants;
|
|||
import ghidra.app.plugin.core.datamgr.archive.DataTypeManagerHandler;
|
||||
import ghidra.app.util.opinion.*;
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.model.data.FileDataTypeManager;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.Msg;
|
||||
|
@ -116,13 +115,12 @@ public class DataTypeArchiveUtility {
|
|||
public static List<String> getArchiveList(Program program) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
|
||||
Options props = program.getOptions(Program.PROGRAM_INFO);
|
||||
String format = props.getString("Executable Format", "");
|
||||
String format = program.getExecutableFormat();
|
||||
|
||||
int size = program.getAddressFactory().getDefaultAddressSpace().getSize();
|
||||
|
||||
if (format.equals(PeLoader.PE_NAME) ||
|
||||
(format.equals(CoffLoader.COFF_NAME) && isVisualStudio(program))) {
|
||||
if (PeLoader.PE_NAME.equals(format) ||
|
||||
(CoffLoader.COFF_NAME.equals(format) && isVisualStudio(program))) {
|
||||
// TODO: add in win7/win10
|
||||
if (size == 64) {
|
||||
list.add("windows_vs12_64");
|
||||
|
@ -131,7 +129,7 @@ public class DataTypeArchiveUtility {
|
|||
list.add("windows_vs12_32");
|
||||
}
|
||||
}
|
||||
else if (format.equals(MachoLoader.MACH_O_NAME)) {
|
||||
else if (MachoLoader.MACH_O_NAME.equals(format)) {
|
||||
// list.add("Cocoa"); // no more cocoa puffs for you
|
||||
// TODO: should we have a 64/32 version?
|
||||
// TODO: multiple OSX versions
|
||||
|
|
|
@ -20,7 +20,6 @@ import ghidra.app.services.AnalyzerType;
|
|||
import ghidra.app.util.bin.*;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.app.util.opinion.BinaryLoader;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.data.DataType;
|
||||
|
@ -48,9 +47,7 @@ public class CramFsAnalyzer extends AbstractAnalyzer {
|
|||
@Override
|
||||
public boolean canAnalyze(Program program) {
|
||||
try {
|
||||
Options options = program.getOptions(Program.PROGRAM_INFO);
|
||||
String format = options.getString("Executable Format", null);
|
||||
if (!BinaryLoader.BINARY_NAME.equals(format)) {
|
||||
if (!BinaryLoader.BINARY_NAME.equals(program.getExecutableFormat())) {
|
||||
return false;
|
||||
}
|
||||
Language language = program.getLanguage();
|
||||
|
|
|
@ -24,7 +24,6 @@ import ghidra.app.util.importer.MessageLog;
|
|||
import ghidra.app.util.opinion.*;
|
||||
import ghidra.file.formats.dump.DumpFile;
|
||||
import ghidra.file.formats.dump.DumpFileReader;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.framework.store.LockException;
|
||||
import ghidra.program.database.mem.FileBytes;
|
||||
import ghidra.program.model.address.*;
|
||||
|
@ -53,8 +52,7 @@ public class Apport extends DumpFile {
|
|||
super(reader, dtm, options, monitor);
|
||||
this.log = log;
|
||||
|
||||
Options props = program.getOptions(Program.PROGRAM_INFO);
|
||||
props.setString("Executable Format", PeLoader.PE_NAME);
|
||||
program.setExecutableFormat(PeLoader.PE_NAME);
|
||||
initManagerList(null);
|
||||
|
||||
header = new ApportHeader(reader, 0L, monitor);
|
||||
|
|
|
@ -24,9 +24,7 @@ import ghidra.app.util.bin.StructConverter;
|
|||
import ghidra.app.util.opinion.PeLoader;
|
||||
import ghidra.file.formats.dump.*;
|
||||
import ghidra.file.formats.dump.cmd.ModuleToPeHelper;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
@ -44,8 +42,7 @@ public class Minidump extends DumpFile {
|
|||
|
||||
super(reader, dtm, options, monitor);
|
||||
|
||||
Options props = program.getOptions(Program.PROGRAM_INFO);
|
||||
props.setString("Executable Format", PeLoader.PE_NAME);
|
||||
program.setExecutableFormat(PeLoader.PE_NAME);
|
||||
initManagerList(null);
|
||||
|
||||
createBlocks =
|
||||
|
|
|
@ -29,9 +29,7 @@ import ghidra.app.util.opinion.PeLoader;
|
|||
import ghidra.app.util.pdb.pdbapplicator.*;
|
||||
import ghidra.file.formats.dump.*;
|
||||
import ghidra.file.formats.dump.cmd.ModuleToPeHelper;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.DuplicateNameException;
|
||||
|
@ -109,8 +107,7 @@ public class Pagedump extends DumpFile {
|
|||
addins.add("ntoskrnl");
|
||||
addins.add("ntkrnlmp");
|
||||
|
||||
Options props = program.getOptions(Program.PROGRAM_INFO);
|
||||
props.setString("Executable Format", PeLoader.PE_NAME);
|
||||
program.setExecutableFormat(PeLoader.PE_NAME);
|
||||
initManagerList(addins);
|
||||
|
||||
createBlocks = OptionUtils.getBooleanOptionValue(CREATE_MEMORY_BLOCKS_OPTION_NAME, options,
|
||||
|
|
|
@ -24,9 +24,7 @@ import ghidra.app.util.OptionUtils;
|
|||
import ghidra.app.util.opinion.PeLoader;
|
||||
import ghidra.file.formats.dump.*;
|
||||
import ghidra.file.formats.dump.cmd.ModuleToPeHelper;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
@ -42,8 +40,7 @@ public class Userdump extends DumpFile {
|
|||
|
||||
super(reader, dtm, options, monitor);
|
||||
|
||||
Options props = program.getOptions(Program.PROGRAM_INFO);
|
||||
props.setString("Executable Format", PeLoader.PE_NAME);
|
||||
program.setExecutableFormat(PeLoader.PE_NAME);
|
||||
initManagerList(null);
|
||||
|
||||
createBlocks =
|
||||
|
|
|
@ -22,7 +22,6 @@ import ghidra.app.util.importer.MessageLog;
|
|||
import ghidra.app.util.opinion.BinaryLoader;
|
||||
import ghidra.app.util.opinion.DyldCacheUtils;
|
||||
import ghidra.file.analyzers.FileFormatAnalyzer;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.data.DataType;
|
||||
|
@ -105,9 +104,7 @@ public class DyldCacheAnalyzer extends FileFormatAnalyzer {
|
|||
|
||||
@Override
|
||||
public boolean canAnalyze(Program program) {
|
||||
Options options = program.getOptions("Program Information");
|
||||
String format = options.getString("Executable Format", null);
|
||||
if (!BinaryLoader.BINARY_NAME.equals(format)) {
|
||||
if (!BinaryLoader.BINARY_NAME.equals(program.getExecutableFormat())) {
|
||||
return false;
|
||||
}
|
||||
return DyldCacheUtils.isDyldCache(program);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue