Rizin
unix-like reverse engineering framework and cli tools
|
Go to the source code of this file.
Classes | |
struct | dex_map_item_t |
struct | dex_string_t |
struct | dex_proto_id_t |
struct | dex_field_id_t |
struct | dex_method_id_t |
struct | dex_encoded_field_t |
struct | dex_encoded_method_t |
struct | dex_class_def_t |
struct | dex_t |
Macros | |
#define | RZ_DEX_RELOC_TARGETS "reloc-targets" |
#define | RZ_DEX_VIRT_ADDRESS 0x0100000000 |
#define | RZ_DEX_RELOC_ADDRESS 0x8000000000 |
#define | DEX_MAP_ITEM_SIZE (12) |
#define | DEX_TYPE_ID_SIZE (sizeof(DexTypeId)) |
#define | DEX_PROTO_ID_SIZE (0xC) |
#define | DEX_FIELD_ID_SIZE (8) |
#define | DEX_METHOD_ID_SIZE (8) |
#define | DEX_CLASS_DEF_SIZE (0x20) |
Typedefs | |
typedef struct dex_map_item_t | DexMapItem |
typedef struct dex_string_t | DexString |
typedef ut32 | DexTypeId |
typedef struct dex_proto_id_t | DexProtoId |
typedef struct dex_field_id_t | DexFieldId |
typedef struct dex_method_id_t | DexMethodId |
typedef struct dex_encoded_field_t | DexEncodedField |
typedef struct dex_encoded_method_t | DexEncodedMethod |
typedef struct dex_class_def_t | DexClassDef |
typedef struct dex_t | RzBinDex |
Functions | |
RZ_API RZ_OWN RzBinDex * | rz_bin_dex_new (RZ_NONNULL RzBuffer *buf, ut64 base, RZ_NONNULL Sdb *kv) |
Parses the dex file and returns a RzBinDex struct. More... | |
RZ_API void | rz_bin_dex_free (RZ_NULLABLE RzBinDex *dex) |
Frees a RzBinDex struct. More... | |
RZ_API RZ_OWN char * | rz_bin_dex_version (RZ_NONNULL RzBinDex *dex) |
Returns the dex version (string format) More... | |
RZ_API ut64 | rz_bin_dex_debug_info (RZ_NONNULL RzBinDex *dex) |
Returns the dex debug info RzBin values. More... | |
RZ_API RZ_OWN RzList * | rz_bin_dex_strings (RZ_NONNULL RzBinDex *dex) |
Returns a RzList<RzBinString*> containing the dex strings. More... | |
RZ_API RZ_OWN RzList * | rz_bin_dex_classes (RZ_NONNULL RzBinDex *dex) |
Returns a RzList<RzBinClass*> containing the dex classes. More... | |
RZ_API RZ_OWN RzList * | rz_bin_dex_fields (RZ_NONNULL RzBinDex *dex) |
Returns a RzList<RzBinField*> containing the dex fields. More... | |
RZ_API RZ_OWN RzList * | rz_bin_dex_sections (RZ_NONNULL RzBinDex *dex) |
Returns a RzList<RzBinSection*> containing the dex sections. More... | |
RZ_API RZ_OWN RzList * | rz_bin_dex_symbols (RZ_NONNULL RzBinDex *dex) |
Returns a RzList<RzBinSymbol*> containing the dex symbols. More... | |
RZ_API RZ_OWN RzList * | rz_bin_dex_imports (RZ_NONNULL RzBinDex *dex) |
Returns a RzList<RzBinImport*> containing the dex imports. More... | |
RZ_API RZ_OWN RzList * | rz_bin_dex_libraries (RZ_NONNULL RzBinDex *dex) |
Returns a RzList<char*> containing the dex libraries. More... | |
RZ_API RZ_OWN RzBinAddr * | rz_bin_dex_resolve_symbol (RZ_NONNULL RzBinDex *dex, RzBinSpecialSymbol resolve) |
Returns a RzBinAddr pointer containing the resolved RzBinSpecialSymbol. More... | |
RZ_API RZ_OWN RzList * | rz_bin_dex_entrypoints (RZ_NONNULL RzBinDex *dex) |
Returns a RzList<RzBinAddr*> containing the dex entripoints. More... | |
RZ_API RZ_BORROW RzBuffer * | rz_bin_dex_relocations (RZ_NONNULL RzBinDex *dex) |
RZ_API RZ_OWN char * | rz_bin_dex_resolve_method_by_idx (RZ_NONNULL RzBinDex *dex, ut32 method_idx) |
Returns the resolved string linked to the given method id. More... | |
RZ_API RZ_OWN char * | rz_bin_dex_resolve_field_by_idx (RZ_NONNULL RzBinDex *dex, ut32 field_idx) |
Returns the resolved string linked to the given field id. More... | |
RZ_API RZ_OWN char * | rz_bin_dex_resolve_class_by_idx (RZ_NONNULL RzBinDex *dex, ut32 class_idx) |
Returns the resolved string linked to the given class id. More... | |
RZ_API RZ_OWN char * | rz_bin_dex_resolve_string_by_idx (RZ_NONNULL RzBinDex *dex, ut32 string_idx) |
Returns the resolved string linked to the given string id. More... | |
RZ_API RZ_OWN char * | rz_bin_dex_resolve_proto_by_idx (RZ_NONNULL RzBinDex *dex, ut32 proto_idx) |
Returns the resolved string linked to the given prototype id. More... | |
RZ_API RZ_OWN char * | rz_bin_dex_resolve_type_id_by_idx (RZ_NONNULL RzBinDex *dex, ut32 type_idx) |
Returns the resolved string linked to the given type id. More... | |
RZ_API RZ_OWN char * | rz_bin_dex_access_flags_readable (ut32 access_flags) |
RZ_API ut64 | rz_bin_dex_resolve_string_offset_by_idx (RZ_NONNULL RzBinDex *dex, ut32 string_idx) |
Returns the resolved offset linked to the given string id. More... | |
RZ_API ut64 | rz_bin_dex_resolve_type_id_offset_by_idx (RZ_NONNULL RzBinDex *dex, ut32 type_idx) |
Returns the resolved offset linked to the given type id. More... | |
RZ_API ut64 | rz_bin_dex_resolve_method_offset_by_idx (RZ_NONNULL RzBinDex *dex, ut32 method_idx) |
Returns the resolved offset linked to the given method id. More... | |
RZ_API void | rz_bin_dex_checksum (RZ_NONNULL RzBinDex *dex, RZ_NONNULL RzBinHash *hash) |
Sets the RzBinHash dex checksum (adler32) More... | |
RZ_API void | rz_bin_dex_sha1 (RZ_NONNULL RzBinDex *dex, RZ_NONNULL RzBinHash *hash) |
Sets the RzBinHash dex digest (sha1) More... | |
typedef struct dex_class_def_t DexClassDef |
typedef struct dex_encoded_field_t DexEncodedField |
typedef struct dex_encoded_method_t DexEncodedMethod |
typedef struct dex_field_id_t DexFieldId |
typedef struct dex_map_item_t DexMapItem |
typedef struct dex_method_id_t DexMethodId |
typedef struct dex_proto_id_t DexProtoId |
typedef struct dex_string_t DexString |
enum DexAccessFlag |
Definition at line 40 of file dex.h.
enum DexMapItemType |
Definition at line 710 of file dex.c.
References ACCESS_FLAG_VARARGS, access_flags_list, CLASS_ACCESS_FLAGS_SIZE, dex_access_flags_readable_t::flag, i, NULL, dex_access_flags_readable_t::readable, rz_strbuf_appendf(), rz_strbuf_drain(), rz_strbuf_new(), and sb.
Referenced by decode_access_flags(), dex_field_to_bin_field(), dex_field_to_symbol(), dex_method_to_symbol(), and rz_bin_dex_classes().
RZ_API void rz_bin_dex_checksum | ( | RZ_NONNULL RzBinDex * | dex, |
RZ_NONNULL RzBinHash * | hash | ||
) |
Sets the RzBinHash dex checksum (adler32)
Definition at line 1990 of file dex.c.
References rz_return_if_fail, and rz_write_le32().
Referenced by info().
RZ_API RZ_OWN RzList* rz_bin_dex_classes | ( | RZ_NONNULL RzBinDex * | dex | ) |
Returns a RzList<RzBinClass*> containing the dex classes.
Definition at line 1131 of file dex.c.
References dex_class_def_t::access_flags, rz_bin_class_t::addr, dex_class_def_t::class_idx, classes(), dex_resolve_fields_in_class(), dex_resolve_methods_in_class(), dex_resolve_type_id(), rz_bin_class_t::fields, free(), free_rz_bin_class(), rz_bin_class_t::index, rz_bin_class_t::methods, rz_bin_class_t::name, NULL, dex_class_def_t::offset, rz_bin_dex_access_flags_readable(), rz_list_append(), rz_list_newf(), RZ_NEW0, RZ_NEWS0, rz_pvector_foreach, rz_pvector_len(), rz_return_val_if_fail, rz_bin_class_t::super, dex_class_def_t::superclass_idx, rz_bin_class_t::visibility, and rz_bin_class_t::visibility_str.
Referenced by classes().
RZ_API ut64 rz_bin_dex_debug_info | ( | RZ_NONNULL RzBinDex * | dex | ) |
Returns the dex debug info RzBin values.
Definition at line 2041 of file dex.c.
References rz_return_val_if_fail.
Referenced by info().
RZ_API RZ_OWN RzList* rz_bin_dex_entrypoints | ( | RZ_NONNULL RzBinDex * | dex | ) |
Returns a RzList<RzBinAddr*> containing the dex entripoints.
Definition at line 1792 of file dex.c.
References dex_resolve_entrypoints_in_class(), entrypoints(), free(), list(), NULL, rz_list_free(), rz_list_join(), rz_list_newf(), rz_pvector_foreach, and rz_return_val_if_fail.
Referenced by entrypoints().
RZ_API RZ_OWN RzList* rz_bin_dex_fields | ( | RZ_NONNULL RzBinDex * | dex | ) |
Returns a RzList<RzBinField*> containing the dex fields.
Definition at line 1232 of file dex.c.
References dex_resolve_fields_in_class(), fields, free(), NULL, rz_bin_field_free(), rz_list_free(), rz_list_join(), rz_list_newf(), RZ_NEWS0, rz_pvector_foreach, rz_pvector_len(), and rz_return_val_if_fail.
Referenced by fields().
RZ_API void rz_bin_dex_free | ( | RZ_NULLABLE RzBinDex * | dex | ) |
Frees a RzBinDex struct.
Definition at line 649 of file dex.c.
References free(), rz_buf_free(), and rz_pvector_free().
Referenced by destroy(), dex_parse(), and rz_bin_dex_new().
RZ_API RZ_OWN RzList* rz_bin_dex_imports | ( | RZ_NONNULL RzBinDex * | dex | ) |
Returns a RzList<RzBinImport*> containing the dex imports.
Definition at line 1379 of file dex.c.
References dex_method_id_t::class_idx, dex_class_def_t::class_idx, dex_resolve_proto_id(), dex_resolve_string_id(), dex_resolve_type_id(), field_id, free(), i, imports(), dex_method_id_t::name_idx, NULL, dex_method_id_t::proto_idx, RZ_BIN_BIND_WEAK_STR, rz_bin_import_free(), RZ_BIN_TYPE_FIELD_STR, RZ_BIN_TYPE_FUNC_STR, rz_list_append(), rz_list_newf(), RZ_NEW0, RZ_NEWS0, rz_pvector_foreach, rz_pvector_len(), rz_return_val_if_fail, rz_str_rchr(), rz_str_replace_ch(), rz_str_replace_char(), and strdup().
Referenced by imports().
RZ_API RZ_OWN RzList* rz_bin_dex_libraries | ( | RZ_NONNULL RzBinDex * | dex | ) |
Returns a RzList<char*> containing the dex libraries.
Definition at line 1520 of file dex.c.
References dex_method_id_t::class_idx, dex_class_def_t::class_idx, compare_strings(), dex_resolve_type_id(), free(), i, libraries(), NULL, p, rz_list_append(), rz_list_find(), rz_list_newf(), RZ_NEWS0, rz_pvector_foreach, rz_pvector_len(), rz_return_val_if_fail, RZ_STR_ISEMPTY, and rz_str_newf().
Referenced by libraries().
RZ_API RZ_OWN RzBinDex* rz_bin_dex_new | ( | RZ_NONNULL RzBuffer * | buf, |
ut64 | base, | ||
RZ_NONNULL Sdb * | kv | ||
) |
Parses the dex file and returns a RzBinDex struct.
Definition at line 669 of file dex.c.
References dex_t::class_defs, dex_class_def_free(), dex_field_id_free, dex_method_id_free, dex_parse(), dex_proto_id_free(), dex_string_free(), dex_t::field_ids, dex_t::method_ids, NULL, dex_t::proto_ids, rz_bin_dex_free(), RZ_NEW0, rz_pvector_new(), rz_return_val_if_fail, and dex_t::strings.
Referenced by load_buffer().
RZ_API RZ_BORROW RzBuffer* rz_bin_dex_relocations | ( | RZ_NONNULL RzBinDex * | dex | ) |
This method will create a buffer filled with return-void values to mapped to the imports and allow the code to generate xrefs pointing to the imports
Definition at line 1821 of file dex.c.
References NULL, and rz_return_val_if_fail.
Referenced by virtual_files().
RZ_API RZ_OWN char* rz_bin_dex_resolve_class_by_idx | ( | RZ_NONNULL RzBinDex * | dex, |
ut32 | class_idx | ||
) |
Returns the resolved string linked to the given class id.
Definition at line 1972 of file dex.c.
References dex_resolve_type_id(), NULL, and rz_return_val_if_fail.
Referenced by get_name().
RZ_API RZ_OWN char* rz_bin_dex_resolve_field_by_idx | ( | RZ_NONNULL RzBinDex * | dex, |
ut32 | field_idx | ||
) |
Returns the resolved string linked to the given field id.
Definition at line 1863 of file dex.c.
References dex_resolve_string_id(), dex_resolve_type_id(), field_id, free(), NULL, rz_pvector_at(), rz_pvector_len(), rz_return_val_if_fail, rz_str_newf(), and type.
Referenced by get_name().
RZ_API RZ_OWN char* rz_bin_dex_resolve_method_by_idx | ( | RZ_NONNULL RzBinDex * | dex, |
ut32 | method_idx | ||
) |
Returns the resolved string linked to the given method id.
Definition at line 1829 of file dex.c.
References dex_method_id_t::class_idx, dex_resolve_proto_id(), dex_resolve_string_id(), dex_resolve_type_id(), free(), dex_method_id_t::name_idx, NULL, dex_method_id_t::proto_idx, RZ_FREE, rz_pvector_at(), rz_pvector_len(), rz_return_val_if_fail, and rz_str_newf().
Referenced by get_name().
RZ_API ut64 rz_bin_dex_resolve_method_offset_by_idx | ( | RZ_NONNULL RzBinDex * | dex, |
ut32 | method_idx | ||
) |
Returns the resolved offset linked to the given method id.
Definition at line 1928 of file dex.c.
References dex_method_id_t::code_offset, RZ_DEX_RELOC_ADDRESS, RZ_DEX_VIRT_ADDRESS, RZ_LOG_INFO, rz_pvector_at(), rz_pvector_len(), rz_return_val_if_fail, and UT64_MAX.
Referenced by get_offset().
RZ_API RZ_OWN char* rz_bin_dex_resolve_proto_by_idx | ( | RZ_NONNULL RzBinDex * | dex, |
ut32 | proto_idx | ||
) |
Returns the resolved string linked to the given prototype id.
Definition at line 1981 of file dex.c.
References dex_resolve_proto_id(), NULL, and rz_return_val_if_fail.
Referenced by dex_print_encoded_method(), and get_name().
RZ_API RZ_OWN char* rz_bin_dex_resolve_string_by_idx | ( | RZ_NONNULL RzBinDex * | dex, |
ut32 | string_idx | ||
) |
Returns the resolved string linked to the given string id.
Definition at line 1963 of file dex.c.
References dex_resolve_string_id(), NULL, and rz_return_val_if_fail.
Referenced by dex_print_encoded_field(), dex_print_encoded_method(), get_name(), and rz_bin_dex_resolve_type_id_by_idx().
RZ_API ut64 rz_bin_dex_resolve_string_offset_by_idx | ( | RZ_NONNULL RzBinDex * | dex, |
ut32 | string_idx | ||
) |
Returns the resolved offset linked to the given string id.
Definition at line 1900 of file dex.c.
References dex_resolve_string_id_native(), RZ_DEX_VIRT_ADDRESS, RZ_LOG_INFO, rz_return_val_if_fail, and UT64_MAX.
Referenced by get_offset(), and rz_bin_dex_resolve_type_id_offset_by_idx().
RZ_API RZ_OWN RzBinAddr* rz_bin_dex_resolve_symbol | ( | RZ_NONNULL RzBinDex * | dex, |
RzBinSpecialSymbol | resolve | ||
) |
Returns a RzBinAddr pointer containing the resolved RzBinSpecialSymbol.
Definition at line 1670 of file dex.c.
References dex_resolve_symbol_in_class_methods(), NULL, rz_bin_addr_t::paddr, resolve(), RZ_NEW0, rz_pvector_foreach, rz_return_val_if_fail, UT64_MAX, and rz_bin_addr_t::vaddr.
Referenced by binsym().
RZ_API RZ_OWN char* rz_bin_dex_resolve_type_id_by_idx | ( | RZ_NONNULL RzBinDex * | dex, |
ut32 | type_idx | ||
) |
Returns the resolved string linked to the given type id.
Definition at line 1949 of file dex.c.
References NULL, rz_bin_dex_resolve_string_by_idx(), RZ_LOG_INFO, and rz_return_val_if_fail.
Referenced by dex_print_class_def(), dex_print_class_def_exports(), dex_print_encoded_field(), and dex_print_encoded_method().
RZ_API ut64 rz_bin_dex_resolve_type_id_offset_by_idx | ( | RZ_NONNULL RzBinDex * | dex, |
ut32 | type_idx | ||
) |
Returns the resolved offset linked to the given type id.
Definition at line 1914 of file dex.c.
References rz_bin_dex_resolve_string_offset_by_idx(), RZ_LOG_INFO, rz_return_val_if_fail, and UT64_MAX.
Referenced by get_offset().
RZ_API RZ_OWN RzList* rz_bin_dex_sections | ( | RZ_NONNULL RzBinDex * | dex | ) |
Returns a RzList<RzBinSection*> containing the dex sections.
Definition at line 1200 of file dex.c.
References NULL, rz_bin_section_free(), RZ_DEX_RELOC_TARGETS, RZ_DEX_VIRT_ADDRESS, rz_list_append(), rz_list_newf(), RZ_PERM_R, RZ_PERM_RWX, rz_return_val_if_fail, section_new(), and sections().
Referenced by sections().
RZ_API void rz_bin_dex_sha1 | ( | RZ_NONNULL RzBinDex * | dex, |
RZ_NONNULL RzBinHash * | hash | ||
) |
Sets the RzBinHash dex digest (sha1)
Definition at line 2003 of file dex.c.
References memcpy(), and rz_return_if_fail.
Referenced by info().
RZ_API RZ_OWN RzList* rz_bin_dex_strings | ( | RZ_NONNULL RzBinDex * | dex | ) |
Returns a RzList<RzBinString*> containing the dex strings.
Definition at line 735 of file dex.c.
References dex_string_t::data, free(), rz_bin_string_t::length, NULL, rz_bin_string_t::ordinal, rz_bin_string_t::paddr, rz_bin_string_free(), RZ_DEX_VIRT_ADDRESS, rz_list_append(), rz_list_newf(), RZ_NEW0, rz_pvector_foreach, rz_return_val_if_fail, rz_str_ndup(), RZ_STRING_ENC_UTF8, dex_string_t::size, rz_bin_string_t::size, rz_bin_string_t::string, strings(), rz_bin_string_t::type, and rz_bin_string_t::vaddr.
Referenced by strings().
RZ_API RZ_OWN RzList* rz_bin_dex_symbols | ( | RZ_NONNULL RzBinDex * | dex | ) |
Returns a RzList<RzBinSymbol*> containing the dex symbols.
Definition at line 1267 of file dex.c.
References rz_bin_symbol_t::bind, dex_method_id_t::class_idx, rz_bin_symbol_t::classname, dex_method_id_t::code_offset, dex_method_id_t::code_size, dex_resolve_fields_in_class_as_symbols(), dex_resolve_library(), dex_resolve_methods_in_class(), dex_resolve_proto_id(), dex_resolve_string_id(), dex_resolve_type_id(), rz_bin_symbol_t::dname, field_id, free(), rz_bin_symbol_t::is_imported, rz_bin_symbol_t::libname, rz_bin_symbol_t::name, dex_method_id_t::name_idx, NULL, rz_bin_symbol_t::paddr, dex_method_id_t::proto_idx, RZ_BIN_BIND_WEAK_STR, rz_bin_symbol_free(), RZ_BIN_TYPE_FIELD_STR, RZ_BIN_TYPE_METH_STR, RZ_DEX_RELOC_ADDRESS, RZ_DEX_VIRT_ADDRESS, rz_list_append(), rz_list_free(), rz_list_join(), rz_list_newf(), RZ_NEW0, RZ_NEWS0, rz_pvector_foreach, rz_pvector_len(), rz_return_val_if_fail, rz_bin_symbol_t::size, symbols(), rz_bin_symbol_t::type, and rz_bin_symbol_t::vaddr.
Referenced by symbols().
RZ_API RZ_OWN char* rz_bin_dex_version | ( | RZ_NONNULL RzBinDex * | dex | ) |
Returns the dex version (string format)
Definition at line 2016 of file dex.c.
References NULL, rz_return_val_if_fail, and strdup().
Referenced by info(), and rz_cmd_dexs_handler().