mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-08-08 07:40:39 -09:00
GP-7104: More deprecations
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
import java.io.*;
|
||||
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.util.Conv;
|
||||
import ghidra.util.NumericUtilities;
|
||||
|
||||
public class BinaryToAsciiScript extends GhidraScript {
|
||||
|
||||
@@ -81,7 +81,7 @@ public class BinaryToAsciiScript extends GhidraScript {
|
||||
out.append('\n');
|
||||
}
|
||||
|
||||
out.write(Conv.toHexString(buffer[i]));
|
||||
out.write(NumericUtilities.toPaddedHexString(buffer[i]));
|
||||
|
||||
++bytesWritten;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package ghidra.app.util.bin.format.ne;
|
||||
import java.io.IOException;
|
||||
|
||||
import ghidra.app.util.bin.BinaryReader;
|
||||
import ghidra.util.Conv;
|
||||
import ghidra.util.NumericUtilities;
|
||||
|
||||
/**
|
||||
* An implementation of the new-executable TNAMEINFO structure.
|
||||
@@ -176,6 +176,6 @@ public class Resource {
|
||||
if (resourceID >= 0 && resourceID < names.length) {
|
||||
return names[resourceID].getName();
|
||||
}
|
||||
return ("NE - Resource - unknown id - " + Conv.toHexString(resourceID));
|
||||
return ("NE - Resource - unknown id - " + NumericUtilities.toPaddedHexString(resourceID));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* 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.
|
||||
@@ -25,7 +25,7 @@ import ghidra.app.util.bin.StructConverter;
|
||||
import ghidra.app.util.bin.format.pe.debug.DebugCodeViewConstants;
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.util.Conv;
|
||||
import ghidra.util.NumericUtilities;
|
||||
|
||||
/**
|
||||
* Older style pdb information, using a simple 32bit hash to link the pdb to its binary.
|
||||
@@ -91,7 +91,8 @@ public class PdbInfoCodeView implements StructConverter, PdbInfo {
|
||||
public void serializeToOptions(Options options) {
|
||||
options.setString(PdbParserConstants.PDB_VERSION,
|
||||
new String(magic, StandardCharsets.US_ASCII));
|
||||
options.setString(PdbParserConstants.PDB_SIGNATURE, Conv.toHexString(sig));
|
||||
options.setString(PdbParserConstants.PDB_SIGNATURE,
|
||||
NumericUtilities.toPaddedHexString(sig));
|
||||
options.setString(PdbParserConstants.PDB_AGE, Integer.toHexString(age));
|
||||
options.setString(PdbParserConstants.PDB_FILE, pdbName);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* 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.
|
||||
@@ -167,21 +167,21 @@ public class GUID {
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(Conv.toHexString(data1));
|
||||
sb.append(NumericUtilities.toPaddedHexString(data1));
|
||||
sb.append("-");
|
||||
sb.append(Conv.toHexString(data2));
|
||||
sb.append(NumericUtilities.toPaddedHexString(data2));
|
||||
sb.append("-");
|
||||
sb.append(Conv.toHexString(data3));
|
||||
sb.append(NumericUtilities.toPaddedHexString(data3));
|
||||
sb.append("-");
|
||||
sb.append(Conv.toHexString(data4[0]));
|
||||
sb.append(Conv.toHexString(data4[1]));
|
||||
sb.append(NumericUtilities.toPaddedHexString(data4[0]));
|
||||
sb.append(NumericUtilities.toPaddedHexString(data4[1]));
|
||||
sb.append("-");
|
||||
sb.append(Conv.toHexString(data4[2]));
|
||||
sb.append(Conv.toHexString(data4[3]));
|
||||
sb.append(Conv.toHexString(data4[4]));
|
||||
sb.append(Conv.toHexString(data4[5]));
|
||||
sb.append(Conv.toHexString(data4[6]));
|
||||
sb.append(Conv.toHexString(data4[7]));
|
||||
sb.append(NumericUtilities.toPaddedHexString(data4[2]));
|
||||
sb.append(NumericUtilities.toPaddedHexString(data4[3]));
|
||||
sb.append(NumericUtilities.toPaddedHexString(data4[4]));
|
||||
sb.append(NumericUtilities.toPaddedHexString(data4[5]));
|
||||
sb.append(NumericUtilities.toPaddedHexString(data4[6]));
|
||||
sb.append(NumericUtilities.toPaddedHexString(data4[7]));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import ghidra.docking.settings.Settings;
|
||||
import ghidra.docking.settings.SettingsDefinition;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.mem.MemBuffer;
|
||||
import ghidra.util.Conv;
|
||||
import ghidra.util.DataConverter;
|
||||
import ghidra.util.NumericUtilities;
|
||||
import ghidra.util.classfinder.ClassTranslator;
|
||||
|
||||
/**
|
||||
@@ -126,17 +126,17 @@ public class GuidDataType extends BuiltIn {
|
||||
}
|
||||
|
||||
String retVal;
|
||||
retVal = Conv.toHexString((int) data[0]) + delim;
|
||||
retVal += Conv.toHexString((short) (data[1])) + delim;
|
||||
retVal += Conv.toHexString((short) (data[1] >> 16)) + delim;
|
||||
retVal = NumericUtilities.toPaddedHexString((int) data[0]) + delim;
|
||||
retVal += NumericUtilities.toPaddedHexString((short) (data[1])) + delim;
|
||||
retVal += NumericUtilities.toPaddedHexString((short) (data[1] >> 16)) + delim;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
retVal += Conv.toHexString((byte) (data[2] >> i * 8));
|
||||
retVal += NumericUtilities.toPaddedHexString((byte) (data[2] >> i * 8));
|
||||
if (i == 1) {
|
||||
retVal += delim;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
retVal += Conv.toHexString((byte) (data[3] >> i * 8));
|
||||
retVal += NumericUtilities.toPaddedHexString((byte) (data[3] >> i * 8));
|
||||
}
|
||||
// retVal = retVal.toUpperCase();
|
||||
if (guidName == null) {
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* 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.
|
||||
@@ -226,17 +226,17 @@ public class GuidUtil {
|
||||
}
|
||||
|
||||
String guidString;
|
||||
guidString = Conv.toHexString((int) data[0]) + delim;
|
||||
guidString += Conv.toHexString((short) (data[1])) + delim;
|
||||
guidString += Conv.toHexString((short) (data[1] >> 16)) + delim;
|
||||
guidString = NumericUtilities.toPaddedHexString((int) data[0]) + delim;
|
||||
guidString += NumericUtilities.toPaddedHexString((short) (data[1])) + delim;
|
||||
guidString += NumericUtilities.toPaddedHexString((short) (data[1] >> 16)) + delim;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
guidString += Conv.toHexString((byte) (data[2] >> i * 8));
|
||||
guidString += NumericUtilities.toPaddedHexString((byte) (data[2] >> i * 8));
|
||||
if (i == 1) {
|
||||
guidString += delim;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
guidString += Conv.toHexString((byte) (data[3] >> i * 8));
|
||||
guidString += NumericUtilities.toPaddedHexString((byte) (data[3] >> i * 8));
|
||||
}
|
||||
// retVal = retVal.toUpperCase();
|
||||
if (validate && !NewGuid.isOKForGUID(bytes, 0)) {
|
||||
@@ -268,17 +268,17 @@ public class GuidUtil {
|
||||
}
|
||||
|
||||
String guidString;
|
||||
guidString = Conv.toHexString((int) data[0]) + delim;
|
||||
guidString += Conv.toHexString((short) (data[1])) + delim;
|
||||
guidString += Conv.toHexString((short) (data[1] >> 16)) + delim;
|
||||
guidString = NumericUtilities.toPaddedHexString((int) data[0]) + delim;
|
||||
guidString += NumericUtilities.toPaddedHexString((short) (data[1])) + delim;
|
||||
guidString += NumericUtilities.toPaddedHexString((short) (data[1] >> 16)) + delim;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
guidString += Conv.toHexString((byte) (data[2] >> i * 8));
|
||||
guidString += NumericUtilities.toPaddedHexString((byte) (data[2] >> i * 8));
|
||||
if (i == 1) {
|
||||
guidString += delim;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
guidString += Conv.toHexString((byte) (data[3] >> i * 8));
|
||||
guidString += NumericUtilities.toPaddedHexString((byte) (data[3] >> i * 8));
|
||||
}
|
||||
// retVal = retVal.toUpperCase();
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
/* ###
|
||||
* 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.
|
||||
@@ -88,15 +87,15 @@ public class NewGuid {
|
||||
return name;
|
||||
}
|
||||
String retVal = type.toString()+delim;
|
||||
retVal += Conv.toHexString((int)data[0])+delim;
|
||||
retVal += Conv.toHexString((short)(data[1]))+delim;
|
||||
retVal += Conv.toHexString((short)(data[1]>>16))+delim;
|
||||
retVal += NumericUtilities.toPaddedHexString((int)data[0])+delim;
|
||||
retVal += NumericUtilities.toPaddedHexString((short)(data[1]))+delim;
|
||||
retVal += NumericUtilities.toPaddedHexString((short)(data[1]>>16))+delim;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
retVal += Conv.toHexString((byte)(data[2]>>i*8));
|
||||
retVal += NumericUtilities.toPaddedHexString((byte)(data[2]>>i*8));
|
||||
if (i == 1) retVal += delim;
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
retVal += Conv.toHexString((byte)(data[3]>>i*8));
|
||||
retVal += NumericUtilities.toPaddedHexString((byte)(data[3]>>i*8));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ import ghidra.program.model.data.StringDataType;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||
import ghidra.util.Conv;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.NumericUtilities;
|
||||
import ghidra.util.exception.InvalidInputException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
@@ -496,7 +496,8 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
|
||||
Options proplist = program.getOptions(Program.PROGRAM_INFO);
|
||||
|
||||
proplist.setString("Debug Misc", actualData);
|
||||
proplist.setString("Debug Misc Datatype", "0x" + Conv.toHexString(datatype));
|
||||
proplist.setString("Debug Misc Datatype",
|
||||
"0x" + NumericUtilities.toPaddedHexString(datatype));
|
||||
}
|
||||
|
||||
private void addLineComment(Address addr, int line) {
|
||||
|
||||
@@ -40,8 +40,8 @@ import ghidra.program.model.reloc.Relocation.Status;
|
||||
import ghidra.program.model.reloc.RelocationTable;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||
import ghidra.util.Conv;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.NumericUtilities;
|
||||
import ghidra.util.exception.*;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
@@ -205,33 +205,33 @@ public class NeLoader extends AbstractOrdinalSupportLoader {
|
||||
|
||||
buffer.append("Title: " + nrnt.getTitle() + "\n");
|
||||
buffer.append("Format: " + "New Executable (NE) Windows" + "\n");
|
||||
buffer.append("CRC: " + Conv.toHexString(ib.getChecksum()) + "\n");
|
||||
buffer.append("CRC: " + NumericUtilities.toPaddedHexString(ib.getChecksum()) + "\n");
|
||||
buffer.append("\n");
|
||||
buffer.append(
|
||||
"Program Entry Point (CS:IP): " + Conv.toHexString(ib.getEntryPointSegment()) + ":" +
|
||||
Conv.toHexString(ib.getEntryPointOffset()) + "\n");
|
||||
"Program Entry Point (CS:IP): " + NumericUtilities.toPaddedHexString(ib.getEntryPointSegment()) + ":" +
|
||||
NumericUtilities.toPaddedHexString(ib.getEntryPointOffset()) + "\n");
|
||||
buffer.append(
|
||||
"Initial Stack Pointer (SS:SP): " + Conv.toHexString(ib.getStackPointerSegment()) +
|
||||
":" + Conv.toHexString(ib.getStackPointerOffset()) + "\n");
|
||||
"Initial Stack Pointer (SS:SP): " + NumericUtilities.toPaddedHexString(ib.getStackPointerSegment()) +
|
||||
":" + NumericUtilities.toPaddedHexString(ib.getStackPointerOffset()) + "\n");
|
||||
buffer.append("Auto Data Segment Index: " +
|
||||
Conv.toHexString(ib.getAutomaticDataSegment()) + "\n");
|
||||
NumericUtilities.toPaddedHexString(ib.getAutomaticDataSegment()) + "\n");
|
||||
buffer.append(
|
||||
"Initial Heap Size: " + Conv.toHexString(ib.getInitialHeapSize()) + "\n");
|
||||
"Initial Heap Size: " + NumericUtilities.toPaddedHexString(ib.getInitialHeapSize()) + "\n");
|
||||
buffer.append(
|
||||
"Initial Stack Size: " + Conv.toHexString(ib.getInitialStackSize()) + "\n");
|
||||
"Initial Stack Size: " + NumericUtilities.toPaddedHexString(ib.getInitialStackSize()) + "\n");
|
||||
buffer.append(
|
||||
"Minimum Code Swap Size: " + Conv.toHexString(ib.getMinCodeSwapSize()) + "\n");
|
||||
"Minimum Code Swap Size: " + NumericUtilities.toPaddedHexString(ib.getMinCodeSwapSize()) + "\n");
|
||||
buffer.append("\n");
|
||||
buffer.append("Linker Version: " + ib.getVersion() + "." + ib.getRevision() + "\n");
|
||||
buffer.append("Target OS: " + ib.getTargetOpSysAsString() + "\n");
|
||||
buffer.append("Windows Version: " + (ib.getExpectedWindowsVersion() >> 8) + "." +
|
||||
(ib.getExpectedWindowsVersion() & 0xff) + "\n");
|
||||
buffer.append("\n");
|
||||
buffer.append("Program Flags: " + Conv.toHexString(ib.getProgramFlags()) + "\n");
|
||||
buffer.append("Program Flags: " + NumericUtilities.toPaddedHexString(ib.getProgramFlags()) + "\n");
|
||||
buffer.append(ib.getProgramFlagsAsString());
|
||||
buffer.append("Application Flags: " + Conv.toHexString(ib.getApplicationFlags()) + "\n");
|
||||
buffer.append("Application Flags: " + NumericUtilities.toPaddedHexString(ib.getApplicationFlags()) + "\n");
|
||||
buffer.append(ib.getApplicationFlagsAsString());
|
||||
buffer.append("Other Flags: " + Conv.toHexString(ib.getOtherFlags()) + "\n");
|
||||
buffer.append("Other Flags: " + NumericUtilities.toPaddedHexString(ib.getOtherFlags()) + "\n");
|
||||
buffer.append(ib.getOtherFlagsAsString());
|
||||
|
||||
firstCU.setComment(CommentType.PLATE, buffer.toString());
|
||||
@@ -297,11 +297,11 @@ public class NeLoader extends AbstractOrdinalSupportLoader {
|
||||
StringBuffer buff = new StringBuffer();
|
||||
buff.append("Segment: " + (i + 1) + "\n");
|
||||
buff.append(
|
||||
"Offset: " + Conv.toHexString(segments[i].getOffsetShiftAligned()) + "\n");
|
||||
buff.append("Length: " + Conv.toHexString(segments[i].getLength()) + "\n");
|
||||
"Offset: " + NumericUtilities.toPaddedHexString(segments[i].getOffsetShiftAligned()) + "\n");
|
||||
buff.append("Length: " + NumericUtilities.toPaddedHexString(segments[i].getLength()) + "\n");
|
||||
buff.append(
|
||||
"Min Alloc: " + Conv.toHexString(segments[i].getMinAllocSize()) + "\n");
|
||||
buff.append("Flags: " + Conv.toHexString(segments[i].getFlagword()) + "\n");
|
||||
"Min Alloc: " + NumericUtilities.toPaddedHexString(segments[i].getMinAllocSize()) + "\n");
|
||||
buff.append("Flags: " + NumericUtilities.toPaddedHexString(segments[i].getFlagword()) + "\n");
|
||||
buff.append(TAB + (segments[i].isCode() ? "Code" : "Data") + "\n");
|
||||
buff.append((segments[i].isDiscardable() ? TAB + "Discardable" + "\n" : ""));
|
||||
buff.append((segments[i].isExecuteOnly() ? TAB + "Execute Only" + "\n" : ""));
|
||||
@@ -371,13 +371,13 @@ public class NeLoader extends AbstractOrdinalSupportLoader {
|
||||
|
||||
//create a comment to describe this resource...
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("Resource Type: " + Conv.toHexString(type.getTypeID()) + " (" + type +
|
||||
buf.append("Resource Type: " + NumericUtilities.toPaddedHexString(type.getTypeID()) + " (" + type +
|
||||
")" + "\n");
|
||||
buf.append(
|
||||
"File Length: " + Conv.toHexString(resource.getFileLengthShifted()) + "\n");
|
||||
"File Length: " + NumericUtilities.toPaddedHexString(resource.getFileLengthShifted()) + "\n");
|
||||
buf.append(
|
||||
"File Offset: " + Conv.toHexString(resource.getFileOffsetShifted()) + "\n");
|
||||
buf.append("Attributes: " + Conv.toHexString(resource.getFlagword()) + " (");
|
||||
"File Offset: " + NumericUtilities.toPaddedHexString(resource.getFileOffsetShifted()) + "\n");
|
||||
buf.append("Attributes: " + NumericUtilities.toPaddedHexString(resource.getFlagword()) + " (");
|
||||
if (resource.isMoveable()) {
|
||||
buf.append("Moveable");
|
||||
}
|
||||
@@ -389,8 +389,8 @@ public class NeLoader extends AbstractOrdinalSupportLoader {
|
||||
}
|
||||
buf.append(")" + "\n");
|
||||
buf.append("Resource ID: " + resource + "\n");
|
||||
buf.append("Handle: " + Conv.toHexString(resource.getHandle()) + "\n");
|
||||
buf.append("Usage: " + Conv.toHexString(resource.getUsage()) + "\n");
|
||||
buf.append("Handle: " + NumericUtilities.toPaddedHexString(resource.getHandle()) + "\n");
|
||||
buf.append("Usage: " + NumericUtilities.toPaddedHexString(resource.getUsage()) + "\n");
|
||||
CodeUnit cu = listing.getCodeUnitAt(addr);
|
||||
if (cu != null) {
|
||||
cu.setComment(CommentType.PRE, buf.toString());
|
||||
|
||||
@@ -43,13 +43,18 @@ import ghidra.program.model.lang.LanguageCompilerSpecPair;
|
||||
import ghidra.program.model.lang.LanguageService;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.util.Conv;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.NumericUtilities;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.exception.CryptoException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
@FileSystemInfo(type = MachoPrelinkFileSystem.IOS_PRELINK_FSTYPE, description = MachoPrelinkConstants.TITLE, priority = FileSystemInfo.PRIORITY_HIGH, factory = GFileSystemBaseFactory.class)
|
||||
@FileSystemInfo(
|
||||
type = MachoPrelinkFileSystem.IOS_PRELINK_FSTYPE,
|
||||
description = MachoPrelinkConstants.TITLE,
|
||||
priority = FileSystemInfo.PRIORITY_HIGH,
|
||||
factory = GFileSystemBaseFactory.class
|
||||
)
|
||||
public class MachoPrelinkFileSystem extends GFileSystemBase implements GFileSystemProgramProvider {
|
||||
|
||||
public final static String IOS_PRELINK_FSTYPE = "iosprelink";
|
||||
@@ -89,7 +94,8 @@ public class MachoPrelinkFileSystem extends GFileSystemBase implements GFileSyst
|
||||
List<Long> machoHeaderOffsets =
|
||||
MachoPrelinkUtils.findPrelinkMachoHeaderOffsets(provider, monitor);
|
||||
try {
|
||||
List<MachoPrelinkMap> prelinkList = MachoPrelinkUtils.parsePrelinkXml(provider, monitor);
|
||||
List<MachoPrelinkMap> prelinkList =
|
||||
MachoPrelinkUtils.parsePrelinkXml(provider, monitor);
|
||||
if (!prelinkList.isEmpty()) {
|
||||
processPrelinkWithMacho(prelinkList, machoHeaderOffsets, monitor);
|
||||
}
|
||||
@@ -249,8 +255,9 @@ public class MachoPrelinkFileSystem extends GFileSystemBase implements GFileSyst
|
||||
monitor.setMessage("Processing PRELINK with found Mach-O headers...");
|
||||
monitor.initialize(prelinkList.size());
|
||||
|
||||
BidiMap<MachoPrelinkMap, Long> map = MachoPrelinkUtils.matchPrelinkToMachoHeaderOffsets(provider,
|
||||
prelinkList, machoHeaderOffsets, monitor);
|
||||
BidiMap<MachoPrelinkMap, Long> map =
|
||||
MachoPrelinkUtils.matchPrelinkToMachoHeaderOffsets(provider,
|
||||
prelinkList, machoHeaderOffsets, monitor);
|
||||
|
||||
for (MachoPrelinkMap info : map.keySet()) {
|
||||
|
||||
@@ -298,8 +305,10 @@ public class MachoPrelinkFileSystem extends GFileSystemBase implements GFileSyst
|
||||
continue;
|
||||
}
|
||||
|
||||
Address address = systemProgram.getAddressFactory().getDefaultAddressSpace().getAddress(
|
||||
prelinkMap.getPrelinkExecutableLoadAddr());
|
||||
Address address = systemProgram.getAddressFactory()
|
||||
.getDefaultAddressSpace()
|
||||
.getAddress(
|
||||
prelinkMap.getPrelinkExecutableLoadAddr());
|
||||
|
||||
ByteProvider systemKextProvider =
|
||||
new MemoryByteProvider(systemProgram.getMemory(), address);
|
||||
@@ -310,8 +319,9 @@ public class MachoPrelinkFileSystem extends GFileSystemBase implements GFileSyst
|
||||
//MachoLoader loader = new MachoLoader();
|
||||
//loader.load( machHeader, systemProgram, new MessageLog(), monitor );
|
||||
|
||||
Namespace namespace = systemProgram.getSymbolTable().createNameSpace(null,
|
||||
file.getName(), SourceType.IMPORTED);
|
||||
Namespace namespace = systemProgram.getSymbolTable()
|
||||
.createNameSpace(null,
|
||||
file.getName(), SourceType.IMPORTED);
|
||||
|
||||
List<SymbolTableCommand> commands =
|
||||
machHeader.getLoadCommands(SymbolTableCommand.class);
|
||||
@@ -404,7 +414,8 @@ public class MachoPrelinkFileSystem extends GFileSystemBase implements GFileSyst
|
||||
if (monitor.isCancelled()) {
|
||||
break;
|
||||
}
|
||||
String kextName = "Kext_0x" + Conv.toHexString(machoHeaderOffset) + ".kext";
|
||||
String kextName =
|
||||
"Kext_0x" + NumericUtilities.toPaddedHexString(machoHeaderOffset) + ".kext";
|
||||
try {
|
||||
MachHeader header = new MachHeader(provider, machoHeaderOffset);
|
||||
header.parse();
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
*/
|
||||
package ghidra.util;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Legacy methods for converting between number data types without negative promotion. Most methods
|
||||
* have been deprecated off in favor of built-in Java methods.
|
||||
* Deprecated class set for removal. Do not use.
|
||||
*/
|
||||
@Deprecated(since = "12.2", forRemoval = true)
|
||||
public class Conv {
|
||||
|
||||
private Conv() {
|
||||
@@ -26,67 +28,66 @@ public class Conv {
|
||||
}
|
||||
|
||||
/**
|
||||
* Consider using {@link String#format(String, Object...) String.format("%02x", b)} instead.
|
||||
* <p>
|
||||
* Converts a byte into a padded hex string.
|
||||
* {@return a byte converted into a padded hex string}
|
||||
*
|
||||
* @param b the byte
|
||||
* @return the padded hex string
|
||||
* @deprecated use {@link NumericUtilities#toPaddedHexString(byte)} instead
|
||||
*/
|
||||
@Deprecated(since = "12.2", forRemoval = true)
|
||||
public static String toHexString(byte b) {
|
||||
return String.format("%02x", b);
|
||||
return NumericUtilities.toPaddedHexString(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Consider using {@link String#format(String, Object...) String.format("%04x", s)} instead.
|
||||
* <p>
|
||||
* Converts a short into a padded hex string.
|
||||
* {@return a short converted into a padded hex string}
|
||||
*
|
||||
* @param s the short
|
||||
* @return the padded hex string
|
||||
* @deprecated use {@link NumericUtilities#toPaddedHexString(short)} instead
|
||||
*/
|
||||
@Deprecated(since = "12.2", forRemoval = true)
|
||||
public static String toHexString(short s) {
|
||||
return String.format("%04x", s);
|
||||
return NumericUtilities.toPaddedHexString(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Consider using {@link String#format(String, Object...) String.format("%08x", i)} instead.
|
||||
* <p>
|
||||
* Converts an integer into a padded hex string.
|
||||
* {@return an int converted into a padded hex string}
|
||||
*
|
||||
* @param i the integer
|
||||
* @return the padded hex string
|
||||
* @param i the int
|
||||
* @deprecated use {@link NumericUtilities#toPaddedHexString(int)} instead
|
||||
*/
|
||||
@Deprecated(since = "12.2", forRemoval = true)
|
||||
public static String toHexString(int i) {
|
||||
return String.format("%08x", i);
|
||||
return NumericUtilities.toPaddedHexString(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Consider using {@link String#format(String, Object...) String.format("%016x", l)} instead.
|
||||
* <p>
|
||||
* Converts a long into a padded hex string.
|
||||
* {@return a long converted into a padded hex string}
|
||||
*
|
||||
* @param l the long
|
||||
* @return the padded hex string
|
||||
* @deprecated use {@link NumericUtilities#toPaddedHexString(long)} instead
|
||||
*/
|
||||
@Deprecated(since = "12.2", forRemoval = true)
|
||||
public static String toHexString(long l) {
|
||||
return String.format("%016x", l);
|
||||
return NumericUtilities.toPaddedHexString(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string that is extended to length len with zeroes.
|
||||
* {@return a string that is extended to length {@code len} with zeroes}
|
||||
*
|
||||
* @param s The string to pad
|
||||
* @param len The length of the return string
|
||||
* @return A string that has been left-padded with zeros to be of length len
|
||||
* @deprecated use {@link StringUtils#leftPad(String, int, char)} instead
|
||||
*/
|
||||
@Deprecated(since = "12.2", forRemoval = true)
|
||||
public static String zeropad(String s, int len) {
|
||||
if (s == null) s = "";
|
||||
if (s == null) {
|
||||
s = "";
|
||||
}
|
||||
StringBuilder builder = new StringBuilder(s);
|
||||
int zerosNeeded = len - s.length();
|
||||
for (int i = 0 ; i < zerosNeeded ; ++i) {
|
||||
int zerosNeeded = len - s.length();
|
||||
for (int i = 0; i < zerosNeeded; ++i) {
|
||||
builder.insert(0, '0');
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,6 +330,42 @@ public final class NumericUtilities {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return a byte converted into a padded hex string}
|
||||
*
|
||||
* @param b the byte
|
||||
*/
|
||||
public static String toPaddedHexString(byte b) {
|
||||
return "%02x".formatted(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return a short converted into a padded hex string}
|
||||
*
|
||||
* @param s the short
|
||||
*/
|
||||
public static String toPaddedHexString(short s) {
|
||||
return "%04x".formatted(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return an int converted into a padded hex string}
|
||||
*
|
||||
* @param i the int
|
||||
*/
|
||||
public static String toPaddedHexString(int i) {
|
||||
return "%08x".formatted(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return a long converted into a padded hex string}
|
||||
*
|
||||
* @param l the long
|
||||
*/
|
||||
public static String toPaddedHexString(long l) {
|
||||
return "%016x".formatted(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a <strong>unsigned</strong> long value, which is currently stored in a java
|
||||
* <strong>signed</strong> long, into a {@link BigInteger}.
|
||||
|
||||
Reference in New Issue
Block a user