Package ghidra.program.model.pcode
Interface PatchEncoder
- All Superinterfaces:
CachedEncoder
,Encoder
- All Known Implementing Classes:
PackedEncodeOverlay
,PatchPackedEncode
This is an encoder that produces encodings that can be retroactively patched.
The contained encoding is expected to be byte based. The user can record a position
in the encoding by calling the size() method in the middle of encoding, and then later
use the returned offset to call the patchIntegerAttribute() method and modify the
encoding at the recorded position.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
patchIntegerAttribute
(int pos, AttributeId attribId, long val) Replace an integer attribute for the element at the given position.int
size()
The returned value can be used as a position for later modificationvoid
writeSpaceId
(AttributeId attribId, long spaceId) Write a given raw spaceid (as returned by AddressSpace.getSpaceID()) as an attribute.Methods inherited from interface ghidra.program.model.pcode.CachedEncoder
clear, isEmpty, writeTo
Methods inherited from interface ghidra.program.model.pcode.Encoder
closeElement, openElement, writeBool, writeOpcode, writeSignedInteger, writeSpace, writeSpace, writeString, writeStringIndexed, writeUnsignedInteger
-
Method Details
-
writeSpaceId
Write a given raw spaceid (as returned by AddressSpace.getSpaceID()) as an attribute. The effect is the same as if writeSpace() was called with the AddressSpace matching the spaceid, i.e. the decoder will read this as just space attribute.- Parameters:
attribId
- is the attributespaceId
- is the given spaceid- Throws:
IOException
- for problems writing to the stream
-
size
int size()The returned value can be used as a position for later modification- Returns:
- the number of bytes written to this stream so far
-
patchIntegerAttribute
Replace an integer attribute for the element at the given position. The position is assumed to be at an open directive for the element containing the attribute to be patched.- Parameters:
pos
- is the given positionattribId
- is the attribute to be patchedval
- is the new value to insert- Returns:
- true if the attribute is successfully patched
-