OAT

Utilities

bool LIEF::OAT::is_oat(const LIEF::ELF::Binary &elf_binary)

Check if the given LIEF::ELF::Binary is an OAT one.

bool LIEF::OAT::is_oat(const std::string &file)

Check if the given file is an OAT one.

bool LIEF::OAT::is_oat(const std::vector<uint8_t> &raw)

Check if the given raw data is an OAT one.

oat_version_t LIEF::OAT::version(const LIEF::ELF::Binary &elf_binary)

Return the OAT version of the given LIEF::ELF::Binary.

oat_version_t LIEF::OAT::version(const std::string &file)

Return the OAT version of the given file.

oat_version_t LIEF::OAT::version(const std::vector<uint8_t> &raw)

Return the OAT version of the raw data.

LIEF::Android::ANDROID_VERSIONS LIEF::OAT::android_version(oat_version_t version)

Return the ANDROID_VERSIONS associated with the given OAT version.


Parser

class Parser : public LIEF::ELF::Parser

Class to parse an OAT file to produce an OAT::Binary.

Public Functions

Parser &operator=(const Parser &copy) = delete
Parser(const Parser &copy) = delete

Public Static Functions

static std::unique_ptr<Binary> parse(const std::string &oat_file)

Parse an OAT file.

static std::unique_ptr<Binary> parse(const std::string &oat_file, const std::string &vdex_file)
static std::unique_ptr<Binary> parse(std::vector<uint8_t> data)

Binary

class Binary : public LIEF::ELF::Binary

Public Types

using dex_files_t = std::vector<std::unique_ptr<DEX::File>>
using it_dex_files = ref_iterator<dex_files_t&, DEX::File*>
using it_const_dex_files = const_ref_iterator<const dex_files_t&, const DEX::File*>
using classes_t = std::unordered_map<std::string, Class*>
using classes_list_t = std::vector<std::unique_ptr<Class>>
using it_classes = ref_iterator<classes_list_t&, Class*>
using it_const_classes = const_ref_iterator<const classes_list_t&, const Class*>
using oat_dex_files_t = std::vector<std::unique_ptr<DexFile>>
using it_oat_dex_files = ref_iterator<oat_dex_files_t&, DexFile*>
using it_const_oat_dex_files = const_ref_iterator<const oat_dex_files_t&, const DexFile*>
using methods_t = std::vector<std::unique_ptr<Method>>
using it_methods = ref_iterator<methods_t&, Method*>
using it_const_methods = const_ref_iterator<const methods_t&, const Method*>
using dex2dex_info_t = std::unordered_map<const DEX::File*, DEX::dex2dex_info_t>

Public Functions

Binary &operator=(const Binary &copy) = delete
Binary(const Binary &copy) = delete
const Header &header() const

OAT Header.

Header &header()
it_dex_files dex_files()

Iterator over LIEF::DEX::File.

it_const_dex_files dex_files() const
it_oat_dex_files oat_dex_files()

Iterator over LIEF::OAT::DexFile.

it_const_oat_dex_files oat_dex_files() const
it_const_classes classes() const

Iterator over LIEF::OAT::Class.

it_classes classes()
bool has_class(const std::string &class_name) const

Check if the current OAT has the given class.

const Class *get_class(const std::string &class_name) const

Return the LIEF::OAT::Class with the given name or a nullptr if the class can’t be found.

Class *get_class(const std::string &class_name)
const Class *get_class(size_t index) const

Return the LIEF::OAT::Class at the given index or a nullptr if it does not exist.

Class *get_class(size_t index)
it_const_methods methods() const

Iterator over LIEF::OAT::Method.

it_methods methods()
dex2dex_info_t dex2dex_info() const
std::string dex2dex_json_info()
inline bool has_vdex() const
virtual void accept(Visitor &visitor) const override

Method associated with the visitor pattern.

~Binary() override

Public Static Functions

static inline bool classof(const LIEF::Binary *bin)

Friends

friend std::ostream &operator<<(std::ostream &os, const Binary &binary)


DexFile

class DexFile : public LIEF::Object

Public Functions

DexFile()
DexFile(const DexFile&)
DexFile &operator=(const DexFile&)
const std::string &location() const
uint32_t checksum() const
uint32_t dex_offset() const
bool has_dex_file() const
const DEX::File *dex_file() const
DEX::File *dex_file()
void location(const std::string &location)
void checksum(uint32_t checksum)
void dex_offset(uint32_t dex_offset)
const std::vector<uint32_t> &classes_offsets() const
uint32_t lookup_table_offset() const
void class_offsets_offset(uint32_t offset)
void lookup_table_offset(uint32_t offset)
virtual void accept(Visitor &visitor) const override
~DexFile() override

Friends

friend std::ostream &operator<<(std::ostream &os, const DexFile &dex_file)

Class

class Class : public LIEF::Object

Public Types

using methods_t = std::vector<Method*>
using it_methods = ref_iterator<methods_t&>
using it_const_methods = const_ref_iterator<const methods_t&>

Public Functions

Class()
Class(OAT_CLASS_STATUS status, OAT_CLASS_TYPES type, DEX::Class *dex_class, std::vector<uint32_t> bitmap = {})
Class(const Class&)
Class &operator=(const Class&)
bool has_dex_class() const
const DEX::Class *dex_class() const
DEX::Class *dex_class()
OAT_CLASS_STATUS status() const
OAT_CLASS_TYPES type() const
const std::string &fullname() const
size_t index() const
it_methods methods()
it_const_methods methods() const
const std::vector<uint32_t> &bitmap() const
bool is_quickened(const DEX::Method &m) const
bool is_quickened(uint32_t relative_index) const
uint32_t method_offsets_index(const DEX::Method &m) const
uint32_t method_offsets_index(uint32_t relative_index) const
uint32_t relative_index(const DEX::Method &m) const
uint32_t relative_index(uint32_t method_absolute_index) const
DEX::dex2dex_class_info_t dex2dex_info() const
virtual void accept(Visitor &visitor) const override
~Class() override

Friends

friend std::ostream &operator<<(std::ostream &os, const Class &cls)

Method

class Method : public LIEF::Object

Public Types

using quick_code_t = std::vector<uint8_t>

Container for the Quick Code.

Public Functions

Method()
Method(DEX::Method *method, Class *oat_class, std::vector<uint8_t> code = {})
Method(const Method&)
Method &operator=(const Method&)
std::string name() const

Method’s name.

const Class *oat_class() const

OAT Class associated with this Method.

Class *oat_class()
bool has_dex_method() const

Check if a LIEF::DEX::Method is associated with this Method.

const DEX::Method *dex_method() const

LIEF::DEX::Method associated (if any)

DEX::Method *dex_method()
bool is_dex2dex_optimized() const

True if the optimization is DEX.

bool is_compiled() const
const DEX::dex2dex_method_info_t &dex2dex_info() const
const quick_code_t &quick_code() const

Quick code associated with the method.

void quick_code(const quick_code_t &code)
virtual void accept(Visitor &visitor) const override
~Method() override

Friends

friend std::ostream &operator<<(std::ostream &os, const Method &meth)

Enums

OAT Class types

enum LIEF::OAT::OAT_CLASS_TYPES

Values:

enumerator OAT_CLASS_ALL_COMPILED = 0
enumerator OAT_CLASS_SOME_COMPILED = 1

OatClass is followed by an OatMethodOffsets for each method.

enumerator OAT_CLASS_NONE_COMPILED = 2

A bitmap of which OatMethodOffsets are present follows the OatClass.


OAT Class Status

enum LIEF::OAT::OAT_CLASS_STATUS

Values:

enumerator STATUS_RETIRED = -2
enumerator STATUS_ERROR = -1
enumerator STATUS_NOTREADY = 0
enumerator STATUS_IDX = 1
enumerator STATUS_LOADED = 2
enumerator STATUS_RESOLVING = 3
enumerator STATUS_RESOLVED = 4
enumerator STATUS_VERIFYING = 5
enumerator STATUS_RETRY_VERIFICATION_AT_RUNTIME = 6
enumerator STATUS_VERIFYING_AT_RUNTIME = 7
enumerator STATUS_VERIFIED = 8
enumerator STATUS_INITIALIZING = 9
enumerator STATUS_INITIALIZED = 10

Header Keys

enum LIEF::OAT::HEADER_KEYS

Values:

enumerator KEY_IMAGE_LOCATION = 0
enumerator KEY_DEX2OAT_CMD_LINE = 1
enumerator KEY_DEX2OAT_HOST = 2
enumerator KEY_PIC = 3
enumerator KEY_HAS_PATCH_INFO = 4
enumerator KEY_DEBUGGABLE = 5
enumerator KEY_NATIVE_DEBUGGABLE = 6
enumerator KEY_COMPILER_FILTER = 7
enumerator KEY_CLASS_PATH = 8
enumerator KEY_BOOT_CLASS_PATH = 9
enumerator KEY_CONCURRENT_COPYING = 10
enumerator KE_COMPILATION_REASON = 11

Instruction sets

enum LIEF::OAT::INSTRUCTION_SETS

Values:

enumerator INST_SET_NONE = 0
enumerator INST_SET_ARM = 1
enumerator INST_SET_ARM_64 = 2
enumerator INST_SET_THUMB2 = 3
enumerator INST_SET_X86 = 4
enumerator INST_SET_X86_64 = 5
enumerator INST_SET_MIPS = 6
enumerator INST_SET_MIPS_64 = 7