GP-1907: Removing ContinuesInterceptor and associated API

This commit is contained in:
Ryan Kurtz 2022-04-11 01:05:30 -04:00
parent 2db3a6be15
commit 96674d4f62
208 changed files with 1125 additions and 3387 deletions

View file

@ -22,7 +22,6 @@ import java.util.Set;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import generic.continues.RethrowContinuesFactory;
import ghidra.app.cmd.disassemble.DisassembleCommand; import ghidra.app.cmd.disassemble.DisassembleCommand;
import ghidra.app.plugin.core.debug.workflow.DisassemblyInject; import ghidra.app.plugin.core.debug.workflow.DisassemblyInject;
import ghidra.app.plugin.core.debug.workflow.DisassemblyInjectInfo; import ghidra.app.plugin.core.debug.workflow.DisassemblyInjectInfo;
@ -107,8 +106,7 @@ public class DbgengX64DisassemblyInject implements DisassemblyInject {
} }
MemoryByteProvider mbp = new MemoryByteProvider(view.getMemory(), module.getBase()); MemoryByteProvider mbp = new MemoryByteProvider(view.getMemory(), module.getBase());
try { try {
PortableExecutable pe = PortableExecutable.createPortableExecutable( PortableExecutable pe = new PortableExecutable(mbp, SectionLayout.MEMORY, false, false);
RethrowContinuesFactory.INSTANCE, mbp, SectionLayout.MEMORY, false, false);
NTHeader ntHeader = pe.getNTHeader(); NTHeader ntHeader = pe.getNTHeader();
if (ntHeader == null) { if (ntHeader == null) {
return Mode.UNK; return Mode.UNK;

View file

@ -29,6 +29,6 @@
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="_Integration Test"/> <stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="_Integration Test"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="ghidra.GhidraRun"/> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="ghidra.GhidraRun"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="_Integration Test"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="_Integration Test"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:+IgnoreUnrecognizedVMOptions&#13;&#10;-Djava.system.class.loader=ghidra.GhidraClassLoader&#13;&#10;-Xshare:off&#13;&#10;-Dfile.encoding=UTF8&#13;&#10;-Duser.country=US&#13;&#10;-Duser.language=en&#13;&#10;-Dsun.java2d.pmoffscreen=false&#13;&#10;-Dsun.java2d.xrender=true&#13;&#10;-Dsun.java2d.d3d=false&#13;&#10;-Xdock:name=&quot;Ghidra&quot;&#13;&#10;-Dvisualvm.display.name=Ghidra&#13;&#10;-Dpython.console.encoding=UTF-8&#13;&#10;--add-opens=java.base/java.lang=ALL-UNNAMED&#13;&#10;--add-opens=java.desktop/sun.awt.image=ALL-UNNAMED"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:+IgnoreUnrecognizedVMOptions&#13;&#10;-Djava.system.class.loader=ghidra.GhidraClassLoader&#13;&#10;-Xshare:off&#13;&#10;-Dfile.encoding=UTF8&#13;&#10;-Duser.country=US&#13;&#10;-Duser.language=en&#13;&#10;-Dsun.java2d.pmoffscreen=false&#13;&#10;-Dsun.java2d.xrender=true&#13;&#10;-Dsun.java2d.d3d=false&#13;&#10;-Xdock:name=&quot;Ghidra&quot;&#13;&#10;-Dvisualvm.display.name=Ghidra&#13;&#10;-Dpython.console.encoding=UTF-8&#13;&#10;--add-opens=java.desktop/sun.awt.image=ALL-UNNAMED"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:Framework Utility}"/> <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:Framework Utility}"/>
</launchConfiguration> </launchConfiguration>

View file

@ -31,5 +31,5 @@
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="Framework Utility"/> <stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="Framework Utility"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="ghidra.GhidraRun"/> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="ghidra.GhidraRun"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Framework Utility"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Framework Utility"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:+IgnoreUnrecognizedVMOptions&#13;&#10;-Djava.system.class.loader=ghidra.GhidraClassLoader&#13;&#10;-Xshare:off&#13;&#10;-Dfile.encoding=UTF8&#13;&#10;-Duser.country=US&#13;&#10;-Duser.language=en&#13;&#10;-Dsun.java2d.pmoffscreen=false&#13;&#10;-Dsun.java2d.xrender=true&#13;&#10;-Dsun.java2d.d3d=false&#13;&#10;-Xdock:name=&quot;Ghidra&quot;&#13;&#10;-Dvisualvm.display.name=Ghidra&#13;&#10;-Dpython.console.encoding=UTF-8&#13;&#10;--add-opens=java.base/java.lang=ALL-UNNAMED&#13;&#10;--add-opens=java.desktop/sun.awt.image=ALL-UNNAMED"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:+IgnoreUnrecognizedVMOptions&#13;&#10;-Djava.system.class.loader=ghidra.GhidraClassLoader&#13;&#10;-Xshare:off&#13;&#10;-Dfile.encoding=UTF8&#13;&#10;-Duser.country=US&#13;&#10;-Duser.language=en&#13;&#10;-Dsun.java2d.pmoffscreen=false&#13;&#10;-Dsun.java2d.xrender=true&#13;&#10;-Dsun.java2d.d3d=false&#13;&#10;-Xdock:name=&quot;Ghidra&quot;&#13;&#10;-Dvisualvm.display.name=Ghidra&#13;&#10;-Dpython.console.encoding=UTF-8&#13;&#10;--add-opens=java.desktop/sun.awt.image=ALL-UNNAMED"/>
</launchConfiguration> </launchConfiguration>

View file

@ -24,7 +24,6 @@ import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import generic.continues.RethrowContinuesFactory;
import ghidra.app.script.GhidraScript; import ghidra.app.script.GhidraScript;
import ghidra.app.util.bin.ByteProvider; import ghidra.app.util.bin.ByteProvider;
import ghidra.app.util.bin.MemoryByteProvider; import ghidra.app.util.bin.MemoryByteProvider;
@ -48,8 +47,7 @@ public class PortableExecutableRichPrintScript extends GhidraScript {
PortableExecutable pe = null; PortableExecutable pe = null;
try { try {
pe = PortableExecutable.createPortableExecutable(RethrowContinuesFactory.INSTANCE, pe = new PortableExecutable(provider, SectionLayout.MEMORY, false, false);
provider, SectionLayout.MEMORY, false, false);
} }
catch (Exception e) { catch (Exception e) {
printerr("Unable to create PE from current program"); printerr("Unable to create PE from current program");

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +18,9 @@
//are placed in the same directory with the processor name appended. //are placed in the same directory with the processor name appended.
//@category Binary //@category Binary
import generic.continues.RethrowContinuesFactory; import java.io.*;
import java.util.List;
import ghidra.app.script.GhidraScript; import ghidra.app.script.GhidraScript;
import ghidra.app.util.bin.ByteProvider; import ghidra.app.util.bin.ByteProvider;
import ghidra.app.util.bin.RandomAccessByteProvider; import ghidra.app.util.bin.RandomAccessByteProvider;
@ -28,9 +29,6 @@ import ghidra.app.util.bin.format.ubi.FatArch;
import ghidra.app.util.bin.format.ubi.FatHeader; import ghidra.app.util.bin.format.ubi.FatHeader;
import ghidra.program.model.lang.Processor; import ghidra.program.model.lang.Processor;
import java.io.*;
import java.util.List;
public class SplitUniversalBinariesScript extends GhidraScript { public class SplitUniversalBinariesScript extends GhidraScript {
@ -40,7 +38,7 @@ public class SplitUniversalBinariesScript extends GhidraScript {
File outputDirectory = askDirectory("Select Output Directory", "GO"); File outputDirectory = askDirectory("Select Output Directory", "GO");
ByteProvider provider = new RandomAccessByteProvider(ubiFile) ; ByteProvider provider = new RandomAccessByteProvider(ubiFile) ;
FatHeader header = FatHeader.createFatHeader(RethrowContinuesFactory.INSTANCE, provider); FatHeader header = new FatHeader(provider);
List<FatArch> architectures = header.getArchitectures(); List<FatArch> architectures = header.getArchitectures();
for (FatArch arch : architectures) { for (FatArch arch : architectures) {

View file

@ -17,7 +17,6 @@ package ghidra.app.cmd.formats;
import java.util.List; import java.util.List;
import generic.continues.RethrowContinuesFactory;
import ghidra.app.plugin.core.analysis.AnalysisWorker; import ghidra.app.plugin.core.analysis.AnalysisWorker;
import ghidra.app.plugin.core.analysis.AutoAnalysisManager; import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
import ghidra.app.util.bin.ByteProvider; import ghidra.app.util.bin.ByteProvider;
@ -94,8 +93,8 @@ public class MachoBinaryAnalysisCommand extends FlatProgramAPI
program.getAddressFactory().getDefaultAddressSpace()); program.getAddressFactory().getDefaultAddressSpace());
try { try {
MachHeader header = MachHeader.createMachHeader(RethrowContinuesFactory.INSTANCE, MachHeader header =
provider, getAddress(program).getOffset(), isRelativeToAddress); new MachHeader(provider, getAddress(program).getOffset(), isRelativeToAddress);
header.parse(); header.parse();
Address machAddress = getAddress(program); Address machAddress = getAddress(program);

View file

@ -18,12 +18,9 @@ package ghidra.app.cmd.formats;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import generic.continues.RethrowContinuesFactory;
import ghidra.app.plugin.core.analysis.AnalysisWorker; import ghidra.app.plugin.core.analysis.AnalysisWorker;
import ghidra.app.plugin.core.analysis.AutoAnalysisManager; import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
import ghidra.app.util.bin.ByteProvider; import ghidra.app.util.bin.*;
import ghidra.app.util.bin.MemoryByteProvider;
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.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;
@ -56,10 +53,9 @@ public class PortableExecutableBinaryAnalysisCommand extends FlatProgramAPI
ByteProvider provider = new MemoryByteProvider(memory, ByteProvider provider = new MemoryByteProvider(memory,
program.getAddressFactory().getDefaultAddressSpace()); program.getAddressFactory().getDefaultAddressSpace());
FactoryBundledWithBinaryReader reader = new FactoryBundledWithBinaryReader( BinaryReader reader = new BinaryReader(provider, !program.getLanguage().isBigEndian());
RethrowContinuesFactory.INSTANCE, provider, !program.getLanguage().isBigEndian());
DOSHeader dosHeader = DOSHeader.createDOSHeader(reader); DOSHeader dosHeader = new DOSHeader(reader);
if (dosHeader.isDosSignature()) { if (dosHeader.isDosSignature()) {
@ -82,9 +78,7 @@ public class PortableExecutableBinaryAnalysisCommand extends FlatProgramAPI
ByteProvider provider = new MemoryByteProvider(currentProgram.getMemory(), ByteProvider provider = new MemoryByteProvider(currentProgram.getMemory(),
program.getAddressFactory().getDefaultAddressSpace()); program.getAddressFactory().getDefaultAddressSpace());
PortableExecutable pe = PortableExecutable pe = new PortableExecutable(provider, SectionLayout.FILE);
PortableExecutable.createPortableExecutable(RethrowContinuesFactory.INSTANCE, provider,
SectionLayout.FILE);
DOSHeader dos = pe.getDOSHeader(); DOSHeader dos = pe.getDOSHeader();
if (dos == null || dos.e_magic() != DOSHeader.IMAGE_DOS_SIGNATURE) { if (dos == null || dos.e_magic() != DOSHeader.IMAGE_DOS_SIGNATURE) {

View file

@ -15,7 +15,10 @@
*/ */
package ghidra.app.plugin.core.analysis; package ghidra.app.plugin.core.analysis;
import generic.continues.RethrowContinuesFactory; import java.io.File;
import java.io.IOException;
import java.util.List;
import ghidra.app.services.*; import ghidra.app.services.*;
import ghidra.app.util.bin.*; import ghidra.app.util.bin.*;
import ghidra.app.util.bin.format.dwarf.DwarfSectionNames; import ghidra.app.util.bin.format.dwarf.DwarfSectionNames;
@ -32,10 +35,6 @@ import ghidra.util.Msg;
import ghidra.util.exception.CancelledException; import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class DwarfLineNumberAnalyzer extends AbstractAnalyzer { public class DwarfLineNumberAnalyzer extends AbstractAnalyzer {
private static final String NAME = "DWARF Line Number"; private static final String NAME = "DWARF Line Number";
private static final String DESCRIPTION = "Extracts DWARF debug line number information."; private static final String DESCRIPTION = "Extracts DWARF debug line number information.";
@ -114,8 +113,7 @@ public class DwarfLineNumberAnalyzer extends AbstractAnalyzer {
} }
RandomAccessByteProvider provider = new RandomAccessByteProvider(dSymFile); RandomAccessByteProvider provider = new RandomAccessByteProvider(dSymFile);
try { try {
MachHeader header = MachHeader header = new MachHeader(provider);
MachHeader.createMachHeader(RethrowContinuesFactory.INSTANCE, provider);
header.parse(); header.parse();
List<Section> allSections = header.getAllSections(); List<Section> allSections = header.getAllSections();
for (Section section : allSections) { for (Section section : allSections) {

View file

@ -19,7 +19,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import generic.continues.GenericFactory;
import ghidra.app.cmd.function.CreateFunctionCmd; import ghidra.app.cmd.function.CreateFunctionCmd;
import ghidra.app.services.*; import ghidra.app.services.*;
import ghidra.app.util.PseudoDisassembler; import ghidra.app.util.PseudoDisassembler;
@ -29,7 +28,6 @@ import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.bin.format.macho.commands.*; import ghidra.app.util.bin.format.macho.commands.*;
import ghidra.app.util.bin.format.macho.dyld.*; import ghidra.app.util.bin.format.macho.dyld.*;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
import ghidra.app.util.importer.MessageLogContinuesFactory;
import ghidra.app.util.opinion.DyldCacheLoader; import ghidra.app.util.opinion.DyldCacheLoader;
import ghidra.app.util.opinion.MachoLoader; import ghidra.app.util.opinion.MachoLoader;
import ghidra.framework.options.Options; import ghidra.framework.options.Options;
@ -170,8 +168,7 @@ public class MachoFunctionStartsAnalyzer extends AbstractAnalyzer {
private void analyzeMachoFunctionStarts(Program program, ByteProvider provider, private void analyzeMachoFunctionStarts(Program program, ByteProvider provider,
AddressSetView set, TaskMonitor monitor, MessageLog log) AddressSetView set, TaskMonitor monitor, MessageLog log)
throws MachException, IOException, CancelledException { throws MachException, IOException, CancelledException {
GenericFactory factory = MessageLogContinuesFactory.create(log); MachHeader header = new MachHeader(provider);
MachHeader header = MachHeader.createMachHeader(factory, provider);
header.parse(); header.parse();
monitor.setIndeterminate(true); monitor.setIndeterminate(true);
monitor.setMessage("Analyzing function starts..."); monitor.setMessage("Analyzing function starts...");
@ -215,8 +212,7 @@ public class MachoFunctionStartsAnalyzer extends AbstractAnalyzer {
monitor.incrementProgress(1); monitor.incrementProgress(1);
// Parse Mach-O header // Parse Mach-O header
MachHeader machoHeader = MachHeader.createMachHeader( MachHeader machoHeader = new MachHeader(providerMap.get(dyldCacheHeader),
MessageLogContinuesFactory.create(log), providerMap.get(dyldCacheHeader),
mappedImage.getAddress() - dyldCacheHeader.getBaseAddress(), false); mappedImage.getAddress() - dyldCacheHeader.getBaseAddress(), false);
machoHeader.parse(); machoHeader.parse();

View file

@ -1,37 +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.bin.format;
import generic.continues.*;
import ghidra.app.util.bin.*;
public class FactoryBundledWithBinaryReader extends BinaryReader {
private final GenericFactory factory;
public GenericFactory getFactory() {
return factory;
}
public FactoryBundledWithBinaryReader(GenericFactory factory,
ByteProvider provider, boolean isLittleEndian) {
super(provider, isLittleEndian);
if (factory == null) {
throw new IllegalArgumentException("factory == null not allowed");
}
this.factory = factory;
}
}

View file

@ -20,7 +20,6 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import generic.continues.RethrowContinuesFactory;
import ghidra.app.util.bin.*; import ghidra.app.util.bin.*;
import ghidra.app.util.bin.format.macho.*; import ghidra.app.util.bin.format.macho.*;
import ghidra.app.util.opinion.MachoLoader; import ghidra.app.util.opinion.MachoLoader;
@ -62,7 +61,7 @@ public class DSymSectionProvider implements DWARFSectionProvider {
public DSymSectionProvider(File dsymFile) throws IOException, MachException { public DSymSectionProvider(File dsymFile) throws IOException, MachException {
this.provider = new RandomAccessByteProvider(dsymFile); this.provider = new RandomAccessByteProvider(dsymFile);
machHeader = MachHeader.createMachHeader(RethrowContinuesFactory.INSTANCE, provider); machHeader = new MachHeader(provider);
machHeader.parse(); machHeader.parse();
for (Section s : machHeader.getAllSections()) { for (Section s : machHeader.getAllSections()) {
// strip leading "_"'s from section name to normalize // strip leading "_"'s from section name to normalize

View file

@ -19,9 +19,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import generic.continues.GenericFactory;
import ghidra.app.util.bin.*; import ghidra.app.util.bin.*;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.commands.*; import ghidra.app.util.bin.format.macho.commands.*;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -44,7 +42,7 @@ public class MachHeader implements StructConverter {
private boolean _is32bit; private boolean _is32bit;
private List<LoadCommand> _commands = new ArrayList<>(); private List<LoadCommand> _commands = new ArrayList<>();
private long _commandIndex; private long _commandIndex;
private FactoryBundledWithBinaryReader _reader; private BinaryReader _reader;
private long _machHeaderStartIndexInProvider; private long _machHeaderStartIndexInProvider;
private long _machHeaderStartIndex = 0; private long _machHeaderStartIndex = 0;
private boolean _parsed = false; private boolean _parsed = false;
@ -65,58 +63,49 @@ public class MachHeader implements StructConverter {
} }
return false; return false;
} }
/** /**
* Assumes the MachHeader starts at index 0 in the ByteProvider. * Creates a new {@link MachHeader}. Assumes the MachHeader starts at index 0 in the
* ByteProvider.
*
* @param provider the ByteProvider * @param provider the ByteProvider
* @throws IOException if an I/O error occurs while reading from the ByteProvider * @throws IOException if an I/O error occurs while reading from the ByteProvider
* @throws MachException if an invalid MachHeader is detected * @throws MachException if an invalid MachHeader is detected
*/ */
public static MachHeader createMachHeader(GenericFactory factory, ByteProvider provider) public MachHeader(ByteProvider provider) throws IOException, MachException {
throws IOException, MachException { this(provider, 0);
return createMachHeader(factory, provider, 0);
} }
/** /**
* Assumes the MachHeader starts at index <i>machHeaderStartIndexInProvider</i> in the ByteProvider. * Creates a new {@link MachHeader}. Assumes the MachHeader starts at index
* <i>machHeaderStartIndexInProvider</i> in the ByteProvider.
*
* @param provider the ByteProvider * @param provider the ByteProvider
* @param machHeaderStartIndexInProvider the index into the ByteProvider where the MachHeader begins. * @param machHeaderStartIndexInProvider the index into the ByteProvider where the MachHeader
* begins
* @throws IOException if an I/O error occurs while reading from the ByteProvider * @throws IOException if an I/O error occurs while reading from the ByteProvider
* @throws MachException if an invalid MachHeader is detected * @throws MachException if an invalid MachHeader is detected
*/ */
public static MachHeader createMachHeader(GenericFactory factory, ByteProvider provider, public MachHeader(ByteProvider provider, long machHeaderStartIndexInProvider)
long machHeaderStartIndexInProvider) throws IOException, MachException { throws IOException, MachException {
MachHeader machHeader = (MachHeader) factory.create(MachHeader.class); this(provider, machHeaderStartIndexInProvider, true);
machHeader.initMachHeader(factory, provider, machHeaderStartIndexInProvider, true);
return machHeader;
} }
/** /**
* Assumes the MachHeader starts at index <i>machHeaderStartIndexInProvider</i> in the ByteProvider. * Creatse a new {@link MachHeader}. Assumes the MachHeader starts at index
* <i>machHeaderStartIndexInProvider</i> in the ByteProvider.
*
* @param provider the ByteProvider * @param provider the ByteProvider
* @param machHeaderStartIndexInProvider the index into the ByteProvider where the MachHeader begins. * @param machHeaderStartIndexInProvider the index into the ByteProvider where the MachHeader
* @param isRemainingMachoRelativeToStartIndex TRUE if the rest of the macho uses relative indexing. This is common in UBI and kernel cache files. * begins.
* FALSE if the rest of the file uses absolute indexing from 0. This is common in DYLD cache files. * @param isRemainingMachoRelativeToStartIndex true if the rest of the macho uses relative
* indexin (this is common in UBI and kernel cache files); otherwise, false if the rest of the
* file uses absolute indexing from 0 (this is common in DYLD cache files)
* @throws IOException if an I/O error occurs while reading from the ByteProvider * @throws IOException if an I/O error occurs while reading from the ByteProvider
* @throws MachException if an invalid MachHeader is detected * @throws MachException if an invalid MachHeader is detected
*/ */
public static MachHeader createMachHeader(GenericFactory factory, ByteProvider provider, public MachHeader(ByteProvider provider, long machHeaderStartIndexInProvider,
long machHeaderStartIndexInProvider, boolean isRemainingMachoRelativeToStartIndex) boolean isRemainingMachoRelativeToStartIndex) throws IOException, MachException {
throws IOException, MachException {
MachHeader machHeader = (MachHeader) factory.create(MachHeader.class);
machHeader.initMachHeader(factory, provider, machHeaderStartIndexInProvider,
isRemainingMachoRelativeToStartIndex);
return machHeader;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public MachHeader() {
}
private void initMachHeader(GenericFactory factory, ByteProvider provider,
long machHeaderStartIndexInProvider, boolean isRemainingMachoRelativeToStartIndex)
throws IOException, MachException {
magic = readMagic(provider, machHeaderStartIndexInProvider); magic = readMagic(provider, machHeaderStartIndexInProvider);
if (!MachConstants.isMagic(magic)) { if (!MachConstants.isMagic(magic)) {
@ -128,7 +117,7 @@ public class MachHeader implements StructConverter {
} }
_machHeaderStartIndexInProvider = machHeaderStartIndexInProvider; _machHeaderStartIndexInProvider = machHeaderStartIndexInProvider;
_reader = new FactoryBundledWithBinaryReader(factory, provider, isLittleEndian()); _reader = new BinaryReader(provider, isLittleEndian());
_reader.setPointerIndex(machHeaderStartIndexInProvider + 4);//skip magic number... _reader.setPointerIndex(machHeaderStartIndexInProvider + 4);//skip magic number...
cpuType = _reader.readNextInt(); cpuType = _reader.readNextInt();
@ -219,13 +208,17 @@ public class MachHeader implements StructConverter {
* Returns the start index that should be used for calculating offsets. * Returns the start index that should be used for calculating offsets.
* This will be 0 for things such as the dyld shared cache where offsets are * This will be 0 for things such as the dyld shared cache where offsets are
* based off the beginning of the file. * based off the beginning of the file.
*
* @return the start index that should be used for calculating offsets
*/ */
public long getStartIndex() { public long getStartIndex() {
return _machHeaderStartIndex; return _machHeaderStartIndex;
} }
/** /**
* Returns offset of MachHeader in the ByteProvider * Returns the offset of the MachHeader in the ByteProvider
*
* @return the offset of the MachHeader in the ByteProvider
*/ */
public long getStartIndexInProvider() { public long getStartIndexInProvider() {
return _machHeaderStartIndexInProvider; return _machHeaderStartIndexInProvider;

View file

@ -17,8 +17,8 @@ package ghidra.app.util.bin.format.macho;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -72,19 +72,7 @@ public class RelocationInfo implements StructConverter {
*/ */
private int r_type; private int r_type;
public static RelocationInfo createRelocationInfo(FactoryBundledWithBinaryReader reader) public RelocationInfo(BinaryReader reader) throws IOException {
throws IOException {
RelocationInfo relocationInfo =
(RelocationInfo) reader.getFactory().create(RelocationInfo.class);
relocationInfo.initRelocationInfo(reader);
return relocationInfo;
}
public RelocationInfo() {
}
private void initRelocationInfo(FactoryBundledWithBinaryReader reader) throws IOException {
int i1 = reader.readNextInt(); int i1 = reader.readNextInt();
int i2 = reader.readNextInt(); int i2 = reader.readNextInt();

View file

@ -20,8 +20,8 @@ import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.commands.SegmentNames; import ghidra.app.util.bin.format.macho.commands.SegmentNames;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -46,25 +46,11 @@ public class Section implements StructConverter {
private int reserved2; private int reserved2;
private int reserved3;//only used for 64 bit private int reserved3;//only used for 64 bit
private FactoryBundledWithBinaryReader reader; private BinaryReader reader;
private boolean is32bit; private boolean is32bit;
private List<RelocationInfo> relocations = new ArrayList<>(); private List<RelocationInfo> relocations = new ArrayList<>();
public static Section createSection(FactoryBundledWithBinaryReader reader, boolean is32bit) public Section(BinaryReader reader, boolean is32bit) throws IOException {
throws IOException {
Section section = (Section) reader.getFactory().create(Section.class);
section.initSection(reader, is32bit);
return section;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public Section() {
}
private void initSection(FactoryBundledWithBinaryReader reader, boolean is32bit)
throws IOException {
this.reader = reader; this.reader = reader;
this.is32bit = is32bit; this.is32bit = is32bit;
@ -93,7 +79,7 @@ public class Section implements StructConverter {
long index = reader.getPointerIndex(); long index = reader.getPointerIndex();
reader.setPointerIndex(reloff); reader.setPointerIndex(reloff);
for (int i = 0; i < nrelocs; ++i) { for (int i = 0; i < nrelocs; ++i) {
relocations.add(RelocationInfo.createRelocationInfo(reader)); relocations.add(new RelocationInfo(reader));
} }
reader.setPointerIndex(index); reader.setPointerIndex(index);
} }

View file

@ -17,8 +17,8 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -42,22 +42,7 @@ public class BuildVersionCommand extends LoadCommand {
private int ntools; private int ntools;
private BuildToolVersion[] buildToolVersions; private BuildToolVersion[] buildToolVersions;
static BuildVersionCommand createBuildVersionCommand(FactoryBundledWithBinaryReader reader) BuildVersionCommand(BinaryReader reader) throws IOException {
throws IOException {
BuildVersionCommand command =
(BuildVersionCommand) reader.getFactory().create(BuildVersionCommand.class);
command.initEntryPointCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public BuildVersionCommand() {
}
private void initEntryPointCommand(FactoryBundledWithBinaryReader reader) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
platform = reader.readNextInt(); platform = reader.readNextInt();

View file

@ -17,8 +17,8 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -41,22 +41,7 @@ public class DyldChainedFixupHeader implements StructConverter {
DyldChainedStartsInImage chainedStartsInImage; DyldChainedStartsInImage chainedStartsInImage;
DyldChainedImports chainedImports; DyldChainedImports chainedImports;
static DyldChainedFixupHeader createDyldChainedFixupHeader( DyldChainedFixupHeader(BinaryReader reader) throws IOException {
FactoryBundledWithBinaryReader reader) throws IOException {
DyldChainedFixupHeader dyldChainedFixupHeader =
(DyldChainedFixupHeader) reader.getFactory().create(DyldChainedFixupHeader.class);
dyldChainedFixupHeader.initDyldChainedFixupHeader(reader);
return dyldChainedFixupHeader;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DyldChainedFixupHeader() {
}
private void initDyldChainedFixupHeader(FactoryBundledWithBinaryReader reader)
throws IOException {
long ptrIndex = reader.getPointerIndex(); long ptrIndex = reader.getPointerIndex();
fixups_version = reader.readNextInt(); fixups_version = reader.readNextInt();
@ -68,10 +53,10 @@ public class DyldChainedFixupHeader implements StructConverter {
symbols_format = reader.readNextInt(); symbols_format = reader.readNextInt();
reader.setPointerIndex(ptrIndex + starts_offset); reader.setPointerIndex(ptrIndex + starts_offset);
chainedStartsInImage = DyldChainedStartsInImage.createDyldChainedStartsInImage(reader); chainedStartsInImage = new DyldChainedStartsInImage(reader);
reader.setPointerIndex(ptrIndex + imports_offset); reader.setPointerIndex(ptrIndex + imports_offset);
chainedImports = DyldChainedImports.createDyldChainedImports(reader, this); chainedImports = new DyldChainedImports(reader, this);
reader.setPointerIndex(ptrIndex + symbols_offset); reader.setPointerIndex(ptrIndex + symbols_offset);
chainedImports.initSymbols(reader, this); chainedImports.initSymbols(reader, this);

View file

@ -18,7 +18,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
import ghidra.program.flatapi.FlatProgramAPI; import ghidra.program.flatapi.FlatProgramAPI;
@ -38,24 +38,13 @@ public class DyldChainedFixupsCommand extends LinkEditDataCommand {
private DyldChainedFixupHeader chainHeader; private DyldChainedFixupHeader chainHeader;
static LinkEditDataCommand createDyldChainedFixupsCommand(FactoryBundledWithBinaryReader reader) DyldChainedFixupsCommand(BinaryReader reader) throws IOException {
throws IOException { super(reader);
DyldChainedFixupsCommand command =
(DyldChainedFixupsCommand) reader.getFactory().create(DyldChainedFixupsCommand.class);
command.initLinkEditDataCommand(reader);
long ptrIndex = reader.getPointerIndex(); long ptrIndex = reader.getPointerIndex();
reader.setPointerIndex(command.getDataOffset()); reader.setPointerIndex(getDataOffset());
command.chainHeader = DyldChainedFixupHeader.createDyldChainedFixupHeader(reader); chainHeader = new DyldChainedFixupHeader(reader);
reader.setPointerIndex(ptrIndex); reader.setPointerIndex(ptrIndex);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DyldChainedFixupsCommand() {
} }
@Override @Override

View file

@ -17,8 +17,8 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -40,25 +40,10 @@ public class DyldChainedImport implements StructConverter {
private long addend; private long addend;
private String symbolName; private String symbolName;
static DyldChainedImport createDyldChainedImport(FactoryBundledWithBinaryReader reader, DyldChainedImport(BinaryReader reader, DyldChainedFixupHeader cfh, int imports_format)
DyldChainedFixupHeader cfh, int imports_format) throws IOException { throws IOException {
DyldChainedImport dyldChainedImport = this.imports_format = imports_format;
(DyldChainedImport) reader.getFactory().create(DyldChainedImport.class); switch (imports_format) {
dyldChainedImport.initDyldChainedImport(reader, cfh, imports_format);
return dyldChainedImport;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DyldChainedImport() {
}
private void initDyldChainedImport(FactoryBundledWithBinaryReader reader,
DyldChainedFixupHeader cfh, int format) throws IOException {
this.imports_format = format;
switch (format) {
case DYLD_CHAINED_IMPORT: { case DYLD_CHAINED_IMPORT: {
int ival = reader.readNextInt(); int ival = reader.readNextInt();
lib_ordinal = ival & 0xff; lib_ordinal = ival & 0xff;
@ -83,7 +68,7 @@ public class DyldChainedImport implements StructConverter {
break; break;
} }
default: default:
throw new IOException("Bad Chained import format: " + format); throw new IOException("Bad Chained import format: " + imports_format);
} }
} }
@ -142,7 +127,7 @@ public class DyldChainedImport implements StructConverter {
return symbolName; return symbolName;
} }
public void initString(FactoryBundledWithBinaryReader reader) throws IOException { public void initString(BinaryReader reader) throws IOException {
symbolName = reader.readNextNullTerminatedAsciiString(); symbolName = reader.readNextNullTerminatedAsciiString();
} }

View file

@ -18,8 +18,8 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.program.model.data.ArrayDataType; import ghidra.program.model.data.ArrayDataType;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -36,23 +36,7 @@ public class DyldChainedImports implements StructConverter {
private long imports_offset; private long imports_offset;
private DyldChainedImport chainedImports[]; private DyldChainedImport chainedImports[];
static DyldChainedImports createDyldChainedImports(FactoryBundledWithBinaryReader reader, DyldChainedImports(BinaryReader reader, DyldChainedFixupHeader cfh) throws IOException {
DyldChainedFixupHeader cfh) throws IOException {
DyldChainedImports dyldChainedImports =
(DyldChainedImports) reader.getFactory().create(DyldChainedImports.class);
dyldChainedImports.initDyldChainedStartsInImage(reader, cfh);
return dyldChainedImports;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DyldChainedImports() {
}
private void initDyldChainedStartsInImage(FactoryBundledWithBinaryReader reader,
DyldChainedFixupHeader cfh) throws IOException {
long ptrIndex = reader.getPointerIndex(); long ptrIndex = reader.getPointerIndex();
imports_offset = ptrIndex; imports_offset = ptrIndex;
@ -61,7 +45,7 @@ public class DyldChainedImports implements StructConverter {
ArrayList<DyldChainedImport> starts = new ArrayList<>(); ArrayList<DyldChainedImport> starts = new ArrayList<>();
for (int i = 0; i < imports_count; i++) { for (int i = 0; i < imports_count; i++) {
starts.add(DyldChainedImport.createDyldChainedImport(reader, cfh, imports_format)); starts.add(new DyldChainedImport(reader, cfh, imports_format));
} }
chainedImports = starts.toArray(DyldChainedImport[]::new); chainedImports = starts.toArray(DyldChainedImport[]::new);
} }
@ -94,8 +78,8 @@ public class DyldChainedImports implements StructConverter {
return chainedImports[ordinal]; return chainedImports[ordinal];
} }
public void initSymbols(FactoryBundledWithBinaryReader reader, public void initSymbols(BinaryReader reader, DyldChainedFixupHeader dyldChainedFixupHeader)
DyldChainedFixupHeader dyldChainedFixupHeader) throws IOException { throws IOException {
long ptrIndex = reader.getPointerIndex(); long ptrIndex = reader.getPointerIndex();
for (DyldChainedImport dyldChainedImport : chainedImports) { for (DyldChainedImport dyldChainedImport : chainedImports) {

View file

@ -18,8 +18,8 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -36,22 +36,7 @@ public class DyldChainedStartsInImage implements StructConverter {
private DyldChainedStartsInSegment chainedStarts[]; private DyldChainedStartsInSegment chainedStarts[];
static DyldChainedStartsInImage createDyldChainedStartsInImage( DyldChainedStartsInImage(BinaryReader reader) throws IOException {
FactoryBundledWithBinaryReader reader) throws IOException {
DyldChainedStartsInImage dyldChainedStartsInImage =
(DyldChainedStartsInImage) reader.getFactory().create(DyldChainedStartsInImage.class);
dyldChainedStartsInImage.initDyldChainedStartsInImage(reader);
return dyldChainedStartsInImage;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DyldChainedStartsInImage() {
}
private void initDyldChainedStartsInImage(FactoryBundledWithBinaryReader reader)
throws IOException {
long ptrIndex = reader.getPointerIndex(); long ptrIndex = reader.getPointerIndex();
@ -62,7 +47,7 @@ public class DyldChainedStartsInImage implements StructConverter {
for (int off : seg_info_offset) { for (int off : seg_info_offset) {
reader.setPointerIndex(ptrIndex + off); reader.setPointerIndex(ptrIndex + off);
starts.add(DyldChainedStartsInSegment.createDyldChainedFixupHeader(reader)); starts.add(new DyldChainedStartsInSegment(reader));
} }
chainedStarts = starts.toArray(DyldChainedStartsInSegment[]::new); chainedStarts = starts.toArray(DyldChainedStartsInSegment[]::new);
} }

View file

@ -17,8 +17,8 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -39,23 +39,7 @@ public class DyldChainedStartsInSegment implements StructConverter {
private short page_starts[]; // each entry is offset in each page of first element in chain private short page_starts[]; // each entry is offset in each page of first element in chain
private short chain_starts[]; // TODO: used for some 32-bit formats with multiple starts per page private short chain_starts[]; // TODO: used for some 32-bit formats with multiple starts per page
static DyldChainedStartsInSegment createDyldChainedFixupHeader( DyldChainedStartsInSegment(BinaryReader reader) throws IOException {
FactoryBundledWithBinaryReader reader) throws IOException {
DyldChainedStartsInSegment dyldChainedFixupHeader =
(DyldChainedStartsInSegment) reader.getFactory().create(
DyldChainedStartsInSegment.class);
dyldChainedFixupHeader.initDyldChainedStartsInSegment(reader);
return dyldChainedFixupHeader;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DyldChainedStartsInSegment() {
}
private void initDyldChainedStartsInSegment(FactoryBundledWithBinaryReader reader)
throws IOException {
size = reader.readNextInt(); size = reader.readNextInt();
page_size = reader.readNextShort(); page_size = reader.readNextShort();
pointer_format = reader.readNextShort(); pointer_format = reader.readNextShort();

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -45,21 +45,7 @@ public class DyldInfoCommand extends LoadCommand {
private int export_off; private int export_off;
private int export_size; private int export_size;
static DyldInfoCommand createDyldInfoCommand(FactoryBundledWithBinaryReader reader) DyldInfoCommand(BinaryReader reader) throws IOException {
throws IOException {
DyldInfoCommand command =
(DyldInfoCommand) reader.getFactory().create(DyldInfoCommand.class);
command.initDyldInfoCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DyldInfoCommand() {
}
private void initDyldInfoCommand(FactoryBundledWithBinaryReader reader) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
rebase_off = reader.readNextInt(); rebase_off = reader.readNextInt();

View file

@ -17,8 +17,8 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -34,23 +34,8 @@ public class DynamicLibrary implements StructConverter {
private int current_version; private int current_version;
private int compatibility_version; private int compatibility_version;
public static DynamicLibrary createDynamicLibrary(FactoryBundledWithBinaryReader reader, public DynamicLibrary(BinaryReader reader, LoadCommand command) throws IOException {
LoadCommand command) throws IOException { name = new LoadCommandString(reader, command);
DynamicLibrary dynamicLibrary =
(DynamicLibrary) reader.getFactory().create(DynamicLibrary.class);
dynamicLibrary.initDynamicLibrary(reader, command);
return dynamicLibrary;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DynamicLibrary() {
}
private void initDynamicLibrary(FactoryBundledWithBinaryReader reader, LoadCommand command)
throws IOException {
name = LoadCommandString.createLoadCommandString(reader, command);
timestamp = reader.readNextInt(); timestamp = reader.readNextInt();
current_version = reader.readNextInt(); current_version = reader.readNextInt();
compatibility_version = reader.readNextInt(); compatibility_version = reader.readNextInt();

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -36,24 +36,9 @@ import ghidra.util.task.TaskMonitor;
public class DynamicLibraryCommand extends LoadCommand { public class DynamicLibraryCommand extends LoadCommand {
private DynamicLibrary dylib; private DynamicLibrary dylib;
static DynamicLibraryCommand createDynamicLibraryCommand(FactoryBundledWithBinaryReader reader) DynamicLibraryCommand(BinaryReader reader) throws IOException {
throws IOException {
DynamicLibraryCommand dynamicLibraryCommand =
(DynamicLibraryCommand) reader.getFactory().create(DynamicLibraryCommand.class);
dynamicLibraryCommand.initDynamicLibraryCommand(reader);
return dynamicLibraryCommand;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DynamicLibraryCommand() {
}
private void initDynamicLibraryCommand(FactoryBundledWithBinaryReader reader)
throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
dylib = DynamicLibrary.createDynamicLibrary(reader, this); dylib = new DynamicLibrary(reader, this);
} }
/** /**

View file

@ -15,13 +15,14 @@
*/ */
package ghidra.app.util.bin.format.macho.commands; package ghidra.app.util.bin.format.macho.commands;
import ghidra.app.util.bin.*; import java.io.IOException;
import ghidra.app.util.bin.format.*;
import ghidra.app.util.bin.format.macho.*;
import ghidra.program.model.data.*;
import ghidra.util.exception.*;
import java.io.*; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException;
public class DynamicLibraryModule implements StructConverter { public class DynamicLibraryModule implements StructConverter {
private int module_name; // the module name (index into string table) private int module_name; // the module name (index into string table)
@ -41,20 +42,7 @@ public class DynamicLibraryModule implements StructConverter {
private boolean is32bit; private boolean is32bit;
private String moduleName; private String moduleName;
public static DynamicLibraryModule createDynamicLibraryModule( public DynamicLibraryModule(BinaryReader reader, MachHeader header) throws IOException {
FactoryBundledWithBinaryReader reader, MachHeader header)
throws IOException {
DynamicLibraryModule dynamicLibraryModule = (DynamicLibraryModule) reader.getFactory().create(DynamicLibraryModule.class);
dynamicLibraryModule.initDynamicLibraryModule(reader, header);
return dynamicLibraryModule;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DynamicLibraryModule() {}
private void initDynamicLibraryModule(FactoryBundledWithBinaryReader reader, MachHeader header) throws IOException {
this.is32bit = header.is32bit(); this.is32bit = header.is32bit();
module_name = reader.readNextInt(); module_name = reader.readNextInt();

View file

@ -17,8 +17,8 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -32,22 +32,7 @@ public class DynamicLibraryReference implements StructConverter {
private int isym; private int isym;
private int flags; private int flags;
static DynamicLibraryReference createDynamicLibraryReference( DynamicLibraryReference(BinaryReader reader) throws IOException {
FactoryBundledWithBinaryReader reader) throws IOException {
DynamicLibraryReference dynamicLibraryReference =
(DynamicLibraryReference) reader.getFactory().create(DynamicLibraryReference.class);
dynamicLibraryReference.initDynamicLibraryReference(reader);
return dynamicLibraryReference;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DynamicLibraryReference() {
}
private void initDynamicLibraryReference(FactoryBundledWithBinaryReader reader)
throws IOException {
int value = reader.readNextInt(); int value = reader.readNextInt();
if (reader.isLittleEndian()) { if (reader.isLittleEndian()) {

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -36,24 +36,9 @@ import ghidra.util.task.TaskMonitor;
public class DynamicLinkerCommand extends LoadCommand { public class DynamicLinkerCommand extends LoadCommand {
private LoadCommandString name; private LoadCommandString name;
public static DynamicLinkerCommand createDynamicLinkerCommand( public DynamicLinkerCommand(BinaryReader reader) throws IOException {
FactoryBundledWithBinaryReader reader) throws IOException {
DynamicLinkerCommand dynamicLinkerCommand =
(DynamicLinkerCommand) reader.getFactory().create(DynamicLinkerCommand.class);
dynamicLinkerCommand.initDynamicLinkerCommand(reader);
return dynamicLinkerCommand;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DynamicLinkerCommand() {
}
private void initDynamicLinkerCommand(FactoryBundledWithBinaryReader reader)
throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
name = LoadCommandString.createLoadCommandString(reader, this); name = new LoadCommandString(reader, this);
} }
public LoadCommandString getLoadCommandString() { public LoadCommandString getLoadCommandString() {

View file

@ -19,7 +19,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.*; import ghidra.app.util.bin.format.macho.*;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
import ghidra.program.flatapi.FlatProgramAPI; import ghidra.program.flatapi.FlatProgramAPI;
@ -65,22 +65,7 @@ public class DynamicSymbolTableCommand extends LoadCommand {
private List<RelocationInfo> externalRelocations = new ArrayList<RelocationInfo>(); private List<RelocationInfo> externalRelocations = new ArrayList<RelocationInfo>();
private List<RelocationInfo> localRelocations = new ArrayList<RelocationInfo>(); private List<RelocationInfo> localRelocations = new ArrayList<RelocationInfo>();
static DynamicSymbolTableCommand createDynamicSymbolTableCommand( DynamicSymbolTableCommand(BinaryReader reader, MachHeader header) throws IOException {
FactoryBundledWithBinaryReader reader, MachHeader header) throws IOException {
DynamicSymbolTableCommand command =
(DynamicSymbolTableCommand) reader.getFactory().create(DynamicSymbolTableCommand.class);
command.initDynamicSymbolTableCommand(reader, header);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DynamicSymbolTableCommand() {
}
private void initDynamicSymbolTableCommand(FactoryBundledWithBinaryReader reader,
MachHeader header) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
ilocalsym = reader.readNextInt(); ilocalsym = reader.readNextInt();
@ -107,19 +92,19 @@ public class DynamicSymbolTableCommand extends LoadCommand {
if (tocoff > 0) { if (tocoff > 0) {
reader.setPointerIndex(header.getStartIndex() + tocoff); reader.setPointerIndex(header.getStartIndex() + tocoff);
for (int i = 0; i < ntoc; ++i) { for (int i = 0; i < ntoc; ++i) {
tocList.add(TableOfContents.createTableOfContents(reader)); tocList.add(new TableOfContents(reader));
} }
} }
if (modtaboff > 0) { if (modtaboff > 0) {
reader.setPointerIndex(header.getStartIndex() + modtaboff); reader.setPointerIndex(header.getStartIndex() + modtaboff);
for (int i = 0; i < nmodtab; ++i) { for (int i = 0; i < nmodtab; ++i) {
moduleList.add(DynamicLibraryModule.createDynamicLibraryModule(reader, header)); moduleList.add(new DynamicLibraryModule(reader, header));
} }
} }
if (extrefsymoff > 0) { if (extrefsymoff > 0) {
reader.setPointerIndex(header.getStartIndex() + extrefsymoff); reader.setPointerIndex(header.getStartIndex() + extrefsymoff);
for (int i = 0; i < nextrefsyms; ++i) { for (int i = 0; i < nextrefsyms; ++i) {
referencedList.add(DynamicLibraryReference.createDynamicLibraryReference(reader)); referencedList.add(new DynamicLibraryReference(reader));
} }
} }
if (indirectsymoff > 0) { if (indirectsymoff > 0) {
@ -132,13 +117,13 @@ public class DynamicSymbolTableCommand extends LoadCommand {
if (extreloff > 0) { if (extreloff > 0) {
reader.setPointerIndex(header.getStartIndex() + extreloff); reader.setPointerIndex(header.getStartIndex() + extreloff);
for (int i = 0; i < nextrel; ++i) { for (int i = 0; i < nextrel; ++i) {
externalRelocations.add(RelocationInfo.createRelocationInfo(reader)); externalRelocations.add(new RelocationInfo(reader));
} }
} }
if (locreloff > 0) { if (locreloff > 0) {
reader.setPointerIndex(header.getStartIndex() + locreloff); reader.setPointerIndex(header.getStartIndex() + locreloff);
for (int i = 0; i < nlocrel; ++i) { for (int i = 0; i < nlocrel; ++i) {
localRelocations.add(RelocationInfo.createRelocationInfo(reader)); localRelocations.add(new RelocationInfo(reader));
} }
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -40,26 +40,10 @@ public class EncryptedInformationCommand extends LoadCommand {
private boolean is32bit; private boolean is32bit;
static EncryptedInformationCommand createEncryptedInformationCommand( EncryptedInformationCommand(BinaryReader reader, boolean is32bit) throws IOException {
FactoryBundledWithBinaryReader reader, boolean is32bit) throws IOException {
EncryptedInformationCommand command =
(EncryptedInformationCommand) reader.getFactory().create(
EncryptedInformationCommand.class);
command.initEncryptedInformationCommand(reader, is32bit);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public EncryptedInformationCommand() {
}
private void initEncryptedInformationCommand(FactoryBundledWithBinaryReader reader,
boolean is32bit) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
this.is32bit = is32bit; this.is32bit = is32bit;
cryptoff = reader.readNextInt(); cryptoff = reader.readNextInt();
cryptsize = reader.readNextInt(); cryptsize = reader.readNextInt();
cryptid = reader.readNextInt(); cryptid = reader.readNextInt();

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -37,22 +37,7 @@ public class EntryPointCommand extends LoadCommand {
private long entryOffset; private long entryOffset;
private long stackSize; private long stackSize;
static EntryPointCommand createEntryPointCommand(FactoryBundledWithBinaryReader reader) EntryPointCommand(BinaryReader reader) throws IOException {
throws IOException {
EntryPointCommand command =
(EntryPointCommand) reader.getFactory().create(EntryPointCommand.class);
command.initEntryPointCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public EntryPointCommand() {
}
private void initEntryPointCommand(FactoryBundledWithBinaryReader reader) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
entryOffset = reader.readNextLong(); entryOffset = reader.readNextLong();
stackSize = reader.readNextLong(); stackSize = reader.readNextLong();

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -42,22 +42,7 @@ public class FileSetEntryCommand extends LoadCommand {
boolean is32bit; boolean is32bit;
public static FileSetEntryCommand createFileSetEntryCommand( public FileSetEntryCommand(BinaryReader reader, boolean is32bit) throws IOException {
FactoryBundledWithBinaryReader reader, boolean is32bit) throws IOException {
FileSetEntryCommand filesetEntryCommand =
(FileSetEntryCommand) reader.getFactory().create(FileSetEntryCommand.class);
filesetEntryCommand.initFileSetEntryCommand(reader, is32bit);
return filesetEntryCommand;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public FileSetEntryCommand() {
}
private void initFileSetEntryCommand(FactoryBundledWithBinaryReader reader, boolean is32bit)
throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
this.is32bit = is32bit; this.is32bit = is32bit;

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -37,23 +37,7 @@ public class FixedVirtualMemoryFileCommand extends LoadCommand {
private LoadCommandString name; private LoadCommandString name;
private int header_addr; private int header_addr;
public static FixedVirtualMemoryFileCommand createFixedVirtualMemoryFileCommand( public FixedVirtualMemoryFileCommand(BinaryReader reader) throws IOException {
FactoryBundledWithBinaryReader reader) throws IOException {
FixedVirtualMemoryFileCommand command =
(FixedVirtualMemoryFileCommand) reader.getFactory().create(
FixedVirtualMemoryFileCommand.class);
command.initFixedVirtualMemoryFileCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public FixedVirtualMemoryFileCommand() {
}
private void initFixedVirtualMemoryFileCommand(FactoryBundledWithBinaryReader reader)
throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachException; import ghidra.app.util.bin.format.macho.MachException;
/** /**
@ -27,24 +27,8 @@ import ghidra.app.util.bin.format.macho.MachException;
*/ */
public class FixedVirtualMemorySharedLibraryCommand extends ObsoleteCommand { public class FixedVirtualMemorySharedLibraryCommand extends ObsoleteCommand {
static FixedVirtualMemorySharedLibraryCommand createFixedVirtualMemorySharedLibraryCommand( FixedVirtualMemorySharedLibraryCommand(BinaryReader reader) throws IOException, MachException {
FactoryBundledWithBinaryReader reader) throws IOException, MachException { super(reader);
FixedVirtualMemorySharedLibraryCommand command =
(FixedVirtualMemorySharedLibraryCommand) reader.getFactory().create(
FixedVirtualMemorySharedLibraryCommand.class);
command.initFixedVirtualMemorySharedLibraryCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public FixedVirtualMemorySharedLibraryCommand() {
}
private void initFixedVirtualMemorySharedLibraryCommand(FactoryBundledWithBinaryReader reader)
throws IOException, MachException {
initObsoleteCommand(reader);
} }
@Override @Override

View file

@ -21,7 +21,6 @@ import java.util.List;
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.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.dwarf4.LEB128; import ghidra.app.util.bin.format.dwarf4.LEB128;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
@ -32,18 +31,8 @@ import ghidra.program.model.address.Address;
*/ */
public class FunctionStartsCommand extends LinkEditDataCommand { public class FunctionStartsCommand extends LinkEditDataCommand {
static FunctionStartsCommand createFunctionStartsCommand(FactoryBundledWithBinaryReader reader) FunctionStartsCommand(BinaryReader reader) throws IOException {
throws IOException { super(reader);
FunctionStartsCommand command =
(FunctionStartsCommand) reader.getFactory().create(FunctionStartsCommand.class);
command.initLinkEditDataCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public FunctionStartsCommand() {
} }
/** /**

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachException; import ghidra.app.util.bin.format.macho.MachException;
/** /**
@ -27,22 +27,8 @@ import ghidra.app.util.bin.format.macho.MachException;
*/ */
public class IdentCommand extends ObsoleteCommand { public class IdentCommand extends ObsoleteCommand {
static IdentCommand createIdentCommand(FactoryBundledWithBinaryReader reader) IdentCommand(BinaryReader reader) throws IOException, MachException {
throws IOException, MachException { super(reader);
IdentCommand identCommand = (IdentCommand) reader.getFactory().create(IdentCommand.class);
identCommand.initIdentCommand(reader);
return identCommand;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public IdentCommand() {
}
private void initIdentCommand(FactoryBundledWithBinaryReader reader)
throws IOException, MachException {
initObsoleteCommand(reader);
} }
@Override @Override

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -37,22 +37,7 @@ public class LinkEditDataCommand extends LoadCommand {
private int dataoff; private int dataoff;
private int datasize; private int datasize;
static LinkEditDataCommand createLinkEditDataCommand(FactoryBundledWithBinaryReader reader) LinkEditDataCommand(BinaryReader reader) throws IOException {
throws IOException {
LinkEditDataCommand command =
(LinkEditDataCommand) reader.getFactory().create(LinkEditDataCommand.class);
command.initLinkEditDataCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public LinkEditDataCommand() {
}
protected void initLinkEditDataCommand(FactoryBundledWithBinaryReader reader)
throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
dataoff = reader.readNextInt(); dataoff = reader.readNextInt();
datasize = reader.readNextInt(); datasize = reader.readNextInt();

View file

@ -19,7 +19,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
import ghidra.program.flatapi.FlatProgramAPI; import ghidra.program.flatapi.FlatProgramAPI;
@ -40,22 +40,7 @@ public class LinkerOptionCommand extends LoadCommand {
private int count; private int count;
private List<String> linkerOptions; private List<String> linkerOptions;
static LinkerOptionCommand createLinkerOptionCommand(FactoryBundledWithBinaryReader reader) LinkerOptionCommand(BinaryReader reader) throws IOException {
throws IOException {
LinkerOptionCommand command =
(LinkerOptionCommand) reader.getFactory().create(LinkerOptionCommand.class);
command.initLinkerOptionCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public LinkerOptionCommand() {
}
private void initLinkerOptionCommand(FactoryBundledWithBinaryReader reader) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
count = reader.readNextInt(); count = reader.readNextInt();
linkerOptions = new ArrayList<>(count); linkerOptions = new ArrayList<>(count);

View file

@ -17,8 +17,8 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
import ghidra.program.flatapi.FlatProgramAPI; import ghidra.program.flatapi.FlatProgramAPI;
@ -37,10 +37,7 @@ public abstract class LoadCommand implements StructConverter {
private int cmd; private int cmd;
private int cmdsize; private int cmdsize;
public LoadCommand() { protected void initLoadCommand(BinaryReader reader) throws IOException {
}
protected void initLoadCommand(FactoryBundledWithBinaryReader reader) throws IOException {
startIndex = reader.getPointerIndex(); startIndex = reader.getPointerIndex();
cmd = reader.readNextInt(); cmd = reader.readNextInt();
cmdsize = reader.readNextInt(); cmdsize = reader.readNextInt();

View file

@ -17,8 +17,8 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -32,23 +32,7 @@ public class LoadCommandString implements StructConverter {
private int offset; private int offset;
private String string; private String string;
static LoadCommandString createLoadCommandString(FactoryBundledWithBinaryReader reader, LoadCommandString(BinaryReader reader, LoadCommand command) throws IOException {
LoadCommand command) throws IOException {
LoadCommandString loadCommandString =
(LoadCommandString) reader.getFactory().create(LoadCommandString.class);
loadCommandString.initLoadCommandString(reader, command);
return loadCommandString;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY
* METHODS INSTEAD.
*/
public LoadCommandString() {
}
private void initLoadCommandString(FactoryBundledWithBinaryReader reader, LoadCommand command)
throws IOException {
offset = reader.readNextInt(); offset = reader.readNextInt();
string = reader.readAsciiString(command.getStartIndex() + offset); string = reader.readAsciiString(command.getStartIndex() + offset);
} }

View file

@ -19,7 +19,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachException; import ghidra.app.util.bin.format.macho.MachException;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.bin.format.macho.threadcommand.ThreadCommand; import ghidra.app.util.bin.format.macho.threadcommand.ThreadCommand;
@ -30,145 +30,143 @@ import ghidra.util.Msg;
*/ */
public final class LoadCommandTypes { public final class LoadCommandTypes {
public static LoadCommand getLoadCommand(FactoryBundledWithBinaryReader reader, public static LoadCommand getLoadCommand(BinaryReader reader, MachHeader header)
MachHeader header) throws IOException, MachException { throws IOException, MachException {
int type = reader.peekNextInt(); int type = reader.peekNextInt();
switch (type) { switch (type) {
case LC_SEGMENT: { case LC_SEGMENT: {
return SegmentCommand.createSegmentCommand(reader, header.is32bit()); return new SegmentCommand(reader, header.is32bit());
} }
case LC_SYMTAB: { case LC_SYMTAB: {
return SymbolTableCommand.createSymbolTableCommand(reader, header); return new SymbolTableCommand(reader, header);
} }
case LC_SYMSEG: { case LC_SYMSEG: {
return SymbolCommand.createSymbolCommand(reader); return new SymbolCommand(reader);
} }
case LC_THREAD: case LC_THREAD:
case LC_UNIXTHREAD: { case LC_UNIXTHREAD: {
return ThreadCommand.createThreadCommand(reader, header); return new ThreadCommand(reader, header);
} }
case LC_LOADFVMLIB: case LC_LOADFVMLIB:
case LC_IDFVMLIB: { case LC_IDFVMLIB: {
return FixedVirtualMemorySharedLibraryCommand return new FixedVirtualMemorySharedLibraryCommand(reader);
.createFixedVirtualMemorySharedLibraryCommand(reader);
} }
case LC_IDENT: { case LC_IDENT: {
return IdentCommand.createIdentCommand(reader); return new IdentCommand(reader);
} }
case LC_FVMFILE: { case LC_FVMFILE: {
return FixedVirtualMemoryFileCommand.createFixedVirtualMemoryFileCommand(reader); return new FixedVirtualMemoryFileCommand(reader);
} }
case LC_PREPAGE: { case LC_PREPAGE: {
return UnsupportedLoadCommand.createUnsupportedLoadCommand(reader, type); return new UnsupportedLoadCommand(reader, type);
} }
case LC_DYSYMTAB: { case LC_DYSYMTAB: {
return DynamicSymbolTableCommand.createDynamicSymbolTableCommand(reader, header); return new DynamicSymbolTableCommand(reader, header);
} }
case LC_LOAD_DYLIB: case LC_LOAD_DYLIB:
case LC_ID_DYLIB: case LC_ID_DYLIB:
case LC_LOAD_UPWARD_DYLIB: case LC_LOAD_UPWARD_DYLIB:
case LC_DYLD_ENVIRONMENT: { case LC_DYLD_ENVIRONMENT: {
return DynamicLibraryCommand.createDynamicLibraryCommand(reader); return new DynamicLibraryCommand(reader);
} }
case LC_LOAD_DYLINKER: case LC_LOAD_DYLINKER:
case LC_ID_DYLINKER: { case LC_ID_DYLINKER: {
return DynamicLinkerCommand.createDynamicLinkerCommand(reader); return new DynamicLinkerCommand(reader);
} }
case LC_PREBOUND_DYLIB: { case LC_PREBOUND_DYLIB: {
return PreboundDynamicLibraryCommand.createPreboundDynamicLibraryCommand(reader); return new PreboundDynamicLibraryCommand(reader);
} }
case LC_ROUTINES: { case LC_ROUTINES: {
return RoutinesCommand.createRoutinesCommand(reader, header.is32bit()); return new RoutinesCommand(reader, header.is32bit());
} }
case LC_SUB_FRAMEWORK: { case LC_SUB_FRAMEWORK: {
return SubFrameworkCommand.createSubFrameworkCommand(reader); return new SubFrameworkCommand(reader);
} }
case LC_SUB_UMBRELLA: { case LC_SUB_UMBRELLA: {
return SubUmbrellaCommand.createSubUmbrellaCommand(reader); return new SubUmbrellaCommand(reader);
} }
case LC_SUB_CLIENT: { case LC_SUB_CLIENT: {
return SubClientCommand.createSubClientCommand(reader); return new SubClientCommand(reader);
} }
case LC_SUB_LIBRARY: { case LC_SUB_LIBRARY: {
return SubLibraryCommand.createSubLibraryCommand(reader); return new SubLibraryCommand(reader);
} }
case LC_TWOLEVEL_HINTS: { case LC_TWOLEVEL_HINTS: {
return TwoLevelHintsCommand.createTwoLevelHintsCommand(reader); return new TwoLevelHintsCommand(reader);
} }
case LC_PREBIND_CKSUM: { case LC_PREBIND_CKSUM: {
return PrebindChecksumCommand.createPrebindChecksumCommand(reader); return new PrebindChecksumCommand(reader);
} }
case LC_LOAD_WEAK_DYLIB: { case LC_LOAD_WEAK_DYLIB: {
return DynamicLibraryCommand.createDynamicLibraryCommand(reader); return new DynamicLibraryCommand(reader);
} }
case LC_SEGMENT_64: { case LC_SEGMENT_64: {
return SegmentCommand.createSegmentCommand(reader, header.is32bit()); return new SegmentCommand(reader, header.is32bit());
} }
case LC_ROUTINES_64: { case LC_ROUTINES_64: {
return RoutinesCommand.createRoutinesCommand(reader, header.is32bit()); return new RoutinesCommand(reader, header.is32bit());
} }
case LC_UUID: { case LC_UUID: {
return UuidCommand.createUuidCommand(reader); return new UuidCommand(reader);
} }
case LC_RPATH: { case LC_RPATH: {
return RunPathCommand.createRunPathCommand(reader); return new RunPathCommand(reader);
} }
case LC_CODE_SIGNATURE: case LC_CODE_SIGNATURE:
case LC_SEGMENT_SPLIT_INFO: case LC_SEGMENT_SPLIT_INFO:
case LC_DATA_IN_CODE: case LC_DATA_IN_CODE:
case LC_OPTIMIZATION_HINT: case LC_OPTIMIZATION_HINT:
case LC_DYLIB_CODE_SIGN_DRS: { case LC_DYLIB_CODE_SIGN_DRS: {
return LinkEditDataCommand.createLinkEditDataCommand(reader); return new LinkEditDataCommand(reader);
} }
case LC_REEXPORT_DYLIB: { case LC_REEXPORT_DYLIB: {
return DynamicLibraryCommand.createDynamicLibraryCommand(reader); return new DynamicLibraryCommand(reader);
} }
case LC_ENCRYPTION_INFO: case LC_ENCRYPTION_INFO:
case LC_ENCRYPTION_INFO_64: { case LC_ENCRYPTION_INFO_64: {
return EncryptedInformationCommand.createEncryptedInformationCommand(reader, return new EncryptedInformationCommand(reader, header.is32bit());
header.is32bit());
} }
case LC_DYLD_INFO: case LC_DYLD_INFO:
case LC_DYLD_INFO_ONLY: { case LC_DYLD_INFO_ONLY: {
return DyldInfoCommand.createDyldInfoCommand(reader); return new DyldInfoCommand(reader);
} }
case LC_VERSION_MIN_MACOSX: case LC_VERSION_MIN_MACOSX:
case LC_VERSION_MIN_IPHONEOS: case LC_VERSION_MIN_IPHONEOS:
case LC_VERSION_MIN_TVOS: case LC_VERSION_MIN_TVOS:
case LC_VERSION_MIN_WATCHOS: { case LC_VERSION_MIN_WATCHOS: {
return VersionMinCommand.createVersionMinCommand(reader); return new VersionMinCommand(reader);
} }
case LC_FUNCTION_STARTS: { case LC_FUNCTION_STARTS: {
return FunctionStartsCommand.createFunctionStartsCommand(reader); return new FunctionStartsCommand(reader);
} }
case LC_MAIN: { case LC_MAIN: {
return EntryPointCommand.createEntryPointCommand(reader); return new EntryPointCommand(reader);
} }
case LC_SOURCE_VERSION: { case LC_SOURCE_VERSION: {
return SourceVersionCommand.createSourceVersionCommand(reader); return new SourceVersionCommand(reader);
} }
case LC_LAZY_LOAD_DYLIB: { case LC_LAZY_LOAD_DYLIB: {
return DynamicLibraryCommand.createDynamicLibraryCommand(reader); return new DynamicLibraryCommand(reader);
} }
case LC_BUILD_VERSION: { case LC_BUILD_VERSION: {
return BuildVersionCommand.createBuildVersionCommand(reader); return new BuildVersionCommand(reader);
} }
case LC_LINKER_OPTIONS: { case LC_LINKER_OPTIONS: {
return LinkerOptionCommand.createLinkerOptionCommand(reader); return new LinkerOptionCommand(reader);
} }
case LC_DYLD_EXPORTS_TRIE: case LC_DYLD_EXPORTS_TRIE:
return LinkEditDataCommand.createLinkEditDataCommand(reader); return new LinkEditDataCommand(reader);
case LC_DYLD_CHAINED_FIXUPS: case LC_DYLD_CHAINED_FIXUPS:
return DyldChainedFixupsCommand.createDyldChainedFixupsCommand(reader); return new DyldChainedFixupsCommand(reader);
case LC_FILESET_ENTRY: case LC_FILESET_ENTRY:
return FileSetEntryCommand.createFileSetEntryCommand(reader, header.is32bit()); return new FileSetEntryCommand(reader, header.is32bit());
default: { default: {
Msg.warn(header, "Unsupported load command " + Integer.toHexString(type)); Msg.warn(header, "Unsupported load command " + Integer.toHexString(type));
return UnsupportedLoadCommand.createUnsupportedLoadCommand(reader, type); return new UnsupportedLoadCommand(reader, type);
} }
} }
} }

View file

@ -17,8 +17,8 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.AssertException; import ghidra.util.exception.AssertException;
@ -39,21 +39,7 @@ public class NList implements StructConverter {
private String string; private String string;
private boolean is32bit; private boolean is32bit;
public static NList createNList(FactoryBundledWithBinaryReader reader, boolean is32bit) public NList(BinaryReader reader, boolean is32bit) throws IOException {
throws IOException {
NList nList = (NList) reader.getFactory().create(NList.class);
nList.initNList(reader, is32bit);
return nList;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public NList() {
}
private void initNList(FactoryBundledWithBinaryReader reader, boolean is32bit)
throws IOException {
this.is32bit = is32bit; this.is32bit = is32bit;
n_strx = reader.readNextInt(); n_strx = reader.readNextInt();
@ -78,10 +64,10 @@ public class NList implements StructConverter {
* scattered. Initializing the strings linearly from the string table is much * scattered. Initializing the strings linearly from the string table is much
* faster. * faster.
* *
* @param reader * @param reader The BinaryReader
* @param stringTableOffset offset of the string table * @param stringTableOffset offset of the string table
*/ */
public void initString(FactoryBundledWithBinaryReader reader, long stringTableOffset) { public void initString(BinaryReader reader, long stringTableOffset) {
try { try {
string = reader.readAsciiString(stringTableOffset + n_strx); string = reader.readAsciiString(stringTableOffset + n_strx);
} }

View file

@ -15,26 +15,21 @@
*/ */
package ghidra.app.util.bin.format.macho.commands; package ghidra.app.util.bin.format.macho.commands;
import ghidra.app.util.bin.format.*; import java.io.IOException;
import ghidra.app.util.bin.format.macho.*;
import ghidra.app.util.importer.*;
import ghidra.program.flatapi.*;
import ghidra.program.model.address.*;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.*;
import ghidra.util.exception.*;
import ghidra.util.task.*;
import java.io.*; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.*;
import ghidra.app.util.importer.MessageLog;
import ghidra.program.flatapi.FlatProgramAPI;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.ProgramModule;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor;
public abstract class ObsoleteCommand extends LoadCommand { public abstract class ObsoleteCommand extends LoadCommand {
/** public ObsoleteCommand(BinaryReader reader) throws IOException, MachException {
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public ObsoleteCommand() {}
protected void initObsoleteCommand(FactoryBundledWithBinaryReader reader) throws IOException, MachException {
initLoadCommand(reader); initLoadCommand(reader);
throw new ObsoleteException(); throw new ObsoleteException();
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -36,22 +36,7 @@ import ghidra.util.task.TaskMonitor;
public class PrebindChecksumCommand extends LoadCommand { public class PrebindChecksumCommand extends LoadCommand {
private int cksum; private int cksum;
static PrebindChecksumCommand createPrebindChecksumCommand( PrebindChecksumCommand(BinaryReader reader) throws IOException {
FactoryBundledWithBinaryReader reader) throws IOException {
PrebindChecksumCommand checksumCommand =
(PrebindChecksumCommand) reader.getFactory().create(PrebindChecksumCommand.class);
checksumCommand.initPrebindChecksumCommand(reader);
return checksumCommand;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public PrebindChecksumCommand() {
}
private void initPrebindChecksumCommand(FactoryBundledWithBinaryReader reader)
throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
cksum = reader.readNextInt(); cksum = reader.readNextInt();
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -38,27 +38,11 @@ public class PreboundDynamicLibraryCommand extends LoadCommand {
private int nmodules; private int nmodules;
private LoadCommandString linkedModules; private LoadCommandString linkedModules;
static PreboundDynamicLibraryCommand createPreboundDynamicLibraryCommand( PreboundDynamicLibraryCommand(BinaryReader reader) throws IOException {
FactoryBundledWithBinaryReader reader) throws IOException {
PreboundDynamicLibraryCommand command =
(PreboundDynamicLibraryCommand) reader.getFactory().create(
PreboundDynamicLibraryCommand.class);
command.initPreboundDynamicLibraryCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public PreboundDynamicLibraryCommand() {
}
private void initPreboundDynamicLibraryCommand(FactoryBundledWithBinaryReader reader)
throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
name = LoadCommandString.createLoadCommandString(reader, this); name = new LoadCommandString(reader, this);
nmodules = reader.readNextInt(); nmodules = reader.readNextInt();
linkedModules = LoadCommandString.createLoadCommandString(reader, this); linkedModules = new LoadCommandString(reader, this);
} }
@Override @Override

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -45,20 +45,7 @@ public class RoutinesCommand extends LoadCommand {
private boolean is32bit; private boolean is32bit;
static RoutinesCommand createRoutinesCommand(FactoryBundledWithBinaryReader reader, RoutinesCommand(BinaryReader reader, boolean is32bit) throws IOException {
boolean is32bit) throws IOException {
RoutinesCommand command = (RoutinesCommand) reader.getFactory().create(RoutinesCommand.class);
command.initRoutinesCommand(reader, is32bit);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public RoutinesCommand() {}
private void initRoutinesCommand(FactoryBundledWithBinaryReader reader, boolean is32bit)
throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
this.is32bit = is32bit; this.is32bit = is32bit;
if (is32bit) { if (is32bit) {

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -36,22 +36,9 @@ import ghidra.util.task.TaskMonitor;
public class RunPathCommand extends LoadCommand { public class RunPathCommand extends LoadCommand {
private LoadCommandString path; private LoadCommandString path;
static RunPathCommand createRunPathCommand(FactoryBundledWithBinaryReader reader) RunPathCommand(BinaryReader reader) throws IOException {
throws IOException {
RunPathCommand command = (RunPathCommand) reader.getFactory().create(RunPathCommand.class);
command.initRunPathCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public RunPathCommand() {
}
private void initRunPathCommand(FactoryBundledWithBinaryReader reader) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
path = LoadCommandString.createLoadCommandString(reader, this); path = new LoadCommandString(reader, this);
} }
public LoadCommandString getPath() { public LoadCommandString getPath() {

View file

@ -19,7 +19,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.*; import ghidra.app.util.bin.format.macho.*;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
import ghidra.program.flatapi.FlatProgramAPI; import ghidra.program.flatapi.FlatProgramAPI;
@ -50,22 +50,7 @@ public class SegmentCommand extends LoadCommand {
private boolean is32bit; private boolean is32bit;
private List<Section> sections = new ArrayList<Section>(); private List<Section> sections = new ArrayList<Section>();
public static SegmentCommand createSegmentCommand(FactoryBundledWithBinaryReader reader, public SegmentCommand(BinaryReader reader, boolean is32bit) throws IOException {
boolean is32bit) throws IOException {
SegmentCommand segmentCommand =
(SegmentCommand) reader.getFactory().create(SegmentCommand.class);
segmentCommand.initSegmentCommand(reader, is32bit);
return segmentCommand;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public SegmentCommand() {
}
private void initSegmentCommand(FactoryBundledWithBinaryReader reader, boolean is32bit)
throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
this.is32bit = is32bit; this.is32bit = is32bit;
@ -88,7 +73,7 @@ public class SegmentCommand extends LoadCommand {
flags = reader.readNextInt(); flags = reader.readNextInt();
for (int i = 0; i < nsects; ++i) { for (int i = 0; i < nsects; ++i) {
sections.add(Section.createSection(reader, is32bit)); sections.add(new Section(reader, is32bit));
} }
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -36,22 +36,7 @@ import ghidra.util.task.TaskMonitor;
public class SourceVersionCommand extends LoadCommand { public class SourceVersionCommand extends LoadCommand {
private long version; private long version;
static SourceVersionCommand createSourceVersionCommand(FactoryBundledWithBinaryReader reader) SourceVersionCommand(BinaryReader reader) throws IOException {
throws IOException {
SourceVersionCommand command =
(SourceVersionCommand) reader.getFactory().create(SourceVersionCommand.class);
command.initEntryPointCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public SourceVersionCommand() {
}
private void initEntryPointCommand(FactoryBundledWithBinaryReader reader) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
version = reader.readNextLong(); version = reader.readNextLong();
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -36,23 +36,9 @@ import ghidra.util.task.TaskMonitor;
public class SubClientCommand extends LoadCommand { public class SubClientCommand extends LoadCommand {
private LoadCommandString client; private LoadCommandString client;
static SubClientCommand createSubClientCommand(FactoryBundledWithBinaryReader reader) SubClientCommand(BinaryReader reader) throws IOException {
throws IOException {
SubClientCommand clientCommand =
(SubClientCommand) reader.getFactory().create(SubClientCommand.class);
clientCommand.initSubClientCommand(reader);
return clientCommand;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public SubClientCommand() {
}
private void initSubClientCommand(FactoryBundledWithBinaryReader reader) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
client = LoadCommandString.createLoadCommandString(reader, this); client = new LoadCommandString(reader, this);
} }
/** /**

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -36,23 +36,9 @@ import ghidra.util.task.TaskMonitor;
public class SubFrameworkCommand extends LoadCommand { public class SubFrameworkCommand extends LoadCommand {
private LoadCommandString umbrella; private LoadCommandString umbrella;
static SubFrameworkCommand createSubFrameworkCommand(FactoryBundledWithBinaryReader reader) SubFrameworkCommand(BinaryReader reader) throws IOException {
throws IOException {
SubFrameworkCommand command =
(SubFrameworkCommand) reader.getFactory().create(SubFrameworkCommand.class);
command.initSubFrameworkCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public SubFrameworkCommand() {
}
private void initSubFrameworkCommand(FactoryBundledWithBinaryReader reader) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
umbrella = LoadCommandString.createLoadCommandString(reader, this); umbrella = new LoadCommandString(reader, this);
} }
public LoadCommandString getUmbrellaFrameworkName() { public LoadCommandString getUmbrellaFrameworkName() {

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -36,23 +36,9 @@ import ghidra.util.task.TaskMonitor;
public class SubLibraryCommand extends LoadCommand { public class SubLibraryCommand extends LoadCommand {
private LoadCommandString sub_library; private LoadCommandString sub_library;
static SubLibraryCommand createSubLibraryCommand(FactoryBundledWithBinaryReader reader) SubLibraryCommand(BinaryReader reader) throws IOException {
throws IOException {
SubLibraryCommand command =
(SubLibraryCommand) reader.getFactory().create(SubLibraryCommand.class);
command.initSubLibraryCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public SubLibraryCommand() {
}
private void initSubLibraryCommand(FactoryBundledWithBinaryReader reader) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
sub_library = LoadCommandString.createLoadCommandString(reader, this); sub_library = new LoadCommandString(reader, this);
} }
public LoadCommandString getSubLibraryName() { public LoadCommandString getSubLibraryName() {

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -36,23 +36,9 @@ import ghidra.util.task.TaskMonitor;
public class SubUmbrellaCommand extends LoadCommand { public class SubUmbrellaCommand extends LoadCommand {
private LoadCommandString sub_umbrella; private LoadCommandString sub_umbrella;
static SubUmbrellaCommand createSubUmbrellaCommand(FactoryBundledWithBinaryReader reader) SubUmbrellaCommand(BinaryReader reader) throws IOException {
throws IOException {
SubUmbrellaCommand command =
(SubUmbrellaCommand) reader.getFactory().create(SubUmbrellaCommand.class);
command.initSubUmbrellaCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public SubUmbrellaCommand() {
}
private void initSubUmbrellaCommand(FactoryBundledWithBinaryReader reader) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
sub_umbrella = LoadCommandString.createLoadCommandString(reader, this); sub_umbrella = new LoadCommandString(reader, this);
} }
public LoadCommandString getSubUmbrellaFrameworkName() { public LoadCommandString getSubUmbrellaFrameworkName() {

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachException; import ghidra.app.util.bin.format.macho.MachException;
/** /**
@ -29,23 +29,10 @@ public class SymbolCommand extends ObsoleteCommand {
private int offset; private int offset;
private int size; private int size;
static SymbolCommand createSymbolCommand( SymbolCommand(BinaryReader reader) throws IOException, MachException {
FactoryBundledWithBinaryReader reader) throws IOException, super(reader);
MachException {
SymbolCommand symbolCommand = (SymbolCommand) reader.getFactory().create(SymbolCommand.class);
symbolCommand.initSymbolCommand(reader);
return symbolCommand;
} }
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public SymbolCommand() {}
private void initSymbolCommand(FactoryBundledWithBinaryReader reader) throws IOException, MachException {
initObsoleteCommand(reader);
}
public int getOffset() { public int getOffset() {
return offset; return offset;
} }

View file

@ -20,7 +20,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -48,22 +48,7 @@ public class SymbolTableCommand extends LoadCommand {
private List<NList> symbols = new ArrayList<NList>(); private List<NList> symbols = new ArrayList<NList>();
public static SymbolTableCommand createSymbolTableCommand(FactoryBundledWithBinaryReader reader, public SymbolTableCommand(BinaryReader reader, MachHeader header) throws IOException {
MachHeader header) throws IOException {
SymbolTableCommand symbolTableCommand =
(SymbolTableCommand) reader.getFactory().create(SymbolTableCommand.class);
symbolTableCommand.initSymbolTableCommand(reader, header);
return symbolTableCommand;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public SymbolTableCommand() {
}
private void initSymbolTableCommand(FactoryBundledWithBinaryReader reader, MachHeader header)
throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
symoff = reader.readNextInt(); symoff = reader.readNextInt();
@ -81,7 +66,7 @@ public class SymbolTableCommand extends LoadCommand {
reader.setPointerIndex(startIndex + symoff); reader.setPointerIndex(startIndex + symoff);
for (int i = 0; i < nsyms; ++i) { for (int i = 0; i < nsyms; ++i) {
nlistList.add(NList.createNList(reader, is32bit)); nlistList.add(new NList(reader, is32bit));
} }
// sort the entries by the index in the string table, so don't jump around reading // sort the entries by the index in the string table, so don't jump around reading
List<NList> sortedList = List<NList> sortedList =

View file

@ -17,8 +17,8 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -32,21 +32,7 @@ public class TableOfContents implements StructConverter {
private int symbol_index; private int symbol_index;
private int module_index; private int module_index;
static TableOfContents createTableOfContents(FactoryBundledWithBinaryReader reader) TableOfContents(BinaryReader reader) throws IOException {
throws IOException {
TableOfContents tableOfContents =
(TableOfContents) reader.getFactory().create(TableOfContents.class);
tableOfContents.initTableOfContents(reader);
return tableOfContents;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public TableOfContents() {
}
private void initTableOfContents(FactoryBundledWithBinaryReader reader) throws IOException {
symbol_index = reader.readNextInt(); symbol_index = reader.readNextInt();
module_index = reader.readNextInt(); module_index = reader.readNextInt();
} }

View file

@ -17,8 +17,8 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -34,20 +34,7 @@ public class TwoLevelHint implements StructConverter {
private int isub_image; private int isub_image;
private int itoc; private int itoc;
static TwoLevelHint createTwoLevelHint(FactoryBundledWithBinaryReader reader) TwoLevelHint(BinaryReader reader) throws IOException {
throws IOException {
TwoLevelHint hint = (TwoLevelHint) reader.getFactory().create(TwoLevelHint.class);
hint.initTwoLevelHint(reader);
return hint;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public TwoLevelHint() {
}
private void initTwoLevelHint(FactoryBundledWithBinaryReader reader) throws IOException {
int value = reader.readNextInt(); int value = reader.readNextInt();
isub_image = value & 0xff; isub_image = value & 0xff;

View file

@ -19,7 +19,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -41,22 +41,7 @@ public class TwoLevelHintsCommand extends LoadCommand {
private int nhints; private int nhints;
private List<TwoLevelHint> hints = new ArrayList<TwoLevelHint>(); private List<TwoLevelHint> hints = new ArrayList<TwoLevelHint>();
static TwoLevelHintsCommand createTwoLevelHintsCommand(FactoryBundledWithBinaryReader reader) TwoLevelHintsCommand(BinaryReader reader) throws IOException {
throws IOException {
TwoLevelHintsCommand command =
(TwoLevelHintsCommand) reader.getFactory().create(TwoLevelHintsCommand.class);
command.initTwoLevelHintsCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public TwoLevelHintsCommand() {
}
private void initTwoLevelHintsCommand(FactoryBundledWithBinaryReader reader)
throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
offset = reader.readNextInt(); offset = reader.readNextInt();
nhints = reader.readNextInt(); nhints = reader.readNextInt();
@ -64,7 +49,7 @@ public class TwoLevelHintsCommand extends LoadCommand {
long index = reader.getPointerIndex(); long index = reader.getPointerIndex();
reader.setPointerIndex(offset); reader.setPointerIndex(offset);
for (int i = 0; i < nhints; ++i) { for (int i = 0; i < nhints; ++i) {
hints.add(TwoLevelHint.createTwoLevelHint(reader)); hints.add(new TwoLevelHint(reader));
} }
reader.setPointerIndex(index); reader.setPointerIndex(index);
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -31,22 +31,7 @@ import ghidra.util.task.TaskMonitor;
public class UnsupportedLoadCommand extends LoadCommand { public class UnsupportedLoadCommand extends LoadCommand {
private int type; private int type;
static UnsupportedLoadCommand createUnsupportedLoadCommand( UnsupportedLoadCommand(BinaryReader reader, int type) throws IOException {
FactoryBundledWithBinaryReader reader, int type) throws IOException {
UnsupportedLoadCommand command =
(UnsupportedLoadCommand) reader.getFactory().create(UnsupportedLoadCommand.class);
command.initUnsupportedLoadCommand(reader, type);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public UnsupportedLoadCommand() {
}
private void initUnsupportedLoadCommand(FactoryBundledWithBinaryReader reader, int type)
throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
this.type = type; this.type = type;
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -36,19 +36,7 @@ import ghidra.util.task.TaskMonitor;
public class UuidCommand extends LoadCommand { public class UuidCommand extends LoadCommand {
private byte[] uuid; private byte[] uuid;
static UuidCommand createUuidCommand(FactoryBundledWithBinaryReader reader) throws IOException { UuidCommand(BinaryReader reader) throws IOException {
UuidCommand command = (UuidCommand) reader.getFactory().create(UuidCommand.class);
command.initUuidCommand(reader);
return command;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public UuidCommand() {
}
private void initUuidCommand(FactoryBundledWithBinaryReader reader) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
uuid = reader.readNextByteArray(16); uuid = reader.readNextByteArray(16);
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.commands;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.MachHeader; import ghidra.app.util.bin.format.macho.MachHeader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -38,21 +38,7 @@ public class VersionMinCommand extends LoadCommand {
private int version; private int version;
private int sdk; private int sdk;
static VersionMinCommand createVersionMinCommand(FactoryBundledWithBinaryReader reader) VersionMinCommand(BinaryReader reader) throws IOException {
throws IOException {
VersionMinCommand versionMinCommand =
(VersionMinCommand) reader.getFactory().create(VersionMinCommand.class);
versionMinCommand.initVersionMinCommand(reader);
return versionMinCommand;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public VersionMinCommand() {
}
private void initVersionMinCommand(FactoryBundledWithBinaryReader reader) throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
version = reader.readNextInt(); version = reader.readNextInt();

View file

@ -20,10 +20,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import generic.continues.RethrowContinuesFactory;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.macho.CpuTypes; import ghidra.app.util.bin.format.macho.CpuTypes;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.app.util.bin.format.macho.commands.NList; import ghidra.app.util.bin.format.macho.commands.NList;
@ -146,15 +144,15 @@ public class DyldCacheLocalSymbolsInfo implements StructConverter {
} }
private void parseNList(MessageLog log, TaskMonitor monitor) throws CancelledException { private void parseNList(MessageLog log, TaskMonitor monitor) throws CancelledException {
FactoryBundledWithBinaryReader nListReader = new FactoryBundledWithBinaryReader( BinaryReader nListReader =
RethrowContinuesFactory.INSTANCE, reader.getByteProvider(), reader.isLittleEndian()); new BinaryReader(reader.getByteProvider(), reader.isLittleEndian());
monitor.setMessage("Parsing DYLD nlist symbol table..."); monitor.setMessage("Parsing DYLD nlist symbol table...");
monitor.initialize(nlistCount * 2); monitor.initialize(nlistCount * 2);
nListReader.setPointerIndex(startIndex + nlistOffset); nListReader.setPointerIndex(startIndex + nlistOffset);
try { try {
for (int i = 0; i < nlistCount; ++i) { for (int i = 0; i < nlistCount; ++i) {
nlistList.add(NList.createNList(nListReader, is32bit)); nlistList.add(new NList(nListReader, is32bit));
monitor.checkCanceled(); monitor.checkCanceled();
monitor.incrementProgress(1); monitor.incrementProgress(1);
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.threadcommand;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.*; import ghidra.app.util.bin.format.macho.*;
import ghidra.app.util.bin.format.macho.commands.LoadCommand; import ghidra.app.util.bin.format.macho.commands.LoadCommand;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
@ -38,54 +38,39 @@ public class ThreadCommand extends LoadCommand {
private ThreadStateHeader threadStateHeader; private ThreadStateHeader threadStateHeader;
private ThreadState threadState; private ThreadState threadState;
public static ThreadCommand createThreadCommand(FactoryBundledWithBinaryReader reader, public ThreadCommand(BinaryReader reader, MachHeader header) throws IOException {
MachHeader header) throws IOException {
ThreadCommand threadCommand =
(ThreadCommand) reader.getFactory().create(ThreadCommand.class);
threadCommand.initThreadCommand(reader, header);
return threadCommand;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public ThreadCommand() {
}
private void initThreadCommand(FactoryBundledWithBinaryReader reader, MachHeader header)
throws IOException {
initLoadCommand(reader); initLoadCommand(reader);
threadStateHeader = ThreadStateHeader.createThreadStateHeader(reader); threadStateHeader = new ThreadStateHeader(reader);
if (header.getCpuType() == CpuTypes.CPU_TYPE_X86) { if (header.getCpuType() == CpuTypes.CPU_TYPE_X86) {
if (threadStateHeader.getFlavor() == ThreadStateX86.x86_THREAD_STATE32) { if (threadStateHeader.getFlavor() == ThreadStateX86.x86_THREAD_STATE32) {
threadState = ThreadStateX86_32.createThreadStateX86_32(reader); threadState = new ThreadStateX86_32(reader);
} }
} }
else if (header.getCpuType() == CpuTypes.CPU_TYPE_X86_64) { else if (header.getCpuType() == CpuTypes.CPU_TYPE_X86_64) {
if (threadStateHeader.getFlavor() == ThreadStateX86.x86_THREAD_STATE64) { if (threadStateHeader.getFlavor() == ThreadStateX86.x86_THREAD_STATE64) {
threadState = ThreadStateX86_64.createThreadStateX86_64(reader); threadState = new ThreadStateX86_64(reader);
} }
} }
else if (header.getCpuType() == CpuTypes.CPU_TYPE_POWERPC) { else if (header.getCpuType() == CpuTypes.CPU_TYPE_POWERPC) {
if (threadStateHeader.getFlavor() == ThreadStatePPC.PPC_THREAD_STATE) { if (threadStateHeader.getFlavor() == ThreadStatePPC.PPC_THREAD_STATE) {
threadState = ThreadStatePPC.createThreadStatePPC(reader, header.is32bit()); threadState = new ThreadStatePPC(reader, header.is32bit());
} }
} }
else if (header.getCpuType() == CpuTypes.CPU_TYPE_POWERPC64) { else if (header.getCpuType() == CpuTypes.CPU_TYPE_POWERPC64) {
if (threadStateHeader.getFlavor() == ThreadStatePPC.PPC_THREAD_STATE64) { if (threadStateHeader.getFlavor() == ThreadStatePPC.PPC_THREAD_STATE64) {
threadState = ThreadStatePPC.createThreadStatePPC(reader, header.is32bit()); threadState = new ThreadStatePPC(reader, header.is32bit());
} }
} }
else if (header.getCpuType() == CpuTypes.CPU_TYPE_ARM) { else if (header.getCpuType() == CpuTypes.CPU_TYPE_ARM) {
if (threadStateHeader.getFlavor() == ThreadStateARM.ARM_THREAD_STATE) { if (threadStateHeader.getFlavor() == ThreadStateARM.ARM_THREAD_STATE) {
threadState = ThreadStateARM.createThreadStateARM(reader); threadState = new ThreadStateARM(reader);
} }
} }
else if (header.getCpuType() == CpuTypes.CPU_TYPE_ARM_64) { else if (header.getCpuType() == CpuTypes.CPU_TYPE_ARM_64) {
if (threadStateHeader.getFlavor() == ThreadStateARM_64.ARM64_THREAD_STATE) { if (threadStateHeader.getFlavor() == ThreadStateARM_64.ARM64_THREAD_STATE) {
threadState = ThreadStateARM_64.createThreadStateARM_64(reader); threadState = new ThreadStateARM_64(reader);
} }
} }
else { else {

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.threadcommand;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.Conv; import ghidra.util.Conv;
@ -53,21 +53,7 @@ public class ThreadStateARM extends ThreadState {
public int pc; public int pc;
public int cpsr; public int cpsr;
static ThreadStateARM createThreadStateARM(FactoryBundledWithBinaryReader reader) ThreadStateARM(BinaryReader reader) throws IOException {
throws IOException {
ThreadStateARM threadStateARM =
(ThreadStateARM) reader.getFactory().create(ThreadStateARM.class);
threadStateARM.initThreadStateARM(reader);
return threadStateARM;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public ThreadStateARM() {
}
private void initThreadStateARM(FactoryBundledWithBinaryReader reader) throws IOException {
r0 = reader.readNextInt(); r0 = reader.readNextInt();
r1 = reader.readNextInt(); r1 = reader.readNextInt();
r2 = reader.readNextInt(); r2 = reader.readNextInt();

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.threadcommand;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -67,21 +67,7 @@ public class ThreadStateARM_64 extends ThreadState {
public int cpsr; public int cpsr;
public int pad; public int pad;
static ThreadStateARM_64 createThreadStateARM_64(FactoryBundledWithBinaryReader reader) ThreadStateARM_64(BinaryReader reader) throws IOException {
throws IOException {
ThreadStateARM_64 threadStateARM_64 =
(ThreadStateARM_64) reader.getFactory().create(ThreadStateARM_64.class);
threadStateARM_64.initThreadStateARM_64(reader);
return threadStateARM_64;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public ThreadStateARM_64() {
}
private void initThreadStateARM_64(FactoryBundledWithBinaryReader reader) throws IOException {
x0 = reader.readNextLong(); x0 = reader.readNextLong();
x1 = reader.readNextLong(); x1 = reader.readNextLong();
x2 = reader.readNextLong(); x2 = reader.readNextLong();

View file

@ -17,8 +17,8 @@ package ghidra.app.util.bin.format.macho.threadcommand;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
import ghidra.program.model.data.StructureDataType; import ghidra.program.model.data.StructureDataType;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -27,21 +27,7 @@ public class ThreadStateHeader implements StructConverter {
private int flavor; private int flavor;
private int count; private int count;
static ThreadStateHeader createThreadStateHeader(FactoryBundledWithBinaryReader reader) ThreadStateHeader(BinaryReader reader) throws IOException {
throws IOException {
ThreadStateHeader threadStateHeader =
(ThreadStateHeader) reader.getFactory().create(ThreadStateHeader.class);
threadStateHeader.initThreadStateHeader(reader);
return threadStateHeader;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public ThreadStateHeader() {
}
private void initThreadStateHeader(FactoryBundledWithBinaryReader reader) throws IOException {
flavor = reader.readNextInt(); flavor = reader.readNextInt();
count = reader.readNextInt(); count = reader.readNextInt();
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.threadcommand;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -80,22 +80,7 @@ public class ThreadStatePPC extends ThreadState {
/** Vector Save Register */ /** Vector Save Register */
public long vrsave; public long vrsave;
static ThreadStatePPC createThreadStatePPC(FactoryBundledWithBinaryReader reader, ThreadStatePPC(BinaryReader reader, boolean is32bit) throws IOException {
boolean is32bit) throws IOException {
ThreadStatePPC threadStatePPC =
(ThreadStatePPC) reader.getFactory().create(ThreadStatePPC.class);
threadStatePPC.initThreadStatePPC(reader, is32bit);
return threadStatePPC;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public ThreadStatePPC() {
}
private void initThreadStatePPC(FactoryBundledWithBinaryReader reader, boolean is32bit)
throws IOException {
srr0 = read(reader, is32bit); srr0 = read(reader, is32bit);
srr1 = read(reader, is32bit); srr1 = read(reader, is32bit);
r0 = read(reader, is32bit); r0 = read(reader, is32bit);
@ -138,7 +123,7 @@ public class ThreadStatePPC extends ThreadState {
vrsave = read(reader, is32bit); vrsave = read(reader, is32bit);
} }
private long read(FactoryBundledWithBinaryReader reader, boolean is32bit) throws IOException { private long read(BinaryReader reader, boolean is32bit) throws IOException {
if (is32bit) { if (is32bit) {
return reader.readNextUnsignedInt(); return reader.readNextUnsignedInt();
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.threadcommand;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.Conv; import ghidra.util.Conv;
@ -46,21 +46,7 @@ public class ThreadStateX86_32 extends ThreadStateX86 {
public int fs; public int fs;
public int gs; public int gs;
static ThreadStateX86_32 createThreadStateX86_32(FactoryBundledWithBinaryReader reader) ThreadStateX86_32(BinaryReader reader) throws IOException {
throws IOException {
ThreadStateX86_32 threadStateX86_32 =
(ThreadStateX86_32) reader.getFactory().create(ThreadStateX86_32.class);
threadStateX86_32.initThreadStateX86_32(reader);
return threadStateX86_32;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public ThreadStateX86_32() {
}
private void initThreadStateX86_32(FactoryBundledWithBinaryReader reader) throws IOException {
eax = reader.readNextInt(); eax = reader.readNextInt();
ebx = reader.readNextInt(); ebx = reader.readNextInt();
ecx = reader.readNextInt(); ecx = reader.readNextInt();

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.macho.threadcommand;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.macho.MachConstants; import ghidra.app.util.bin.format.macho.MachConstants;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -50,21 +50,7 @@ public class ThreadStateX86_64 extends ThreadStateX86 {
public long fs; public long fs;
public long gs; public long gs;
static ThreadStateX86_64 createThreadStateX86_64(FactoryBundledWithBinaryReader reader) ThreadStateX86_64(BinaryReader reader) throws IOException {
throws IOException {
ThreadStateX86_64 threadStateX86_64 =
(ThreadStateX86_64) reader.getFactory().create(ThreadStateX86_64.class);
threadStateX86_64.initThreadStateX86_64(reader);
return threadStateX86_64;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public ThreadStateX86_64() {
}
private void initThreadStateX86_64(FactoryBundledWithBinaryReader reader) throws IOException {
rax = reader.readNextLong(); rax = reader.readNextLong();
rbx = reader.readNextLong(); rbx = reader.readNextLong();
rcx = reader.readNextLong(); rcx = reader.readNextLong();

View file

@ -18,8 +18,8 @@ package ghidra.app.util.bin.format.mz;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.app.util.bin.format.Writeable; import ghidra.app.util.bin.format.Writeable;
import ghidra.app.util.bin.format.ne.InvalidWindowsHeaderException; import ghidra.app.util.bin.format.ne.InvalidWindowsHeaderException;
import ghidra.app.util.bin.format.ne.WindowsHeader; import ghidra.app.util.bin.format.ne.WindowsHeader;
@ -89,27 +89,14 @@ public class DOSHeader implements StructConverter, Writeable {
private byte [] stubBytes; private byte [] stubBytes;
private FactoryBundledWithBinaryReader reader; private BinaryReader reader;
/** /**
* Constructs a new DOS header. * Constructs a new DOS header.
* @param reader the binary reader * @param reader the binary reader
*/ */
public static DOSHeader createDOSHeader( public DOSHeader(BinaryReader reader) throws IOException {
FactoryBundledWithBinaryReader reader) throws IOException {
DOSHeader dosHeader = (DOSHeader) reader.getFactory().create(DOSHeader.class);
dosHeader.initDOSHeader(reader);
return dosHeader;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DOSHeader() {}
private void initDOSHeader(FactoryBundledWithBinaryReader reader) throws IOException {
this.reader = reader; this.reader = reader;
parse(); parse();
} }
@ -283,7 +270,7 @@ public class DOSHeader implements StructConverter, Writeable {
if (e_lfanew >= 0 && e_lfanew <= 0x1000000) { if (e_lfanew >= 0 && e_lfanew <= 0x1000000) {
try { try {
NTHeader ntHeader = NTHeader ntHeader =
NTHeader.createNTHeader(reader, e_lfanew, SectionLayout.FILE, false, false); new NTHeader(reader, e_lfanew, SectionLayout.FILE, false, false);
if (ntHeader != null && ntHeader.getOptionalHeader() != null) { if (ntHeader != null && ntHeader.getOptionalHeader() != null) {
return true; return true;
} }

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,11 +15,10 @@
*/ */
package ghidra.app.util.bin.format.mz; package ghidra.app.util.bin.format.mz;
import generic.continues.*; import java.io.IOException;
import ghidra.app.util.bin.*;
import ghidra.app.util.bin.format.*;
import java.io.*; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.ByteProvider;
/** /**
* A class to manage loading Old-style (MZ) Executables. * A class to manage loading Old-style (MZ) Executables.
@ -28,7 +26,7 @@ import java.io.*;
* *
*/ */
public class OldStyleExecutable { public class OldStyleExecutable {
private FactoryBundledWithBinaryReader reader; private BinaryReader reader;
private DOSHeader dosHeader; private DOSHeader dosHeader;
/** /**
@ -36,16 +34,16 @@ public class OldStyleExecutable {
* @param bp the byte provider * @param bp the byte provider
* @throws IOException if an I/O error occurs * @throws IOException if an I/O error occurs
*/ */
public OldStyleExecutable(GenericFactory factory, ByteProvider bp) throws IOException { public OldStyleExecutable(ByteProvider bp) throws IOException {
reader = new FactoryBundledWithBinaryReader(factory, bp, true); reader = new BinaryReader(bp, true);
dosHeader = DOSHeader.createDOSHeader(reader); dosHeader = new DOSHeader(reader);
} }
/** /**
* Returns the underlying binary reader. * Returns the underlying binary reader.
* @return the underlying binary reader * @return the underlying binary reader
*/ */
public FactoryBundledWithBinaryReader getBinaryReader() { public BinaryReader getBinaryReader() {
return reader; return reader;
} }

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +17,7 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.*; import ghidra.app.util.bin.BinaryReader;
/** /**
* A class to represent a new-executable entry point. * A class to represent a new-executable entry point.
@ -43,7 +42,7 @@ public class EntryPoint {
* @param reader the binary reader * @param reader the binary reader
* @param etb the entry table bundle * @param etb the entry table bundle
*/ */
EntryPoint(FactoryBundledWithBinaryReader reader, EntryTableBundle etb) throws IOException { EntryPoint(BinaryReader reader, EntryTableBundle etb) throws IOException {
this.etb = etb; this.etb = etb;
flagword = reader.readNextByte(); flagword = reader.readNextByte();

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,12 +15,12 @@
*/ */
package ghidra.app.util.bin.format.ne; package ghidra.app.util.bin.format.ne;
import ghidra.app.util.bin.format.*;
import ghidra.util.Conv;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent a new-executable entry table. * A class to represent a new-executable entry table.
* *
@ -36,7 +35,7 @@ public class EntryTable {
* @param index the index where the entry table begins * @param index the index where the entry table begins
* @param byteCount the length in bytes of the entry table * @param byteCount the length in bytes of the entry table
*/ */
EntryTable(FactoryBundledWithBinaryReader reader, short index, short byteCount) throws IOException { EntryTable(BinaryReader reader, short index, short byteCount) throws IOException {
long oldIndex = reader.getPointerIndex(); long oldIndex = reader.getPointerIndex();
reader.setPointerIndex(Conv.shortToInt(index)); reader.setPointerIndex(Conv.shortToInt(index));

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +17,7 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.*; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv; import ghidra.util.Conv;
/** /**
@ -49,7 +48,7 @@ public class EntryTableBundle {
* Constructs a new entry table bundle. * Constructs a new entry table bundle.
* @param reader the binary reader * @param reader the binary reader
*/ */
EntryTableBundle(FactoryBundledWithBinaryReader reader) throws IOException { EntryTableBundle(BinaryReader reader) throws IOException {
count = reader.readNextByte(); count = reader.readNextByte();
if (count == 0) return; //do not read anymore data... if (count == 0) return; //do not read anymore data...

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +17,7 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.*; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv; import ghidra.util.Conv;
/** /**
@ -27,7 +26,7 @@ import ghidra.util.Conv;
* *
*/ */
public class ImportedNameTable { public class ImportedNameTable {
private FactoryBundledWithBinaryReader reader; private BinaryReader reader;
private short index; private short index;
/** /**
@ -35,7 +34,7 @@ public class ImportedNameTable {
* @param reader the binary reader * @param reader the binary reader
* @param index the index where the table begins * @param index the index where the table begins
*/ */
ImportedNameTable(FactoryBundledWithBinaryReader reader, short index) { ImportedNameTable(BinaryReader reader, short index) {
this.reader = reader; this.reader = reader;
this.index = index; this.index = index;
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv; import ghidra.util.Conv;
/** /**
@ -195,7 +195,7 @@ public class InformationBlock {
private short ne_swaparea; // Minimum code swap area size private short ne_swaparea; // Minimum code swap area size
private short ne_expver; // Expected windows version number private short ne_expver; // Expected windows version number
InformationBlock(FactoryBundledWithBinaryReader reader, short index) InformationBlock(BinaryReader reader, short index)
throws InvalidWindowsHeaderException, IOException { throws InvalidWindowsHeaderException, IOException {
long oldIndex = reader.getPointerIndex(); long oldIndex = reader.getPointerIndex();
reader.setPointerIndex(Conv.shortToInt(index)); reader.setPointerIndex(Conv.shortToInt(index));

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +17,7 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.*; import ghidra.app.util.bin.BinaryReader;
/** /**
* A class to hold a length/string/ordinal set. * A class to hold a length/string/ordinal set.
@ -30,7 +29,7 @@ public class LengthStringOrdinalSet extends LengthStringSet {
* Constructs a new length/string/ordinal set. * Constructs a new length/string/ordinal set.
* @param reader the binary reader * @param reader the binary reader
*/ */
LengthStringOrdinalSet(FactoryBundledWithBinaryReader reader) throws IOException { LengthStringOrdinalSet(BinaryReader reader) throws IOException {
super(reader); super(reader);
if (getLength() == 0) return; if (getLength() == 0) return;

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,11 +15,11 @@
*/ */
package ghidra.app.util.bin.format.ne; package ghidra.app.util.bin.format.ne;
import ghidra.app.util.bin.format.*;
import ghidra.util.Conv;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to store a length/string set, * A class to store a length/string set,
* where the string is not null-terminated * where the string is not null-terminated
@ -38,7 +37,7 @@ public class LengthStringSet {
* Constructs a new length/string set. * Constructs a new length/string set.
* @param reader the binary reader * @param reader the binary reader
*/ */
LengthStringSet(FactoryBundledWithBinaryReader reader) throws IOException { LengthStringSet(BinaryReader reader) throws IOException {
index = reader.getPointerIndex(); index = reader.getPointerIndex();
length = reader.readNextByte(); length = reader.readNextByte();

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,12 +15,12 @@
*/ */
package ghidra.app.util.bin.format.ne; package ghidra.app.util.bin.format.ne;
import ghidra.app.util.bin.format.*;
import ghidra.util.Conv;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent the new-executable module reference table. * A class to represent the new-executable module reference table.
* *
@ -38,7 +37,8 @@ public class ModuleReferenceTable {
* @param count the count of modules referenced * @param count the count of modules referenced
* @param imp the imported name table * @param imp the imported name table
*/ */
ModuleReferenceTable(FactoryBundledWithBinaryReader reader, short index, short count, ImportedNameTable imp) throws IOException { ModuleReferenceTable(BinaryReader reader, short index, short count, ImportedNameTable imp)
throws IOException {
long oldIndex = reader.getPointerIndex(); long oldIndex = reader.getPointerIndex();
reader.setPointerIndex(Conv.shortToInt(index)); reader.setPointerIndex(Conv.shortToInt(index));

View file

@ -17,9 +17,8 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import generic.continues.GenericFactory; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.ByteProvider; 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.DOSHeader;
import ghidra.program.model.address.SegmentedAddress; import ghidra.program.model.address.SegmentedAddress;
@ -29,7 +28,7 @@ import ghidra.program.model.address.SegmentedAddress;
* *
*/ */
public class NewExecutable { public class NewExecutable {
private FactoryBundledWithBinaryReader reader; private BinaryReader reader;
private DOSHeader dosHeader; private DOSHeader dosHeader;
private WindowsHeader winHeader; private WindowsHeader winHeader;
@ -40,10 +39,9 @@ public class NewExecutable {
* @param baseAddr the image base of the executable * @param baseAddr the image base of the executable
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */
public NewExecutable(GenericFactory factory, ByteProvider bp, SegmentedAddress baseAddr) public NewExecutable(ByteProvider bp, SegmentedAddress baseAddr) throws IOException {
throws IOException { reader = new BinaryReader(bp, true);
reader = new FactoryBundledWithBinaryReader(factory, bp, true); dosHeader = new DOSHeader(reader);
dosHeader = DOSHeader.createDOSHeader(reader);
if (dosHeader.isDosSignature()) { if (dosHeader.isDosSignature()) {
try { try {
@ -57,7 +55,7 @@ public class NewExecutable {
* Returns the underlying binary reader. * Returns the underlying binary reader.
* @return the underlying binary reader * @return the underlying binary reader
*/ */
public FactoryBundledWithBinaryReader getBinaryReader() { public BinaryReader getBinaryReader() {
return reader; return reader;
} }
/** /**

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,11 +15,11 @@
*/ */
package ghidra.app.util.bin.format.ne; package ghidra.app.util.bin.format.ne;
import ghidra.app.util.bin.format.*;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader;
/** /**
* A class to represent the new-executable non-resident name table. * A class to represent the new-executable non-resident name table.
* *
@ -36,7 +35,7 @@ public class NonResidentNameTable {
* @param index the index where the non-resident name table begins * @param index the index where the non-resident name table begins
* @param byteCount the number of bytes in the non-resident name table * @param byteCount the number of bytes in the non-resident name table
*/ */
NonResidentNameTable(FactoryBundledWithBinaryReader reader, int index, short byteCount) throws IOException { NonResidentNameTable(BinaryReader reader, int index, short byteCount) throws IOException {
long oldIndex = reader.getPointerIndex(); long oldIndex = reader.getPointerIndex();
reader.setPointerIndex(index); reader.setPointerIndex(index);

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,12 +15,12 @@
*/ */
package ghidra.app.util.bin.format.ne; package ghidra.app.util.bin.format.ne;
import ghidra.app.util.bin.format.*;
import ghidra.util.Conv;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent the new-executable resident name table. * A class to represent the new-executable resident name table.
* *
@ -29,7 +28,7 @@ import java.util.ArrayList;
public class ResidentNameTable { public class ResidentNameTable {
private LengthStringOrdinalSet [] names; private LengthStringOrdinalSet [] names;
ResidentNameTable(FactoryBundledWithBinaryReader reader, short index) throws IOException { ResidentNameTable(BinaryReader reader, short index) throws IOException {
long oldIndex = reader.getPointerIndex(); long oldIndex = reader.getPointerIndex();
reader.setPointerIndex(Conv.shortToInt(index)); reader.setPointerIndex(Conv.shortToInt(index));

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv; import ghidra.util.Conv;
/** /**
@ -33,7 +33,7 @@ public class Resource {
/**The resource is preloaded.*/ /**The resource is preloaded.*/
public final static short FLAG_PRELOAD = 0x0040; public final static short FLAG_PRELOAD = 0x0040;
private FactoryBundledWithBinaryReader reader; private BinaryReader reader;
private ResourceTable rt; private ResourceTable rt;
private short fileOffset; //this value must be shifted private short fileOffset; //this value must be shifted
private short fileLength; //this value must be shifted private short fileLength; //this value must be shifted
@ -42,7 +42,7 @@ public class Resource {
private short handle; //reserved private short handle; //reserved
private short usage; //reserved private short usage; //reserved
Resource(FactoryBundledWithBinaryReader reader, ResourceTable rt) throws IOException { Resource(BinaryReader reader, ResourceTable rt) throws IOException {
this.reader = reader; this.reader = reader;
this.rt = rt; this.rt = rt;
fileOffset = reader.readNextShort(); fileOffset = reader.readNextShort();

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,10 +15,10 @@
*/ */
package ghidra.app.util.bin.format.ne; package ghidra.app.util.bin.format.ne;
import ghidra.app.util.bin.format.*;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
/** /**
* A class for storing new-executable resource names. * A class for storing new-executable resource names.
* *
@ -33,7 +32,7 @@ public class ResourceName {
* Constructs a resource name. * Constructs a resource name.
* @param reader the binary reader * @param reader the binary reader
*/ */
ResourceName(FactoryBundledWithBinaryReader reader) throws IOException { ResourceName(BinaryReader reader) throws IOException {
index = reader.getPointerIndex(); index = reader.getPointerIndex();
lns = new LengthStringSet(reader); lns = new LengthStringSet(reader);

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,12 +15,12 @@
*/ */
package ghidra.app.util.bin.format.ne; package ghidra.app.util.bin.format.ne;
import ghidra.app.util.bin.format.*;
import ghidra.util.Conv;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class for storing new-executable resource string tables. * A class for storing new-executable resource string tables.
* Strings are not stored as individual resources, rather * Strings are not stored as individual resources, rather
@ -38,7 +37,7 @@ public class ResourceStringTable extends Resource {
* @param reader the binary reade * @param reader the binary reade
* @param rt the resource table where this resource string table is defined * @param rt the resource table where this resource string table is defined
*/ */
ResourceStringTable(FactoryBundledWithBinaryReader reader, ResourceTable rt) throws IOException { ResourceStringTable(BinaryReader reader, ResourceTable rt) throws IOException {
super(reader, rt); super(reader, rt);
byte [] bytes = getBytes(); byte [] bytes = getBytes();

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,12 +15,12 @@
*/ */
package ghidra.app.util.bin.format.ne; package ghidra.app.util.bin.format.ne;
import ghidra.app.util.bin.format.*;
import ghidra.util.Conv;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class for storing the new-executable resource table. * A class for storing the new-executable resource table.
* A resource table contains all of the supported types * A resource table contains all of the supported types
@ -41,7 +40,7 @@ public class ResourceTable {
* @param index the byte index where the Resource Table begins, * @param index the byte index where the Resource Table begins,
* (this is relative to the beginning of the file * (this is relative to the beginning of the file
*/ */
ResourceTable(FactoryBundledWithBinaryReader reader, short index) throws IOException { ResourceTable(BinaryReader reader, short index) throws IOException {
this.index = index; this.index = index;
long oldIndex = reader.getPointerIndex(); long oldIndex = reader.getPointerIndex();

View file

@ -18,7 +18,7 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv; import ghidra.util.Conv;
/** /**
@ -69,7 +69,7 @@ public class ResourceType {
* @param reader the binary reader * @param reader the binary reader
* @param rt the resource table * @param rt the resource table
*/ */
ResourceType(FactoryBundledWithBinaryReader reader, ResourceTable rt) throws IOException { ResourceType(BinaryReader reader, ResourceTable rt) throws IOException {
typeID = reader.readNextShort(); typeID = reader.readNextShort();
if (typeID == 0) { if (typeID == 0) {
return; //not a valid resource type... return; //not a valid resource type...

View file

@ -15,12 +15,12 @@
*/ */
package ghidra.app.util.bin.format.ne; package ghidra.app.util.bin.format.ne;
import ghidra.app.util.bin.format.*;
import ghidra.util.Conv;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent a new-executable segment. * A class to represent a new-executable segment.
* *
@ -50,7 +50,7 @@ public class Segment {
/**segment is 32 bit */ /**segment is 32 bit */
private final static short FLAG_32BIT = (short) 0x2000; private final static short FLAG_32BIT = (short) 0x2000;
private FactoryBundledWithBinaryReader reader; private BinaryReader reader;
private int segmentID; private int segmentID;
private short offset; //byte offset to content, relative to BOF (zero means no file data) private short offset; //byte offset to content, relative to BOF (zero means no file data)
private short length; //length of segment in file (zero means 64k) private short length; //length of segment in file (zero means 64k)
@ -60,7 +60,7 @@ public class Segment {
private short nRelocations; //number of relocations private short nRelocations; //number of relocations
private SegmentRelocation [] relocations; //relocation records private SegmentRelocation [] relocations; //relocation records
Segment(FactoryBundledWithBinaryReader reader, short segmentAlignment, int segmentID) throws IOException { Segment(BinaryReader reader, short segmentAlignment, int segmentID) throws IOException {
this.reader = reader; this.reader = reader;
this.segmentID = segmentID; this.segmentID = segmentID;

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,10 +15,10 @@
*/ */
package ghidra.app.util.bin.format.ne; package ghidra.app.util.bin.format.ne;
import ghidra.app.util.bin.format.*;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader;
/** /**
* A class to represent a new-executable segment relocation. * A class to represent a new-executable segment relocation.
* *
@ -102,7 +101,7 @@ public class SegmentRelocation {
* Constucts a new segment relocation. * Constucts a new segment relocation.
* @param reader the binary reader * @param reader the binary reader
*/ */
SegmentRelocation(FactoryBundledWithBinaryReader reader, int segment) throws IOException { SegmentRelocation(BinaryReader reader, int segment) throws IOException {
this.segment = segment; this.segment = segment;
type = reader.readNextByte(); type = reader.readNextByte();
flagbyte = reader.readNextByte(); flagbyte = reader.readNextByte();

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.program.model.address.SegmentedAddress; import ghidra.program.model.address.SegmentedAddress;
import ghidra.program.model.address.SegmentedAddressSpace; import ghidra.program.model.address.SegmentedAddressSpace;
import ghidra.util.Conv; import ghidra.util.Conv;
@ -29,8 +29,8 @@ import ghidra.util.Conv;
public class SegmentTable { public class SegmentTable {
private Segment [] segments; private Segment [] segments;
SegmentTable(FactoryBundledWithBinaryReader reader, SegmentedAddress baseAddr, short index, SegmentTable(BinaryReader reader, SegmentedAddress baseAddr, short index, short segmentCount,
short segmentCount, short shiftAlignCount) throws IOException { short shiftAlignCount) throws IOException {
long oldIndex = reader.getPointerIndex(); long oldIndex = reader.getPointerIndex();
reader.setPointerIndex(Conv.shortToInt(index)); reader.setPointerIndex(Conv.shortToInt(index));

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.program.model.address.SegmentedAddress; import ghidra.program.model.address.SegmentedAddress;
/** /**
@ -48,7 +48,7 @@ public class WindowsHeader {
* the specified index do not constitute a valid windows header. * the specified index do not constitute a valid windows header.
* @throws IOException for problems reading the header bytes * @throws IOException for problems reading the header bytes
*/ */
public WindowsHeader(FactoryBundledWithBinaryReader reader, SegmentedAddress baseAddr, public WindowsHeader(BinaryReader reader, SegmentedAddress baseAddr,
short index) throws InvalidWindowsHeaderException, IOException { short index) throws InvalidWindowsHeaderException, IOException {
this.infoBlock = new InformationBlock(reader, index); this.infoBlock = new InformationBlock(reader, index);

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.pe;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
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.data.*; import ghidra.program.model.data.*;
@ -32,22 +32,9 @@ public class ArchitectureDataDirectory extends DataDirectory {
private String copyright; private String copyright;
static ArchitectureDataDirectory createArchitectureDataDirectory( ArchitectureDataDirectory(NTHeader ntHeader, BinaryReader reader) throws IOException {
NTHeader ntHeader, FactoryBundledWithBinaryReader reader)
throws IOException {
ArchitectureDataDirectory architectureDataDirectory = (ArchitectureDataDirectory) reader.getFactory().create(ArchitectureDataDirectory.class);
architectureDataDirectory.initArchitectureDataDirectory(ntHeader, reader);
return architectureDataDirectory;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public ArchitectureDataDirectory() {}
private void initArchitectureDataDirectory(NTHeader ntHeader, FactoryBundledWithBinaryReader reader) throws IOException {
processDataDirectory(ntHeader, reader); processDataDirectory(ntHeader, reader);
} }
@Override @Override
public String getDirectoryName() { public String getDirectoryName() {

View file

@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import ghidra.app.util.bin.*; import ghidra.app.util.bin.*;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.DataConverter; import ghidra.util.DataConverter;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -85,33 +84,20 @@ public class BaseRelocation implements StructConverter, ByteArrayConverter {
private int sizeOfBlock; private int sizeOfBlock;
private List<TypeOffset> typeOffsetList = new ArrayList<TypeOffset>(); private List<TypeOffset> typeOffsetList = new ArrayList<TypeOffset>();
static BaseRelocation createBaseRelocation( BaseRelocation(BinaryReader reader, int index) throws IOException {
FactoryBundledWithBinaryReader reader, int index) virtualAddress = reader.readInt(index); index += BinaryReader.SIZEOF_INT;
throws IOException { sizeOfBlock = reader.readInt(index); index += BinaryReader.SIZEOF_INT;
BaseRelocation baseRelocation = (BaseRelocation) reader.getFactory().create(BaseRelocation.class); if (virtualAddress < 0) return;
baseRelocation.initBaseRelocation(reader, index); if (sizeOfBlock < 0 || sizeOfBlock > NTHeader.MAX_SANE_COUNT) return;
return baseRelocation;
}
/** int len = (sizeOfBlock-IMAGE_SIZEOF_BASE_RELOCATION)/BinaryReader.SIZEOF_SHORT;
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public BaseRelocation() {}
private void initBaseRelocation(FactoryBundledWithBinaryReader reader, int index) throws IOException { for (int i = 0 ; i < len ; ++i) {
virtualAddress = reader.readInt(index); index += BinaryReader.SIZEOF_INT; short typeOffset = reader.readShort(index);
sizeOfBlock = reader.readInt(index); index += BinaryReader.SIZEOF_INT; index += BinaryReader.SIZEOF_SHORT;
if (virtualAddress < 0) return;
if (sizeOfBlock < 0 || sizeOfBlock > NTHeader.MAX_SANE_COUNT) return;
int len = (sizeOfBlock-IMAGE_SIZEOF_BASE_RELOCATION)/BinaryReader.SIZEOF_SHORT; typeOffsetList.add(new TypeOffset(typeOffset));
}
for (int i = 0 ; i < len ; ++i) {
short typeOffset = reader.readShort(index);
index += BinaryReader.SIZEOF_SHORT;
typeOffsetList.add(new TypeOffset(typeOffset));
}
} }
BaseRelocation(int virtualAddress) { BaseRelocation(int virtualAddress) {

View file

@ -19,8 +19,8 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.ByteArrayConverter; import ghidra.app.util.bin.ByteArrayConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
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.data.*; import ghidra.program.model.data.*;
@ -38,23 +38,11 @@ public class BaseRelocationDataDirectory extends DataDirectory implements ByteAr
private BaseRelocation [] relocs; private BaseRelocation [] relocs;
static BaseRelocationDataDirectory createBaseRelocationDataDirectory( BaseRelocationDataDirectory(NTHeader ntHeader, BinaryReader reader) throws IOException {
NTHeader ntHeader, FactoryBundledWithBinaryReader reader)
throws IOException {
BaseRelocationDataDirectory baseRelocationDataDirectory = (BaseRelocationDataDirectory) reader.getFactory().create(BaseRelocationDataDirectory.class);
baseRelocationDataDirectory.initBaseRelocationDataDirectory(ntHeader, reader);
return baseRelocationDataDirectory;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public BaseRelocationDataDirectory() {}
private void initBaseRelocationDataDirectory(NTHeader ntHeader, FactoryBundledWithBinaryReader reader) throws IOException {
processDataDirectory(ntHeader, reader); processDataDirectory(ntHeader, reader);
if (relocs == null) relocs = new BaseRelocation[0]; if (relocs == null)
} relocs = new BaseRelocation[0];
}
@Override @Override
public String getDirectoryName() { public String getDirectoryName() {
@ -107,7 +95,7 @@ public class BaseRelocationDataDirectory extends DataDirectory implements ByteAr
while (true) { while (true) {
if (addr >= stop) break; if (addr >= stop) break;
BaseRelocation br = BaseRelocation.createBaseRelocation(reader, addr); BaseRelocation br = new BaseRelocation(reader, addr);
// Sanity check to make sure the data looks OK. // Sanity check to make sure the data looks OK.
if (br.getVirtualAddress() == 0) if (br.getVirtualAddress() == 0)

View file

@ -19,7 +19,7 @@ import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import java.util.*; import java.util.*;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
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.AddressSpace; import ghidra.program.model.address.AddressSpace;
@ -40,20 +40,7 @@ public class BoundImportDataDirectory extends DataDirectory {
private BoundImportDescriptor [] descriptors; private BoundImportDescriptor [] descriptors;
private LinkedHashMap<String,Short> nameHash; private LinkedHashMap<String,Short> nameHash;
static BoundImportDataDirectory createBoundImportDataDirectory( BoundImportDataDirectory(NTHeader ntHeader, BinaryReader reader) throws IOException {
NTHeader ntHeader, FactoryBundledWithBinaryReader reader)
throws IOException {
BoundImportDataDirectory boundImportDataDirectory = (BoundImportDataDirectory) reader.getFactory().create(BoundImportDataDirectory.class);
boundImportDataDirectory.initBoundImportDataDirectory(ntHeader, reader);
return boundImportDataDirectory;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public BoundImportDataDirectory() {}
private void initBoundImportDataDirectory(NTHeader ntHeader, FactoryBundledWithBinaryReader reader) throws IOException {
processDataDirectory(ntHeader, reader); processDataDirectory(ntHeader, reader);
if (descriptors == null) descriptors = new BoundImportDescriptor[0]; if (descriptors == null) descriptors = new BoundImportDescriptor[0];
@ -134,7 +121,7 @@ public class BoundImportDataDirectory extends DataDirectory {
Msg.error(this, "Invalid file index "+ptr); Msg.error(this, "Invalid file index "+ptr);
break; break;
} }
BoundImportDescriptor bid = BoundImportDescriptor.createBoundImportDescriptor(reader, ptr, rva); BoundImportDescriptor bid = new BoundImportDescriptor(reader, ptr, rva);
if (bid.getTimeDateStamp() == 0) break; if (bid.getTimeDateStamp() == 0) break;
if (bid.getNumberOfModuleForwarderRefs() < 0) break; if (bid.getNumberOfModuleForwarderRefs() < 0) break;

View file

@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import ghidra.app.util.bin.*; import ghidra.app.util.bin.*;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.*; import ghidra.util.*;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -56,35 +55,29 @@ public class BoundImportDescriptor implements StructConverter, ByteArrayConverte
private List<BoundImportForwarderRef> forwarders = new ArrayList<BoundImportForwarderRef>(); private List<BoundImportForwarderRef> forwarders = new ArrayList<BoundImportForwarderRef>();
static BoundImportDescriptor createBoundImportDescriptor( BoundImportDescriptor(BinaryReader reader, int readerIndex, int biddIndex) throws IOException {
FactoryBundledWithBinaryReader reader, int readerIndex, timeDateStamp = reader.readInt(readerIndex);
int biddIndex) throws IOException { readerIndex += BinaryReader.SIZEOF_INT;
BoundImportDescriptor boundImportDescriptor = (BoundImportDescriptor) reader.getFactory().create(BoundImportDescriptor.class); offsetModuleName = reader.readShort(readerIndex);
boundImportDescriptor.initBoundImportDescriptor(reader, readerIndex, biddIndex); readerIndex += BinaryReader.SIZEOF_SHORT;
return boundImportDescriptor; numberOfModuleForwarderRefs = reader.readShort(readerIndex);
readerIndex += BinaryReader.SIZEOF_SHORT;
if (offsetModuleName < 0) {
Msg.error(this, "Invalid offsetModuleName " + offsetModuleName);
return;
}
moduleName = reader.readAsciiString(biddIndex + offsetModuleName);
for (int i = 0; i < numberOfModuleForwarderRefs; ++i) {
forwarders.add(new BoundImportForwarderRef(reader, readerIndex, biddIndex));
readerIndex += BoundImportForwarderRef.IMAGE_SIZEOF_BOUND_IMPORT_FORWARDER_REF;
}
} }
/** BoundImportDescriptor() {
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public BoundImportDescriptor() {}
private void initBoundImportDescriptor(FactoryBundledWithBinaryReader reader, int readerIndex, int biddIndex) throws IOException { }
timeDateStamp = reader.readInt (readerIndex); readerIndex += BinaryReader.SIZEOF_INT;
offsetModuleName = reader.readShort(readerIndex); readerIndex += BinaryReader.SIZEOF_SHORT;
numberOfModuleForwarderRefs = reader.readShort(readerIndex); readerIndex += BinaryReader.SIZEOF_SHORT;
if (offsetModuleName < 0) {
Msg.error(this, "Invalid offsetModuleName "+offsetModuleName);
return;
}
moduleName = reader.readAsciiString(biddIndex + offsetModuleName);
for (int i = 0 ; i < numberOfModuleForwarderRefs ; ++i) {
forwarders.add(BoundImportForwarderRef.createBoundImportForwarderRef(reader, readerIndex, biddIndex));
readerIndex += BoundImportForwarderRef.IMAGE_SIZEOF_BOUND_IMPORT_FORWARDER_REF;
}
}
public BoundImportDescriptor(String name, int timeDateStamp) { public BoundImportDescriptor(String name, int timeDateStamp) {
this.moduleName = name; this.moduleName = name;

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.pe;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.*; import ghidra.app.util.bin.*;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.DataConverter; import ghidra.util.DataConverter;
import ghidra.util.Msg; import ghidra.util.Msg;
@ -58,20 +57,8 @@ public class BoundImportForwarderRef implements StructConverter, ByteArrayConver
* @param readerIndex the index into the binary reader * @param readerIndex the index into the binary reader
* @param biddIndex the index where the bound import data directory begins * @param biddIndex the index where the bound import data directory begins
*/ */
static BoundImportForwarderRef createBoundImportForwarderRef( BoundImportForwarderRef(BinaryReader reader, int readerIndex, int biddIndex)
FactoryBundledWithBinaryReader reader, int readerIndex, throws IOException {
int biddIndex) throws IOException {
BoundImportForwarderRef boundImportForwarderRef = (BoundImportForwarderRef) reader.getFactory().create(BoundImportForwarderRef.class);
boundImportForwarderRef.initBoundImportForwarderRef(reader, readerIndex, biddIndex);
return boundImportForwarderRef;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public BoundImportForwarderRef() {}
private void initBoundImportForwarderRef(FactoryBundledWithBinaryReader reader, int readerIndex, int biddIndex) throws IOException {
timeDateStamp = reader.readInt (readerIndex); readerIndex += BinaryReader.SIZEOF_INT; timeDateStamp = reader.readInt (readerIndex); readerIndex += BinaryReader.SIZEOF_INT;
offsetModuleName = reader.readShort(readerIndex); readerIndex += BinaryReader.SIZEOF_SHORT; offsetModuleName = reader.readShort(readerIndex); readerIndex += BinaryReader.SIZEOF_SHORT;
reserved = reader.readShort(readerIndex); readerIndex += BinaryReader.SIZEOF_SHORT; reserved = reader.readShort(readerIndex); readerIndex += BinaryReader.SIZEOF_SHORT;

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.pe;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
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.data.*; import ghidra.program.model.data.*;
@ -35,23 +35,7 @@ public class COMDescriptorDataDirectory extends DataDirectory {
private ImageCor20Header header; private ImageCor20Header header;
static COMDescriptorDataDirectory createCOMDescriptorDataDirectory(NTHeader ntHeader, COMDescriptorDataDirectory(NTHeader ntHeader, BinaryReader reader) throws IOException {
FactoryBundledWithBinaryReader reader) throws IOException {
COMDescriptorDataDirectory comDescriptorDataDirectory =
(COMDescriptorDataDirectory) reader.getFactory().create(
COMDescriptorDataDirectory.class);
comDescriptorDataDirectory.initCOMDescriptorDataDirectory(ntHeader, reader);
return comDescriptorDataDirectory;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public COMDescriptorDataDirectory() {
}
private void initCOMDescriptorDataDirectory(NTHeader ntHeader,
FactoryBundledWithBinaryReader reader) throws IOException {
this.ntHeader = ntHeader; this.ntHeader = ntHeader;
processDataDirectory(ntHeader, reader); processDataDirectory(ntHeader, reader);
} }
@ -72,7 +56,7 @@ public class COMDescriptorDataDirectory extends DataDirectory {
return false; return false;
} }
header = ImageCor20Header.createImageCor20Header(reader, ptr, ntHeader); header = new ImageCor20Header(reader, ptr, ntHeader);
boolean ret = false; boolean ret = false;
if (ntHeader.shouldParseCliHeaders()) { if (ntHeader.shouldParseCliHeaders()) {

View file

@ -18,8 +18,8 @@ package ghidra.app.util.bin.format.pe;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;
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.data.DataType; import ghidra.program.model.data.DataType;
@ -54,12 +54,12 @@ public abstract class DataDirectory implements StructConverter, PeMarkupable {
public final static byte IMAGE_SIZEOF_IMAGE_DIRECTORY_ENTRY = 8; public final static byte IMAGE_SIZEOF_IMAGE_DIRECTORY_ENTRY = 8;
protected NTHeader ntHeader; protected NTHeader ntHeader;
protected FactoryBundledWithBinaryReader reader; protected BinaryReader reader;
protected int virtualAddress; protected int virtualAddress;
protected int size; protected int size;
protected boolean hasParsed = false; protected boolean hasParsed = false;
protected void processDataDirectory(NTHeader ntHeader, FactoryBundledWithBinaryReader reader) protected void processDataDirectory(NTHeader ntHeader, BinaryReader reader)
throws IOException { throws IOException {
this.ntHeader = ntHeader; this.ntHeader = ntHeader;
this.reader = reader; this.reader = reader;

View file

@ -18,7 +18,7 @@ package ghidra.app.util.bin.format.pe;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.format.pdb.PdbInfoCodeView; import ghidra.app.util.bin.format.pdb.PdbInfoCodeView;
import ghidra.app.util.bin.format.pdb.PdbInfoDotNet; import ghidra.app.util.bin.format.pdb.PdbInfoDotNet;
import ghidra.app.util.bin.format.pe.debug.*; import ghidra.app.util.bin.format.pe.debug.*;
@ -41,22 +41,9 @@ public class DebugDataDirectory extends DataDirectory {
private DebugDirectoryParser parser; private DebugDirectoryParser parser;
static DebugDataDirectory createDebugDataDirectory( DebugDataDirectory(NTHeader ntHeader, BinaryReader reader) throws IOException {
NTHeader ntHeader, FactoryBundledWithBinaryReader reader)
throws IOException {
DebugDataDirectory debugDataDirectory = (DebugDataDirectory) reader.getFactory().create(DebugDataDirectory.class);
debugDataDirectory.initDebugDataDirectory(ntHeader, reader);
return debugDataDirectory;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DebugDataDirectory() {}
private void initDebugDataDirectory(NTHeader ntHeader, FactoryBundledWithBinaryReader reader) throws IOException {
processDataDirectory(ntHeader, reader); processDataDirectory(ntHeader, reader);
} }
@Override @Override
public String getDirectoryName() { public String getDirectoryName() {
@ -70,7 +57,7 @@ public class DebugDataDirectory extends DataDirectory {
return false; return false;
} }
parser = DebugDirectoryParser.createDebugDirectoryParser(reader, ptr, size, ntHeader); parser = new DebugDirectoryParser(reader, ptr, size, ntHeader);
return true; return true;
} }

View file

@ -17,7 +17,7 @@ package ghidra.app.util.bin.format.pe;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
@ -26,22 +26,9 @@ import ghidra.util.task.TaskMonitor;
public class DefaultDataDirectory extends DataDirectory { public class DefaultDataDirectory extends DataDirectory {
static DefaultDataDirectory createDefaultDataDirectory( DefaultDataDirectory(NTHeader ntHeader, BinaryReader reader) throws IOException {
NTHeader ntHeader, FactoryBundledWithBinaryReader reader)
throws IOException {
DefaultDataDirectory defaultDataDirectory = (DefaultDataDirectory) reader.getFactory().create(DefaultDataDirectory.class);
defaultDataDirectory.initDefaultDataDirectory(ntHeader, reader);
return defaultDataDirectory;
}
/**
* DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
*/
public DefaultDataDirectory() {}
private void initDefaultDataDirectory(NTHeader ntHeader, FactoryBundledWithBinaryReader reader) throws IOException {
processDataDirectory(ntHeader, reader); processDataDirectory(ntHeader, reader);
} }
@Override @Override
public String getDirectoryName() { public String getDirectoryName() {

Some files were not shown because too many files have changed in this diff Show more