Interface IDecompilerUnit

All Superinterfaces:
IAddressableUnit, IEventSource, IInteractiveUnit, IUnit, IUnitCreator, IUserDataSupport
All Known Subinterfaces:
IDexDecompilerUnit, INativeDecompilerUnit<InsnType>

@Ser public interface IDecompilerUnit extends IInteractiveUnit
Generic interface for decompilers.
  • Field Details

    • propnameListOfDisabledExternalPlugins

      static final String propnameListOfDisabledExternalPlugins
      See Also:
    • FLAG_NO_INNER_DECOMPILATION

      static final int FLAG_NO_INNER_DECOMPILATION
      Restrictive flag: shallow decompilation (eg, a request to decompile a method would not decompile inner items contained within the method).

      A decompiler may choose to ignore this flag.

      See Also:
    • FLAG_NO_DEFERRED_DECOMPILATION

      static final int FLAG_NO_DEFERRED_DECOMPILATION
      Restrictive flag: disallow deferred decompilations. Deferred decompilations are decompilations of additional items, that usually take place after the main request has completed or partially completed, in order to provide better output.

      A decompiler may choose to ignore this flag.

      See Also:
    • FLAG_NO_CONCURRENT_DECOMPILATION

      static final int FLAG_NO_CONCURRENT_DECOMPILATION
      Restrictive flag: if the decompiler supports concurrent decompilations (multi-threading), setting this flag requests it to disable it and perform serial decompilations.

      A decompiler may choose to ignore this flag.

      See Also:
    • FLAG_NO_METHOD_AST_GENERATION

      static final int FLAG_NO_METHOD_AST_GENERATION
      Special flag indicating that the final stage of a method decompilation (the generation and optimization of its abstract syntax tree) shall be skipped.

      By using this flags, these other flags will be automatically set: FLAG_NO_DEFERRED_DECOMPILATION.
      It is also recommended to use FLAG_NO_INNER_DECOMPILATION when setting this flag.

      A decompiler cannot ignore this flag.

      See Also:
    • FLAG_TEMP_FORCED_REDECOMPILATIONS

      static final int FLAG_TEMP_FORCED_REDECOMPILATIONS
      Special flag indicating that already decompiled methods should be temporarily redecompiled. Existing decompilations will not be replaced by new ones.

      By using this flags, these other flags will be automatically set: FLAG_NO_DEFERRED_DECOMPILATION, FLAG_NO_METHOD_AST_GENERATION.
      It is also recommended to use FLAG_NO_INNER_DECOMPILATION when setting this flag.

      A decompiler cannot ignore this flag.

      See Also:
    • FLAG_BATCH_DECOMPILATION

      static final int FLAG_BATCH_DECOMPILATION
      This indicative flag is to let the decompiler know that the current decompilation is part of a batch decompilation. This flag may be provided to internal components, that may change their behavior when it is set.

      A decompiler may ignore this flag.

      See Also:
    • FLAG_KEEP_IR

      static final int FLAG_KEEP_IR
      This indicative flag is to let the decompiler know that the intermediate representation shall be kept.

      A decompiler may not be able to honor this flag.

      See Also:
    • FLAG_STANDALONE_IR_CONVERSION

      static final int FLAG_STANDALONE_IR_CONVERSION
      Indicate that the decompiler should perform a fresh decompilation up to the NativeDecompilationStage.IR_CONVERSION stage (regardless of the provided user-requested stage). The decompilation will not be registered with the decompiler. In general, this flag should be combined with FLAG_KEEP_IR in order to examine the IR post decompilation.

      A decompiler may not be able to honor this flag.

      See Also:
  • Method Details

    • getCodeUnit

      ICodeUnit getCodeUnit()
      Get the code unit (possibly the parent, possibly null) that is providing the low-level data to this decompiler.
      Returns:
      a code unit, possibly null
    • getOutputType

      DecompilerOutputType getOutputType()
      Get the type of output produced by this decompiler.
      Returns:
      the unit (newly created or retrieved) or null if no decompilation could be performed
    • canDecompile

      boolean canDecompile(String identifier)
      Determine if a decompilation at the provided identifier/address has a chance to succeed. A positive result may result in a valid decompilation; a negative result will always result in an invalid/impossible decompilation.
      Parameters:
      identifier -
      Returns:
    • getDecompiledUnit

      ISourceUnit getDecompiledUnit(String identifier)
      Retrieve the unit representing the decompiled entity at the provided identifier/address. No decompilation is performed.
      Parameters:
      identifier - the identifier or address
      Returns:
      the unit or null, if no decompilation at the provided identifier previously took place
    • decompileToUnit

      ISourceUnit decompileToUnit(String identifier)
      Retrieve a decompiled unit or perform a decompilation. This is a high-level function used to decompile generate meaningful (to clients) decompiled code units. The decompiler may normalize the identifier.
      Parameters:
      identifier - the identifier or address at which the decompilation should be performed
      Returns:
      the source unit
    • decompileToUnit

      ISourceUnit decompileToUnit(String identifier, DecompilationContext ctx)
      Retrieve a decompiled unit or perform a decompilation. This is a high-level function used to decompile and generate meaningful (to clients) source code units. The decompiler may normalize the identifier.

      If a source unit encompassing the provided identifier address already exists, it is returned.

      Parameters:
      identifier - the identifier or address at which the decompilation should be performed
      ctx - optional decompilation context and options
      Returns:
      a source unit, null on error
    • decompileClass

      boolean decompileClass(String identifier)
      Decompile a class.
      Parameters:
      identifier - class identifier
      Returns:
      success indicator
    • decompileClass

      boolean decompileClass(String identifier, DecompilationContext ctx)
      Decompile a class.
      Parameters:
      identifier - class identifier
      ctx -
      Returns:
      success indicator
    • decompileField

      boolean decompileField(String identifier)
      Decompile a field.
      Parameters:
      identifier - field identifier
      Returns:
      success indicator
    • decompileField

      boolean decompileField(String identifier, DecompilationContext ctx)
      Decompile a field.
      Parameters:
      identifier - field identifier
      ctx -
      Returns:
      success indicator
    • decompileMethod

      boolean decompileMethod(String identifier)
      Decompile a method.
      Parameters:
      identifier - method identifier
      Returns:
      success indicator
    • decompileMethod

      boolean decompileMethod(String identifier, DecompilationContext ctx)
      Decompile a method.
      Parameters:
      identifier - method identifier
      ctx -
      Returns:
      success indicator
    • decompileMethods

      boolean decompileMethods(Collection<String> identifiers, DecompilationContext ctx)
      Decompile a collection of methods.
      Parameters:
      identifiers -
      ctx -
      Returns:
      true if and only if all requested methods were successfully decompiled
    • decompileAllMethods

      boolean decompileAllMethods(DecompilationContext ctx)
      Decompile all methods.
      Parameters:
      ctx -
      Returns:
      true if and only if all methods were successfully decompiled
    • decompileClasses

      boolean decompileClasses(Collection<String> identifiers, DecompilationContext ctx)
      Decompile a collection of classes.
      Parameters:
      identifiers -
      ctx -
      Returns:
      true if and only if all requested classes were successfully decompiled
    • decompileAllClasses

      boolean decompileAllClasses(DecompilationContext ctx)
      Decompile all classes.
      Parameters:
      ctx -
      Returns:
      true if and only if all classes were successfully decompiled
    • decompileAll

      boolean decompileAll(DecompilationContext ctx)
      Decompile everything meaningful.
      Parameters:
      ctx -
      Returns:
      true if and only if all decompilations succeeded
    • decompile

      boolean decompile(Collection<String> identifiers, DecompilationContext ctx)
      Decompile multiple items.
      Parameters:
      identifiers - a collection of item identifiers to be decompiled
      ctx - optional context
      Returns:
      true if and only if all decompilations succeeded
    • resetDecompilation

      void resetDecompilation(String identifier)
      Reset a decompilation.

      Note that if a source unit representing the decompiled object exists, it is not guaranteed to be removed. It will simply be reset, making a redecompilation possible. In order to remove a child unit of a decompiler, use IUnit.removeChild(com.pnfsoftware.jeb.core.units.IUnit). To do a proper removal, use removeDecompilation(String).

      Parameters:
      identifier -
    • removeDecompilation

      void removeDecompilation(String identifier)
      Remove a decompilation.
      Parameters:
      identifier -
    • resetAllDecompilations

      void resetAllDecompilations()
      Reset all decompilations.
    • removeAllDecompilations

      void removeAllDecompilations()
      Remove all decompilations.
    • removeFreeElements

      void removeFreeElements()
      Remove all decompilation objects that exist but are not directly or indirectly managed by an existing decompiled source unit.
    • runGarbageCollection

      default void runGarbageCollection()
      This method instructs the decompiler to perform garbage collection. It includes the actions performed by removeFreeElements().
    • getDecompiledText

      String getDecompiledText(String identifier)
      Retrieve the decompiled source for the provided item.
      Parameters:
      identifier - object identifier
      Returns:
    • getDecompiledClassText

      String getDecompiledClassText(String identifier)
      Retrieve the decompiled source for the provided class.
      Parameters:
      identifier - class identifier
      Returns:
    • getDecompiledFieldText

      String getDecompiledFieldText(String identifier)
      Retrieve the decompiled source for the provided field.
      Parameters:
      identifier - field identifier
      Returns:
    • getDecompiledMethodText

      String getDecompiledMethodText(String identifier)
      Retrieve the decompiled source for the provided method.
      Parameters:
      identifier - method identifier
      Returns:
    • canPerformConcurrentDecompilations

      boolean canPerformConcurrentDecompilations()
      Determine whether this decompiler can perform decompilations concurrently.
      Returns:
    • getThreadPoolSize

      int getThreadPoolSize()
      Set the maximum number of threads to be used when decompiling multiple items concurrently.

      Will always return 1 if canPerformConcurrentDecompilations() is false.

      Returns:
    • setThreadPoolSize

      void setThreadPoolSize(int threadPoolSize)
      Get the maximum number of threads to be used when decompiling multiple items concurrently.

      N/A if canPerformConcurrentDecompilations() is false.

      Parameters:
      threadPoolSize -
    • getExporter

      DecompilerExporter getExporter()
      Convenience method used to create an exporter object used to decompile and export some or all potentially decompilable to source files on disk.
      Returns: