mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GT-2845: Removing MemoryConflictHandler.
This commit is contained in:
parent
07129cca77
commit
7617f30756
36 changed files with 103 additions and 213 deletions
|
@ -19,7 +19,6 @@ import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.framework.store.LockException;
|
import ghidra.framework.store.LockException;
|
||||||
import ghidra.program.model.address.*;
|
import ghidra.program.model.address.*;
|
||||||
import ghidra.program.model.listing.*;
|
import ghidra.program.model.listing.*;
|
||||||
|
@ -47,19 +46,16 @@ public class MemoryBlockUtil {
|
||||||
private Listing listing;
|
private Listing listing;
|
||||||
private Memory memory;
|
private Memory memory;
|
||||||
private SymbolTable symbolTable;
|
private SymbolTable symbolTable;
|
||||||
private MemoryConflictHandler handler;
|
|
||||||
private StringBuffer messages;
|
private StringBuffer messages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new memory block utility.
|
* Constructs a new memory block utility.
|
||||||
* @param program the program having memory blocks created
|
* @param program the program having memory blocks created
|
||||||
* @param handler the memory conflict handler
|
|
||||||
*/
|
*/
|
||||||
public MemoryBlockUtil(Program program, MemoryConflictHandler handler) {
|
public MemoryBlockUtil(Program program) {
|
||||||
this.listing = program.getListing();
|
this.listing = program.getListing();
|
||||||
this.memory = program.getMemory();
|
this.memory = program.getMemory();
|
||||||
this.symbolTable = program.getSymbolTable();
|
this.symbolTable = program.getSymbolTable();
|
||||||
this.handler = handler;
|
|
||||||
this.messages = new StringBuffer();
|
this.messages = new StringBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +74,6 @@ public class MemoryBlockUtil {
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
listing = null;
|
listing = null;
|
||||||
memory = null;
|
memory = null;
|
||||||
handler = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -317,7 +312,7 @@ public class MemoryBlockUtil {
|
||||||
|
|
||||||
boolean shouldOverwriteBlock = true;
|
boolean shouldOverwriteBlock = true;
|
||||||
if (existingBlocks.length > 0) {
|
if (existingBlocks.length > 0) {
|
||||||
shouldOverwriteBlock = handler.allowOverwrite(start, end);
|
shouldOverwriteBlock = /*handler.allowOverwrite(start, end);*/ true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: collect all user references in (start,end)
|
//TODO: collect all user references in (start,end)
|
||||||
|
|
|
@ -272,8 +272,7 @@ public final class AutoImporter {
|
||||||
|
|
||||||
public static boolean importAddToProgram(File file, Program program, MessageLog messageLog,
|
public static boolean importAddToProgram(File file, Program program, MessageLog messageLog,
|
||||||
TaskMonitor monitor, Predicate<Loader> loaderFilter, LoadSpecChooser loadSpecChooser,
|
TaskMonitor monitor, Predicate<Loader> loaderFilter, LoadSpecChooser loadSpecChooser,
|
||||||
OptionChooser optionChooser, MemoryConflictHandler memoryConflictHandler)
|
OptionChooser optionChooser) throws IOException, CancelledException {
|
||||||
throws IOException, CancelledException {
|
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -347,7 +346,7 @@ public final class AutoImporter {
|
||||||
|
|
||||||
try (RandomAccessByteProvider provider = new RandomAccessByteProvider(file)) {
|
try (RandomAccessByteProvider provider = new RandomAccessByteProvider(file)) {
|
||||||
return loadSpec.getLoader().loadInto(provider, loadSpec, options, messageLog, program,
|
return loadSpec.getLoader().loadInto(provider, loadSpec, options, messageLog, program,
|
||||||
monitor, memoryConflictHandler);
|
monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
/* ###
|
|
||||||
* IP: GHIDRA
|
|
||||||
* REVIEWED: YES
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package ghidra.app.util.importer;
|
|
||||||
|
|
||||||
import ghidra.program.model.address.Address;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An interface for handling memory block conflicts
|
|
||||||
* that are encountered during an import.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface MemoryConflictHandler {
|
|
||||||
/**
|
|
||||||
* An implementation that always overwrites conflicts.
|
|
||||||
*/
|
|
||||||
public final static MemoryConflictHandler ALWAYS_OVERWRITE = new MemoryConflictHandler() {
|
|
||||||
public boolean allowOverwrite(Address start, Address end) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* An implementation that never overwrites conflicts.
|
|
||||||
*/
|
|
||||||
public final static MemoryConflictHandler NEVER_OVERWRITE = new MemoryConflictHandler() {
|
|
||||||
public boolean allowOverwrite(Address start, Address end) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* This method is invoked when a memory block conflict
|
|
||||||
* is detected. The start and end addresses of the conflict
|
|
||||||
* are passed into the method. To overwrite the conflict, return true.
|
|
||||||
* Otherwise return false to NOT overwrite the conflict.
|
|
||||||
* @param start the start address of the conflict
|
|
||||||
* @param end the end address of the conflict
|
|
||||||
* @return true to overwrite the conflict
|
|
||||||
*/
|
|
||||||
public boolean allowOverwrite(Address start, Address end);
|
|
||||||
}
|
|
|
@ -25,7 +25,8 @@ import org.apache.commons.io.FilenameUtils;
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.bin.RandomAccessByteProvider;
|
import ghidra.app.util.bin.RandomAccessByteProvider;
|
||||||
import ghidra.app.util.importer.*;
|
import ghidra.app.util.importer.LibrarySearchPathManager;
|
||||||
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.formats.gfilesystem.FSRL;
|
import ghidra.formats.gfilesystem.FSRL;
|
||||||
import ghidra.framework.model.*;
|
import ghidra.framework.model.*;
|
||||||
import ghidra.framework.options.Options;
|
import ghidra.framework.options.Options;
|
||||||
|
@ -59,14 +60,13 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
|
||||||
* @param loadSpec The {@link LoadSpec} to use during load.
|
* @param loadSpec The {@link LoadSpec} to use during load.
|
||||||
* @param options The load options.
|
* @param options The load options.
|
||||||
* @param program The {@link Program} to load into.
|
* @param program The {@link Program} to load into.
|
||||||
* @param handler How to handle memory conflicts that occur during the load.
|
|
||||||
* @param monitor A cancelable task monitor.
|
* @param monitor A cancelable task monitor.
|
||||||
* @param log The message log.
|
* @param log The message log.
|
||||||
* @throws IOException if there was an IO-related problem loading.
|
* @throws IOException if there was an IO-related problem loading.
|
||||||
* @throws CancelledException if the user cancelled the load.
|
* @throws CancelledException if the user cancelled the load.
|
||||||
*/
|
*/
|
||||||
protected abstract void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
protected abstract void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
Program program, TaskMonitor monitor, MessageLog log)
|
||||||
throws CancelledException, IOException;
|
throws CancelledException, IOException;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -110,8 +110,8 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
||||||
List<Option> options, MessageLog log, Program program, TaskMonitor monitor,
|
List<Option> options, MessageLog log, Program program, TaskMonitor monitor)
|
||||||
MemoryConflictHandler memoryConflictHandler) throws CancelledException, IOException {
|
throws CancelledException, IOException {
|
||||||
|
|
||||||
LanguageCompilerSpecPair pair = loadSpec.getLanguageCompilerSpec();
|
LanguageCompilerSpecPair pair = loadSpec.getLanguageCompilerSpec();
|
||||||
LanguageID languageID = program.getLanguageID();
|
LanguageID languageID = program.getLanguageID();
|
||||||
|
@ -122,7 +122,7 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
log.appendMsg("----- Loading " + provider.getAbsolutePath() + " -----");
|
log.appendMsg("----- Loading " + provider.getAbsolutePath() + " -----");
|
||||||
load(provider, loadSpec, options, program, memoryConflictHandler, monitor, log);
|
load(provider, loadSpec, options, program, monitor, log);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,8 +343,7 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
log.appendMsg("----- Loading " + provider.getAbsolutePath() + " -----");
|
log.appendMsg("----- Loading " + provider.getAbsolutePath() + " -----");
|
||||||
load(provider, loadSpec, options, program, MemoryConflictHandler.ALWAYS_OVERWRITE,
|
load(provider, loadSpec, options, program, monitor, log);
|
||||||
monitor, log);
|
|
||||||
|
|
||||||
createDefaultMemoryBlocks(program, language, log);
|
createDefaultMemoryBlocks(program, language, log);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ import ghidra.app.plugin.processors.generic.MemoryBlockDefinition;
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.OptionUtils;
|
import ghidra.app.util.OptionUtils;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.framework.model.DomainFolder;
|
import ghidra.framework.model.DomainFolder;
|
||||||
import ghidra.framework.model.DomainObject;
|
import ghidra.framework.model.DomainObject;
|
||||||
|
@ -89,14 +88,13 @@ public abstract class AbstractProgramLoader implements Loader {
|
||||||
* @param messageLog The message log.
|
* @param messageLog The message log.
|
||||||
* @param program The {@link Program} to load into.
|
* @param program The {@link Program} to load into.
|
||||||
* @param monitor A cancelable task monitor.
|
* @param monitor A cancelable task monitor.
|
||||||
* @param memoryConflictHandler How to handle memory conflicts that occur during the load.
|
|
||||||
* @return True if the file was successfully loaded; otherwise, false.
|
* @return True if the file was successfully loaded; otherwise, false.
|
||||||
* @throws IOException if there was an IO-related problem loading.
|
* @throws IOException if there was an IO-related problem loading.
|
||||||
* @throws CancelledException if the user cancelled the load.
|
* @throws CancelledException if the user cancelled the load.
|
||||||
*/
|
*/
|
||||||
protected abstract boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
protected abstract boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
||||||
List<Option> options, MessageLog messageLog, Program program, TaskMonitor monitor,
|
List<Option> options, MessageLog messageLog, Program program, TaskMonitor monitor)
|
||||||
MemoryConflictHandler memoryConflictHandler) throws IOException, CancelledException;
|
throws IOException, CancelledException;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final List<DomainObject> load(ByteProvider provider, String name, DomainFolder folder,
|
public final List<DomainObject> load(ByteProvider provider, String name, DomainFolder folder,
|
||||||
|
@ -157,8 +155,8 @@ public abstract class AbstractProgramLoader implements Loader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
public final boolean loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
MessageLog messageLog, Program program, TaskMonitor monitor,
|
MessageLog messageLog, Program program, TaskMonitor monitor)
|
||||||
MemoryConflictHandler memoryConflictHandler) throws IOException, CancelledException {
|
throws IOException, CancelledException {
|
||||||
|
|
||||||
if (!loadSpec.isComplete()) {
|
if (!loadSpec.isComplete()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -168,8 +166,7 @@ public abstract class AbstractProgramLoader implements Loader {
|
||||||
int transactionID = program.startTransaction("Loading - " + getName());
|
int transactionID = program.startTransaction("Loading - " + getName());
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
success = loadProgramInto(provider, loadSpec, options, messageLog, program, monitor,
|
success = loadProgramInto(provider, loadSpec, options, messageLog, program, monitor);
|
||||||
memoryConflictHandler);
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.util.*;
|
||||||
|
|
||||||
import ghidra.app.util.*;
|
import ghidra.app.util.*;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.framework.model.DomainFolder;
|
import ghidra.framework.model.DomainFolder;
|
||||||
import ghidra.framework.model.DomainObject;
|
import ghidra.framework.model.DomainObject;
|
||||||
|
@ -278,8 +277,7 @@ public class BinaryLoader extends AbstractProgramLoader {
|
||||||
importerCompilerSpec, consumer);
|
importerCompilerSpec, consumer);
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
success = loadInto(provider, loadSpec, options, log, prog, monitor,
|
success = loadInto(provider, loadSpec, options, log, prog, monitor);
|
||||||
MemoryConflictHandler.ALWAYS_OVERWRITE);
|
|
||||||
if (success) {
|
if (success) {
|
||||||
createDefaultMemoryBlocks(prog, importerLanguage, log);
|
createDefaultMemoryBlocks(prog, importerLanguage, log);
|
||||||
}
|
}
|
||||||
|
@ -299,8 +297,8 @@ public class BinaryLoader extends AbstractProgramLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
||||||
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor,
|
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor)
|
||||||
MemoryConflictHandler handler) throws IOException {
|
throws IOException {
|
||||||
long length = getLength(options);
|
long length = getLength(options);
|
||||||
//File file = provider.getFile();
|
//File file = provider.getFile();
|
||||||
long fileOffset = getFileOffset(options);
|
long fileOffset = getFileOffset(options);
|
||||||
|
|
|
@ -26,7 +26,6 @@ import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.bin.format.coff.*;
|
import ghidra.app.util.bin.format.coff.*;
|
||||||
import ghidra.app.util.bin.format.coff.relocation.CoffRelocationHandler;
|
import ghidra.app.util.bin.format.coff.relocation.CoffRelocationHandler;
|
||||||
import ghidra.app.util.bin.format.coff.relocation.CoffRelocationHandlerFactory;
|
import ghidra.app.util.bin.format.coff.relocation.CoffRelocationHandlerFactory;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.framework.model.DomainObject;
|
import ghidra.framework.model.DomainObject;
|
||||||
import ghidra.program.database.function.OverlappingFunctionException;
|
import ghidra.program.database.function.OverlappingFunctionException;
|
||||||
|
@ -182,8 +181,7 @@ public class CoffLoader extends AbstractLibrarySupportLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
protected void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
boolean performFakeLinking = performFakeLinking(options);
|
boolean performFakeLinking = performFakeLinking(options);
|
||||||
|
|
||||||
|
@ -193,7 +191,7 @@ public class CoffLoader extends AbstractLibrarySupportLoader {
|
||||||
Map<CoffSectionHeader, Address> sectionsMap = new HashMap<>();
|
Map<CoffSectionHeader, Address> sectionsMap = new HashMap<>();
|
||||||
Map<CoffSymbol, Symbol> symbolsMap = new HashMap<>();
|
Map<CoffSymbol, Symbol> symbolsMap = new HashMap<>();
|
||||||
|
|
||||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program, handler);
|
MemoryBlockUtil mbu = new MemoryBlockUtil(program);
|
||||||
|
|
||||||
int id = program.startTransaction("loading program from COFF");
|
int id = program.startTransaction("loading program from COFF");
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
|
@ -26,7 +26,8 @@ import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.bin.RandomAccessByteProvider;
|
import ghidra.app.util.bin.RandomAccessByteProvider;
|
||||||
import ghidra.app.util.bin.format.pe.*;
|
import ghidra.app.util.bin.format.pe.*;
|
||||||
import ghidra.app.util.bin.format.pe.PortableExecutable.SectionLayout;
|
import ghidra.app.util.bin.format.pe.PortableExecutable.SectionLayout;
|
||||||
import ghidra.app.util.importer.*;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
|
import ghidra.app.util.importer.MessageLogContinuesFactory;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
import ghidra.util.Conv;
|
import ghidra.util.Conv;
|
||||||
|
@ -72,9 +73,8 @@ public class DbgLoader extends AbstractPeDebugLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program prog,
|
||||||
Program prog, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
GenericFactory factory = MessageLogContinuesFactory.create(log);
|
GenericFactory factory = MessageLogContinuesFactory.create(log);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
import ghidra.program.model.symbol.*;
|
import ghidra.program.model.symbol.*;
|
||||||
|
@ -81,9 +80,8 @@ public class DefLoader extends AbstractLibrarySupportLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program prog,
|
||||||
Program prog, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
if (!prog.getExecutableFormat().equals(PeLoader.PE_NAME)) {
|
if (!prog.getExecutableFormat().equals(PeLoader.PE_NAME)) {
|
||||||
throw new IOException("Program must be a " + PeLoader.PE_NAME);
|
throw new IOException("Program must be a " + PeLoader.PE_NAME);
|
||||||
|
|
|
@ -24,7 +24,6 @@ import ghidra.app.util.bin.BinaryReader;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.bin.format.macho.dyld.DyldArchitecture;
|
import ghidra.app.util.bin.format.macho.dyld.DyldArchitecture;
|
||||||
import ghidra.app.util.bin.format.macho.dyld.DyldCacheHeader;
|
import ghidra.app.util.bin.format.macho.dyld.DyldCacheHeader;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.framework.model.DomainObject;
|
import ghidra.framework.model.DomainObject;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
|
@ -81,8 +80,7 @@ public class DyldCacheLoader extends AbstractLibrarySupportLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DyldCacheProgramBuilder.buildProgram(program, provider,
|
DyldCacheProgramBuilder.buildProgram(program, provider,
|
||||||
|
|
|
@ -25,7 +25,8 @@ import ghidra.app.util.OptionUtils;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.bin.format.elf.ElfException;
|
import ghidra.app.util.bin.format.elf.ElfException;
|
||||||
import ghidra.app.util.bin.format.elf.ElfHeader;
|
import ghidra.app.util.bin.format.elf.ElfHeader;
|
||||||
import ghidra.app.util.importer.*;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
|
import ghidra.app.util.importer.MessageLogContinuesFactory;
|
||||||
import ghidra.framework.model.DomainFolder;
|
import ghidra.framework.model.DomainFolder;
|
||||||
import ghidra.framework.model.DomainObject;
|
import ghidra.framework.model.DomainObject;
|
||||||
import ghidra.program.model.lang.Endian;
|
import ghidra.program.model.lang.Endian;
|
||||||
|
@ -128,8 +129,7 @@ public class ElfLoader extends AbstractLibrarySupportLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
GenericFactory factory = MessageLogContinuesFactory.create(log);
|
GenericFactory factory = MessageLogContinuesFactory.create(log);
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.framework.model.*;
|
import ghidra.framework.model.*;
|
||||||
import ghidra.framework.store.local.ItemSerializer;
|
import ghidra.framework.store.local.ItemSerializer;
|
||||||
|
@ -84,8 +83,8 @@ public class GdtLoader implements Loader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
public boolean loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
MessageLog messageLog, Program program, TaskMonitor monitor,
|
MessageLog messageLog, Program program, TaskMonitor monitor)
|
||||||
MemoryConflictHandler memoryConflictHandler) throws IOException, CancelledException {
|
throws IOException, CancelledException {
|
||||||
throw new UnsupportedOperationException("cannot add GDT to program");
|
throw new UnsupportedOperationException("cannot add GDT to program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ import db.DBConstants;
|
||||||
import db.DBHandle;
|
import db.DBHandle;
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.framework.model.*;
|
import ghidra.framework.model.*;
|
||||||
import ghidra.framework.store.db.PackedDatabase;
|
import ghidra.framework.store.db.PackedDatabase;
|
||||||
|
@ -136,8 +135,8 @@ public class GzfLoader implements Loader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
public boolean loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
MessageLog messageLog, Program program, TaskMonitor monitor,
|
MessageLog messageLog, Program program, TaskMonitor monitor)
|
||||||
MemoryConflictHandler memoryConflictHandler) throws IOException, CancelledException {
|
throws IOException, CancelledException {
|
||||||
throw new UnsupportedOperationException("cannot add GZF to program");
|
throw new UnsupportedOperationException("cannot add GZF to program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.util.*;
|
||||||
|
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.framework.model.DomainFolder;
|
import ghidra.framework.model.DomainFolder;
|
||||||
import ghidra.framework.model.DomainObject;
|
import ghidra.framework.model.DomainObject;
|
||||||
|
@ -155,8 +154,7 @@ public class IntelHexLoader extends AbstractProgramLoader {
|
||||||
importerCompilerSpec, consumer);
|
importerCompilerSpec, consumer);
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
success = loadInto(provider, loadSpec, options, log, prog, monitor,
|
success = loadInto(provider, loadSpec, options, log, prog, monitor);
|
||||||
MemoryConflictHandler.ALWAYS_OVERWRITE);
|
|
||||||
if (success) {
|
if (success) {
|
||||||
createDefaultMemoryBlocks(prog, importerLanguage, log);
|
createDefaultMemoryBlocks(prog, importerLanguage, log);
|
||||||
}
|
}
|
||||||
|
@ -176,8 +174,8 @@ public class IntelHexLoader extends AbstractProgramLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
||||||
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor,
|
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor)
|
||||||
MemoryConflictHandler handler) throws IOException, CancelledException {
|
throws IOException, CancelledException {
|
||||||
Address baseAddr = getBaseAddr(options);
|
Address baseAddr = getBaseAddr(options);
|
||||||
|
|
||||||
if (baseAddr == null) {
|
if (baseAddr == null) {
|
||||||
|
@ -185,7 +183,7 @@ public class IntelHexLoader extends AbstractProgramLoader {
|
||||||
}
|
}
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
processIntelHex(provider, options, log, prog, monitor, handler);
|
processIntelHex(provider, options, log, prog, monitor);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
catch (AddressOverflowException e) {
|
catch (AddressOverflowException e) {
|
||||||
|
@ -196,7 +194,7 @@ public class IntelHexLoader extends AbstractProgramLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processIntelHex(ByteProvider provider, List<Option> options, MessageLog log,
|
private void processIntelHex(ByteProvider provider, List<Option> options, MessageLog log,
|
||||||
Program program, TaskMonitor monitor, MemoryConflictHandler handler)
|
Program program, TaskMonitor monitor)
|
||||||
throws IOException, AddressOverflowException, CancelledException {
|
throws IOException, AddressOverflowException, CancelledException {
|
||||||
String blockName = getBlockName(options);
|
String blockName = getBlockName(options);
|
||||||
boolean isOverlay = isOverlay(options);
|
boolean isOverlay = isOverlay(options);
|
||||||
|
@ -232,7 +230,7 @@ public class IntelHexLoader extends AbstractProgramLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
String msg = memImage.createMemory(getName(), provider.getName(),
|
String msg = memImage.createMemory(getName(), provider.getName(),
|
||||||
isOverlay ? blockName : null, isOverlay, program, handler, monitor);
|
isOverlay ? blockName : null, isOverlay, program, monitor);
|
||||||
|
|
||||||
if (msg.length() > 0) {
|
if (msg.length() > 0) {
|
||||||
log.appendMsg(msg);
|
log.appendMsg(msg);
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.io.ByteArrayInputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import ghidra.app.util.MemoryBlockUtil;
|
import ghidra.app.util.MemoryBlockUtil;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.program.model.address.*;
|
import ghidra.program.model.address.*;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
|
@ -177,10 +176,9 @@ class IntelHexMemImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
String createMemory(String creator, String progFile, String blockName, boolean isOverlay,
|
String createMemory(String creator, String progFile, String blockName, boolean isOverlay,
|
||||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor)
|
Program program, TaskMonitor monitor) throws AddressOverflowException {
|
||||||
throws AddressOverflowException {
|
|
||||||
|
|
||||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program, handler);
|
MemoryBlockUtil mbu = new MemoryBlockUtil(program);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//this code is required to allow hex lines to not appear
|
//this code is required to allow hex lines to not appear
|
||||||
|
@ -254,10 +252,10 @@ class IntelHexMemImage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String createMemory(String creator, String progFile, Program program,
|
String createMemory(String creator, String progFile, Program program, TaskMonitor monitor)
|
||||||
MemoryConflictHandler handler, TaskMonitor monitor) throws AddressOverflowException {
|
throws AddressOverflowException {
|
||||||
|
|
||||||
return createMemory(creator, progFile, null, false, program, handler, monitor);
|
return createMemory(creator, progFile, null, false, program, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBaseAddr(Address address) {
|
void setBaseAddr(Address address) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.util.List;
|
||||||
|
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.framework.model.DomainFolder;
|
import ghidra.framework.model.DomainFolder;
|
||||||
import ghidra.framework.model.DomainObject;
|
import ghidra.framework.model.DomainObject;
|
||||||
|
@ -97,14 +96,13 @@ public interface Loader extends ExtensionPoint, Comparable<Loader> {
|
||||||
* @param messageLog The message log.
|
* @param messageLog The message log.
|
||||||
* @param program The {@link Program} to load into.
|
* @param program The {@link Program} to load into.
|
||||||
* @param monitor A cancelable task monitor.
|
* @param monitor A cancelable task monitor.
|
||||||
* @param memoryConflictHandler How to handle memory conflicts that occur during the load.
|
|
||||||
* @return True if the file was successfully loaded; otherwise, false.
|
* @return True if the file was successfully loaded; otherwise, false.
|
||||||
* @throws IOException if there was an IO-related problem loading.
|
* @throws IOException if there was an IO-related problem loading.
|
||||||
* @throws CancelledException if the user cancelled the load.
|
* @throws CancelledException if the user cancelled the load.
|
||||||
*/
|
*/
|
||||||
public boolean loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
public boolean loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
MessageLog messageLog, Program program, TaskMonitor monitor,
|
MessageLog messageLog, Program program, TaskMonitor monitor)
|
||||||
MemoryConflictHandler memoryConflictHandler) throws IOException, CancelledException;
|
throws IOException, CancelledException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default {@link Loader} options.
|
* Gets the default {@link Loader} options.
|
||||||
|
|
|
@ -26,7 +26,6 @@ import ghidra.app.util.bin.*;
|
||||||
import ghidra.app.util.bin.format.macho.*;
|
import ghidra.app.util.bin.format.macho.*;
|
||||||
import ghidra.app.util.bin.format.macho.prelink.PrelinkMap;
|
import ghidra.app.util.bin.format.macho.prelink.PrelinkMap;
|
||||||
import ghidra.app.util.bin.format.ubi.*;
|
import ghidra.app.util.bin.format.ubi.*;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.framework.model.DomainFolder;
|
import ghidra.framework.model.DomainFolder;
|
||||||
import ghidra.program.database.mem.FileBytes;
|
import ghidra.program.database.mem.FileBytes;
|
||||||
|
@ -79,8 +78,7 @@ public class MachoLoader extends AbstractLibrarySupportLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileBytes fileBytes = MemoryBlockUtils.createFileBytes(program, provider);
|
FileBytes fileBytes = MemoryBlockUtils.createFileBytes(program, provider);
|
||||||
|
@ -93,8 +91,7 @@ public class MachoLoader extends AbstractLibrarySupportLoader {
|
||||||
log, monitor);
|
log, monitor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MachoProgramBuilder.buildProgram(program, provider, fileBytes, log, handler,
|
MachoProgramBuilder.buildProgram(program, provider, fileBytes, log, monitor);
|
||||||
monitor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
|
|
@ -27,7 +27,8 @@ import ghidra.app.util.bin.format.macho.commands.*;
|
||||||
import ghidra.app.util.bin.format.macho.commands.dyld.*;
|
import ghidra.app.util.bin.format.macho.commands.dyld.*;
|
||||||
import ghidra.app.util.bin.format.macho.threadcommand.ThreadCommand;
|
import ghidra.app.util.bin.format.macho.threadcommand.ThreadCommand;
|
||||||
import ghidra.app.util.bin.format.objectiveC.ObjectiveC1_Constants;
|
import ghidra.app.util.bin.format.objectiveC.ObjectiveC1_Constants;
|
||||||
import ghidra.app.util.importer.*;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
|
import ghidra.app.util.importer.MessageLogContinuesFactory;
|
||||||
import ghidra.framework.options.Options;
|
import ghidra.framework.options.Options;
|
||||||
import ghidra.program.database.function.OverlappingFunctionException;
|
import ghidra.program.database.function.OverlappingFunctionException;
|
||||||
import ghidra.program.database.mem.FileBytes;
|
import ghidra.program.database.mem.FileBytes;
|
||||||
|
@ -91,13 +92,11 @@ public class MachoProgramBuilder {
|
||||||
* @param provider The {@link ByteProvider} that contains the Mach-O's bytes.
|
* @param provider The {@link ByteProvider} that contains the Mach-O's bytes.
|
||||||
* @param fileBytes Where the Mach-O's bytes came from.
|
* @param fileBytes Where the Mach-O's bytes came from.
|
||||||
* @param log The log.
|
* @param log The log.
|
||||||
* @param memoryConflictHandler How to handle memory conflicts that may occur.
|
|
||||||
* @param monitor A cancelable task monitor.
|
* @param monitor A cancelable task monitor.
|
||||||
* @throws Exception if a problem occurs.
|
* @throws Exception if a problem occurs.
|
||||||
*/
|
*/
|
||||||
public static void buildProgram(Program program, ByteProvider provider, FileBytes fileBytes,
|
public static void buildProgram(Program program, ByteProvider provider, FileBytes fileBytes,
|
||||||
MessageLog log, MemoryConflictHandler memoryConflictHandler, TaskMonitor monitor)
|
MessageLog log, TaskMonitor monitor) throws Exception {
|
||||||
throws Exception {
|
|
||||||
MachoProgramBuilder machoProgramBuilder =
|
MachoProgramBuilder machoProgramBuilder =
|
||||||
new MachoProgramBuilder(program, provider, fileBytes, log, monitor);
|
new MachoProgramBuilder(program, provider, fileBytes, log, monitor);
|
||||||
machoProgramBuilder.build();
|
machoProgramBuilder.build();
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.util.*;
|
||||||
|
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.program.model.address.AddressSpace;
|
import ghidra.program.model.address.AddressSpace;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
|
@ -122,7 +121,7 @@ public class MapLoader extends AbstractLibrarySupportLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program prog,
|
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program prog,
|
||||||
MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log) throws IOException {
|
TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
|
|
||||||
if (!prog.getExecutableFormat().equals(PeLoader.PE_NAME)) {
|
if (!prog.getExecutableFormat().equals(PeLoader.PE_NAME)) {
|
||||||
throw new IOException("Program must be a " + PeLoader.PE_NAME);
|
throw new IOException("Program must be a " + PeLoader.PE_NAME);
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.util.*;
|
||||||
import ghidra.app.util.MemoryBlockUtil;
|
import ghidra.app.util.MemoryBlockUtil;
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.framework.model.DomainFolder;
|
import ghidra.framework.model.DomainFolder;
|
||||||
import ghidra.framework.model.DomainObject;
|
import ghidra.framework.model.DomainObject;
|
||||||
|
@ -173,8 +172,7 @@ public class MotorolaHexLoader extends AbstractProgramLoader {
|
||||||
importerCompilerSpec, consumer);
|
importerCompilerSpec, consumer);
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
success = loadInto(provider, loadSpec, options, log, prog, monitor,
|
success = loadInto(provider, loadSpec, options, log, prog, monitor);
|
||||||
MemoryConflictHandler.ALWAYS_OVERWRITE);
|
|
||||||
if (success) {
|
if (success) {
|
||||||
createDefaultMemoryBlocks(prog, importerLanguage, log);
|
createDefaultMemoryBlocks(prog, importerLanguage, log);
|
||||||
}
|
}
|
||||||
|
@ -194,8 +192,8 @@ public class MotorolaHexLoader extends AbstractProgramLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
||||||
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor,
|
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor)
|
||||||
MemoryConflictHandler handler) throws IOException, CancelledException {
|
throws IOException, CancelledException {
|
||||||
Address baseAddr = getBaseAddr(options);
|
Address baseAddr = getBaseAddr(options);
|
||||||
|
|
||||||
if (baseAddr == null) {
|
if (baseAddr == null) {
|
||||||
|
@ -203,7 +201,7 @@ public class MotorolaHexLoader extends AbstractProgramLoader {
|
||||||
}
|
}
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
processMotorolaHex(provider, options, prog, baseAddr, monitor, handler);
|
processMotorolaHex(provider, options, prog, baseAddr, monitor);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
catch (AddressOverflowException e) {
|
catch (AddressOverflowException e) {
|
||||||
|
@ -214,7 +212,7 @@ public class MotorolaHexLoader extends AbstractProgramLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processMotorolaHex(ByteProvider provider, List<Option> options, Program program,
|
private void processMotorolaHex(ByteProvider provider, List<Option> options, Program program,
|
||||||
Address baseAddr, TaskMonitor monitor, MemoryConflictHandler handler)
|
Address baseAddr, TaskMonitor monitor)
|
||||||
throws IOException, AddressOverflowException, CancelledException {
|
throws IOException, AddressOverflowException, CancelledException {
|
||||||
String blockName = getBlockName(options);
|
String blockName = getBlockName(options);
|
||||||
boolean isOverlay = isOverlay(options);
|
boolean isOverlay = isOverlay(options);
|
||||||
|
@ -231,7 +229,7 @@ public class MotorolaHexLoader extends AbstractProgramLoader {
|
||||||
byte[] dataBuffer = new byte[BUFSIZE];
|
byte[] dataBuffer = new byte[BUFSIZE];
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|
||||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program, handler);
|
MemoryBlockUtil mbu = new MemoryBlockUtil(program);
|
||||||
try (BufferedReader in =
|
try (BufferedReader in =
|
||||||
new BufferedReader(new InputStreamReader(provider.getInputStream(0)))) {
|
new BufferedReader(new InputStreamReader(provider.getInputStream(0)))) {
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
|
|
|
@ -27,7 +27,8 @@ import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
|
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
|
||||||
import ghidra.app.util.bin.format.mz.DOSHeader;
|
import ghidra.app.util.bin.format.mz.DOSHeader;
|
||||||
import ghidra.app.util.bin.format.mz.OldStyleExecutable;
|
import ghidra.app.util.bin.format.mz.OldStyleExecutable;
|
||||||
import ghidra.app.util.importer.*;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
|
import ghidra.app.util.importer.MessageLogContinuesFactory;
|
||||||
import ghidra.framework.store.LockException;
|
import ghidra.framework.store.LockException;
|
||||||
import ghidra.program.model.address.*;
|
import ghidra.program.model.address.*;
|
||||||
import ghidra.program.model.lang.Register;
|
import ghidra.program.model.lang.Register;
|
||||||
|
@ -85,7 +86,7 @@ public class MzLoader extends AbstractLibrarySupportLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program prog,
|
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program prog,
|
||||||
MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log) throws IOException {
|
TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
|
|
||||||
AddressFactory af = prog.getAddressFactory();
|
AddressFactory af = prog.getAddressFactory();
|
||||||
if (!(af.getDefaultAddressSpace() instanceof SegmentedAddressSpace)) {
|
if (!(af.getDefaultAddressSpace() instanceof SegmentedAddressSpace)) {
|
||||||
|
@ -98,7 +99,7 @@ public class MzLoader extends AbstractLibrarySupportLoader {
|
||||||
Memory memory = prog.getMemory();
|
Memory memory = prog.getMemory();
|
||||||
|
|
||||||
ContinuesFactory factory = MessageLogContinuesFactory.create(log);
|
ContinuesFactory factory = MessageLogContinuesFactory.create(log);
|
||||||
MemoryBlockUtil mbu = new MemoryBlockUtil(prog, handler);
|
MemoryBlockUtil mbu = new MemoryBlockUtil(prog);
|
||||||
try {
|
try {
|
||||||
OldStyleExecutable ose = new OldStyleExecutable(factory, provider);
|
OldStyleExecutable ose = new OldStyleExecutable(factory, provider);
|
||||||
DOSHeader dos = ose.getDOSHeader();
|
DOSHeader dos = ose.getDOSHeader();
|
||||||
|
|
|
@ -26,7 +26,8 @@ import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.bin.format.ne.*;
|
import ghidra.app.util.bin.format.ne.*;
|
||||||
import ghidra.app.util.bin.format.ne.Resource;
|
import ghidra.app.util.bin.format.ne.Resource;
|
||||||
import ghidra.app.util.importer.*;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
|
import ghidra.app.util.importer.MessageLogContinuesFactory;
|
||||||
import ghidra.framework.options.Options;
|
import ghidra.framework.options.Options;
|
||||||
import ghidra.program.model.address.*;
|
import ghidra.program.model.address.*;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
|
@ -82,7 +83,7 @@ public class NeLoader extends AbstractLibrarySupportLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program prog,
|
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program prog,
|
||||||
MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log) throws IOException {
|
TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
|
|
||||||
if (monitor.isCancelled()) {
|
if (monitor.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
|
@ -92,7 +93,7 @@ public class NeLoader extends AbstractLibrarySupportLoader {
|
||||||
initVars();
|
initVars();
|
||||||
|
|
||||||
ContinuesFactory factory = MessageLogContinuesFactory.create(log);
|
ContinuesFactory factory = MessageLogContinuesFactory.create(log);
|
||||||
MemoryBlockUtil mbu = new MemoryBlockUtil(prog, handler);
|
MemoryBlockUtil mbu = new MemoryBlockUtil(prog);
|
||||||
try {
|
try {
|
||||||
NewExecutable ne = new NewExecutable(factory, provider);
|
NewExecutable ne = new NewExecutable(factory, provider);
|
||||||
WindowsHeader wh = ne.getWindowsHeader();
|
WindowsHeader wh = ne.getWindowsHeader();
|
||||||
|
|
|
@ -24,7 +24,6 @@ import ghidra.app.util.bin.BinaryReader;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.bin.format.omf.*;
|
import ghidra.app.util.bin.format.omf.*;
|
||||||
import ghidra.app.util.bin.format.omf.OmfFixupRecord.Subrecord;
|
import ghidra.app.util.bin.format.omf.OmfFixupRecord.Subrecord;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.address.AddressOverflowException;
|
import ghidra.program.model.address.AddressOverflowException;
|
||||||
|
@ -108,8 +107,7 @@ public class OmfLoader extends AbstractLibrarySupportLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
protected void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
OmfFileHeader header = null;
|
OmfFileHeader header = null;
|
||||||
BinaryReader reader = OmfFileHeader.createReader(provider);
|
BinaryReader reader = OmfFileHeader.createReader(provider);
|
||||||
|
@ -125,7 +123,7 @@ public class OmfLoader extends AbstractLibrarySupportLoader {
|
||||||
}
|
}
|
||||||
log.appendMsg("File was corrupted - leaving partial program " + provider.getName());
|
log.appendMsg("File was corrupted - leaving partial program " + provider.getName());
|
||||||
}
|
}
|
||||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program, handler);
|
MemoryBlockUtil mbu = new MemoryBlockUtil(program);
|
||||||
int id = program.startTransaction("loading program from OMF");
|
int id = program.startTransaction("loading program from OMF");
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -30,7 +30,8 @@ import ghidra.app.util.bin.format.pe.*;
|
||||||
import ghidra.app.util.bin.format.pe.PortableExecutable.SectionLayout;
|
import ghidra.app.util.bin.format.pe.PortableExecutable.SectionLayout;
|
||||||
import ghidra.app.util.bin.format.pe.debug.DebugCOFFSymbol;
|
import ghidra.app.util.bin.format.pe.debug.DebugCOFFSymbol;
|
||||||
import ghidra.app.util.bin.format.pe.debug.DebugDirectoryParser;
|
import ghidra.app.util.bin.format.pe.debug.DebugDirectoryParser;
|
||||||
import ghidra.app.util.importer.*;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
|
import ghidra.app.util.importer.MessageLogContinuesFactory;
|
||||||
import ghidra.framework.model.DomainObject;
|
import ghidra.framework.model.DomainObject;
|
||||||
import ghidra.framework.options.Options;
|
import ghidra.framework.options.Options;
|
||||||
import ghidra.program.model.address.*;
|
import ghidra.program.model.address.*;
|
||||||
|
@ -93,8 +94,7 @@ public class PeLoader extends AbstractPeDebugLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
protected void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
if (monitor.isCancelled()) {
|
if (monitor.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
|
@ -115,7 +115,7 @@ public class PeLoader extends AbstractPeDebugLoader {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<Integer, Address> sectionNumberToAddress =
|
Map<Integer, Address> sectionNumberToAddress =
|
||||||
processMemoryBlocks(pe, program, handler, monitor, log);
|
processMemoryBlocks(pe, program, monitor, log);
|
||||||
|
|
||||||
monitor.setCancelEnabled(false);
|
monitor.setCancelEnabled(false);
|
||||||
optionalHeader.processDataDirectories(monitor);
|
optionalHeader.processDataDirectories(monitor);
|
||||||
|
@ -564,8 +564,7 @@ public class PeLoader extends AbstractPeDebugLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Integer, Address> processMemoryBlocks(PortableExecutable pe, Program prog,
|
private Map<Integer, Address> processMemoryBlocks(PortableExecutable pe, Program prog,
|
||||||
MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
TaskMonitor monitor, MessageLog log) throws AddressOverflowException, IOException {
|
||||||
throws AddressOverflowException, IOException {
|
|
||||||
|
|
||||||
AddressFactory af = prog.getAddressFactory();
|
AddressFactory af = prog.getAddressFactory();
|
||||||
AddressSpace space = af.getDefaultAddressSpace();
|
AddressSpace space = af.getDefaultAddressSpace();
|
||||||
|
@ -580,7 +579,7 @@ public class PeLoader extends AbstractPeDebugLoader {
|
||||||
FileHeader fileHeader = ntHeader.getFileHeader();
|
FileHeader fileHeader = ntHeader.getFileHeader();
|
||||||
OptionalHeader optionalHeader = ntHeader.getOptionalHeader();
|
OptionalHeader optionalHeader = ntHeader.getOptionalHeader();
|
||||||
|
|
||||||
MemoryBlockUtil mbu = new MemoryBlockUtil(prog, handler);
|
MemoryBlockUtil mbu = new MemoryBlockUtil(prog);
|
||||||
|
|
||||||
SectionHeader[] sections = fileHeader.getSectionHeaders();
|
SectionHeader[] sections = fileHeader.getSectionHeaders();
|
||||||
if (sections.length == 0) {
|
if (sections.length == 0) {
|
||||||
|
@ -608,7 +607,7 @@ public class PeLoader extends AbstractPeDebugLoader {
|
||||||
mbu = null;
|
mbu = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
mbu = new MemoryBlockUtil(prog, handler);
|
mbu = new MemoryBlockUtil(prog);
|
||||||
|
|
||||||
// Section blocks
|
// Section blocks
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -25,7 +25,6 @@ import ghidra.app.util.MemoryBlockUtil;
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.bin.format.pef.*;
|
import ghidra.app.util.bin.format.pef.*;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.program.model.address.*;
|
import ghidra.program.model.address.*;
|
||||||
import ghidra.program.model.data.PointerDataType;
|
import ghidra.program.model.data.PointerDataType;
|
||||||
|
@ -68,8 +67,7 @@ public class PefLoader extends AbstractLibrarySupportLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
Program program,
|
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log) throws IOException {
|
|
||||||
|
|
||||||
ImportStateCache importState = null;
|
ImportStateCache importState = null;
|
||||||
try {
|
try {
|
||||||
|
@ -373,7 +371,7 @@ public class PefLoader extends AbstractLibrarySupportLoader {
|
||||||
ImportStateCache importState, MessageLog log, TaskMonitor monitor)
|
ImportStateCache importState, MessageLog log, TaskMonitor monitor)
|
||||||
throws AddressOverflowException, IOException {
|
throws AddressOverflowException, IOException {
|
||||||
|
|
||||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program, MemoryConflictHandler.ALWAYS_OVERWRITE);
|
MemoryBlockUtil mbu = new MemoryBlockUtil(program);
|
||||||
|
|
||||||
List<SectionHeader> sections = header.getSections();
|
List<SectionHeader> sections = header.getSections();
|
||||||
for (SectionHeader section : sections) {
|
for (SectionHeader section : sections) {
|
||||||
|
|
|
@ -27,7 +27,6 @@ import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.OptionException;
|
import ghidra.app.util.OptionException;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.app.util.xml.*;
|
import ghidra.app.util.xml.*;
|
||||||
import ghidra.framework.model.DomainFolder;
|
import ghidra.framework.model.DomainFolder;
|
||||||
|
@ -201,8 +200,7 @@ public class XmlLoader extends AbstractProgramLoader {
|
||||||
importerCompilerSpec, consumer);
|
importerCompilerSpec, consumer);
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
success = doImport(result.lastXmlMgr, options, log, prog, monitor,
|
success = doImport(result.lastXmlMgr, options, log, prog, monitor, false);
|
||||||
MemoryConflictHandler.ALWAYS_OVERWRITE, false);
|
|
||||||
if (success) {
|
if (success) {
|
||||||
createDefaultMemoryBlocks(prog, importerLanguage, log);
|
createDefaultMemoryBlocks(prog, importerLanguage, log);
|
||||||
}
|
}
|
||||||
|
@ -221,22 +219,22 @@ public class XmlLoader extends AbstractProgramLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
||||||
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor,
|
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor)
|
||||||
MemoryConflictHandler handler) throws IOException, CancelledException {
|
throws IOException, CancelledException {
|
||||||
File file = provider.getFile();
|
File file = provider.getFile();
|
||||||
return doImport(new ProgramXmlMgr(file), options, log, prog, monitor, handler, true);
|
return doImport(new ProgramXmlMgr(file), options, log, prog, monitor, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean doImportWork(final ProgramXmlMgr mgr, final List<Option> options,
|
private boolean doImportWork(final ProgramXmlMgr mgr, final List<Option> options,
|
||||||
final MessageLog log, Program prog, TaskMonitor monitor,
|
final MessageLog log, Program prog, TaskMonitor monitor,
|
||||||
final MemoryConflictHandler handler, final boolean isAddToProgram) throws IOException {
|
final boolean isAddToProgram) throws IOException {
|
||||||
MessageLog mgrLog = null;
|
MessageLog mgrLog = null;
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
XmlProgramOptions xmlOptions = new XmlProgramOptions();
|
XmlProgramOptions xmlOptions = new XmlProgramOptions();
|
||||||
xmlOptions.setOptions(options);
|
xmlOptions.setOptions(options);
|
||||||
xmlOptions.setAddToProgram(isAddToProgram);
|
xmlOptions.setAddToProgram(isAddToProgram);
|
||||||
mgrLog = mgr.read(prog, monitor, xmlOptions, handler);
|
mgrLog = mgr.read(prog, monitor, xmlOptions);
|
||||||
log.copyFrom(mgrLog);
|
log.copyFrom(mgrLog);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
@ -255,13 +253,13 @@ public class XmlLoader extends AbstractProgramLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean doImport(final ProgramXmlMgr mgr, final List<Option> options,
|
private boolean doImport(final ProgramXmlMgr mgr, final List<Option> options,
|
||||||
final MessageLog log, Program prog, TaskMonitor monitor,
|
final MessageLog log, Program prog, TaskMonitor monitor, final boolean isAddToProgram)
|
||||||
final MemoryConflictHandler handler, final boolean isAddToProgram) throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
if (!AutoAnalysisManager.hasAutoAnalysisManager(prog)) {
|
if (!AutoAnalysisManager.hasAutoAnalysisManager(prog)) {
|
||||||
int txId = prog.startTransaction("XML Import");
|
int txId = prog.startTransaction("XML Import");
|
||||||
try {
|
try {
|
||||||
return doImportWork(mgr, options, log, prog, monitor, handler, isAddToProgram);
|
return doImportWork(mgr, options, log, prog, monitor, isAddToProgram);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
prog.endTransaction(txId, true);
|
prog.endTransaction(txId, true);
|
||||||
|
@ -280,8 +278,7 @@ public class XmlLoader extends AbstractProgramLoader {
|
||||||
@Override
|
@Override
|
||||||
public boolean analysisWorkerCallback(Program program, Object workerContext,
|
public boolean analysisWorkerCallback(Program program, Object workerContext,
|
||||||
TaskMonitor taskMonitor) throws Exception, CancelledException {
|
TaskMonitor taskMonitor) throws Exception, CancelledException {
|
||||||
return doImportWork(mgr, options, log, program, taskMonitor, handler,
|
return doImportWork(mgr, options, log, program, taskMonitor, isAddToProgram);
|
||||||
isAddToProgram);
|
|
||||||
}
|
}
|
||||||
}, null, false, monitor);
|
}, null, false, monitor);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.util.Arrays;
|
||||||
import org.xml.sax.SAXParseException;
|
import org.xml.sax.SAXParseException;
|
||||||
|
|
||||||
import ghidra.app.util.MemoryBlockUtil;
|
import ghidra.app.util.MemoryBlockUtil;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.program.database.mem.SourceInfo;
|
import ghidra.program.database.mem.SourceInfo;
|
||||||
import ghidra.program.model.address.*;
|
import ghidra.program.model.address.*;
|
||||||
|
@ -54,10 +53,10 @@ class MemoryMapXmlMgr {
|
||||||
///////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void read(XmlPullParser parser, boolean overwriteConflicts, TaskMonitor monitor,
|
void read(XmlPullParser parser, boolean overwriteConflicts, TaskMonitor monitor,
|
||||||
String directory, MemoryConflictHandler handler)
|
String directory)
|
||||||
throws SAXParseException, FileNotFoundException, CancelledException {
|
throws SAXParseException, FileNotFoundException, CancelledException {
|
||||||
|
|
||||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program, handler);
|
MemoryBlockUtil mbu = new MemoryBlockUtil(program);
|
||||||
try {
|
try {
|
||||||
XmlElement element = parser.next();
|
XmlElement element = parser.next();
|
||||||
element = parser.next();
|
element = parser.next();
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Date;
|
||||||
import org.xml.sax.*;
|
import org.xml.sax.*;
|
||||||
|
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.app.util.opinion.*;
|
import ghidra.app.util.opinion.*;
|
||||||
import ghidra.formats.gfilesystem.FSRL;
|
import ghidra.formats.gfilesystem.FSRL;
|
||||||
|
@ -188,15 +187,12 @@ public class ProgramXmlMgr {
|
||||||
* @param program the program to load the XML into
|
* @param program the program to load the XML into
|
||||||
* @param monitor the task monitor
|
* @param monitor the task monitor
|
||||||
* @param options the XML options, which features to load and to ignore
|
* @param options the XML options, which features to load and to ignore
|
||||||
* @param handler the memory conflict handler
|
|
||||||
* @return the message log containing any warning/error messages
|
* @return the message log containing any warning/error messages
|
||||||
* @throws SAXException if an XML error occurs
|
* @throws SAXException if an XML error occurs
|
||||||
* @throws IOException if an I/O occurs
|
* @throws IOException if an I/O occurs
|
||||||
* @throws AddressFormatException if an invalid address is specified in the XML
|
* @throws AddressFormatException if an invalid address is specified in the XML
|
||||||
* @throws CancelledException if the user cancels the read
|
|
||||||
*/
|
*/
|
||||||
public MessageLog read(Program program, TaskMonitor monitor, XmlProgramOptions options,
|
public MessageLog read(Program program, TaskMonitor monitor, XmlProgramOptions options)
|
||||||
MemoryConflictHandler handler)
|
|
||||||
throws SAXException, IOException, AddressFormatException {
|
throws SAXException, IOException, AddressFormatException {
|
||||||
|
|
||||||
if (getProgramInfo() == null) {
|
if (getProgramInfo() == null) {
|
||||||
|
@ -269,7 +265,7 @@ public class ProgramXmlMgr {
|
||||||
monitor.setMessage("Processing MEMORY MAP ...");
|
monitor.setMessage("Processing MEMORY MAP ...");
|
||||||
MemoryMapXmlMgr mgr = new MemoryMapXmlMgr(program, log);
|
MemoryMapXmlMgr mgr = new MemoryMapXmlMgr(program, log);
|
||||||
mgr.read(parser, options.isOverwriteMemoryConflicts(), monitor,
|
mgr.read(parser, options.isOverwriteMemoryConflicts(), monitor,
|
||||||
file.getParent(), handler);
|
file.getParent());
|
||||||
}
|
}
|
||||||
else if (options.isRegisters() && name.equals("REGISTER_VALUES")) {
|
else if (options.isRegisters() && name.equals("REGISTER_VALUES")) {
|
||||||
monitor.setMessage("Processing REGISTER VALUES ...");
|
monitor.setMessage("Processing REGISTER VALUES ...");
|
||||||
|
|
|
@ -27,7 +27,6 @@ import ghidra.app.services.ProgramManager;
|
||||||
import ghidra.app.util.GenericHelpTopics;
|
import ghidra.app.util.GenericHelpTopics;
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.app.util.opinion.*;
|
import ghidra.app.util.opinion.*;
|
||||||
import ghidra.formats.gfilesystem.*;
|
import ghidra.formats.gfilesystem.*;
|
||||||
|
@ -467,8 +466,7 @@ public class ImporterUtilities {
|
||||||
|
|
||||||
MessageLog messageLog = new MessageLog();
|
MessageLog messageLog = new MessageLog();
|
||||||
try (ByteProvider bp = FileSystemService.getInstance().getByteProvider(fsrl, monitor)) {
|
try (ByteProvider bp = FileSystemService.getInstance().getByteProvider(fsrl, monitor)) {
|
||||||
loadSpec.getLoader().loadInto(bp, loadSpec, options, messageLog, program, monitor,
|
loadSpec.getLoader().loadInto(bp, loadSpec, options, messageLog, program, monitor);
|
||||||
MemoryConflictHandler.ALWAYS_OVERWRITE);
|
|
||||||
displayResults(tool, program, program.getDomainFile(), messageLog.toString());
|
displayResults(tool, program, program.getDomainFile(), messageLog.toString());
|
||||||
}
|
}
|
||||||
catch (CancelledException e) {
|
catch (CancelledException e) {
|
||||||
|
|
|
@ -23,7 +23,6 @@ import db.DBHandle;
|
||||||
import db.buffers.BufferFile;
|
import db.buffers.BufferFile;
|
||||||
import generic.test.AbstractGTest;
|
import generic.test.AbstractGTest;
|
||||||
import generic.test.AbstractGenericTest;
|
import generic.test.AbstractGenericTest;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.xml.*;
|
import ghidra.app.util.xml.*;
|
||||||
import ghidra.framework.data.DomainObjectAdapterDB;
|
import ghidra.framework.data.DomainObjectAdapterDB;
|
||||||
import ghidra.framework.model.*;
|
import ghidra.framework.model.*;
|
||||||
|
@ -387,7 +386,7 @@ public class TestProgramManager {
|
||||||
ProgramDB p = new ProgramDB(programName, language, compilerSpec, this);
|
ProgramDB p = new ProgramDB(programName, language, compilerSpec, this);
|
||||||
int txId = p.startTransaction("Import");
|
int txId = p.startTransaction("Import");
|
||||||
try {
|
try {
|
||||||
mgr.read(p, monitor, new XmlProgramOptions(), MemoryConflictHandler.ALWAYS_OVERWRITE);
|
mgr.read(p, monitor, new XmlProgramOptions());
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
p.endTransaction(txId, true);
|
p.endTransaction(txId, true);
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.app.util;
|
package ghidra.app.util;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -24,7 +23,6 @@ import java.util.Arrays;
|
||||||
|
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
|
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.program.database.ProgramBuilder;
|
import ghidra.program.database.ProgramBuilder;
|
||||||
import ghidra.program.model.address.AddressSpace;
|
import ghidra.program.model.address.AddressSpace;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
|
@ -51,7 +49,7 @@ public class MemoryBlockUtilTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
|
|
||||||
id = prog.startTransaction("test");
|
id = prog.startTransaction("test");
|
||||||
space = prog.getAddressFactory().getDefaultAddressSpace();
|
space = prog.getAddressFactory().getDefaultAddressSpace();
|
||||||
mbu = new MemoryBlockUtil(prog, MemoryConflictHandler.ALWAYS_OVERWRITE);
|
mbu = new MemoryBlockUtil(prog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|
|
@ -28,7 +28,6 @@ import java.util.Iterator;
|
||||||
import ghidra.app.script.GhidraScript;
|
import ghidra.app.script.GhidraScript;
|
||||||
import ghidra.app.util.MemoryBlockUtil;
|
import ghidra.app.util.MemoryBlockUtil;
|
||||||
import ghidra.app.util.NamespaceUtils;
|
import ghidra.app.util.NamespaceUtils;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.program.model.listing.*;
|
import ghidra.program.model.listing.*;
|
||||||
import ghidra.program.model.mem.*;
|
import ghidra.program.model.mem.*;
|
||||||
import ghidra.program.model.symbol.*;
|
import ghidra.program.model.symbol.*;
|
||||||
|
@ -242,8 +241,7 @@ public class MergeTwoProgramsScript extends GhidraScript {
|
||||||
|
|
||||||
private void mergeMemory( Program currProgram, Program otherProgram ) throws Exception {
|
private void mergeMemory( Program currProgram, Program otherProgram ) throws Exception {
|
||||||
monitor.setMessage( "Merging memory..." );
|
monitor.setMessage( "Merging memory..." );
|
||||||
MemoryConflictHandler memoryConflictHandler = MemoryConflictHandler.ALWAYS_OVERWRITE;
|
MemoryBlockUtil mbu = new MemoryBlockUtil(currProgram);
|
||||||
MemoryBlockUtil mbu = new MemoryBlockUtil( currProgram, memoryConflictHandler );
|
|
||||||
try {
|
try {
|
||||||
Memory otherMemory = otherProgram.getMemory();
|
Memory otherMemory = otherProgram.getMemory();
|
||||||
MemoryBlock [] otherBlocks = otherMemory.getBlocks();
|
MemoryBlock [] otherBlocks = otherMemory.getBlocks();
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.util.*;
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.BinaryReader;
|
import ghidra.app.util.bin.BinaryReader;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.file.formats.android.dex.format.*;
|
import ghidra.file.formats.android.dex.format.*;
|
||||||
import ghidra.file.formats.android.dex.util.DexUtil;
|
import ghidra.file.formats.android.dex.util.DexUtil;
|
||||||
|
@ -68,8 +67,7 @@ public class DexLoader extends AbstractLibrarySupportLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
monitor.setMessage( "DEX Loader: creating dex memory" );
|
monitor.setMessage( "DEX Loader: creating dex memory" );
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -29,7 +29,6 @@ import ghidra.app.util.bin.format.macho.*;
|
||||||
import ghidra.app.util.bin.format.macho.commands.*;
|
import ghidra.app.util.bin.format.macho.commands.*;
|
||||||
import ghidra.app.util.bin.format.macho.prelink.PrelinkConstants;
|
import ghidra.app.util.bin.format.macho.prelink.PrelinkConstants;
|
||||||
import ghidra.app.util.bin.format.macho.prelink.PrelinkMap;
|
import ghidra.app.util.bin.format.macho.prelink.PrelinkMap;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.app.util.opinion.*;
|
import ghidra.app.util.opinion.*;
|
||||||
import ghidra.formats.gfilesystem.*;
|
import ghidra.formats.gfilesystem.*;
|
||||||
|
@ -192,7 +191,7 @@ public class PrelinkFileSystem extends GFileSystemBase implements GFileSystemPro
|
||||||
ByteProvider providerWrapper =
|
ByteProvider providerWrapper =
|
||||||
new ByteProviderWrapper(provider, offset, provider.length() - offset);
|
new ByteProviderWrapper(provider, offset, provider.length() - offset);
|
||||||
MachoProgramBuilder.buildProgram(program, providerWrapper, fileBytes, new MessageLog(),
|
MachoProgramBuilder.buildProgram(program, providerWrapper, fileBytes, new MessageLog(),
|
||||||
MemoryConflictHandler.NEVER_OVERWRITE, monitor);
|
monitor);
|
||||||
program.setExecutableFormat(MachoLoader.MACH_O_NAME);
|
program.setExecutableFormat(MachoLoader.MACH_O_NAME);
|
||||||
program.setExecutablePath(file.getPath());
|
program.setExecutablePath(file.getPath());
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import ghidra.app.cmd.register.SetRegisterCmd;
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.BinaryReader;
|
import ghidra.app.util.bin.BinaryReader;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.framework.store.LockException;
|
import ghidra.framework.store.LockException;
|
||||||
import ghidra.javaclass.format.*;
|
import ghidra.javaclass.format.*;
|
||||||
|
@ -91,8 +90,7 @@ public class JavaLoader extends AbstractLibrarySupportLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||||
throws IOException {
|
|
||||||
try {
|
try {
|
||||||
doLoad(provider, program, monitor);
|
doLoad(provider, program, monitor);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +113,7 @@ public class JavaLoader extends AbstractLibrarySupportLoader {
|
||||||
|
|
||||||
public void load(ByteProvider provider, Program program, TaskMonitor monitor)
|
public void load(ByteProvider provider, Program program, TaskMonitor monitor)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
load(provider, null, null, program, null, monitor, null);
|
load(provider, null, null, program, monitor, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doLoad(ByteProvider provider, Program program, TaskMonitor monitor)
|
private void doLoad(ByteProvider provider, Program program, TaskMonitor monitor)
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.util.*;
|
||||||
|
|
||||||
import ghidra.app.util.Option;
|
import ghidra.app.util.Option;
|
||||||
import ghidra.app.util.bin.ByteProvider;
|
import ghidra.app.util.bin.ByteProvider;
|
||||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.app.util.opinion.AbstractLibrarySupportLoader;
|
import ghidra.app.util.opinion.AbstractLibrarySupportLoader;
|
||||||
import ghidra.app.util.opinion.LoadSpec;
|
import ghidra.app.util.opinion.LoadSpec;
|
||||||
|
@ -55,7 +54,7 @@ public class SkeletonLoader extends AbstractLibrarySupportLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
protected void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
Program program, TaskMonitor monitor, MessageLog log)
|
||||||
throws CancelledException, IOException {
|
throws CancelledException, IOException {
|
||||||
|
|
||||||
// TODO: Load the bytes from 'provider' into the 'program'.
|
// TODO: Load the bytes from 'provider' into the 'program'.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue