package

com.pnfsoftware.jeb.core.units.code.android.ir

This package contains types used to publicly access and manipulate JEB's DEX Decompiler (referred to as dexdec) Intermediate Representation (IR) objects. Users can use this API to write custom IR optimizers, that will be run by dexdec when decompiling code. Interfaces and classes/enums in this package start with ID... or D..., respectively -- for "(Interface) dexdec" (or dex/dalvik)). Exception classes are named DexDec...Exception.

Design note: Note the symmetry with JEB's Generic Decompiler (gendec) naming conventions, whose public interfaces and types start with IE... or E.... That symmetry does not extend to naming only: dexdec IR type structure closely mirror, whenever possible, gendec's.

dexdec IR optimizer plugins may be written in Python or Java.

A sample skeleton plugin, in Python:

 #?type=dexdec-ir
 from com.pnfsoftware.jeb.core.units.code.android.ir import AbstractDOptimizer
 
 class DOptSamplePython(AbstractDOptimizer):
   def perform(self):
     # do not perform optimizations, simply print out each IR instruction of the current IR CFG
     for blk in self.cfg:  # BasicBlock (of IDInstruction)
       for insn in blk:  # IDInstruction
         logger.info("%04X: %s" % (insn.getOffset(), insn))
     # no optimization performed
     return 0
 

The same sample plugin, in Java:

 //?type=dexdec-ir
 import com.pnfsoftware.jeb.core.units.code.android.controlflow.BasicBlock;
 import com.pnfsoftware.jeb.core.units.code.android.ir.AbstractDOptimizer;
 import com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction;
 
 public class DOptSampleJava extends AbstractDOptimizer {
     // note: implicit no-arg constructor is calling super()
     
     @Override
     public int perform() {
         // do not perform optimizations, simply print out each IR instruction of the current IR CFG
         for(BasicBlock<IDInstruction> b: cfg) {
             for(IDInstruction insn: b) {
                 logger.info("%04X: %s", insn.getOffset(), insn);
             }
         }
         // no optimization performed
         return 0;
     }
 }
 
Refer to the sub-directory coreplugins/, located in the JEB installation folder, for examples.
Additional resources: refer to the User Manual and Technical Blogs, at https://www.pnfsoftware.com.

Interfaces

IDAllocObjectInfo dexdec IR object-allocation information that can be used by invoke instructions
IDArrayElt dexdec IR array element. 
IDCallInfo dexdec IR invocation information used by invoke instructions to represent calls to methods. 
IDElement Base interface for all dexdec IR elements. 
IDEmuClass An emulated class, represent the type of an emulated object. 
IDEmuContext An emulator context, used by dexdec State objects. 
IDEmuFrame An emulator frame, used by dexdec State objects. 
IDEmulatorHooks An interface for user-defined hooks called by dexdec's IR emulator when executing internal (in DEX) code. 
IDEmuObject An emulated object, representing an internal emulated object. 
IDExceptionHandler dexdec exception handler definition. 
IDExceptionItem dexdec exception item definition. 
IDExpression Base interface for all dexdec IR expressions, such as IR instructions, fields/attributes, immediates, variables/identifiers, operations, etc. 
IDField dexdec IR generic interface for field elements, that is, static fields and instance fields. 
IDGlobalContext dexdec IR global context. 
IDImm This dual-purpose dexdec IR element serves to encode immediate values (primitives and pooled strings) and evaluated values (primitives and objects). 
IDIndex dexdec IR interface for objects representing a pool index (e.g. 
IDInstanceField dexdec IR instance field. 
IDInstruction dexdec IR instruction object. 
IDInvokeInfo dexdec IR generic interface holding invocation information for IDCallInfo, IDNewInfo, IDNewArrayInfo, IDAllocObjectInfo
IDMasterOptimizer A manager of IR optimizers
IDMasterOptimizerInstrumenter Instrumenter interface for IR master optimizer (MO). 
IDMethodContext dexdec IR method context. 
IDMethodExecutionHelper Method execution helper interface, to be registered with a {@dexdec } IR state
IDNewArrayInfo dexdec IR element holding new array creation information. 
IDNewInfo dexdec IR new (alloc+init) information used by invoke instructions
IDOperation dexdec IR operation expression. 
IDOptimizer Plugin interface for dexdec (DEX decompiler) IR optimizer plugins. 
IDPredicate Special operation typed as boolean and used as conditions for IR_JCOND instructions. 
IDReferenceType dexdec IR reference type object. 
IDSandboxHooks An interface for user-defined hooks called by dexdec's IR sandbox when executing external (not in DEX) code. 
IDState dexdec IR state (referred as "State"), used to perform IR evaluations, emulation and sandboxing. 
IDStaticField dexdec IR static field, including a type's class pseudo-attribute. 
IDSwitchData dexdec IR switch data, used to specify the case and target values of a high-level switch instruction
IDTarget dexdec IR target information, containing an intra-method IR offset. 
IDTryData dexdec exception handling information, optionally provided by an IR method context
IDTypeInfoProvider Type information provider interface. 
IDVar dexdec IR interface used to represent a variable (a.k.a. 
IDVisitor Specialized tree node visitor interface for dexdec IR expressions

Classes

AbstractDInstrumenter Skeleton for an IR Master Optimizer instrumenter. 
AbstractDOptimizer Base class for dexdec (DEX decompiler) IR optimizer plugins. 
DCopyOptions IR element copy() options. 
DEmuExternalPolicy The emulation policy for API methods relying or depending on the execution environment, the date and time, and random number generators. 
DExecutionParameters dexdec IR emulation parameters object. 
DFormattingContext dexdec IR formatting context, providing an output sink and specifications for the output. 
DTypeInfo Type information object used to collect typing results when propagating types through an SSA'ed IR. 
DTypeInfo.TypingConlict Details about a typing conflict. 
DUtil dexdec IR access and manipulation utility methods. 
DVisitResults Visit result object, provided to the call-back methods of a dexdec IR visitor object. 

Enums

DInvokeType dexdec IR types of invocation, used to specify IDCallInfo
DOpcodeType This enumeration defines the opcode types of the intermediate representation (IR) instructions used by dexdec
DOptimizerType dexdec IR optimizer type. 

Exceptions

DexDecConversionException A Dalvik-to-IR conversion exception. 
DexDecEvalCodeThrownException Those objects are used to wrap throwables raised by the emulated code. 
DexDecEvalItercountExceededException The emulation is taking too long (maximum iteration count exceeded). 
DexDecEvalSandboxExecutionException An error occurred while executing code in the emulator-controlled sandbox. 
DexDecEvalStubException An internal exception used when attempting to emulate a method whose body was removed. 
DexDecEvalTimeoutExceededException The emulation is taking too long (timeout exceeded). 
DexDecEvaluationException This exception and its sub-types are throw by the State components and evaluate methods. 
DexDecNativeEvalFailedException An error occurred while evaluating native code.