java.lang.Object | |
↳ | com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.EState |
An IR machine state object, onto which stand-alone evaluations
or full emulation
can be performed.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
class | EState.Frame |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
EState(IEGlobalContext gctx)
Create a state object with a fresh VM, set up according to the providing context properties.
| |||||||||||
EState(Endianness end)
Create an empty state object with no VM, empty global vars, no local vars.
| |||||||||||
EState(EState src)
Copy constructor.
| |||||||||||
EState(EState src, boolean duplicateMemory)
Copy constructor.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void | addHooks(IEStateHooks hooks) | ||||||||||
int | adjustVirtualPC(int delta) | ||||||||||
int | countFrames() | ||||||||||
void | enableMemoryWriteHitmap(boolean enabled, boolean recordBadWrites) | ||||||||||
String | formatVars(boolean skipZeroRegs) | ||||||||||
static CharSequence | formatVars(Map<Integer, IEImm> vars, IEGlobalContext gctx, IERoutineContext ctx, Collection<Integer> includedIds, Collection<Integer> excludedIds, boolean skipZeroRegs) | ||||||||||
static CharSequence | formatVars(Map<Integer, IEImm> vars, IEGlobalContext gctx, IERoutineContext ctx) | ||||||||||
IVirtualMemory |
getBadMemory()
Retrieve the optional 'bad data' VM.
| ||||||||||
int | getEvaluationCount() | ||||||||||
IEGlobalContext | getGlobalContext() | ||||||||||
int | getMaxEvaluationCount() | ||||||||||
IVirtualMemory | getMemory() | ||||||||||
Map<Long, Integer> | getMemoryWriteHitmap() | ||||||||||
long |
getNativeStackEnd()
Retrieve the optional high-address (exclusive) for the native stack of the current frame.
| ||||||||||
long |
getNativeStackStart()
Retrieve the optional low-address for the native stack of the current frame.
| ||||||||||
EEmulator | getPrimaryEmulator() | ||||||||||
IEImm |
getProgramCounter()
Convenience method to read the PC.
| ||||||||||
IERoutineContext | getRoutineContext() | ||||||||||
long |
getSegmentBase(int segment)
Retrieve the memory address associated with a segment.
| ||||||||||
IEImm |
getStackPointer()
Convenience method to read the SP.
| ||||||||||
IEImm |
getValue(int id)
Retrieve the value of a variable.
| ||||||||||
IEImm |
getValue(IEVar var)
Retrieve the value of a variable.
| ||||||||||
long |
getValueAsLong(int id)
Convenience method used to retrieve the value of an initialized variable as a long.
| ||||||||||
Long |
getValueAsLongSafe(int id)
Convenience method used to retrieve the value of a variable as a long object.
| ||||||||||
long |
getValueAsUnsignedLong(int id)
Convenience method used to retrieve the value of a variable as a long object.
| ||||||||||
IEImm |
getValueSafe(IEVar var)
Retrieve the value of a variable.
| ||||||||||
IEImm |
getValueSafe(int id)
Retrieve the value of a variable.
| ||||||||||
Map<Integer, IEImm> | getVariables() | ||||||||||
int | getVirtualPC() | ||||||||||
boolean |
hasBadValue(int id)
Determine whether the provided variable is currently set to BAD.
| ||||||||||
boolean | hasSegmentBases() | ||||||||||
boolean |
hasValue(int id)
Determine whether the provided variable is defined (i.e., not unknown, not set to BAD).
| ||||||||||
boolean | incrementEvaluationCount() | ||||||||||
boolean | isBigEndian() | ||||||||||
boolean | isDisabledHooks() | ||||||||||
boolean |
isExecuteSubRoutines()
Determine whether call-to-sub PC-assigns are truly evaluated (the state controller, such as
the
EEmulator , is responsible for adjusting the state), or simply skipped over (only
the side-effects are applied). | ||||||||||
boolean | isRecordBadWrites() | ||||||||||
boolean |
isSoftFailMode()
Determine whether the soft-fail mode is used to track 'bad data' read attempts.
| ||||||||||
int |
mergeWith(EState state, IMergeController mergeController, Set<Integer> removals, Set<Integer> additions)
Merge the provided output state with this input state.
| ||||||||||
int |
mergeWithOld(EState state, Collection<Integer> removeMerges, boolean mergeOutputAbsentFromInput, Collection<Integer> preventMerges, Collection<Integer> discrepancies)
Merge the provided output state with this input state.
| ||||||||||
EState.Frame |
popFrame()
Restore the current values of PC, variables, and native stack boundaries by popping the
top-level frame.
| ||||||||||
void |
pushFrame()
Save a frame that will contain the current virtual PC, variables, and native stack
boundaries.
| ||||||||||
boolean |
readMemory(long address, byte[] buffer)
Read memory bytes.
| ||||||||||
int |
readMemory2(long address, byte[] buffer)
Read memory bytes.
| ||||||||||
void | removeHooks(IEStateHooks hooks) | ||||||||||
boolean | removeValue(int id) | ||||||||||
void |
setBadMemory(IVirtualMemory bad_vm)
Set a specific VM used to contain information about areas of memory that are known to contain
'bad' data.
| ||||||||||
boolean | setDisabledHooks(boolean disabled) | ||||||||||
void | setExecuteSubRoutines(boolean executeSubRoutines) | ||||||||||
void | setMaxEvaluationCount(int maxEvalcnt) | ||||||||||
void | setMemory(IVirtualMemory vm) | ||||||||||
void |
setNativeStackEnd(long nativeStackEnd)
Set the high-address (exclusive) for the native stack of the current frame.
| ||||||||||
void |
setNativeStackStart(long nativeStackStart)
Set the low-address for the native stack of the current frame.
| ||||||||||
void | setPrimaryEmulator(EEmulator primaryEmulator) | ||||||||||
void |
setProgramCounter(IEImm val)
Convenience method to write the PC.
| ||||||||||
void | setRecordBadWrites(boolean recordBadWrites) | ||||||||||
void | setRoutineContext(IERoutineContext ectx) | ||||||||||
void |
setSegmentBase(int segment, long base)
Set the memory address associated with a segment.
| ||||||||||
void |
setSegmentMapping(String segmentName, int segmentValue, long baseAddress)
Convenience routine.
| ||||||||||
void |
setSoftFailMode(boolean enabled)
Enable or disable the soft-fail mode.
| ||||||||||
void |
setStackPointer(IEImm val)
Convenience method to write the SP.
| ||||||||||
void |
setValue(IEVar var, IEImm val)
Set a variable to a defined value or the BAD value.
| ||||||||||
void |
setValue(int id, long val)
Set a variable to a defined value.
| ||||||||||
void |
setValue(IEVar var, long val)
Set a variable to a defined value.
| ||||||||||
void |
setVariables(Map<Integer, IEImm> vars)
Replace the variables of this state by another set of variables.
| ||||||||||
void | setVirtualPC(int virtualPC) | ||||||||||
String | toString() | ||||||||||
boolean |
writeMemory(long address, byte[] buffer)
Write memory bytes to specific (defined) values.
| ||||||||||
boolean |
writeMemoryBad(long address, int bitsize, int policy)
Specify a range of memory bytes known to contain BAD data.
| ||||||||||
boolean |
writeMemoryBad(long address, int bitsize)
Specify a range of memory bytes known to contain BAD data.
| ||||||||||
synchronized boolean |
writeMemoryInt(long address, int val)
Write a 32-bit value to memory.
| ||||||||||
synchronized boolean |
writeMemoryLong(long address, long val)
Write a 64-bit value to memory.
| ||||||||||
synchronized boolean |
writeMemoryPointer(long address, long val)
Write a pointer (address) to memory.
| ||||||||||
synchronized boolean |
writeMemoryShort(long address, short val)
Write a 16-bit value to memory.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Create a state object with a fresh VM, set up according to the providing context properties.
Create an empty state object with no VM, empty global vars, no local vars.
Copy constructor. The VM may be optionally duplicated.
delta | increment to be added to the current virtual PC |
---|
Retrieve the optional 'bad data' VM. See setBadMemory(IVirtualMemory)
.
Retrieve the optional high-address (exclusive) for the native stack of the current frame.
Retrieve the optional low-address for the native stack of the current frame.
Convenience method to read the PC. Will throw on error. A global context must have been set.
Retrieve the memory address associated with a segment.
segment | the value of a segment register |
---|
Convenience method to read the SP. Will throw on error. A global context must have been set.
Retrieve the value of a variable.
Retrieve the value of a variable.
Convenience method used to retrieve the value of an initialized variable as a long. This
method throws a EvaluationException
if the variable is uninitialized or BAD.
id | variable id |
---|
Convenience method used to retrieve the value of a variable as a long object. This method returns null if the variable is uninitialized or BAD.
id | variable id |
---|
Convenience method used to retrieve the value of a variable as a long object. This method
throws a EvaluationException
if the variable is uninitialized or BAD.
id | variable id |
---|
Retrieve the value of a variable.
Retrieve the value of a variable.
Determine whether the provided variable is currently set to BAD.
Determine whether the provided variable is defined (i.e., not unknown, not set to BAD).
Determine whether call-to-sub PC-assigns are truly evaluated (the state controller, such as
the EEmulator
, is responsible for adjusting the state), or simply skipped over (only
the side-effects are applied).
Determine whether the soft-fail mode is used to track 'bad data' read attempts.
Merge the provided output state with this input state. Memories are not merged.
state | input state |
---|---|
mergeController | optional controller, will use StandardMergeController if none
is provided |
Merge the provided output state with this input state. Memories are not merged.
state | second state (the output), to be merged with `this` (the input) |
---|---|
removeMerges | optional collection of input-state variables that should be removed, if they were not present in the input state; if this parameter is null, all input-state only (ie, not present in the output-state) variables will be kept |
mergeOutputAbsentFromInput | if true, variables present in the output state, but not present in the input state, will be added (merged into) the input state, unless they're listed in the `preventMerges` collection parameter |
preventMerges | optional input collection of registers that cannot be merged; disregarded if `mergeOutputAbsentFromInput` is false |
discrepancies | optional output collection of mismatched registers (discrepancies) |
Restore the current values of PC, variables, and native stack boundaries by popping the top-level frame.
Save a frame that will contain the current virtual PC, variables, and native stack boundaries. The value of the PC is reset to 0, the variable slate is a copy of the previous variable slate, and the native stack boundaries are reset.
This method used to provide support for the execution of IR sub-routines (IECall
emulation).
Read memory bytes.
Read memory bytes. Same as readMemory(long, byte[])
, but provide a finer result when
in soft-fail mode.
MEMREAD_OK
, MEMREAD_FAILED
, or MEMREAD_BADDATA
(on
soft-fail mode only)
Set a specific VM used to contain information about areas of memory that are known to contain 'bad' data. The term here may be understood as existing data in memory whose value is stale or incorrect. It is not recommended to write to this VM directly. Its use is internal to this class.
Note that this method is low-level. A higher-level way to set a bad memory is to enable
soft-fail
mode.
bad_vm | optional memory object |
---|
Set the high-address (exclusive) for the native stack of the current frame.
Set the low-address for the native stack of the current frame.
Convenience method to write the PC. Will throw on error. A global context must have been set.
Set the memory address associated with a segment.
segment | the value of a segment register |
---|---|
base | the base memory address associated with the segment |
Convenience routine.
Enable or disable the soft-fail mode. In soft-fail mode, a 'bad data' memory is used to track
VM-read attempts to memory areas known to contain 'bad' data. See
setBadMemory(IVirtualMemory)
for details.
Convenience method to write the SP. Will throw on error. A global context must have been set.
Set a variable to a defined value or the BAD value.
val | a value; null indicates the explicit BAD value |
---|
Set a variable to a defined value.
id | the positive id of a global context variable |
---|
Replace the variables of this state by another set of variables.
Write memory bytes to specific (defined) values.
Specify a range of memory bytes known to contain BAD data.
policy | one of POLICY_MEMWRITE_BADHIT_xxx |
---|
Specify a range of memory bytes known to contain BAD data.
Write a 32-bit value to memory. Uses the VM-provided endianness attribute for encoding.
Write a 64-bit value to memory. Uses the VM-provided endianness attribute for encoding.
Write a pointer (address) to memory. Uses the VM-provided endianness attribute for encoding.
Write a 16-bit value to memory. Uses the VM-provided endianness attribute for encoding.