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.List;
|
||||
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.framework.store.LockException;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.*;
|
||||
|
@ -47,19 +46,16 @@ public class MemoryBlockUtil {
|
|||
private Listing listing;
|
||||
private Memory memory;
|
||||
private SymbolTable symbolTable;
|
||||
private MemoryConflictHandler handler;
|
||||
private StringBuffer messages;
|
||||
|
||||
/**
|
||||
* Constructs a new memory block utility.
|
||||
* @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.memory = program.getMemory();
|
||||
this.symbolTable = program.getSymbolTable();
|
||||
this.handler = handler;
|
||||
this.messages = new StringBuffer();
|
||||
}
|
||||
|
||||
|
@ -78,7 +74,6 @@ public class MemoryBlockUtil {
|
|||
public void dispose() {
|
||||
listing = null;
|
||||
memory = null;
|
||||
handler = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -317,7 +312,7 @@ public class MemoryBlockUtil {
|
|||
|
||||
boolean shouldOverwriteBlock = true;
|
||||
if (existingBlocks.length > 0) {
|
||||
shouldOverwriteBlock = handler.allowOverwrite(start, end);
|
||||
shouldOverwriteBlock = /*handler.allowOverwrite(start, end);*/ true;
|
||||
}
|
||||
|
||||
//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,
|
||||
TaskMonitor monitor, Predicate<Loader> loaderFilter, LoadSpecChooser loadSpecChooser,
|
||||
OptionChooser optionChooser, MemoryConflictHandler memoryConflictHandler)
|
||||
throws IOException, CancelledException {
|
||||
OptionChooser optionChooser) throws IOException, CancelledException {
|
||||
if (file == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -347,7 +346,7 @@ public final class AutoImporter {
|
|||
|
||||
try (RandomAccessByteProvider provider = new RandomAccessByteProvider(file)) {
|
||||
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.bin.ByteProvider;
|
||||
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.framework.model.*;
|
||||
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 options The load options.
|
||||
* @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 log The message log.
|
||||
* @throws IOException if there was an IO-related problem loading.
|
||||
* @throws CancelledException if the user cancelled the load.
|
||||
*/
|
||||
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;
|
||||
|
||||
@Override
|
||||
|
@ -110,8 +110,8 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
|
|||
|
||||
@Override
|
||||
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
||||
List<Option> options, MessageLog log, Program program, TaskMonitor monitor,
|
||||
MemoryConflictHandler memoryConflictHandler) throws CancelledException, IOException {
|
||||
List<Option> options, MessageLog log, Program program, TaskMonitor monitor)
|
||||
throws CancelledException, IOException {
|
||||
|
||||
LanguageCompilerSpecPair pair = loadSpec.getLanguageCompilerSpec();
|
||||
LanguageID languageID = program.getLanguageID();
|
||||
|
@ -122,7 +122,7 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
|
|||
return false;
|
||||
}
|
||||
log.appendMsg("----- Loading " + provider.getAbsolutePath() + " -----");
|
||||
load(provider, loadSpec, options, program, memoryConflictHandler, monitor, log);
|
||||
load(provider, loadSpec, options, program, monitor, log);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -343,8 +343,7 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
|
|||
boolean success = false;
|
||||
try {
|
||||
log.appendMsg("----- Loading " + provider.getAbsolutePath() + " -----");
|
||||
load(provider, loadSpec, options, program, MemoryConflictHandler.ALWAYS_OVERWRITE,
|
||||
monitor, log);
|
||||
load(provider, loadSpec, options, program, monitor, 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.OptionUtils;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.framework.model.DomainFolder;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
|
@ -89,14 +88,13 @@ public abstract class AbstractProgramLoader implements Loader {
|
|||
* @param messageLog The message log.
|
||||
* @param program The {@link Program} to load into.
|
||||
* @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.
|
||||
* @throws IOException if there was an IO-related problem loading.
|
||||
* @throws CancelledException if the user cancelled the load.
|
||||
*/
|
||||
protected abstract boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
||||
List<Option> options, MessageLog messageLog, Program program, TaskMonitor monitor,
|
||||
MemoryConflictHandler memoryConflictHandler) throws IOException, CancelledException;
|
||||
List<Option> options, MessageLog messageLog, Program program, TaskMonitor monitor)
|
||||
throws IOException, CancelledException;
|
||||
|
||||
@Override
|
||||
public final List<DomainObject> load(ByteProvider provider, String name, DomainFolder folder,
|
||||
|
@ -157,8 +155,8 @@ public abstract class AbstractProgramLoader implements Loader {
|
|||
|
||||
@Override
|
||||
public final boolean loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
MessageLog messageLog, Program program, TaskMonitor monitor,
|
||||
MemoryConflictHandler memoryConflictHandler) throws IOException, CancelledException {
|
||||
MessageLog messageLog, Program program, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
|
||||
if (!loadSpec.isComplete()) {
|
||||
return false;
|
||||
|
@ -168,8 +166,7 @@ public abstract class AbstractProgramLoader implements Loader {
|
|||
int transactionID = program.startTransaction("Loading - " + getName());
|
||||
boolean success = false;
|
||||
try {
|
||||
success = loadProgramInto(provider, loadSpec, options, messageLog, program, monitor,
|
||||
memoryConflictHandler);
|
||||
success = loadProgramInto(provider, loadSpec, options, messageLog, program, monitor);
|
||||
return success;
|
||||
}
|
||||
finally {
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.*;
|
|||
|
||||
import ghidra.app.util.*;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.framework.model.DomainFolder;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
|
@ -278,8 +277,7 @@ public class BinaryLoader extends AbstractProgramLoader {
|
|||
importerCompilerSpec, consumer);
|
||||
boolean success = false;
|
||||
try {
|
||||
success = loadInto(provider, loadSpec, options, log, prog, monitor,
|
||||
MemoryConflictHandler.ALWAYS_OVERWRITE);
|
||||
success = loadInto(provider, loadSpec, options, log, prog, monitor);
|
||||
if (success) {
|
||||
createDefaultMemoryBlocks(prog, importerLanguage, log);
|
||||
}
|
||||
|
@ -299,8 +297,8 @@ public class BinaryLoader extends AbstractProgramLoader {
|
|||
|
||||
@Override
|
||||
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
||||
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor,
|
||||
MemoryConflictHandler handler) throws IOException {
|
||||
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor)
|
||||
throws IOException {
|
||||
long length = getLength(options);
|
||||
//File file = provider.getFile();
|
||||
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.relocation.CoffRelocationHandler;
|
||||
import ghidra.app.util.bin.format.coff.relocation.CoffRelocationHandlerFactory;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
import ghidra.program.database.function.OverlappingFunctionException;
|
||||
|
@ -182,8 +181,7 @@ public class CoffLoader extends AbstractLibrarySupportLoader {
|
|||
|
||||
@Override
|
||||
protected void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
||||
throws IOException {
|
||||
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||
|
||||
boolean performFakeLinking = performFakeLinking(options);
|
||||
|
||||
|
@ -193,7 +191,7 @@ public class CoffLoader extends AbstractLibrarySupportLoader {
|
|||
Map<CoffSectionHeader, Address> sectionsMap = 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");
|
||||
boolean success = false;
|
||||
|
|
|
@ -26,7 +26,8 @@ import ghidra.app.util.bin.ByteProvider;
|
|||
import ghidra.app.util.bin.RandomAccessByteProvider;
|
||||
import ghidra.app.util.bin.format.pe.*;
|
||||
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.listing.Program;
|
||||
import ghidra.util.Conv;
|
||||
|
@ -72,9 +73,8 @@ public class DbgLoader extends AbstractPeDebugLoader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
Program prog, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
||||
throws IOException {
|
||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program prog,
|
||||
TaskMonitor monitor, MessageLog log) throws IOException {
|
||||
|
||||
GenericFactory factory = MessageLogContinuesFactory.create(log);
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.util.function.Consumer;
|
|||
|
||||
import ghidra.app.util.Option;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.symbol.*;
|
||||
|
@ -81,9 +80,8 @@ public class DefLoader extends AbstractLibrarySupportLoader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
Program prog, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
||||
throws IOException {
|
||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program prog,
|
||||
TaskMonitor monitor, MessageLog log) throws IOException {
|
||||
|
||||
if (!prog.getExecutableFormat().equals(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.format.macho.dyld.DyldArchitecture;
|
||||
import ghidra.app.util.bin.format.macho.dyld.DyldCacheHeader;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
@ -81,8 +80,7 @@ public class DyldCacheLoader extends AbstractLibrarySupportLoader {
|
|||
|
||||
@Override
|
||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
||||
throws IOException {
|
||||
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||
|
||||
try {
|
||||
DyldCacheProgramBuilder.buildProgram(program, provider,
|
||||
|
|
|
@ -25,7 +25,8 @@ import ghidra.app.util.OptionUtils;
|
|||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.bin.format.elf.ElfException;
|
||||
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.DomainObject;
|
||||
import ghidra.program.model.lang.Endian;
|
||||
|
@ -128,8 +129,7 @@ public class ElfLoader extends AbstractLibrarySupportLoader {
|
|||
|
||||
@Override
|
||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
||||
throws IOException {
|
||||
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||
|
||||
try {
|
||||
GenericFactory factory = MessageLogContinuesFactory.create(log);
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.apache.commons.io.FilenameUtils;
|
|||
|
||||
import ghidra.app.util.Option;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.framework.model.*;
|
||||
import ghidra.framework.store.local.ItemSerializer;
|
||||
|
@ -84,8 +83,8 @@ public class GdtLoader implements Loader {
|
|||
|
||||
@Override
|
||||
public boolean loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
MessageLog messageLog, Program program, TaskMonitor monitor,
|
||||
MemoryConflictHandler memoryConflictHandler) throws IOException, CancelledException {
|
||||
MessageLog messageLog, Program program, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
throw new UnsupportedOperationException("cannot add GDT to program");
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import db.DBConstants;
|
|||
import db.DBHandle;
|
||||
import ghidra.app.util.Option;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.framework.model.*;
|
||||
import ghidra.framework.store.db.PackedDatabase;
|
||||
|
@ -136,8 +135,8 @@ public class GzfLoader implements Loader {
|
|||
|
||||
@Override
|
||||
public boolean loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
MessageLog messageLog, Program program, TaskMonitor monitor,
|
||||
MemoryConflictHandler memoryConflictHandler) throws IOException, CancelledException {
|
||||
MessageLog messageLog, Program program, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
throw new UnsupportedOperationException("cannot add GZF to program");
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.*;
|
|||
|
||||
import ghidra.app.util.Option;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.framework.model.DomainFolder;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
|
@ -155,8 +154,7 @@ public class IntelHexLoader extends AbstractProgramLoader {
|
|||
importerCompilerSpec, consumer);
|
||||
boolean success = false;
|
||||
try {
|
||||
success = loadInto(provider, loadSpec, options, log, prog, monitor,
|
||||
MemoryConflictHandler.ALWAYS_OVERWRITE);
|
||||
success = loadInto(provider, loadSpec, options, log, prog, monitor);
|
||||
if (success) {
|
||||
createDefaultMemoryBlocks(prog, importerLanguage, log);
|
||||
}
|
||||
|
@ -176,8 +174,8 @@ public class IntelHexLoader extends AbstractProgramLoader {
|
|||
|
||||
@Override
|
||||
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
||||
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor,
|
||||
MemoryConflictHandler handler) throws IOException, CancelledException {
|
||||
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
Address baseAddr = getBaseAddr(options);
|
||||
|
||||
if (baseAddr == null) {
|
||||
|
@ -185,7 +183,7 @@ public class IntelHexLoader extends AbstractProgramLoader {
|
|||
}
|
||||
boolean success = false;
|
||||
try {
|
||||
processIntelHex(provider, options, log, prog, monitor, handler);
|
||||
processIntelHex(provider, options, log, prog, monitor);
|
||||
success = true;
|
||||
}
|
||||
catch (AddressOverflowException e) {
|
||||
|
@ -196,7 +194,7 @@ public class IntelHexLoader extends AbstractProgramLoader {
|
|||
}
|
||||
|
||||
private void processIntelHex(ByteProvider provider, List<Option> options, MessageLog log,
|
||||
Program program, TaskMonitor monitor, MemoryConflictHandler handler)
|
||||
Program program, TaskMonitor monitor)
|
||||
throws IOException, AddressOverflowException, CancelledException {
|
||||
String blockName = getBlockName(options);
|
||||
boolean isOverlay = isOverlay(options);
|
||||
|
@ -232,7 +230,7 @@ public class IntelHexLoader extends AbstractProgramLoader {
|
|||
}
|
||||
|
||||
String msg = memImage.createMemory(getName(), provider.getName(),
|
||||
isOverlay ? blockName : null, isOverlay, program, handler, monitor);
|
||||
isOverlay ? blockName : null, isOverlay, program, monitor);
|
||||
|
||||
if (msg.length() > 0) {
|
||||
log.appendMsg(msg);
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.io.ByteArrayInputStream;
|
|||
import java.util.*;
|
||||
|
||||
import ghidra.app.util.MemoryBlockUtil;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.Msg;
|
||||
|
@ -177,10 +176,9 @@ class IntelHexMemImage {
|
|||
}
|
||||
|
||||
String createMemory(String creator, String progFile, String blockName, boolean isOverlay,
|
||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor)
|
||||
throws AddressOverflowException {
|
||||
Program program, TaskMonitor monitor) throws AddressOverflowException {
|
||||
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program, handler);
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program);
|
||||
|
||||
try {
|
||||
//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,
|
||||
MemoryConflictHandler handler, TaskMonitor monitor) throws AddressOverflowException {
|
||||
String createMemory(String creator, String progFile, Program program, TaskMonitor monitor)
|
||||
throws AddressOverflowException {
|
||||
|
||||
return createMemory(creator, progFile, null, false, program, handler, monitor);
|
||||
return createMemory(creator, progFile, null, false, program, monitor);
|
||||
}
|
||||
|
||||
void setBaseAddr(Address address) {
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.util.List;
|
|||
|
||||
import ghidra.app.util.Option;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.framework.model.DomainFolder;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
|
@ -97,14 +96,13 @@ public interface Loader extends ExtensionPoint, Comparable<Loader> {
|
|||
* @param messageLog The message log.
|
||||
* @param program The {@link Program} to load into.
|
||||
* @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.
|
||||
* @throws IOException if there was an IO-related problem loading.
|
||||
* @throws CancelledException if the user cancelled the load.
|
||||
*/
|
||||
public boolean loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
MessageLog messageLog, Program program, TaskMonitor monitor,
|
||||
MemoryConflictHandler memoryConflictHandler) throws IOException, CancelledException;
|
||||
MessageLog messageLog, Program program, TaskMonitor monitor)
|
||||
throws IOException, CancelledException;
|
||||
|
||||
/**
|
||||
* 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.prelink.PrelinkMap;
|
||||
import ghidra.app.util.bin.format.ubi.*;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.framework.model.DomainFolder;
|
||||
import ghidra.program.database.mem.FileBytes;
|
||||
|
@ -79,8 +78,7 @@ public class MachoLoader extends AbstractLibrarySupportLoader {
|
|||
|
||||
@Override
|
||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
||||
throws IOException {
|
||||
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||
|
||||
try {
|
||||
FileBytes fileBytes = MemoryBlockUtils.createFileBytes(program, provider);
|
||||
|
@ -93,8 +91,7 @@ public class MachoLoader extends AbstractLibrarySupportLoader {
|
|||
log, monitor);
|
||||
}
|
||||
else {
|
||||
MachoProgramBuilder.buildProgram(program, provider, fileBytes, log, handler,
|
||||
monitor);
|
||||
MachoProgramBuilder.buildProgram(program, provider, fileBytes, log, monitor);
|
||||
}
|
||||
}
|
||||
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.threadcommand.ThreadCommand;
|
||||
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.program.database.function.OverlappingFunctionException;
|
||||
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 fileBytes Where the Mach-O's bytes came from.
|
||||
* @param log The log.
|
||||
* @param memoryConflictHandler How to handle memory conflicts that may occur.
|
||||
* @param monitor A cancelable task monitor.
|
||||
* @throws Exception if a problem occurs.
|
||||
*/
|
||||
public static void buildProgram(Program program, ByteProvider provider, FileBytes fileBytes,
|
||||
MessageLog log, MemoryConflictHandler memoryConflictHandler, TaskMonitor monitor)
|
||||
throws Exception {
|
||||
MessageLog log, TaskMonitor monitor) throws Exception {
|
||||
MachoProgramBuilder machoProgramBuilder =
|
||||
new MachoProgramBuilder(program, provider, fileBytes, log, monitor);
|
||||
machoProgramBuilder.build();
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.util.*;
|
|||
|
||||
import ghidra.app.util.Option;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.program.model.address.AddressSpace;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
@ -122,7 +121,7 @@ public class MapLoader extends AbstractLibrarySupportLoader {
|
|||
|
||||
@Override
|
||||
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)) {
|
||||
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.Option;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.framework.model.DomainFolder;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
|
@ -173,8 +172,7 @@ public class MotorolaHexLoader extends AbstractProgramLoader {
|
|||
importerCompilerSpec, consumer);
|
||||
boolean success = false;
|
||||
try {
|
||||
success = loadInto(provider, loadSpec, options, log, prog, monitor,
|
||||
MemoryConflictHandler.ALWAYS_OVERWRITE);
|
||||
success = loadInto(provider, loadSpec, options, log, prog, monitor);
|
||||
if (success) {
|
||||
createDefaultMemoryBlocks(prog, importerLanguage, log);
|
||||
}
|
||||
|
@ -194,8 +192,8 @@ public class MotorolaHexLoader extends AbstractProgramLoader {
|
|||
|
||||
@Override
|
||||
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
||||
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor,
|
||||
MemoryConflictHandler handler) throws IOException, CancelledException {
|
||||
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
Address baseAddr = getBaseAddr(options);
|
||||
|
||||
if (baseAddr == null) {
|
||||
|
@ -203,7 +201,7 @@ public class MotorolaHexLoader extends AbstractProgramLoader {
|
|||
}
|
||||
boolean success = false;
|
||||
try {
|
||||
processMotorolaHex(provider, options, prog, baseAddr, monitor, handler);
|
||||
processMotorolaHex(provider, options, prog, baseAddr, monitor);
|
||||
success = true;
|
||||
}
|
||||
catch (AddressOverflowException e) {
|
||||
|
@ -214,7 +212,7 @@ public class MotorolaHexLoader extends AbstractProgramLoader {
|
|||
}
|
||||
|
||||
private void processMotorolaHex(ByteProvider provider, List<Option> options, Program program,
|
||||
Address baseAddr, TaskMonitor monitor, MemoryConflictHandler handler)
|
||||
Address baseAddr, TaskMonitor monitor)
|
||||
throws IOException, AddressOverflowException, CancelledException {
|
||||
String blockName = getBlockName(options);
|
||||
boolean isOverlay = isOverlay(options);
|
||||
|
@ -231,7 +229,7 @@ public class MotorolaHexLoader extends AbstractProgramLoader {
|
|||
byte[] dataBuffer = new byte[BUFSIZE];
|
||||
int counter = 0;
|
||||
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program, handler);
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program);
|
||||
try (BufferedReader in =
|
||||
new BufferedReader(new InputStreamReader(provider.getInputStream(0)))) {
|
||||
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.mz.DOSHeader;
|
||||
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.program.model.address.*;
|
||||
import ghidra.program.model.lang.Register;
|
||||
|
@ -85,7 +86,7 @@ public class MzLoader extends AbstractLibrarySupportLoader {
|
|||
|
||||
@Override
|
||||
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();
|
||||
if (!(af.getDefaultAddressSpace() instanceof SegmentedAddressSpace)) {
|
||||
|
@ -98,7 +99,7 @@ public class MzLoader extends AbstractLibrarySupportLoader {
|
|||
Memory memory = prog.getMemory();
|
||||
|
||||
ContinuesFactory factory = MessageLogContinuesFactory.create(log);
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(prog, handler);
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(prog);
|
||||
try {
|
||||
OldStyleExecutable ose = new OldStyleExecutable(factory, provider);
|
||||
DOSHeader dos = ose.getDOSHeader();
|
||||
|
|
|
@ -26,7 +26,8 @@ import ghidra.app.util.Option;
|
|||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.bin.format.ne.*;
|
||||
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.program.model.address.*;
|
||||
import ghidra.program.model.data.*;
|
||||
|
@ -82,7 +83,7 @@ public class NeLoader extends AbstractLibrarySupportLoader {
|
|||
|
||||
@Override
|
||||
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()) {
|
||||
return;
|
||||
|
@ -92,7 +93,7 @@ public class NeLoader extends AbstractLibrarySupportLoader {
|
|||
initVars();
|
||||
|
||||
ContinuesFactory factory = MessageLogContinuesFactory.create(log);
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(prog, handler);
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(prog);
|
||||
try {
|
||||
NewExecutable ne = new NewExecutable(factory, provider);
|
||||
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.format.omf.*;
|
||||
import ghidra.app.util.bin.format.omf.OmfFixupRecord.Subrecord;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressOverflowException;
|
||||
|
@ -108,8 +107,7 @@ public class OmfLoader extends AbstractLibrarySupportLoader {
|
|||
|
||||
@Override
|
||||
protected void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
||||
throws IOException {
|
||||
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||
|
||||
OmfFileHeader header = null;
|
||||
BinaryReader reader = OmfFileHeader.createReader(provider);
|
||||
|
@ -125,7 +123,7 @@ public class OmfLoader extends AbstractLibrarySupportLoader {
|
|||
}
|
||||
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");
|
||||
boolean success = false;
|
||||
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.debug.DebugCOFFSymbol;
|
||||
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.options.Options;
|
||||
import ghidra.program.model.address.*;
|
||||
|
@ -93,8 +94,7 @@ public class PeLoader extends AbstractPeDebugLoader {
|
|||
|
||||
@Override
|
||||
protected void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
||||
throws IOException {
|
||||
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||
|
||||
if (monitor.isCancelled()) {
|
||||
return;
|
||||
|
@ -115,7 +115,7 @@ public class PeLoader extends AbstractPeDebugLoader {
|
|||
|
||||
try {
|
||||
Map<Integer, Address> sectionNumberToAddress =
|
||||
processMemoryBlocks(pe, program, handler, monitor, log);
|
||||
processMemoryBlocks(pe, program, monitor, log);
|
||||
|
||||
monitor.setCancelEnabled(false);
|
||||
optionalHeader.processDataDirectories(monitor);
|
||||
|
@ -564,8 +564,7 @@ public class PeLoader extends AbstractPeDebugLoader {
|
|||
}
|
||||
|
||||
private Map<Integer, Address> processMemoryBlocks(PortableExecutable pe, Program prog,
|
||||
MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
||||
throws AddressOverflowException, IOException {
|
||||
TaskMonitor monitor, MessageLog log) throws AddressOverflowException, IOException {
|
||||
|
||||
AddressFactory af = prog.getAddressFactory();
|
||||
AddressSpace space = af.getDefaultAddressSpace();
|
||||
|
@ -580,7 +579,7 @@ public class PeLoader extends AbstractPeDebugLoader {
|
|||
FileHeader fileHeader = ntHeader.getFileHeader();
|
||||
OptionalHeader optionalHeader = ntHeader.getOptionalHeader();
|
||||
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(prog, handler);
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(prog);
|
||||
|
||||
SectionHeader[] sections = fileHeader.getSectionHeaders();
|
||||
if (sections.length == 0) {
|
||||
|
@ -608,7 +607,7 @@ public class PeLoader extends AbstractPeDebugLoader {
|
|||
mbu = null;
|
||||
}
|
||||
|
||||
mbu = new MemoryBlockUtil(prog, handler);
|
||||
mbu = new MemoryBlockUtil(prog);
|
||||
|
||||
// Section blocks
|
||||
try {
|
||||
|
|
|
@ -25,7 +25,6 @@ import ghidra.app.util.MemoryBlockUtil;
|
|||
import ghidra.app.util.Option;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.bin.format.pef.*;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.data.PointerDataType;
|
||||
|
@ -68,8 +67,7 @@ public class PefLoader extends AbstractLibrarySupportLoader {
|
|||
|
||||
@Override
|
||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
Program program,
|
||||
MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||
|
||||
ImportStateCache importState = null;
|
||||
try {
|
||||
|
@ -373,7 +371,7 @@ public class PefLoader extends AbstractLibrarySupportLoader {
|
|||
ImportStateCache importState, MessageLog log, TaskMonitor monitor)
|
||||
throws AddressOverflowException, IOException {
|
||||
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program, MemoryConflictHandler.ALWAYS_OVERWRITE);
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program);
|
||||
|
||||
List<SectionHeader> sections = header.getSections();
|
||||
for (SectionHeader section : sections) {
|
||||
|
|
|
@ -27,7 +27,6 @@ import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
|
|||
import ghidra.app.util.Option;
|
||||
import ghidra.app.util.OptionException;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.app.util.xml.*;
|
||||
import ghidra.framework.model.DomainFolder;
|
||||
|
@ -201,8 +200,7 @@ public class XmlLoader extends AbstractProgramLoader {
|
|||
importerCompilerSpec, consumer);
|
||||
boolean success = false;
|
||||
try {
|
||||
success = doImport(result.lastXmlMgr, options, log, prog, monitor,
|
||||
MemoryConflictHandler.ALWAYS_OVERWRITE, false);
|
||||
success = doImport(result.lastXmlMgr, options, log, prog, monitor, false);
|
||||
if (success) {
|
||||
createDefaultMemoryBlocks(prog, importerLanguage, log);
|
||||
}
|
||||
|
@ -221,22 +219,22 @@ public class XmlLoader extends AbstractProgramLoader {
|
|||
|
||||
@Override
|
||||
protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec,
|
||||
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor,
|
||||
MemoryConflictHandler handler) throws IOException, CancelledException {
|
||||
List<Option> options, MessageLog log, Program prog, TaskMonitor monitor)
|
||||
throws IOException, CancelledException {
|
||||
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,
|
||||
final MessageLog log, Program prog, TaskMonitor monitor,
|
||||
final MemoryConflictHandler handler, final boolean isAddToProgram) throws IOException {
|
||||
final boolean isAddToProgram) throws IOException {
|
||||
MessageLog mgrLog = null;
|
||||
boolean success = false;
|
||||
try {
|
||||
XmlProgramOptions xmlOptions = new XmlProgramOptions();
|
||||
xmlOptions.setOptions(options);
|
||||
xmlOptions.setAddToProgram(isAddToProgram);
|
||||
mgrLog = mgr.read(prog, monitor, xmlOptions, handler);
|
||||
mgrLog = mgr.read(prog, monitor, xmlOptions);
|
||||
log.copyFrom(mgrLog);
|
||||
success = true;
|
||||
}
|
||||
|
@ -255,13 +253,13 @@ public class XmlLoader extends AbstractProgramLoader {
|
|||
}
|
||||
|
||||
private boolean doImport(final ProgramXmlMgr mgr, final List<Option> options,
|
||||
final MessageLog log, Program prog, TaskMonitor monitor,
|
||||
final MemoryConflictHandler handler, final boolean isAddToProgram) throws IOException {
|
||||
final MessageLog log, Program prog, TaskMonitor monitor, final boolean isAddToProgram)
|
||||
throws IOException {
|
||||
|
||||
if (!AutoAnalysisManager.hasAutoAnalysisManager(prog)) {
|
||||
int txId = prog.startTransaction("XML Import");
|
||||
try {
|
||||
return doImportWork(mgr, options, log, prog, monitor, handler, isAddToProgram);
|
||||
return doImportWork(mgr, options, log, prog, monitor, isAddToProgram);
|
||||
}
|
||||
finally {
|
||||
prog.endTransaction(txId, true);
|
||||
|
@ -280,8 +278,7 @@ public class XmlLoader extends AbstractProgramLoader {
|
|||
@Override
|
||||
public boolean analysisWorkerCallback(Program program, Object workerContext,
|
||||
TaskMonitor taskMonitor) throws Exception, CancelledException {
|
||||
return doImportWork(mgr, options, log, program, taskMonitor, handler,
|
||||
isAddToProgram);
|
||||
return doImportWork(mgr, options, log, program, taskMonitor, isAddToProgram);
|
||||
}
|
||||
}, null, false, monitor);
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.Arrays;
|
|||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import ghidra.app.util.MemoryBlockUtil;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.program.database.mem.SourceInfo;
|
||||
import ghidra.program.model.address.*;
|
||||
|
@ -54,10 +53,10 @@ class MemoryMapXmlMgr {
|
|||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void read(XmlPullParser parser, boolean overwriteConflicts, TaskMonitor monitor,
|
||||
String directory, MemoryConflictHandler handler)
|
||||
String directory)
|
||||
throws SAXParseException, FileNotFoundException, CancelledException {
|
||||
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program, handler);
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(program);
|
||||
try {
|
||||
XmlElement element = parser.next();
|
||||
element = parser.next();
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Date;
|
|||
import org.xml.sax.*;
|
||||
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.app.util.opinion.*;
|
||||
import ghidra.formats.gfilesystem.FSRL;
|
||||
|
@ -188,15 +187,12 @@ public class ProgramXmlMgr {
|
|||
* @param program the program to load the XML into
|
||||
* @param monitor the task monitor
|
||||
* @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
|
||||
* @throws SAXException if an XML error occurs
|
||||
* @throws IOException if an I/O occurs
|
||||
* @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,
|
||||
MemoryConflictHandler handler)
|
||||
public MessageLog read(Program program, TaskMonitor monitor, XmlProgramOptions options)
|
||||
throws SAXException, IOException, AddressFormatException {
|
||||
|
||||
if (getProgramInfo() == null) {
|
||||
|
@ -269,7 +265,7 @@ public class ProgramXmlMgr {
|
|||
monitor.setMessage("Processing MEMORY MAP ...");
|
||||
MemoryMapXmlMgr mgr = new MemoryMapXmlMgr(program, log);
|
||||
mgr.read(parser, options.isOverwriteMemoryConflicts(), monitor,
|
||||
file.getParent(), handler);
|
||||
file.getParent());
|
||||
}
|
||||
else if (options.isRegisters() && name.equals("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.Option;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.app.util.opinion.*;
|
||||
import ghidra.formats.gfilesystem.*;
|
||||
|
@ -467,8 +466,7 @@ public class ImporterUtilities {
|
|||
|
||||
MessageLog messageLog = new MessageLog();
|
||||
try (ByteProvider bp = FileSystemService.getInstance().getByteProvider(fsrl, monitor)) {
|
||||
loadSpec.getLoader().loadInto(bp, loadSpec, options, messageLog, program, monitor,
|
||||
MemoryConflictHandler.ALWAYS_OVERWRITE);
|
||||
loadSpec.getLoader().loadInto(bp, loadSpec, options, messageLog, program, monitor);
|
||||
displayResults(tool, program, program.getDomainFile(), messageLog.toString());
|
||||
}
|
||||
catch (CancelledException e) {
|
||||
|
|
|
@ -23,7 +23,6 @@ import db.DBHandle;
|
|||
import db.buffers.BufferFile;
|
||||
import generic.test.AbstractGTest;
|
||||
import generic.test.AbstractGenericTest;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.xml.*;
|
||||
import ghidra.framework.data.DomainObjectAdapterDB;
|
||||
import ghidra.framework.model.*;
|
||||
|
@ -387,7 +386,7 @@ public class TestProgramManager {
|
|||
ProgramDB p = new ProgramDB(programName, language, compilerSpec, this);
|
||||
int txId = p.startTransaction("Import");
|
||||
try {
|
||||
mgr.read(p, monitor, new XmlProgramOptions(), MemoryConflictHandler.ALWAYS_OVERWRITE);
|
||||
mgr.read(p, monitor, new XmlProgramOptions());
|
||||
}
|
||||
finally {
|
||||
p.endTransaction(txId, true);
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
*/
|
||||
package ghidra.app.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
@ -24,7 +23,6 @@ import java.util.Arrays;
|
|||
|
||||
import org.junit.*;
|
||||
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.program.database.ProgramBuilder;
|
||||
import ghidra.program.model.address.AddressSpace;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
@ -51,7 +49,7 @@ public class MemoryBlockUtilTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
|
||||
id = prog.startTransaction("test");
|
||||
space = prog.getAddressFactory().getDefaultAddressSpace();
|
||||
mbu = new MemoryBlockUtil(prog, MemoryConflictHandler.ALWAYS_OVERWRITE);
|
||||
mbu = new MemoryBlockUtil(prog);
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
|
@ -28,7 +28,6 @@ import java.util.Iterator;
|
|||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.app.util.MemoryBlockUtil;
|
||||
import ghidra.app.util.NamespaceUtils;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.mem.*;
|
||||
import ghidra.program.model.symbol.*;
|
||||
|
@ -242,8 +241,7 @@ public class MergeTwoProgramsScript extends GhidraScript {
|
|||
|
||||
private void mergeMemory( Program currProgram, Program otherProgram ) throws Exception {
|
||||
monitor.setMessage( "Merging memory..." );
|
||||
MemoryConflictHandler memoryConflictHandler = MemoryConflictHandler.ALWAYS_OVERWRITE;
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil( currProgram, memoryConflictHandler );
|
||||
MemoryBlockUtil mbu = new MemoryBlockUtil(currProgram);
|
||||
try {
|
||||
Memory otherMemory = otherProgram.getMemory();
|
||||
MemoryBlock [] otherBlocks = otherMemory.getBlocks();
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.*;
|
|||
import ghidra.app.util.Option;
|
||||
import ghidra.app.util.bin.BinaryReader;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.file.formats.android.dex.format.*;
|
||||
import ghidra.file.formats.android.dex.util.DexUtil;
|
||||
|
@ -68,8 +67,7 @@ public class DexLoader extends AbstractLibrarySupportLoader {
|
|||
|
||||
@Override
|
||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
||||
throws IOException {
|
||||
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||
|
||||
monitor.setMessage( "DEX Loader: creating dex memory" );
|
||||
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.prelink.PrelinkConstants;
|
||||
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.opinion.*;
|
||||
import ghidra.formats.gfilesystem.*;
|
||||
|
@ -192,7 +191,7 @@ public class PrelinkFileSystem extends GFileSystemBase implements GFileSystemPro
|
|||
ByteProvider providerWrapper =
|
||||
new ByteProviderWrapper(provider, offset, provider.length() - offset);
|
||||
MachoProgramBuilder.buildProgram(program, providerWrapper, fileBytes, new MessageLog(),
|
||||
MemoryConflictHandler.NEVER_OVERWRITE, monitor);
|
||||
monitor);
|
||||
program.setExecutableFormat(MachoLoader.MACH_O_NAME);
|
||||
program.setExecutablePath(file.getPath());
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import ghidra.app.cmd.register.SetRegisterCmd;
|
|||
import ghidra.app.util.Option;
|
||||
import ghidra.app.util.bin.BinaryReader;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.framework.store.LockException;
|
||||
import ghidra.javaclass.format.*;
|
||||
|
@ -91,8 +90,7 @@ public class JavaLoader extends AbstractLibrarySupportLoader {
|
|||
|
||||
@Override
|
||||
public void load(ByteProvider provider, LoadSpec loadSpec, List<Option> options,
|
||||
Program program, MemoryConflictHandler handler, TaskMonitor monitor, MessageLog log)
|
||||
throws IOException {
|
||||
Program program, TaskMonitor monitor, MessageLog log) throws IOException {
|
||||
try {
|
||||
doLoad(provider, program, monitor);
|
||||
}
|
||||
|
@ -115,7 +113,7 @@ public class JavaLoader extends AbstractLibrarySupportLoader {
|
|||
|
||||
public void load(ByteProvider provider, Program program, TaskMonitor monitor)
|
||||
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)
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.*;
|
|||
|
||||
import ghidra.app.util.Option;
|
||||
import ghidra.app.util.bin.ByteProvider;
|
||||
import ghidra.app.util.importer.MemoryConflictHandler;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.app.util.opinion.AbstractLibrarySupportLoader;
|
||||
import ghidra.app.util.opinion.LoadSpec;
|
||||
|
@ -55,7 +54,7 @@ public class SkeletonLoader extends AbstractLibrarySupportLoader {
|
|||
|
||||
@Override
|
||||
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 {
|
||||
|
||||
// TODO: Load the bytes from 'provider' into the 'program'.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue