DEX

Utilities

lief.DEX.is_dex(*args, **kwargs)

Overloaded function.

  1. is_dex(path: str) -> bool

Check if the file given in parameter is an DDEX

  1. is_dex(raw: List[int]) -> bool

Check if the raw data given in parameter is a DEX

lief.DEX.version(*args, **kwargs)

Overloaded function.

  1. version(file: str) -> int

Return the DEX version of the file given in parameter

  1. version(raw: List[int]) -> int

Return the DEX version of the raw data given in parameter


Parser

lief.DEX.parse(*args, **kwargs)

Overloaded function.

  1. parse(Parse the given filename and return a File objectfilename: str) -> LIEF::DEX::File

  2. parse(Parse the given raw data and return a File object

raw: List[int], name: str=’’) -> LIEF::DEX::File

  1. parse(io: object, name: str=’’) -> LIEF::DEX::File


File

class lief.DEX.File

DEX File representation

property classes

Iterator over Dex Class

property dex2dex_json_info
get_class(*args, **kwargs)

Overloaded function.

  1. get_class(self: lief.DEX.File, classname: str) -> LIEF::DEX::Class

  2. get_class(self: lief.DEX.File, classname: int) -> LIEF::DEX::Class

has_class(self: lief.DEX.File, classname: str) → bool

Check if a class with a name given in parameter exists

property header

Dex File Header

property location

Original location of the dex file

property map

Dex MapList

property methods

Iterator over Dex Method

property name

Name of the dex file

property prototypes

Iterator over Dex Prototype

raw(self: lief.DEX.File, deoptimize: bool=True) → List[int]

Original raw file

save(self: lief.DEX.File, output: str='', deoptimize: bool=True) → str

Save the original file into the file given in first parameter

property strings

Iterator over Dex strings

property types

Iterator over Dex Type

property version

Dex version



Method

class lief.DEX.Method

DEX Method representation

property access_flags

List of ACCESS_FLAGS

property bytecode

Dalvik Bytecode as a list of bytes

property cls

Class associated with this method

property code_offset

Offset to the Dalvik Bytecode

has(self: lief.DEX.Method, flag: lief.DEX.ACCESS_FLAGS) → bool

Check if the given ACCESS_FLAGS is present

property has_class

True if a class is associated with this method

property index

Original DEX file index of the method

insert_dex2dex_info(self: lief.DEX.Method, pc: int, index: int) → None

Insert de-optimization information

property is_virtual

True if the method is a virtual (not private, static, final, constructor)

property name

Method’s name

property prototype

Prototype of this method


Class

class lief.DEX.Class

DEX Class representation

property access_flags

List of ACCESS_FLAGS

property dex2dex_info

De-optimize information

property fullname

Mangled class name (e.g. Lcom/example/android/MyActivity;)

get_method(self: lief.DEX.Class, name: str) → lief.DEX.lief.DEX.it_methods

Iterator over Method (s) having the given name

has(self: lief.DEX.Class, flag: lief.DEX.ACCESS_FLAGS) → bool

Check if the given ACCESS_FLAGS is present

property has_parent

True if the current class extends another one

property index

Original index in the DEX class pool

property methods

Iterator over Method implemented in this class

property name

Class name (e.g. MyActivity)

property package_name

Package Name (e.g. com.example.android)

property parent

Class parent class

property pretty_name

Demangled class name (e.g. com.example.android.MyActivity)

property source_filename

Original filename


Code Info

class lief.DEX.CodeInfo

DEX CodeInfo representation


Prototype

class lief.DEX.Prototype

DEX Prototype representation

property parameters_type

Iterator over parameters Type

property return_type

Type returned


Type

class lief.DEX.Type

DEX Type representation

