# Interface: com.pnfsoftware.jeb.core.units.code.android.ir.IDEmulatorHooks

An interface for user\-defined hooks called by `dexdec`'s IR emulator when executing internal \(in DEX\) code. 

 Tutorial on how to use emulator hooks: in the JEB `coreplugins/scripts/` folder, refer to `DOptEmuHooksExample.py.DISABLED` for an example in Python, `DOptEmuHooksGlobalExample.java.DISABLED` for an example in Java \(remove the .DISABLED extension to enable the plugin\).

## Method: examineFieldValue
- parameter: `reqid`, type: `long`
- parameter: `value`, type: `com.pnfsoftware.jeb.util.base.Wrapper<com.pnfsoftware.jeb.core.units.code.android.ir.IDImm>`
- return type: `com.pnfsoftware.jeb.util.base.Wrapper<com.pnfsoftware.jeb.core.units.code.android.ir.IDImm>`

Description: **Currently, this hook is ignored by dexdec emulator. An implementation may be provided but it will not be invoked.** 

 This method is called after the emulator has read a field value. It provides the field value and offers a chance for the hook to modify or replace it.
parameter: reqid: internal request id, matching a previous call to            [getField](#getField(long, String, IDImm))
parameter: value: the field value that was read
return: the hook may provide an object \(wrapped in a Wrapper object; the object itself may be         null\); returning null means proceed as normal \(other hooks will be tried, and         eventually, the sandbox will resume and provide the value previously retrieved\)

## Method: examineMethodResult
- parameter: `reqid`, type: `long`
- parameter: `result`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`
- return type: `com.pnfsoftware.jeb.util.base.Wrapper<com.pnfsoftware.jeb.core.units.code.android.ir.IDImm>`

Description: This method is called after the emulator successfully executed the IR of an internal dex method.
parameter: reqid: internal request id \(matching the id provided to a previous call to            [invokeMethod](#invokeMethod(long, String, List))\)
parameter: result: the execution result, which may be modified
return: the hook may provide an object \(wrapped in a Wrapper object; the object itself may be         null\); returning null means proceed as normal \(other hooks will be tried, and         eventually, the emulator execution will resume and provide the original returned         value\)

## Method: getField
- parameter: `reqid`, type: `long`
- parameter: `fsig`, type: `java.lang.String`
- parameter: `obj`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`
- return type: `com.pnfsoftware.jeb.util.base.Wrapper<com.pnfsoftware.jeb.core.units.code.android.ir.IDImm>`

Description: This method is called when the emulator is about to get \(retrieve\) an internal field's value.
parameter: reqid: internal request id
parameter: fsig: field signature
parameter: obj: field object, null if static
return: null to indicate that nothing was done and execution should proceed as normal; else,         an object to returned instead of the actual field value

## Method: invokeMethod
- parameter: `reqid`, type: `long`
- parameter: `msig`, type: `java.lang.String`
- parameter: `args`, type: `java.util.List<com.pnfsoftware.jeb.core.units.code.android.ir.IDImm>`
- return type: `com.pnfsoftware.jeb.util.base.Wrapper<com.pnfsoftware.jeb.core.units.code.android.ir.IDImm>`

Description: This method is called when the emulator is about to execute the IR of an internal dex method.
parameter: reqid: internal request id
parameter: msig: target method to be executed
parameter: args: the evaluated arguments \(careful, the first entry is the object's \`this\` iff the            target method is not static\)
return: if non\-null, the result will be used as the invocation return; if null, proceed         \(other hooks will be executed\)

## Method: setField
- parameter: `reqid`, type: `long`
- parameter: `fsig`, type: `java.lang.String`
- parameter: `obj`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`
- parameter: `avalue`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm[]`
- return type: `java.lang.Boolean`

Description: This method is called when the emulator is about to set an internal field's value.
parameter: reqid: internal request id
parameter: fsig: field signature
parameter: obj: field object, null if static
parameter: avalue: a one\-element array containing the value to be set \(this is an input/output            array; if this method returns false, the value located in the array will be used            by the sandbox to set the field\)
return: null to indicate that nothing was done and execution should proceed as normal; false         to indicate that the hook provided a field value to be set by the emulator itself \(no         other hook will run, the emulator will set the field located in the \`avalue\` array\);         true to indicate that the hook has completed the operation \(no other hook will run,         the emulator will not set the field\)

