mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
99feb8d545
2 changed files with 30 additions and 10 deletions
|
@ -421,8 +421,8 @@ public class AddressXML {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
decoder.rewindAttributes();
|
decoder.rewindAttributes();
|
||||||
Varnode[] pieces = Varnode.decodePieces(decoder);
|
Varnode.Join join = Varnode.decodePieces(decoder);
|
||||||
storage = pcodeFactory.getJoinStorage(pieces);
|
storage = pcodeFactory.getJoinStorage(join.pieces);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (InvalidInputException e) {
|
catch (InvalidInputException e) {
|
||||||
|
|
|
@ -39,6 +39,15 @@ public class Varnode {
|
||||||
private static final long masks[] = { 0L, 0xffL, 0xffffL, 0xffffffL, 0xffffffffL, 0xffffffffffL,
|
private static final long masks[] = { 0L, 0xffL, 0xffffL, 0xffffffL, 0xffffffffL, 0xffffffffffL,
|
||||||
0xffffffffffffL, 0xffffffffffffffL, 0xffffffffffffffffL };
|
0xffffffffffffL, 0xffffffffffffffL, 0xffffffffffffffffL };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set of Varnode pieces referred to by a single Varnode in join space
|
||||||
|
* as returned by Varnode.decodePieces
|
||||||
|
*/
|
||||||
|
public static class Join {
|
||||||
|
public Varnode[] pieces; // The list of individual Varnodes being joined
|
||||||
|
public int logicalSize; // The size (in bytes) of the logical whole.
|
||||||
|
}
|
||||||
|
|
||||||
private Address address;
|
private Address address;
|
||||||
private int size;
|
private int size;
|
||||||
private int spaceID;
|
private int spaceID;
|
||||||
|
@ -385,10 +394,12 @@ public class Varnode {
|
||||||
if ((spc != null) && (spc.getType() == AddressSpace.TYPE_VARIABLE)) { // Check for a composite Address
|
if ((spc != null) && (spc.getType() == AddressSpace.TYPE_VARIABLE)) { // Check for a composite Address
|
||||||
decoder.rewindAttributes();
|
decoder.rewindAttributes();
|
||||||
try {
|
try {
|
||||||
Varnode[] pieces = decodePieces(decoder);
|
Join join = decodePieces(decoder);
|
||||||
VariableStorage storage = factory.getJoinStorage(pieces);
|
VariableStorage storage = factory.getJoinStorage(join.pieces);
|
||||||
// Update "join" address to the one just registered with the pieces
|
// Update "join" address to the one just registered with the pieces
|
||||||
addr = factory.getJoinAddress(storage);
|
addr = factory.getJoinAddress(storage);
|
||||||
|
// Update size to be the size of the pieces
|
||||||
|
sz = join.logicalSize;
|
||||||
}
|
}
|
||||||
catch (InvalidInputException e) {
|
catch (InvalidInputException e) {
|
||||||
throw new DecoderException("Invalid varnode pieces: " + e.getMessage());
|
throw new DecoderException("Invalid varnode pieces: " + e.getMessage());
|
||||||
|
@ -487,16 +498,21 @@ public class Varnode {
|
||||||
* space, a contiguous sequence of bytes, at a specific Address, represent a logical value
|
* space, a contiguous sequence of bytes, at a specific Address, represent a logical value
|
||||||
* that may physically be split across multiple registers or other storage locations.
|
* that may physically be split across multiple registers or other storage locations.
|
||||||
* @param decoder is the stream decoder
|
* @param decoder is the stream decoder
|
||||||
* @return an array of decoded Varnodes
|
* @return an array of decoded Varnodes and the logical size
|
||||||
* @throws DecoderException for any errors in the encoding
|
* @throws DecoderException for any errors in the encoding
|
||||||
*/
|
*/
|
||||||
public static Varnode[] decodePieces(Decoder decoder) throws DecoderException {
|
public static Join decodePieces(Decoder decoder) throws DecoderException {
|
||||||
ArrayList<Varnode> list = new ArrayList<>();
|
ArrayList<Varnode> list = new ArrayList<>();
|
||||||
|
int sizeAccum = 0;
|
||||||
|
int logicalSize = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int attribId = decoder.getNextAttributeId();
|
int attribId = decoder.getNextAttributeId();
|
||||||
if (attribId == 0) {
|
if (attribId == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else if (attribId == ATTRIB_LOGICALSIZE.id()) {
|
||||||
|
logicalSize = (int) decoder.readUnsignedInteger();
|
||||||
|
}
|
||||||
else if (attribId == ATTRIB_UNKNOWN.id()) {
|
else if (attribId == ATTRIB_UNKNOWN.id()) {
|
||||||
attribId = decoder.getIndexedAttributeId(ATTRIB_PIECE);
|
attribId = decoder.getIndexedAttributeId(ATTRIB_PIECE);
|
||||||
}
|
}
|
||||||
|
@ -509,12 +525,16 @@ public class Varnode {
|
||||||
if (index != list.size()) {
|
if (index != list.size()) {
|
||||||
throw new DecoderException("\"piece\" attributes must be in order");
|
throw new DecoderException("\"piece\" attributes must be in order");
|
||||||
}
|
}
|
||||||
list.add(decodePiece(decoder.readString(), decoder.getAddressFactory()));
|
Varnode vn = decodePiece(decoder.readString(), decoder.getAddressFactory());
|
||||||
|
list.add(vn);
|
||||||
|
sizeAccum += vn.getSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Varnode[] pieces = new Varnode[list.size()];
|
Join join = new Join();
|
||||||
list.toArray(pieces);
|
join.pieces = new Varnode[list.size()];
|
||||||
return pieces;
|
join.logicalSize = (logicalSize != 0) ? logicalSize : sizeAccum;
|
||||||
|
list.toArray(join.pieces);
|
||||||
|
return join;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue