GP-0: Fixing deprecated calls to Conv

This commit is contained in:
Ryan Kurtz 2025-06-13 08:30:19 -04:00
parent 412bd0ffc1
commit 5ac69075e3
55 changed files with 225 additions and 285 deletions

View file

@ -32,7 +32,6 @@ import ghidra.app.util.bin.format.pe.PortableExecutable;
import ghidra.app.util.bin.format.pe.PortableExecutable.SectionLayout; import ghidra.app.util.bin.format.pe.PortableExecutable.SectionLayout;
import ghidra.app.util.bin.format.pe.RichHeader; import ghidra.app.util.bin.format.pe.RichHeader;
import ghidra.app.util.bin.format.pe.rich.*; import ghidra.app.util.bin.format.pe.rich.*;
import ghidra.util.Conv;
public class PortableExecutableRichPrintScript extends GhidraScript { public class PortableExecutableRichPrintScript extends GhidraScript {
@ -170,7 +169,7 @@ public class PortableExecutableRichPrintScript extends GhidraScript {
data[0x3d] = 0; data[0x3d] = 0;
for (int i = 0; i < DOSHeader.SIZEOF_DOS_HEADER + programLength; i++) { for (int i = 0; i < DOSHeader.SIZEOF_DOS_HEADER + programLength; i++) {
int b = data[i] & Conv.BYTE_MASK; int b = Byte.toUnsignedInt(data[i]);
checksum += rol32(b, (i & 0x1f)); checksum += rol32(b, (i & 0x1f));
} }
return checksum; return checksum;

View file

@ -22,8 +22,6 @@ import javax.swing.KeyStroke;
import docking.action.*; import docking.action.*;
import ghidra.app.context.ListingActionContext; import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction; import ghidra.app.context.ListingContextAction;
import ghidra.program.database.symbol.CodeSymbol;
import ghidra.program.database.symbol.FunctionSymbol;
import ghidra.program.model.symbol.*; import ghidra.program.model.symbol.*;
/** /**

View file

@ -19,7 +19,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader; 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.
@ -37,7 +36,7 @@ public class EntryTable {
*/ */
EntryTable(BinaryReader 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(Short.toUnsignedInt(index));
ArrayList<EntryTableBundle> list = new ArrayList<EntryTableBundle>(); ArrayList<EntryTableBundle> list = new ArrayList<EntryTableBundle>();
while (true) { while (true) {

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent a new-executable entry table bundle. * A class to represent a new-executable entry table bundle.
@ -55,7 +54,7 @@ public class EntryTableBundle {
type = reader.readNextByte(); type = reader.readNextByte();
if (type == 0) return; //unused bundle... if (type == 0) return; //unused bundle...
int count_int = Conv.byteToInt(count); int count_int = Byte.toUnsignedInt(count);
entryPoints = new EntryPoint[count_int]; entryPoints = new EntryPoint[count_int];
for (int i = 0 ; i < count_int ; ++i) { for (int i = 0 ; i < count_int ; ++i) {

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent the new-executable imported name table. * A class to represent the new-executable imported name table.
@ -49,7 +48,7 @@ public class ImportedNameTable {
*/ */
public LengthStringSet getNameAt(short offset) throws IOException { public LengthStringSet getNameAt(short offset) throws IOException {
long oldIndex = reader.getPointerIndex(); long oldIndex = reader.getPointerIndex();
int newIndex = Conv.shortToInt(index)+Conv.shortToInt(offset); int newIndex = Short.toUnsignedInt(index) + Short.toUnsignedInt(offset);
reader.setPointerIndex(newIndex); reader.setPointerIndex(newIndex);
LengthStringSet lss = new LengthStringSet(reader); LengthStringSet lss = new LengthStringSet(reader);
reader.setPointerIndex(oldIndex); reader.setPointerIndex(oldIndex);

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* <p> * <p>
@ -198,7 +197,7 @@ public class InformationBlock {
InformationBlock(BinaryReader 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(Short.toUnsignedInt(index));
ne_magic = reader.readNextShort(); ne_magic = reader.readNextShort();

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.ne;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; 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,
@ -34,16 +33,17 @@ public class LengthStringSet {
private String name; private String name;
/** /**
* Constructs a new length/string set. * Constructs a new length/string set.
* @param reader the binary reader * @param reader the binary reader
*/ * @throws IOException if there was an IO-related error
*/
LengthStringSet(BinaryReader reader) throws IOException { LengthStringSet(BinaryReader reader) throws IOException {
index = reader.getPointerIndex(); index = reader.getPointerIndex();
length = reader.readNextByte(); length = reader.readNextByte();
if (length == 0) return; if (length == 0) return;
name = reader.readNextAsciiString(Conv.byteToInt(length)); //not null-terminated name = reader.readNextAsciiString(Byte.toUnsignedInt(length)); //not null-terminated
} }
/** /**

View file

@ -19,7 +19,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader; 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.
@ -40,9 +39,9 @@ public class ModuleReferenceTable {
ModuleReferenceTable(BinaryReader reader, short index, short count, ImportedNameTable imp) ModuleReferenceTable(BinaryReader reader, short index, short count, ImportedNameTable imp)
throws IOException { throws IOException {
long oldIndex = reader.getPointerIndex(); long oldIndex = reader.getPointerIndex();
reader.setPointerIndex(Conv.shortToInt(index)); reader.setPointerIndex(Short.toUnsignedInt(index));
offsets = new short[Conv.shortToInt(count)]; offsets = new short[Short.toUnsignedInt(count)];
for (short i = 0 ; i < count ; ++i) { for (short i = 0 ; i < count ; ++i) {
offsets[i] = reader.readNextShort(); offsets[i] = reader.readNextShort();
} }

View file

@ -19,7 +19,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader; 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.
@ -30,7 +29,7 @@ public class ResidentNameTable {
ResidentNameTable(BinaryReader 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(Short.toUnsignedInt(index));
ArrayList<LengthStringOrdinalSet> list = new ArrayList<LengthStringOrdinalSet>(); ArrayList<LengthStringOrdinalSet> list = new ArrayList<LengthStringOrdinalSet>();
while (true) { while (true) {

View file

@ -131,8 +131,8 @@ public class Resource {
* @return the shifted file offset of this resource * @return the shifted file offset of this resource
*/ */
public int getFileOffsetShifted() { public int getFileOffsetShifted() {
int shift_int = Conv.shortToInt(rt.getAlignmentShiftCount()); int shift_int = Short.toUnsignedInt(rt.getAlignmentShiftCount());
int offset_int = Conv.shortToInt(fileOffset); int offset_int = Short.toUnsignedInt(fileOffset);
return offset_int << shift_int; return offset_int << shift_int;
} }
@ -142,8 +142,8 @@ public class Resource {
* @return the shifted file length of this resource * @return the shifted file length of this resource
*/ */
public int getFileLengthShifted() { public int getFileLengthShifted() {
int shift_int = Conv.shortToInt(rt.getAlignmentShiftCount()); int shift_int = Short.toUnsignedInt(rt.getAlignmentShiftCount());
int length_int = Conv.shortToInt(fileLength); int length_int = Short.toUnsignedInt(fileLength);
return length_int << shift_int; return length_int << shift_int;
} }

View file

@ -19,7 +19,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader; 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.
@ -33,9 +32,10 @@ public class ResourceStringTable extends Resource {
private LengthStringSet [] strings; private LengthStringSet [] strings;
/** /**
* Constucts a new resource string table. * Constructs a new resource string table.
* @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
* @throws IOException if there was an IO-related error
*/ */
ResourceStringTable(BinaryReader reader, ResourceTable rt) throws IOException { ResourceStringTable(BinaryReader reader, ResourceTable rt) throws IOException {
super(reader, rt); super(reader, rt);
@ -49,7 +49,7 @@ public class ResourceStringTable extends Resource {
LengthStringSet lss = new LengthStringSet(reader); LengthStringSet lss = new LengthStringSet(reader);
if (lss.getLength() == 0) break; if (lss.getLength() == 0) break;
list.add(lss); list.add(lss);
i += (Conv.byteToInt(lss.getLength())+1); i += (Byte.toUnsignedInt(lss.getLength()) + 1);
reader.setPointerIndex(oldIndex); reader.setPointerIndex(oldIndex);
} }
else { else {

View file

@ -19,7 +19,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader; 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.
@ -44,7 +43,7 @@ public class ResourceTable {
this.index = index; this.index = index;
long oldIndex = reader.getPointerIndex(); long oldIndex = reader.getPointerIndex();
reader.setPointerIndex(Conv.shortToInt(index)); reader.setPointerIndex(Short.toUnsignedInt(index));
alignmentShiftCount = reader.readNextShort(); alignmentShiftCount = reader.readNextShort();

View file

@ -19,7 +19,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* An implementation of the TTYPEINFO structure. * An implementation of the TTYPEINFO structure.
@ -80,7 +79,7 @@ public class ResourceType {
ArrayList<Resource> list = new ArrayList<Resource>(); ArrayList<Resource> list = new ArrayList<Resource>();
int count_int = Conv.shortToInt(count); int count_int = Short.toUnsignedInt(count);
for (int i = 0; i < count_int; ++i) { for (int i = 0; i < count_int; ++i) {
if ((short) (typeID & 0x7fff) == RT_STRING) { if ((short) (typeID & 0x7fff) == RT_STRING) {
list.add(new ResourceStringTable(reader, rt)); list.add(new ResourceStringTable(reader, rt));

View file

@ -19,7 +19,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader; 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.
@ -69,11 +68,11 @@ public class Segment {
flagword = reader.readNextShort(); flagword = reader.readNextShort();
minAllocSize = reader.readNextShort(); minAllocSize = reader.readNextShort();
offsetAlign = Conv.shortToInt(offset) * Conv.shortToInt(segmentAlignment); offsetAlign = Short.toUnsignedInt(offset) * Short.toUnsignedInt(segmentAlignment);
ArrayList<SegmentRelocation> list = new ArrayList<SegmentRelocation>(); ArrayList<SegmentRelocation> list = new ArrayList<SegmentRelocation>();
if (hasRelocation()) { if (hasRelocation()) {
int relocPos = offsetAlign + Conv.shortToInt(length); int relocPos = offsetAlign + Short.toUnsignedInt(length);
long oldIndex = reader.getPointerIndex(); long oldIndex = reader.getPointerIndex();
reader.setPointerIndex(relocPos); reader.setPointerIndex(relocPos);

View file

@ -20,7 +20,6 @@ import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; 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;
/** /**
* A class to represent the new-executable segment table. * A class to represent the new-executable segment table.
@ -32,12 +31,12 @@ public class SegmentTable {
SegmentTable(BinaryReader reader, SegmentedAddress baseAddr, short index, short segmentCount, SegmentTable(BinaryReader reader, SegmentedAddress baseAddr, short index, 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(Short.toUnsignedInt(index));
//create a value of the shift count... //create a value of the shift count...
shiftAlignCount = (short)(0x01 << shiftAlignCount); shiftAlignCount = (short)(0x01 << shiftAlignCount);
int segmentCountInt = Conv.shortToInt(segmentCount); int segmentCountInt = Short.toUnsignedInt(segmentCount);
segments = new Segment[segmentCountInt]; segments = new Segment[segmentCountInt];

View file

@ -15,17 +15,16 @@
*/ */
package ghidra.app.util.bin.format.objc2; package ghidra.app.util.bin.format.objc2;
import java.io.IOException;
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.objectiveC.*; import ghidra.app.util.bin.format.objectiveC.*;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.symbol.Namespace; import ghidra.program.model.symbol.Namespace;
import ghidra.util.Conv;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
import java.io.IOException;
public class ObjectiveC2_ClassRW implements StructConverter { public class ObjectiveC2_ClassRW implements StructConverter {
public final static String NAME = "class_rw_t"; public final static String NAME = "class_rw_t";
@ -51,15 +50,15 @@ public class ObjectiveC2_ClassRW implements StructConverter {
this._index = reader.getPointerIndex(); this._index = reader.getPointerIndex();
if (state.is32bit) { if (state.is32bit) {
flags = reader.readNextInt() & Conv.INT_MASK; flags = reader.readNextUnsignedInt();
instanceStart = reader.readNextInt() & Conv.INT_MASK; instanceStart = reader.readNextUnsignedInt();
instanceSize = reader.readNextInt() & Conv.INT_MASK; instanceSize = reader.readNextUnsignedInt();
reserved = reader.readNextInt() & Conv.INT_MASK; reserved = reader.readNextUnsignedInt();
} }
else { else {
flags = reader.readNextLong(); flags = reader.readNextLong();
instanceStart = reader.readNextLong(); instanceStart = reader.readNextLong();
instanceSize = reader.readNextLong(); instanceSize = reader.readNextLong();
} }
readName(reader); readName(reader);

View file

@ -21,7 +21,6 @@ import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
import ghidra.program.model.data.TypedefDataType; import ghidra.program.model.data.TypedefDataType;
import ghidra.util.Conv;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
public class ObjectiveC2_Implementation implements StructConverter { public class ObjectiveC2_Implementation implements StructConverter {
@ -42,7 +41,7 @@ public class ObjectiveC2_Implementation implements StructConverter {
} }
else { else {
if (state.is32bit) { if (state.is32bit) {
imp = reader.readNextInt() & Conv.INT_MASK; imp = reader.readNextUnsignedInt();
} }
else { else {
imp = reader.readNextLong(); imp = reader.readNextLong();
@ -75,6 +74,7 @@ public class ObjectiveC2_Implementation implements StructConverter {
} }
public void applyTo() throws Exception { public void applyTo() throws Exception {
// do nothing
} }
} }

View file

@ -15,17 +15,16 @@
*/ */
package ghidra.app.util.bin.format.objc2; package ghidra.app.util.bin.format.objc2;
import java.io.IOException;
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.objectiveC.ObjectiveC1_Utilities; import ghidra.app.util.bin.format.objectiveC.ObjectiveC1_Utilities;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.symbol.Namespace; import ghidra.program.model.symbol.Namespace;
import ghidra.util.Conv;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
import java.io.IOException;
public class ObjectiveC2_InstanceVariable implements StructConverter { public class ObjectiveC2_InstanceVariable implements StructConverter {
private ObjectiveC2_State _state; private ObjectiveC2_State _state;
@ -39,7 +38,7 @@ public class ObjectiveC2_InstanceVariable implements StructConverter {
this._state = state; this._state = state;
if (state.is32bit) { if (state.is32bit) {
offset = reader.readNextInt() & Conv.INT_MASK; offset = reader.readNextUnsignedInt();
} }
else { else {
offset = reader.readNextLong(); offset = reader.readNextLong();

View file

@ -15,15 +15,14 @@
*/ */
package ghidra.app.util.bin.format.objc2; package ghidra.app.util.bin.format.objc2;
import java.io.IOException;
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.objectiveC.ObjectiveC1_Utilities; import ghidra.app.util.bin.format.objectiveC.ObjectiveC1_Utilities;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.Conv;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
import java.io.IOException;
public class ObjectiveC2_MessageReference implements StructConverter { public class ObjectiveC2_MessageReference implements StructConverter {
public static final String NAME = "message_ref"; public static final String NAME = "message_ref";
@ -40,7 +39,7 @@ public class ObjectiveC2_MessageReference implements StructConverter {
this._state = state; this._state = state;
if (state.is32bit) { if (state.is32bit) {
implementation = reader.readNextInt() & Conv.INT_MASK; implementation = reader.readNextUnsignedInt();
} }
else { else {
implementation = reader.readNextLong(); implementation = reader.readNextLong();

View file

@ -15,17 +15,16 @@
*/ */
package ghidra.app.util.bin.format.objc2; package ghidra.app.util.bin.format.objc2;
import java.io.IOException;
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.objectiveC.*; import ghidra.app.util.bin.format.objectiveC.*;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.symbol.Namespace; import ghidra.program.model.symbol.Namespace;
import ghidra.util.Conv;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
import java.io.IOException;
public class ObjectiveC2_Protocol implements StructConverter { public class ObjectiveC2_Protocol implements StructConverter {
public final static String NAME = "protocol_t"; public final static String NAME = "protocol_t";
@ -58,8 +57,8 @@ public class ObjectiveC2_Protocol implements StructConverter {
readInstanceProperties(reader); readInstanceProperties(reader);
if (state.is32bit) { if (state.is32bit) {
unknown0 = reader.readNextInt() & Conv.INT_MASK; unknown0 = reader.readNextUnsignedInt();
unknown1 = reader.readNextInt() & Conv.INT_MASK; unknown1 = reader.readNextUnsignedInt();
} }
else { else {
unknown0 = reader.readNextLong(); unknown0 = reader.readNextLong();

View file

@ -26,7 +26,6 @@ import ghidra.app.util.bin.format.objectiveC.ObjectiveC1_Utilities;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.program.model.symbol.Namespace; import ghidra.program.model.symbol.Namespace;
import ghidra.util.Conv;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
public class ObjectiveC2_ProtocolList implements StructConverter { public class ObjectiveC2_ProtocolList implements StructConverter {
@ -41,7 +40,7 @@ public class ObjectiveC2_ProtocolList implements StructConverter {
this._state = state; this._state = state;
this._index = reader.getPointerIndex(); this._index = reader.getPointerIndex();
long count = state.is32bit ? reader.readNextInt() & Conv.INT_MASK : reader.readNextLong(); long count = state.is32bit ? reader.readNextUnsignedInt() : reader.readNextLong();
for (long i = 0 ; i < count ; ++i) { for (long i = 0 ; i < count ; ++i) {
long protocolIndex = ObjectiveC1_Utilities.readNextIndex(reader, state.is32bit); long protocolIndex = ObjectiveC1_Utilities.readNextIndex(reader, state.is32bit);

View file

@ -25,7 +25,6 @@ import ghidra.program.model.listing.Program;
import ghidra.program.model.mem.Memory; import ghidra.program.model.mem.Memory;
import ghidra.program.model.mem.MemoryBlock; import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.model.symbol.*; import ghidra.program.model.symbol.*;
import ghidra.util.Conv;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
import ghidra.util.exception.InvalidInputException; import ghidra.util.exception.InvalidInputException;
@ -37,7 +36,7 @@ final class ObjectiveC2_Utilities {
*/ */
static long readNextIndex(BinaryReader reader, boolean is32bit) throws IOException { static long readNextIndex(BinaryReader reader, boolean is32bit) throws IOException {
if (is32bit) { if (is32bit) {
return reader.readNextInt() & Conv.INT_MASK; return reader.readNextUnsignedInt();
} }
return reader.readNextLong(); return reader.readNextLong();
} }

View file

@ -15,13 +15,12 @@
*/ */
package ghidra.app.util.bin.format.objectiveC; package ghidra.app.util.bin.format.objectiveC;
import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.Conv;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
import java.io.IOException;
public class ObjectiveC1_Method extends ObjectiveC_Method { public class ObjectiveC1_Method extends ObjectiveC_Method {
private String name; private String name;
private String signature; private String signature;
@ -45,7 +44,7 @@ public class ObjectiveC1_Method extends ObjectiveC_Method {
} }
@Override @Override
public long getImplementation() { public long getImplementation() {
return address & Conv.INT_MASK; return Integer.toUnsignedLong(address);
} }
@Override @Override

View file

@ -39,7 +39,8 @@ import ghidra.program.model.mem.Memory;
import ghidra.program.model.mem.MemoryBlock; import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.model.symbol.*; import ghidra.program.model.symbol.*;
import ghidra.program.model.util.CodeUnitInsertionException; import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.util.*; import ghidra.util.Msg;
import ghidra.util.StringUtilities;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
import ghidra.util.exception.InvalidInputException; import ghidra.util.exception.InvalidInputException;
@ -59,7 +60,7 @@ public final class ObjectiveC1_Utilities {
*/ */
public static long readNextIndex(BinaryReader reader, boolean is32bit) throws IOException { public static long readNextIndex(BinaryReader reader, boolean is32bit) throws IOException {
if (is32bit) { if (is32bit) {
return reader.readNextInt() & Conv.INT_MASK; return reader.readNextUnsignedInt();
} }
return reader.readNextLong(); return reader.readNextLong();
} }

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.pe.debug;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent the COFF Line number data structure. * A class to represent the COFF Line number data structure.
@ -47,7 +46,7 @@ public class DebugCOFFLineNumber {
symbolTableIndex = reader.readInt(index); symbolTableIndex = reader.readInt(index);
virtualAddress = reader.readInt(index); virtualAddress = reader.readInt(index);
index += BinaryReader.SIZEOF_INT; index += BinaryReader.SIZEOF_INT;
lineNumber = Conv.shortToInt(reader.readShort(index)); lineNumber = Short.toUnsignedInt(reader.readShort(index));
} }
/** /**

View file

@ -19,7 +19,6 @@ import java.io.IOException;
import ghidra.app.util.bin.*; import ghidra.app.util.bin.*;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.Conv;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
/** /**
@ -158,7 +157,7 @@ public class DebugCOFFSymbol implements StructConverter {
numberOfAuxSymbols = reader.readByte (index); index += BinaryReader.SIZEOF_BYTE; numberOfAuxSymbols = reader.readByte (index); index += BinaryReader.SIZEOF_BYTE;
// process auxiliary symbols... // process auxiliary symbols...
auxSymbols = new DebugCOFFSymbolAux[Conv.byteToInt(numberOfAuxSymbols)]; auxSymbols = new DebugCOFFSymbolAux[Byte.toUnsignedInt(numberOfAuxSymbols)];
for (int i = 0 ; i < numberOfAuxSymbols ; ++i) { for (int i = 0 ; i < numberOfAuxSymbols ; ++i) {

View file

@ -21,7 +21,6 @@ import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.StructConverter;
import ghidra.app.util.bin.format.pe.OffsetValidator; import ghidra.app.util.bin.format.pe.OffsetValidator;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
import ghidra.util.Conv;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
@ -68,7 +67,7 @@ public class DebugMisc implements StructConverter {
long oldIndex = reader.getPointerIndex(); long oldIndex = reader.getPointerIndex();
long index = debugDir.getPointerToRawData() & Conv.INT_MASK; long index = Integer.toUnsignedLong(debugDir.getPointerToRawData());
if (!validator.checkPointer(index)) { if (!validator.checkPointer(index)) {
Msg.error(this, "Invalid file index " + Long.toHexString(index)); Msg.error(this, "Invalid file index " + Long.toHexString(index));
return; return;

View file

@ -19,7 +19,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent the Object Module Format (OMF) File Index data structure. * A class to represent the Object Module Format (OMF) File Index data structure.
@ -51,31 +50,31 @@ public class OMFFileIndex {
cRef = reader.readShort(index); cRef = reader.readShort(index);
index += BinaryReader.SIZEOF_SHORT; index += BinaryReader.SIZEOF_SHORT;
modStart = new short[Conv.shortToInt(cMod)]; modStart = new short[Short.toUnsignedInt(cMod)];
for (int i = 0; i < cMod; ++i) { for (int i = 0; i < cMod; ++i) {
modStart[i] = reader.readShort(index); modStart[i] = reader.readShort(index);
index += BinaryReader.SIZEOF_SHORT; index += BinaryReader.SIZEOF_SHORT;
} }
cRefCnt = new short[Conv.shortToInt(cMod)]; cRefCnt = new short[Short.toUnsignedInt(cMod)];
for (int i = 0; i < cMod; i++) { for (int i = 0; i < cMod; i++) {
cRefCnt[i] = reader.readShort(index); cRefCnt[i] = reader.readShort(index);
index += BinaryReader.SIZEOF_SHORT; index += BinaryReader.SIZEOF_SHORT;
} }
nameRef = new int[Conv.shortToInt(cRef)]; nameRef = new int[Short.toUnsignedInt(cRef)];
for (int i = 0; i < cRef; ++i) { for (int i = 0; i < cRef; ++i) {
nameRef[i] = reader.readInt(index); nameRef[i] = reader.readInt(index);
index += BinaryReader.SIZEOF_INT; index += BinaryReader.SIZEOF_INT;
} }
ArrayList<String> namesList = new ArrayList<String>(); ArrayList<String> namesList = new ArrayList<String>();
for (int i = 0; i < Conv.shortToInt(cRef); ++i) { for (int i = 0; i < Short.toUnsignedInt(cRef); ++i) {
int nameIndex = index + nameRef[i]; int nameIndex = index + nameRef[i];
byte len = reader.readByte(nameIndex); byte len = reader.readByte(nameIndex);
nameIndex += BinaryReader.SIZEOF_BYTE; nameIndex += BinaryReader.SIZEOF_BYTE;
int length = Conv.byteToInt(len); int length = Byte.toUnsignedInt(len);
String name = reader.readAsciiString(nameIndex, length); String name = reader.readAsciiString(nameIndex, length);
namesList.add(name); namesList.add(name);

View file

@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent the Object Module Format (OMF) Global data structure. * A class to represent the Object Module Format (OMF) Global data structure.
@ -57,7 +56,7 @@ public class OMFGlobal {
if (sym != null) { if (sym != null) {
symbols.add(sym); symbols.add(sym);
int recLen = Conv.shortToInt(sym.getLength()); int recLen = Short.toUnsignedInt(sym.getLength());
bytesLeft -= recLen; bytesLeft -= recLen;
ptr += recLen - 2; ptr += recLen - 2;
} }

View file

@ -19,7 +19,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent the Object Module Format (OMF) Library data structure. * A class to represent the Object Module Format (OMF) Library data structure.
@ -34,7 +33,7 @@ public class OMFLibrary {
byte len = reader.readByte(ptr); byte len = reader.readByte(ptr);
ptr += BinaryReader.SIZEOF_BYTE; ptr += BinaryReader.SIZEOF_BYTE;
numBytes -= BinaryReader.SIZEOF_BYTE; numBytes -= BinaryReader.SIZEOF_BYTE;
int length = Conv.byteToInt(len); int length = Byte.toUnsignedInt(len);
String lib = reader.readAsciiString(ptr, length); String lib = reader.readAsciiString(ptr, length);
ptr += length; ptr += length;
numBytes -= length; numBytes -= length;

View file

@ -19,7 +19,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent the Object Module Format (OMF) Source Module data structure. * A class to represent the Object Module Format (OMF) Source Module data structure.
@ -55,29 +54,29 @@ public class OMFSrcModule {
cSeg = reader.readShort(index); cSeg = reader.readShort(index);
index += BinaryReader.SIZEOF_SHORT; index += BinaryReader.SIZEOF_SHORT;
baseSrcFile = new int[Conv.shortToInt(cFile)]; baseSrcFile = new int[Short.toUnsignedInt(cFile)];
for (int i = 0; i < Conv.shortToInt(cFile); ++i) { for (int i = 0; i < Short.toUnsignedInt(cFile); ++i) {
baseSrcFile[i] = reader.readInt(index); baseSrcFile[i] = reader.readInt(index);
index += BinaryReader.SIZEOF_INT; index += BinaryReader.SIZEOF_INT;
} }
starts = new int[Conv.shortToInt(cSeg)]; starts = new int[Short.toUnsignedInt(cSeg)];
ends = new int[Conv.shortToInt(cSeg)]; ends = new int[Short.toUnsignedInt(cSeg)];
for (int i = 0; i < Conv.shortToInt(cSeg); ++i) { for (int i = 0; i < Short.toUnsignedInt(cSeg); ++i) {
starts[i] = reader.readInt(index); starts[i] = reader.readInt(index);
index += BinaryReader.SIZEOF_INT; index += BinaryReader.SIZEOF_INT;
ends[i] = reader.readInt(index); ends[i] = reader.readInt(index);
index += BinaryReader.SIZEOF_INT; index += BinaryReader.SIZEOF_INT;
} }
segs = new short[Conv.shortToInt(cSeg)]; segs = new short[Short.toUnsignedInt(cSeg)];
for (int i = 0; i < Conv.shortToInt(cSeg); ++i) { for (int i = 0; i < Short.toUnsignedInt(cSeg); ++i) {
segs[i] = reader.readShort(index); segs[i] = reader.readShort(index);
index += BinaryReader.SIZEOF_SHORT; index += BinaryReader.SIZEOF_SHORT;
} }
for (int i = 0; i < Conv.shortToInt(cFile); ++i) { for (int i = 0; i < Short.toUnsignedInt(cFile); ++i) {
moduleFileList.add(new OMFSrcModuleFile(reader, ptr, ptr + baseSrcFile[i])); moduleFileList.add(new OMFSrcModuleFile(reader, ptr, ptr + baseSrcFile[i]));
} }
} }

View file

@ -15,12 +15,10 @@
*/ */
package ghidra.app.util.bin.format.pe.debug; package ghidra.app.util.bin.format.pe.debug;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent the Object Module Format (OMF) Source Module File data structure. * A class to represent the Object Module Format (OMF) Source Module File data structure.
@ -62,16 +60,16 @@ public class OMFSrcModuleFile {
pad = reader.readShort(index); pad = reader.readShort(index);
index += BinaryReader.SIZEOF_SHORT; index += BinaryReader.SIZEOF_SHORT;
baseSrcLn = new int[Conv.shortToInt(cSeg)]; baseSrcLn = new int[Short.toUnsignedInt(cSeg)];
for (int i = 0; i < cSeg; ++i) { for (int i = 0; i < cSeg; ++i) {
baseSrcLn[i] = reader.readInt(index); baseSrcLn[i] = reader.readInt(index);
index += BinaryReader.SIZEOF_INT; index += BinaryReader.SIZEOF_INT;
} }
starts = new int[Conv.shortToInt(cSeg)]; starts = new int[Short.toUnsignedInt(cSeg)];
ends = new int[Conv.shortToInt(cSeg)]; ends = new int[Short.toUnsignedInt(cSeg)];
for (int i = 0; i < Conv.shortToInt(cSeg); ++i) { for (int i = 0; i < Short.toUnsignedInt(cSeg); ++i) {
starts[i] = reader.readInt(index); starts[i] = reader.readInt(index);
index += BinaryReader.SIZEOF_INT; index += BinaryReader.SIZEOF_INT;
ends[i] = reader.readInt(index); ends[i] = reader.readInt(index);
@ -84,7 +82,7 @@ public class OMFSrcModuleFile {
name = reader.readAsciiString(index, Byte.toUnsignedInt(cbName)); name = reader.readAsciiString(index, Byte.toUnsignedInt(cbName));
index += Byte.toUnsignedInt(cbName); index += Byte.toUnsignedInt(cbName);
for (int i = 0; i < Conv.shortToInt(cSeg); ++i) { for (int i = 0; i < Short.toUnsignedInt(cSeg); ++i) {
//OMFSrcModuleLine line = new OMFSrcModuleLine(reader, index); //OMFSrcModuleLine line = new OMFSrcModuleLine(reader, index);
OMFSrcModuleLine line = new OMFSrcModuleLine(reader, moduleBase + baseSrcLn[i]); OMFSrcModuleLine line = new OMFSrcModuleLine(reader, moduleBase + baseSrcLn[i]);
moduleLineList.add(line); moduleLineList.add(line);

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.pe.debug;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent the Object Module Format (OMF) Source Module Line data structure. * A class to represent the Object Module Format (OMF) Source Module Line data structure.
@ -45,13 +44,13 @@ public class OMFSrcModuleLine {
seg = reader.readShort(index); index+=BinaryReader.SIZEOF_SHORT; seg = reader.readShort(index); index+=BinaryReader.SIZEOF_SHORT;
cPair = reader.readShort(index); index+=BinaryReader.SIZEOF_SHORT; cPair = reader.readShort(index); index+=BinaryReader.SIZEOF_SHORT;
offsets = new int[Conv.shortToInt(cPair)]; offsets = new int[Short.toUnsignedInt(cPair)];
for (int i = 0 ; i < Conv.shortToInt(cPair) ; ++i) { for (int i = 0 ; i < Short.toUnsignedInt(cPair) ; ++i) {
offsets[i] = reader.readInt(index); index+=BinaryReader.SIZEOF_INT; offsets[i] = reader.readInt(index); index+=BinaryReader.SIZEOF_INT;
} }
linenumbers = new short[Conv.shortToInt(cPair)]; linenumbers = new short[Short.toUnsignedInt(cPair)];
for (int i = 0 ; i < Conv.shortToInt(cPair) ; ++i) { for (int i = 0 ; i < Short.toUnsignedInt(cPair) ; ++i) {
linenumbers[i] = reader.readShort(index); index+=BinaryReader.SIZEOF_SHORT; linenumbers[i] = reader.readShort(index); index+=BinaryReader.SIZEOF_SHORT;
} }
} }

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.pe.debug;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
/** /**
* A class to represent the S_BPREL32_NEW data structure. * A class to represent the S_BPREL32_NEW data structure.
@ -41,7 +40,7 @@ public class S_BPREL32_NEW extends DebugSymbol {
byte nameLen = reader.readByte(ptr); byte nameLen = reader.readByte(ptr);
ptr += BinaryReader.SIZEOF_BYTE; ptr += BinaryReader.SIZEOF_BYTE;
name = reader.readAsciiString(ptr, Conv.byteToInt(nameLen)); name = reader.readAsciiString(ptr, Byte.toUnsignedInt(nameLen));
} }
/** /**

View file

@ -18,10 +18,10 @@ package ghidra.app.util.bin.format.pe.debug;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
class S_CONSTANT32 extends DebugSymbol { class S_CONSTANT32 extends DebugSymbol {
@SuppressWarnings("unused")
S_CONSTANT32(short length, short type, BinaryReader reader, int ptr) throws IOException { S_CONSTANT32(short length, short type, BinaryReader reader, int ptr) throws IOException {
processDebugSymbol(length, type); processDebugSymbol(length, type);
@ -33,7 +33,7 @@ class S_CONSTANT32 extends DebugSymbol {
byte nameLen = reader.readByte(ptr); byte nameLen = reader.readByte(ptr);
ptr += BinaryReader.SIZEOF_BYTE; ptr += BinaryReader.SIZEOF_BYTE;
name = reader.readAsciiString(ptr, Conv.byteToInt(nameLen)); name = reader.readAsciiString(ptr, Byte.toUnsignedInt(nameLen));
} }
} }

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.pe.debug;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
import ghidra.util.Msg; import ghidra.util.Msg;
class S_GDATA32_NEW extends DebugSymbol { class S_GDATA32_NEW extends DebugSymbol {
@ -37,7 +36,7 @@ class S_GDATA32_NEW extends DebugSymbol {
byte nameLen = reader.readByte(ptr); byte nameLen = reader.readByte(ptr);
ptr += BinaryReader.SIZEOF_BYTE; ptr += BinaryReader.SIZEOF_BYTE;
name = reader.readAsciiString(ptr, Conv.byteToInt(nameLen)); name = reader.readAsciiString(ptr, Byte.toUnsignedInt(nameLen));
Msg.debug(this, "S_DATA32_NEW: " + unknown); Msg.debug(this, "S_DATA32_NEW: " + unknown);
} }

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.pe.debug;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
import ghidra.util.Msg; import ghidra.util.Msg;
class S_LABEL32 extends DebugSymbol { class S_LABEL32 extends DebugSymbol {
@ -36,7 +35,7 @@ class S_LABEL32 extends DebugSymbol {
byte nameLen = reader.readByte(ptr); byte nameLen = reader.readByte(ptr);
ptr += BinaryReader.SIZEOF_BYTE; ptr += BinaryReader.SIZEOF_BYTE;
name = reader.readAsciiString(ptr, Conv.byteToInt(nameLen)); name = reader.readAsciiString(ptr, Byte.toUnsignedInt(nameLen));
Msg.debug(this, "Created label symbol: " + name); Msg.debug(this, "Created label symbol: " + name);
} }

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.pe.debug;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
class S_LDATA32_NEW extends DebugSymbol{ class S_LDATA32_NEW extends DebugSymbol{
private int reserved; private int reserved;
@ -35,13 +34,13 @@ class S_LDATA32_NEW extends DebugSymbol{
this.name = reader.readAsciiString(ptr, Byte.toUnsignedInt(nameLen)); this.name = reader.readAsciiString(ptr, Byte.toUnsignedInt(nameLen));
ptr += Byte.toUnsignedInt(nameLen); ptr += Byte.toUnsignedInt(nameLen);
int sizeOfPadding = Conv.shortToInt(length) - int sizeOfPadding = Short.toUnsignedInt(length) -
BinaryReader.SIZEOF_SHORT - BinaryReader.SIZEOF_SHORT -
BinaryReader.SIZEOF_INT - BinaryReader.SIZEOF_INT -
BinaryReader.SIZEOF_INT - BinaryReader.SIZEOF_INT -
BinaryReader.SIZEOF_SHORT - BinaryReader.SIZEOF_SHORT -
BinaryReader.SIZEOF_BYTE - BinaryReader.SIZEOF_BYTE -
Conv.byteToInt(nameLen); Byte.toUnsignedInt(nameLen);
padding = reader.readByteArray(ptr, sizeOfPadding); padding = reader.readByteArray(ptr, sizeOfPadding);
} }

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.pe.debug;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
class S_OBJNAME extends DebugSymbol { class S_OBJNAME extends DebugSymbol {
private int signature; private int signature;
@ -33,12 +32,12 @@ class S_OBJNAME extends DebugSymbol {
name = reader.readAsciiString(ptr, Byte.toUnsignedInt(nameLen)); name = reader.readAsciiString(ptr, Byte.toUnsignedInt(nameLen));
ptr += Byte.toUnsignedInt(nameLen) + 1; ptr += Byte.toUnsignedInt(nameLen) + 1;
int sizeOfPadding = BinaryReader.SIZEOF_SHORT+ int sizeOfPadding = BinaryReader.SIZEOF_SHORT +
BinaryReader.SIZEOF_INT+ BinaryReader.SIZEOF_INT +
BinaryReader.SIZEOF_INT+ BinaryReader.SIZEOF_INT +
BinaryReader.SIZEOF_INT+ BinaryReader.SIZEOF_INT +
BinaryReader.SIZEOF_BYTE+ BinaryReader.SIZEOF_BYTE +
Conv.byteToInt(nameLen)+1; Byte.toUnsignedInt(nameLen) + 1;
padding = reader.readByteArray(ptr, sizeOfPadding); padding = reader.readByteArray(ptr, sizeOfPadding);
} }

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.pe.debug;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
class S_PROCREF extends DebugSymbol { class S_PROCREF extends DebugSymbol {
private int module; private int module;
@ -39,9 +38,9 @@ class S_PROCREF extends DebugSymbol {
if (checksum == 0) { if (checksum == 0) {
byte nameLen = reader.readByte (ptr); ptr += BinaryReader.SIZEOF_BYTE; byte nameLen = reader.readByte (ptr); ptr += BinaryReader.SIZEOF_BYTE;
name = reader.readAsciiString(ptr, Conv.byteToInt(nameLen)); name = reader.readAsciiString(ptr, Byte.toUnsignedInt(nameLen));
ptr += Conv.byteToInt(nameLen); ptr += Byte.toUnsignedInt(nameLen);
int val = ptr & 0xf; int val = ptr & 0xf;

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.pe.debug;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
class S_UDT32 extends DebugSymbol { class S_UDT32 extends DebugSymbol {
private int checksum; private int checksum;
@ -35,7 +34,7 @@ class S_UDT32 extends DebugSymbol {
ptr += BinaryReader.SIZEOF_INT; ptr += BinaryReader.SIZEOF_INT;
this.typeLen = reader.readByte(ptr); this.typeLen = reader.readByte(ptr);
ptr += BinaryReader.SIZEOF_BYTE; ptr += BinaryReader.SIZEOF_BYTE;
this.name = reader.readAsciiString(ptr, Conv.byteToInt(typeLen)); this.name = reader.readAsciiString(ptr, Byte.toUnsignedInt(typeLen));
} }
public int getChecksum() { public int getChecksum() {

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.pe.debug;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
class S_UDT32_NEW extends DebugSymbol { class S_UDT32_NEW extends DebugSymbol {
private int symType; private int symType;
@ -32,7 +31,7 @@ class S_UDT32_NEW extends DebugSymbol {
byte nameLen = reader.readByte(ptr); byte nameLen = reader.readByte(ptr);
ptr += BinaryReader.SIZEOF_BYTE; ptr += BinaryReader.SIZEOF_BYTE;
name = reader.readAsciiString(ptr, Conv.byteToInt(nameLen)); name = reader.readAsciiString(ptr, Byte.toUnsignedInt(nameLen));
} }
/** /**

View file

@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.pe.debug;
import java.io.IOException; import java.io.IOException;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.BinaryReader;
import ghidra.util.Conv;
import ghidra.util.Msg; import ghidra.util.Msg;
class UnknownSymbol extends DebugSymbol{ class UnknownSymbol extends DebugSymbol{
@ -27,7 +26,7 @@ class UnknownSymbol extends DebugSymbol{
UnknownSymbol(short length, short type, BinaryReader reader, int ptr) throws IOException { UnknownSymbol(short length, short type, BinaryReader reader, int ptr) throws IOException {
processDebugSymbol(length, type); processDebugSymbol(length, type);
try { try {
unknown = reader.readByteArray(ptr, Conv.shortToInt(length)); unknown = reader.readByteArray(ptr, Short.toUnsignedInt(length));
} }
catch (RuntimeException e) { catch (RuntimeException e) {
Msg.error(this, "Unexpected Exception: " + e.getMessage(), e); Msg.error(this, "Unexpected Exception: " + e.getMessage(), e);

View file

@ -234,7 +234,7 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
Address address = sectionToAddress.get(fileHeader.getSectionHeader(segVal - 1)); Address address = sectionToAddress.get(fileHeader.getSectionHeader(segVal - 1));
if (address != null) { if (address != null) {
address = address.add(Conv.intToLong(offVal)); address = address.add(Integer.toUnsignedLong(offVal));
try { try {
symTable.createLabel(address, name, SourceType.IMPORTED); symTable.createLabel(address, name, SourceType.IMPORTED);
@ -293,11 +293,11 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
continue; continue;
} }
Address startAddr = addr.add(Conv.intToLong(starts[k])); Address startAddr = addr.add(Integer.toUnsignedLong(starts[k]));
String cmt = "START-> " + file.getName() + ": " + "?"; String cmt = "START-> " + file.getName() + ": " + "?";
setComment(CommentType.PRE, startAddr, cmt); setComment(CommentType.PRE, startAddr, cmt);
Address endAddr = addr.add(Conv.intToLong(ends[k])); Address endAddr = addr.add(Integer.toUnsignedLong(ends[k]));
cmt = "END-> " + file.getName() + ": " + "?"; cmt = "END-> " + file.getName() + ": " + "?";
setComment(CommentType.PRE, endAddr, cmt); setComment(CommentType.PRE, endAddr, cmt);
@ -327,8 +327,8 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
return; return;
} }
if (offsets[j] > 0) { if (offsets[j] > 0) {
addLineComment(addr.add(Conv.intToLong(offsets[j])), addLineComment(addr.add(Integer.toUnsignedLong(offsets[j])),
Conv.shortToInt(lineNumbers[j])); Short.toUnsignedInt(lineNumbers[j]));
} }
} }
} }
@ -372,7 +372,8 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
} }
else { else {
addLineComment( addLineComment(
program.getImageBase().add(Conv.intToLong(lineNumber.getVirtualAddress())), program.getImageBase()
.add(Integer.toUnsignedLong(lineNumber.getVirtualAddress())),
lineNumber.getLineNumber()); lineNumber.getLineNumber());
} }
} }
@ -502,18 +503,14 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
} }
protected boolean hasComment(CommentType type, Address address) { protected boolean hasComment(CommentType type, Address address) {
switch (type) { return switch (type) {
case PLATE: case PLATE -> plateCommentMap.get(address) != null;
return plateCommentMap.get(address) != null; case PRE -> preCommentMap.get(address) != null;
case PRE: case POST -> postCommentMap.get(address) != null;
return preCommentMap.get(address) != null; case EOL -> eolCommentMap.get(address) != null;
case POST: default -> throw new IllegalArgumentException(
return postCommentMap.get(address) != null; "Unsupported comment type: " + type.name());
case EOL: };
return eolCommentMap.get(address) != null;
default:
throw new IllegalArgumentException("Unsupported comment type: " + type.name());
}
} }
protected void setComment(CommentType type, Address address, String comment) { protected void setComment(CommentType type, Address address, String comment) {
@ -550,11 +547,9 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
default: default:
throw new IllegalArgumentException("Unsupported comment type: " + type.name()); throw new IllegalArgumentException("Unsupported comment type: " + type.name());
} }
if (buffer != null) { if (buffer.length() > 0) {
if (buffer.length() > 0) { buffer.append('\n');
buffer.append('\n');
}
buffer.append(comment);
} }
buffer.append(comment);
} }
} }

View file

@ -27,7 +27,6 @@ import ghidra.app.util.bin.format.pe.PortableExecutable.SectionLayout;
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.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.util.Conv;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
/** /**
@ -55,7 +54,7 @@ public class DbgLoader extends AbstractPeDebugLoader {
} }
SeparateDebugHeader debug = new SeparateDebugHeader(provider); SeparateDebugHeader debug = new SeparateDebugHeader(provider);
if (debug.getSignature() == SeparateDebugHeader.IMAGE_SEPARATE_DEBUG_SIGNATURE) { if (debug.getSignature() == SeparateDebugHeader.IMAGE_SEPARATE_DEBUG_SIGNATURE) {
long imageBase = Conv.intToLong(debug.getImageBase()); long imageBase = Integer.toUnsignedLong(debug.getImageBase());
String machineName = debug.getMachineName(); String machineName = debug.getMachineName();
for (QueryResult result : QueryOpinionService.query(getName(), machineName, null)) { for (QueryResult result : QueryOpinionService.query(getName(), machineName, null)) {
loadSpecs.add(new LoadSpec(this, imageBase, result)); loadSpecs.add(new LoadSpec(this, imageBase, result));

View file

@ -17,7 +17,6 @@ package ghidra.app.merge.listing;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import org.junit.Assert; import org.junit.Assert;
@ -35,10 +34,6 @@ import ghidra.util.exception.InvalidInputException;
*/ */
public class ExternalProgramMergerTest extends AbstractListingMergeManagerTest { public class ExternalProgramMergerTest extends AbstractListingMergeManagerTest {
/**
*
* @param arg0
*/
public ExternalProgramMergerTest() { public ExternalProgramMergerTest() {
super(); super();
} }
@ -422,7 +417,6 @@ public class ExternalProgramMergerTest extends AbstractListingMergeManagerTest {
public void modifyLatest(ProgramDB program) { public void modifyLatest(ProgramDB program) {
try { try {
removeExternalLibrary(program, "ADVAPI32.DLL"); removeExternalLibrary(program, "ADVAPI32.DLL");
String[] names = program.getExternalManager().getExternalLibraryNames();
Reference[] refs = Reference[] refs =
program.getReferenceManager().getReferencesFrom(addr(program, "0x10011e4")); // SetCursor program.getReferenceManager().getReferencesFrom(addr(program, "0x10011e4")); // SetCursor
SymbolTable symTab = program.getSymbolTable(); SymbolTable symTab = program.getSymbolTable();

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.
@ -25,7 +24,6 @@ import ghidra.program.model.listing.*;
import ghidra.program.model.scalar.Scalar; import ghidra.program.model.scalar.Scalar;
import ghidra.program.model.symbol.RefType; import ghidra.program.model.symbol.RefType;
import ghidra.program.model.symbol.Reference; import ghidra.program.model.symbol.Reference;
import ghidra.util.Conv;
public class ResolveReferencesRelativeToEbxScript extends GhidraScript { public class ResolveReferencesRelativeToEbxScript extends GhidraScript {
@ -91,7 +89,8 @@ public class ResolveReferencesRelativeToEbxScript extends GhidraScript {
if ( register.equals( EBX ) ) { if ( register.equals( EBX ) ) {
Address address = toAddr( (ebx + scalar.getUnsignedValue()) & Conv.INT_MASK ); Address address =
toAddr((ebx + scalar.getUnsignedValue()) & 0x00000000ffffffffL);
if ( isValid( address ) ) { if ( isValid( address ) ) {

View file

@ -23,7 +23,6 @@ import ghidra.program.model.data.Composite;
import ghidra.program.model.data.Structure; import ghidra.program.model.data.Structure;
import ghidra.program.model.listing.CommentType; import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.util.Conv;
final class PdbUtil { final class PdbUtil {
@ -34,7 +33,7 @@ final class PdbUtil {
* @return the calculated {@link Address} * @return the calculated {@link Address}
*/ */
final static Address reladdr(Program program, int relativeOffset) { final static Address reladdr(Program program, int relativeOffset) {
return reladdr(program, relativeOffset & Conv.INT_MASK); return reladdr(program, Integer.toUnsignedLong(relativeOffset));
} }
/** /**

View file

@ -48,15 +48,15 @@ public class Conv {
@Deprecated(forRemoval = true, since = "10.2") @Deprecated(forRemoval = true, since = "10.2")
public static final long INT_MASK = 0x00000000ffffffffL; public static final long INT_MASK = 0x00000000ffffffffL;
/** /**
* @param b the byte * @param b the byte
* @return the short equivalent of the byte * @return the short equivalent of the byte
* @deprecated Use other built-ins like {@link Byte#toUnsignedInt(byte)} * @deprecated Use other built-ins like {@link Byte#toUnsignedInt(byte)}
*/ */
@Deprecated(forRemoval = true, since = "10.2") @Deprecated(forRemoval = true, since = "10.2")
public static short byteToShort(byte b) { public static short byteToShort(byte b) {
return (short)(b & BYTE_MASK); return (short) (b & 0xff);
} }
/** /**
* Converts a byte to an integer. * Converts a byte to an integer.
@ -67,8 +67,8 @@ public class Conv {
*/ */
@Deprecated(forRemoval = true, since = "10.2") @Deprecated(forRemoval = true, since = "10.2")
public static int byteToInt(byte b) { public static int byteToInt(byte b) {
return (b & BYTE_MASK); return Byte.toUnsignedInt(b);
} }
/** /**
* Converts a byte to a long. * Converts a byte to a long.
@ -78,8 +78,8 @@ public class Conv {
*/ */
@Deprecated(forRemoval = true, since = "10.2") @Deprecated(forRemoval = true, since = "10.2")
public static long byteToLong(byte b) { public static long byteToLong(byte b) {
return intToLong(b & BYTE_MASK); return Byte.toUnsignedLong(b);
} }
/** /**
* Converts a short to an integer. * Converts a short to an integer.
@ -89,18 +89,18 @@ public class Conv {
*/ */
@Deprecated(forRemoval = true, since = "10.2") @Deprecated(forRemoval = true, since = "10.2")
public static int shortToInt(short s) { public static int shortToInt(short s) {
return (s & SHORT_MASK); return Short.toUnsignedInt(s);
} }
/** /**
* Converts a short to a long. * Converts a short to a long.
* @param s the short * @param s the short
* @return the long eqivalent of the short * @return the long equivalent of the short
* @deprecated Use {@link Short#toUnsignedLong(short)} instead * @deprecated Use {@link Short#toUnsignedLong(short)} instead
*/ */
@Deprecated(forRemoval = true, since = "10.2") @Deprecated(forRemoval = true, since = "10.2")
public static long shortToLong(short s) { public static long shortToLong(short s) {
return intToLong(s & SHORT_MASK); return Short.toUnsignedLong(s);
} }
/** /**
@ -111,26 +111,25 @@ public class Conv {
*/ */
@Deprecated(forRemoval = true, since = "10.2") @Deprecated(forRemoval = true, since = "10.2")
public static long intToLong(int i) { public static long intToLong(int i) {
return (i & INT_MASK); return Integer.toUnsignedLong(i);
} }
/** /**
* <p>
* Old and <b>incorrect</b> way to convert bytes to a String by casting their * Old and <b>incorrect</b> way to convert bytes to a String by casting their
* values to chars. Do not use. Does not seem to be used in current codebase. * values to chars. Do not use. Does not seem to be used in current codebase.
* *
* @param array * @param array The bytes to convert
* @return * @return The converted bytes
* @deprecated Use {@link String#String(byte[], java.nio.charset.Charset) new String(bytes, StandardCharSets.US_ASCII)} * @deprecated Use {@link String#String(byte[], java.nio.charset.Charset) new String(bytes, StandardCharSets.US_ASCII)}
* instead * instead
*/ */
@Deprecated(forRemoval = true, since = "10.2") @Deprecated(forRemoval = true, since = "10.2")
public static String toString(byte [] array) { public static String toString(byte [] array) {
StringBuilder buffer = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (byte b : array) { for (byte b : array) {
buffer.append((char)b); builder.append((char) b);
} }
return buffer.toString(); return builder.toString();
} }
/** /**
@ -142,7 +141,7 @@ public class Conv {
* @return the padded hex string * @return the padded hex string
*/ */
public static String toHexString(byte b) { public static String toHexString(byte b) {
return zeropad(Integer.toHexString(byteToInt(b)), 2); return zeropad(Integer.toHexString(Byte.toUnsignedInt(b)), 2);
} }
/** /**
@ -154,7 +153,7 @@ public class Conv {
* @return the padded hex string * @return the padded hex string
*/ */
public static String toHexString(short s) { public static String toHexString(short s) {
return zeropad(Integer.toHexString(shortToInt(s)), 4); return zeropad(Integer.toHexString(Short.toUnsignedInt(s)), 4);
} }
/** /**
@ -190,12 +189,12 @@ public class Conv {
*/ */
public static String zeropad(String s, int len) { public static String zeropad(String s, int len) {
if (s == null) s = ""; if (s == null) s = "";
StringBuffer buffer = new StringBuffer(s); StringBuilder builder = new StringBuilder(s);
int zerosNeeded = len - s.length(); int zerosNeeded = len - s.length();
for (int i = 0 ; i < zerosNeeded ; ++i) { for (int i = 0 ; i < zerosNeeded ; ++i) {
buffer.insert(0, '0'); builder.insert(0, '0');
} }
return buffer.toString(); return builder.toString();
} }
} }

View file

@ -15,8 +15,6 @@
*/ */
package ghidra.util.xml; package ghidra.util.xml;
import ghidra.util.Conv;
import java.math.BigInteger; import java.math.BigInteger;
/** /**
@ -106,7 +104,7 @@ public class XmlAttributes {
* @param hex true if value should be written in hex * @param hex true if value should be written in hex
*/ */
public void addAttribute(String name, byte value, boolean hex) { public void addAttribute(String name, byte value, boolean hex) {
addAttribute(name, hex ? Conv.byteToInt(value) : (int) value, hex); addAttribute(name, hex ? Byte.toUnsignedInt(value) : (int) value, hex);
} }
/** /**
@ -125,7 +123,7 @@ public class XmlAttributes {
* @param hex true if value should be written in hex * @param hex true if value should be written in hex
*/ */
public void addAttribute(String name, short value, boolean hex) { public void addAttribute(String name, short value, boolean hex) {
addAttribute(name, hex ? Conv.shortToInt(value) : (int) value, hex); addAttribute(name, hex ? Short.toUnsignedInt(value) : (int) value, hex);
} }
/** /**

View file

@ -19,7 +19,6 @@ import ghidra.docking.settings.Settings;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressOverflowException; import ghidra.program.model.address.AddressOverflowException;
import ghidra.program.model.mem.*; import ghidra.program.model.mem.*;
import ghidra.util.Conv;
import ghidra.util.Msg; import ghidra.util.Msg;
/** /**
@ -157,13 +156,13 @@ public abstract class CountedDynamicDataType extends DynamicDataType {
try { try {
switch (counterSize) { switch (counterSize) {
case 1: case 1:
test = Conv.byteToLong(memory.getByte(loc)); test = Byte.toUnsignedLong(memory.getByte(loc));
break; break;
case 2: case 2:
test = Conv.shortToLong(memory.getShort(loc)); test = Short.toUnsignedLong(memory.getShort(loc));
break; break;
case 4: case 4:
test = Conv.intToLong(memory.getInt(loc)); test = Integer.toUnsignedLong(memory.getInt(loc));
break; break;
case 8: case 8:
test = memory.getLong(loc); test = memory.getLong(loc);

View file

@ -21,7 +21,6 @@ import ghidra.docking.settings.Settings;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressOverflowException; import ghidra.program.model.address.AddressOverflowException;
import ghidra.program.model.mem.*; import ghidra.program.model.mem.*;
import ghidra.util.Conv;
import ghidra.util.Msg; import ghidra.util.Msg;
/** /**
@ -239,13 +238,13 @@ public abstract class IndexedDynamicDataType extends DynamicDataType {
try { try {
switch (indexSize) { switch (indexSize) {
case 1: case 1:
test = Conv.byteToLong(memory.getByte(loc)); test = Byte.toUnsignedLong(memory.getByte(loc));
break; break;
case 2: case 2:
test = Conv.shortToLong(memory.getShort(loc)); test = Short.toUnsignedLong(memory.getShort(loc));
break; break;
case 4: case 4:
test = Conv.intToLong(memory.getInt(loc)); test = Integer.toUnsignedLong(memory.getInt(loc));
break; break;
case 8: case 8:
test = memory.getLong(loc); test = memory.getLong(loc);

View file

@ -21,7 +21,6 @@ import ghidra.docking.settings.Settings;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressOverflowException; import ghidra.program.model.address.AddressOverflowException;
import ghidra.program.model.mem.*; import ghidra.program.model.mem.*;
import ghidra.util.Conv;
import ghidra.util.Msg; import ghidra.util.Msg;
/** /**
@ -158,13 +157,13 @@ public abstract class RepeatedDynamicDataType extends DynamicDataType {
try { try {
switch (terminatorSize) { switch (terminatorSize) {
case 1: case 1:
test = Conv.byteToLong(memory.getByte(loc)); test = Byte.toUnsignedLong(memory.getByte(loc));
break; break;
case 2: case 2:
test = Conv.shortToLong(memory.getShort(loc)); test = Short.toUnsignedLong(memory.getShort(loc));
break; break;
case 4: case 4:
test = Conv.intToLong(memory.getInt(loc)); test = Integer.toUnsignedLong(memory.getInt(loc));
break; break;
case 8: case 8:
test = memory.getLong(loc); test = memory.getLong(loc);

View file

@ -18,7 +18,6 @@
package ghidra.program.util; package ghidra.program.util;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
/** /**

View file

@ -23,7 +23,6 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.reloc.Relocation.Status; import ghidra.program.model.reloc.Relocation.Status;
import ghidra.program.model.reloc.RelocationResult; import ghidra.program.model.reloc.RelocationResult;
import ghidra.util.Conv;
/** /**
* A {@link MachoRelocationHandler} for AARCH64 * A {@link MachoRelocationHandler} for AARCH64
@ -133,7 +132,7 @@ public class AARCH64_MachoRelocationHandler extends MachoRelocationHandler {
break; break;
} }
case ARM64_RELOC_AUTHENTICATED_POINTER: { case ARM64_RELOC_AUTHENTICATED_POINTER: {
long addend = orig & Conv.INT_MASK; long addend = orig & 0x00000000ffffffffL;
long value = targetAddr.getOffset() + addend; long value = targetAddr.getOffset() + addend;
byteLength = write(relocation, value); byteLength = write(relocation, value);
break; break;