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)).

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:

 # file: DexDecIRPluginSample.py
 from com.pnfsoftware.jeb.core.units.code.android.ir import AbstractDOptimizer
 
 class DexDecIRPluginSample(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:

 # file: DexDecIRPluginSample.java
 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 DexDecIRPluginSample 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

IDArrayElt dexdec IR array element. 
IDCallInfo dexdec IR invocation information used by invoke instructions
IDElement Base interface for all dexdec IR elements. 
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
IDMethodContext dexdec IR method context. 
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. 
IDState dexdec IR state, used to perform IR evaluations. 
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  
IDVar dexdec IR interface used to represent a variable (identifier). 
IDVisitor Specialized tree node visitor interface for dexdec IR expressions

Classes

AbstractDOptimizer Base class for dexdec (DEX decompiler) IR optimizer plugins. 
DCopyOptions IR element copy() options. 
DFormattingContext dexdec IR formatting context, providing an output sink and specifications for the output. 
DTreeVisitResults Visit result object, provided to the call-back methods of a dexdec IR visitor object. 
DUtil dexdec IR access and manipulation utility methods. 

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

DexDecEvaluationException This exception and its sub-types are throw by evaluate(IDMethodContext) methods.