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 LIEF::OAT::Parser : public LIEF::Parser

Class which parse an OAT file and transform into a OAT::Binary.

Public Functions

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

Public Static Functions

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

Parse an OAT file.

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

Friends

friend struct ::Profiler

Binary

class LIEF::OAT::Binary : public LIEF::ELF::Binary

Public Functions

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

OAT Header.

Header &header(void)
DEX::it_dex_files dex_files(void)

Iterator over LIEF::DEX::File.

DEX::it_const_dex_files dex_files(void) const
it_dex_files oat_dex_files(void)

Iterator over LIEF::OAT::DexFile.

it_const_dex_files oat_dex_files(void) const
it_const_classes classes(void) const

Iterator over LIEF::OAT::Class.

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

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

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.

Class &get_class(size_t index)
it_const_methods methods(void) const

Iterator over LIEF::OAT::Method.

it_methods methods(void)
dex2dex_info_t dex2dex_info(void) const
std::string dex2dex_json_info(void)
bool operator==(const Binary &rhs) const
bool operator!=(const Binary &rhs) const
void accept(Visitor &visitor) const override

Method so that the visitor can visit us.

~Binary(void)

Friends

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

class LIEF::OAT::Header : public LIEF::Object

Public Types

using magic_t = std::array<uint8_t, sizeof(oat_magic)>
using key_values_t = std::map<HEADER_KEYS, std::string>
using it_key_values_t = ref_iterator<std::vector<std::pair<HEADER_KEYS, std::reference_wrapper<std::string>>>>
using it_const_key_values_t = const_ref_iterator<std::vector<std::pair<HEADER_KEYS, std::string>>>
using keys_t = std::vector<HEADER_KEYS>

Iterator type over.

using values_t = std::vector<std::string>

Public Functions

Header(void)
Header(const Header&)
Header &operator=(const Header&)
template<class T>
Header(const T *header)
Header::magic_t magic(void) const

Magic value: oat

oat_version_t version(void) const

OAT version.

uint32_t checksum(void) const
INSTRUCTION_SETS instruction_set(void) const
uint32_t nb_dex_files(void) const
uint32_t oat_dex_files_offset(void) const
uint32_t executable_offset(void) const
uint32_t i2i_bridge_offset(void) const
uint32_t i2c_code_bridge_offset(void) const
uint32_t jni_dlsym_lookup_offset(void) const
uint32_t quick_generic_jni_trampoline_offset(void) const
uint32_t quick_imt_conflict_trampoline_offset(void) const
uint32_t quick_resolution_trampoline_offset(void) const
uint32_t quick_to_interpreter_bridge_offset(void) const
int32_t image_patch_delta(void) const
uint32_t image_file_location_oat_checksum(void) const
uint32_t image_file_location_oat_data_begin(void) const
uint32_t key_value_size(void) const
it_key_values_t key_values(void)
it_const_key_values_t key_values(void) const
keys_t keys(void) const
values_t values(void) const
const std::string &get(HEADER_KEYS key) const
std::string &get(HEADER_KEYS key)
Header &set(HEADER_KEYS key, const std::string &value)
const std::string &operator[](HEADER_KEYS key) const
std::string &operator[](HEADER_KEYS key)
void magic(const magic_t &magic)
void accept(Visitor &visitor) const override
bool operator==(const Header &rhs) const
bool operator!=(const Header &rhs) const

Public Static Functions

std::string key_to_string(HEADER_KEYS key)

Return the string value associated with the given key.

Friends

std::ostream &operator<<(std::ostream &os, const Header &hdr)

DexFile

class LIEF::OAT::DexFile : public LIEF::Object

Public Functions

DexFile(void)
DexFile(const DexFile&)
DexFile &operator=(const DexFile&)
const std::string &location(void) const
uint32_t checksum(void) const
uint32_t dex_offset(void) const
bool has_dex_file(void) const
const DEX::File &dex_file(void) const
DEX::File &dex_file(void)
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(void) const
uint32_t lookup_table_offset(void) const
void class_offsets_offset(uint32_t offset)
void lookup_table_offset(uint32_t offset)
void accept(Visitor &visitor) const override
bool operator==(const DexFile &rhs) const
bool operator!=(const DexFile &rhs) const
~DexFile(void)

Friends

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

Class

class LIEF::OAT::Class : public LIEF::Object

Public Functions

Class(void)
Class(OAT_CLASS_STATUS status, OAT_CLASS_TYPES type, DEX::Class *dex_class, const std::vector<uint32_t> &bitmap = {})
Class(const Class&)
Class &operator=(const Class&)
bool has_dex_class(void) const
const DEX::Class &dex_class(void) const
DEX::Class &dex_class(void)
OAT_CLASS_STATUS status(void) const
OAT_CLASS_TYPES type(void) const
const std::string &fullname(void) const
size_t index(void) const
it_methods methods(void)
it_const_methods methods(void) const
const std::vector<uint32_t> &bitmap(void) 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(void) const
void accept(Visitor &visitor) const override
bool operator==(const Class &rhs) const
bool operator!=(const Class &rhs) const
~Class(void)

Friends

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

Method

class LIEF::OAT::Method : public LIEF::Object

Public Types

using quick_code_t = std::vector<uint8_t>

Container for the Quick Code.

Public Functions

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

Method’s name.

const Class &oat_class(void) const

OAT Class associated with this Method.

Class &oat_class(void)
bool has_dex_method(void) const

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

const DEX::Method &dex_method(void) const

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

DEX::Method &dex_method(void)
bool is_dex2dex_optimized(void) const

True if the optimization is DEX.

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

Quick code associated with the method.

void quick_code(const quick_code_t &code)
void accept(Visitor &visitor) const override
bool operator==(const Method &rhs) const
bool operator!=(const Method &rhs) const
~Method(void)

Friends

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