Package ghidra.program.model.lang
Class MaskImpl
java.lang.Object
ghidra.program.model.lang.MaskImpl
- All Implemented Interfaces:
Mask
,Serializable
Implements the Mask interface as a byte array.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
applyMask
(byte[] cde, byte[] result) Apply the mask to a byte array.void
applyMask
(byte[] cde, int cdeOffset, byte[] results, int resultsOffset) Apply the mask to a byte array.byte[]
Apply the mask to a memory buffer.byte[]
complementMask
(byte[] msk, byte[] results) applies the complement of the mask to the given byte array.boolean
equalMaskedValue
(byte[] cde, byte[] target) Tests if the results of apply the mask to the given array matches a target array.boolean
equals
(byte[] otherMask) Check if the mask represented by the byte array is equal to this one.boolean
Test if the given object is equal to this object.byte[]
getBytes()
Returns the bytes that make up this mask.boolean
subMask
(byte[] msk) Tests if the given mask matches the this mask for the first n bytes, where n is the size of the given mask.toString()
-
Constructor Details
-
MaskImpl
public MaskImpl(byte[] msk) Construct a mask from a byte array.- Parameters:
msk
- the bits that make up the mask.
-
-
Method Details
-
equals
Description copied from interface:Mask
Test if the given object is equal to this object. Two masks are equal if they have exactly the same values in thier byte arrays. -
equals
public boolean equals(byte[] otherMask) Description copied from interface:Mask
Check if the mask represented by the byte array is equal to this one. -
applyMask
Description copied from interface:Mask
Apply the mask to a byte array.- Specified by:
applyMask
in interfaceMask
- Parameters:
cde
- the array that contains the values to be maskedresult
- the array to contain the results.- Returns:
- the resulting byte array.
- Throws:
IncompatibleMaskException
- thrown if byte arrays are not of the correct size- See Also:
-
applyMask
public void applyMask(byte[] cde, int cdeOffset, byte[] results, int resultsOffset) throws IncompatibleMaskException Description copied from interface:Mask
Apply the mask to a byte array.- Specified by:
applyMask
in interfaceMask
- Parameters:
cde
- the array that contains the values to be maskedcdeOffset
- the offset into the array that contains the values to be maskedresults
- the array to contain the results.resultsOffset
- the offset into the array that contains the results- Throws:
IncompatibleMaskException
- thrown if byte arrays are not of the correct size
-
applyMask
Description copied from interface:Mask
Apply the mask to a memory buffer.- Specified by:
applyMask
in interfaceMask
- Parameters:
buffer
- the memory buffer that contains the values to be masked- Returns:
- the resulting masked byte array.
- Throws:
MemoryAccessException
- thrown if mask exceeds the available data within buffer- See Also:
-
equalMaskedValue
Description copied from interface:Mask
Tests if the results of apply the mask to the given array matches a target array.- Specified by:
equalMaskedValue
in interfaceMask
- Parameters:
cde
- the source bytes.target
- the result bytes to be tested.- Returns:
- true if the target array is equal to the source array with the mask applied.
- Throws:
IncompatibleMaskException
- thrown if byte arrays are not of the correct size- See Also:
-
subMask
Description copied from interface:Mask
Tests if the given mask matches the this mask for the first n bytes, where n is the size of the given mask.- Specified by:
subMask
in interfaceMask
- Parameters:
msk
- the bytes to be tested to see if they match the first bytes of this mask.- Returns:
- true if the bytes match up to the length of the passed in byte array.
- Throws:
IncompatibleMaskException
- thrown if byte arrays are not of the correct size- See Also:
-
complementMask
Description copied from interface:Mask
applies the complement of the mask to the given byte array.- Specified by:
complementMask
in interfaceMask
- Parameters:
msk
- the bytes to apply the inverted mask.results
- the array for storing the results.- Returns:
- the results array.
- Throws:
IncompatibleMaskException
- thrown if byte arrays are not of the correct size- See Also:
-
toString
-
getBytes
public byte[] getBytes()Description copied from interface:Mask
Returns the bytes that make up this mask.
-