Interface IDexDecompilerUnit

All Superinterfaces:
IAddressableUnit, IDecompilerUnit, IEventSource, IInteractiveUnit, IUnit, IUnitCreator, IUserDataSupport

@Ser public interface IDexDecompilerUnit extends IDecompilerUnit
Specialized interface representing Dex (Dalvik) decompiler Units.
  • Field Details

    • propnameEmulatorConfigPath

      static final String propnameEmulatorConfigPath
      Unit property name for the emulator configuration path.
      See Also:
  • Method Details

    • getCodeUnit

      IDexUnit getCodeUnit()
      Description copied from interface: IDecompilerUnit
      Get the code unit (possibly the parent, possibly null) that is providing the low-level data to this decompiler.
      Specified by:
      getCodeUnit in interface IDecompilerUnit
      Returns:
      a code unit, possibly null
    • getIntermediateContext

      IDGlobalContext getIntermediateContext()
      Retrieve the global IR context.
      Returns:
      the global IR context
    • getHighLevelContext

      IJavaGlobalContext getHighLevelContext()
      Retrieve the global AST context.
      Returns:
      the global AST context
    • getDynamicContentManager

      IDynamicContentManager getDynamicContentManager()
      Retrieve a DCR used during AST generation.
      Returns:
      the dynamic content manager
    • setIdentifierName

      boolean setIdentifierName(String msig, String currentName, String newName)
      Rename an identifier by method signature and current name.
      Parameters:
      msig - method signature
      currentName - current identifier name
      newName - new identifier name
      Returns:
      success indicator
    • setIdentifierName

      boolean setIdentifierName(IJavaIdentifier ident, String name)
      Rename an identifier.
      Parameters:
      ident - identifier to rename
      name - new name
      Returns:
      success indicator
    • setIdentifierName

      boolean setIdentifierName(IJavaIdentifier ident, String name, boolean failOnNameConflict, boolean notify)
      Rename an identifier.
      Parameters:
      ident - identifier to rename
      name - new name
      failOnNameConflict - true to fail if the name conflicts with another identifier
      notify - true to notify listeners of the change
      Returns:
      success indicator
    • getIdentifierName

      String getIdentifierName(IJavaIdentifier ident)
      Retrieve the effective (renamed) name of an identifier in this method's AST.
      Parameters:
      ident - identifier
      Returns:
      the effective name
    • getClass

      IJavaClass getClass(String csig, boolean createIfNotExist)
      Retrieve a previously decompiled AST class object or create an empty AST class element.
      Parameters:
      csig - class signature
      createIfNotExist - true to create an empty element if none exists
      Returns:
      the Java class, or null if none exists and creation was not requested
    • getField

      IJavaField getField(String fsig, boolean createIfNotExist)
      Retrieve a previously decompiled AST field object or create an empty AST field element.
      Parameters:
      fsig - field signature
      createIfNotExist - true to create an empty element if none exists
      Returns:
      the Java field, or null if none exists and creation was not requested
    • getMethod

      IJavaMethod getMethod(String msig, boolean createIfNotExist)
      Retrieve a previously decompiled AST method object or create an empty AST method element.
      Parameters:
      msig - method signature
      createIfNotExist - true to create an empty element if none exists
      Returns:
      the Java method, or null if none exists and creation was not requested
    • resetDecompilation

      void resetDecompilation(String identifier)
      Remove a decompiled object (i.e., same as IDecompilerUnit.removeDecompilation(String).) For a dex decompiler, reset and removal actions are equivalent.
      Specified by:
      resetDecompilation in interface IDecompilerUnit
      Parameters:
      identifier - identifier or address
    • resetClassElement

      boolean resetClassElement(IJavaClass c)
      Remove an AST class object.
      Parameters:
      c - class to reset
      Returns:
      success indicator
    • resetFieldElement

      boolean resetFieldElement(IJavaField f)
      Remove an AST field object.
      Parameters:
      f - field to reset
      Returns:
      success indicator
    • resetMethodElement

      boolean resetMethodElement(IJavaMethod m)
      Remove an AST method object.
      Parameters:
      m - method to reset
      Returns:
      success indicator
    • registerEventQueue

      void registerEventQueue(DexDecompilerEventQueue queue)
      Register a user-controlled event queue that will receive decompilation events.
      Parameters:
      queue - event queue to register
    • unregisterEventQueue

      void unregisterEventQueue(DexDecompilerEventQueue queue)
      Unregister a previously registered user-controlled decompilation event queue.
      Parameters:
      queue - event queue to unregister
    • getGlobalDecompilationEvents

      Collection<DexDecompilerEvent<?>> getGlobalDecompilationEvents()
      Retrieve the list decompilation events, without duplicates. Note that this queue is managed separately than user-controlled event queues.
      Returns:
      the global decompilation events
    • getGlobalDecompilationEvents

      Collection<DexDecompilerEvent<?>> getGlobalDecompilationEvents(boolean keepDuplicates)
      Retrieve a copy of the decompilation events. Note that this queue is managed separately than user-controlled event queues.
      Parameters:
      keepDuplicates - if true, duplicate events will be present in the returned collection
      Returns:
      the global decompilation events
    • resetGlobalDecompilationEvents

      void resetGlobalDecompilationEvents()
      Reset the global decompilation events list. This operation is not reversible.
    • recordDecompilationEvent

      void recordDecompilationEvent(DexDecompilerEvent<?> event)
      Record a decompilation event.
      Parameters:
      event - event to record
    • addSpecialComment

      void addSpecialComment(String address, String value)
      Add a special comment to the decompiled output.
      Parameters:
      address - target address
      value - comment value
    • clearSpecialComments

      void clearSpecialComments(String address)
      Clear special comments at an address.
      Parameters:
      address - target address
    • createEmulatedAndroid

      IEmulatedAndroid createEmulatedAndroid()
      Create a limited environment to emulate dex code and native code. Currently, the emulated environment is a simple Arm 64-bit (aarch64) Android 13 system (API level 33). This dex decompiler must be the descendant of an APK unit.
      Returns:
      an emulated Android environment
    • createGenericUnpacker

      IGenericUnpacker createGenericUnpacker()
      Create a generic unpacker, backed by an emulated-android object, that can be used to attempt to retrieve resources unpacked at runtime. This dex decompiler must be the descendant of an APK unit.
      Returns:
      an emulated Android environment
    • formatOngoingDecompilations

      String formatOngoingDecompilations()
      Generate a user-friendly text buffer of the decompilations currently being performed by this unit.
      Returns:
      formatted ongoing decompilation information
    • setCachePolicy

      default void setCachePolicy(int maxCount, int maxSeconds)
      Deprecated.
      Parameters:
      maxCount - maximum number of entries in the cache
      maxSeconds - timeout in seconds after the last access
    • setIRCachePolicy

      void setIRCachePolicy(int maxCount, int maxSeconds)
      Set the policy for the cache of decompiled IRs.

      Special calls:
      - To store all IRs and disabled cache eviction, call with maxCount=-1 and maxSeconds=-1.
      - To disabled IR storage entirely, call with maxCount=0 or maxSeconds=0.

      Parameters:
      maxCount - maximum number of entries in the cache (-1 means no cap, which is not recommended; 0 can be used to disable caching entirely)
      maxSeconds - starting from the last access to an entry, this value is a timeout in seconds after which the entry is auto-removed from the cache (-1 means no time-based removal)
    • clearCachedIRs

      void clearCachedIRs()
      Forcefully clear the cache of IRs for decompiled methods.
    • getCountOfCachedIRs

      int getCountOfCachedIRs()
      Retrieve the number of cached IRs for decompiled methods.
      Returns:
      the number of cached IRs
    • retrieveCachedIR

      IDMethodContext retrieveCachedIR(String msig)
      Attempt to retrieve the Intermediate Representation (IR) of a previously decompiled method.
      Parameters:
      msig - original method signature (internal format, e.g. Lcom/xyz/Object;->foo(I)V)
      Returns:
      an IR object or null if it was not found in the cache
    • retrieveCachedIRs

      List<IDMethodContext> retrieveCachedIRs()
      Retrieve all cached IRs available at this time.
      Returns:
      a list of IR method contexts (the list is a copy of the cache and may be modified without affecting the cache)
    • setCodeMatchingOverride

      Boolean setCodeMatchingOverride(Boolean enabled)
      Override the .CodeMatchSetting unit property.

      Note: this flag does not override IDecompilerUnit.FLAG_ALLOW_EXTRA_WORK, which must a required condition to allow code matching

      Parameters:
      enabled - null to disable the override; true to force-enable code matching; false to force-disable code matching
      Returns:
      the previous setting for the override
    • getCodeMatchingOverride

      Boolean getCodeMatchingOverride()
      Retrieve the code matching behavior override. Refer to setCodeMatchingOverride(Boolean) for details.
      Returns:
      null if there is no override; else, a boolean value
    • applyCodeMatches

      int applyCodeMatches()
      Apply the currently un-applied code matches. When applying matches, matched methods may be renamed, classes may be renamed and/or moved to existing or newly-created packages. Related types may be renamed as well.

      Note: if the .CodeMatchSetting unit property is set to 2 or above, this method is automatically called after IDecompilerUnit.decompileToUnit(java.lang.String).

      Returns:
      a number indicating the number of modifications performed (e.g. renames, moves, etc.)
    • getUnappliedCodeMatches

      Map<String,MethodMatch> getUnappliedCodeMatches()
      Retrieve the currently un-applied code matches.
      Returns:
      a map of original internal method signature to its current best code match
    • clearCodeMatches

      void clearCodeMatches()
      Clear the map of currently un-applied code matches.