class PRIMITIVES(self: lief.DEX.Type.PRIMITIVES, arg0: int) → None
BOOLEAN = PRIMITIVES.BOOLEAN
BYTE = PRIMITIVES.BYTE
CHAR = PRIMITIVES.CHAR
DOUBLE = PRIMITIVES.DOUBLE
FLOAT = PRIMITIVES.FLOAT
INT = PRIMITIVES.INT
LONG = PRIMITIVES.LONG
SHORT = PRIMITIVES.SHORT
VOID_T = PRIMITIVES.VOID_T
class TYPES(self: lief.DEX.Type.TYPES, arg0: int) → None
ARRAY = TYPES.ARRAY
CLASS = TYPES.CLASS
PRIMITIVE = TYPES.PRIMITIVE
UNKNOWN = TYPES.UNKNOWN
property dim

If the current type is an array, return its dimension otherwise 0

pretty_name(primitive: lief.DEX.Type.PRIMITIVES) → str

Pretty name of primitives

property type

TYPES of this object

property underlying_array_type

Underlying type of the array

property value

Depending on the TYPES, return Class or PRIMITIVES or array


MapList

class lief.DEX.MapList

DEX MapList representation

get(self: lief.DEX.MapList, type: LIEF::DEX::MapItem::TYPES) → LIEF::DEX::MapItem

Return the TYPES from the given TYPES

has(self: lief.DEX.MapList, type: LIEF::DEX::MapItem::TYPES) → bool

Check if the given TYPES is present

property items

Iterator over MapItem


MapItem

class lief.DEX.MapItem

DEX MapItem representation

class TYPES(self: lief.DEX.MapItem.TYPES, arg0: int) → None
ANNOTATION = TYPES.ANNOTATION
ANNOTATIONS_DIRECTORY = TYPES.ANNOTATIONS_DIRECTORY
ANNOTATION_SET = TYPES.ANNOTATION_SET
ANNOTATION_SET_REF_LIST = TYPES.ANNOTATION_SET_REF_LIST
CALL_SITE_ID = TYPES.CALL_SITE_ID
CLASS_DATA = TYPES.CLASS_DATA
CLASS_DEF = TYPES.CLASS_DEF
CODE = TYPES.CODE
DEBUG_INFO = TYPES.DEBUG_INFO
ENCODED_ARRAY = TYPES.ENCODED_ARRAY
FIELD_ID = TYPES.FIELD_ID
HEADER = TYPES.HEADER
MAP_LIST = TYPES.MAP_LIST
METHOD_HANDLE = TYPES.METHOD_HANDLE
METHOD_ID = TYPES.METHOD_ID
PROTO_ID = TYPES.PROTO_ID
STRING_DATA = TYPES.STRING_DATA
STRING_ID = TYPES.STRING_ID
TYPE_ID = TYPES.TYPE_ID
TYPE_LIST = TYPES.TYPE_LIST
property offset

Offset from the start of the file to the items in question

property size

count of the number of items to be found at the indicated offset

property type

TYPES of the item


Enums

Access Flags

class lief.DEX.ACCESS_FLAGS(self: lief.DEX.ACCESS_FLAGS, arg0: int) → None
ABSTRACT = ACCESS_FLAGS.ABSTRACT
ANNOTATION = ACCESS_FLAGS.ANNOTATION
CONSTRUCTOR = ACCESS_FLAGS.CONSTRUCTOR
DECLARED_SYNCHRONIZED = ACCESS_FLAGS.DECLARED_SYNCHRONIZED
ENUM = ACCESS_FLAGS.ENUM
FINAL = ACCESS_FLAGS.FINAL
INTERFACE = ACCESS_FLAGS.INTERFACE
NATIVE = ACCESS_FLAGS.NATIVE
PRIVATE = ACCESS_FLAGS.PRIVATE
PROTECTED = ACCESS_FLAGS.PROTECTED
PUBLIC = ACCESS_FLAGS.PUBLIC
STATIC = ACCESS_FLAGS.STATIC
STRICT = ACCESS_FLAGS.STRICT
SYNCHRONIZED = ACCESS_FLAGS.SYNCHRONIZED
SYNTHETIC = ACCESS_FLAGS.SYNTHETIC
TRANSIENT = ACCESS_FLAGS.TRANSIENT
UNKNOWN = ACCESS_FLAGS.UNKNOWN
VOLATILE = ACCESS_FLAGS.VOLATILE