11 #include "../format/mach0/dyldcache.h"
14 #define RZ_DYLDCACHE_VFILE_NAME_REBASED "rebased"
42 struct MACH0_(opts_t) opts;
45 opts.header_at =
bin->header_at -
bin->hdr_offset;
46 opts.symbols_off =
bin->symbols_off;
48 struct MACH0_(obj_t) *mach0 =
MACH0_(new_buf)(
buf, &opts);
65 if (rzhdr !=
sizeof(hdr) - 1) {
112 if (strstr(cache->
hdr->
magic,
"x86_64")) {
117 ret->
bits = strstr(cache->
hdr->
magic,
"arm64") ? 64 : 32;
134 struct MACH0_(obj_t) *mach0 = bin_to_mach0(bf,
bin);
173 if (strstr(
name,
"_cstring")) {
176 if (strstr(
name,
"_os_log")) {
179 if (strstr(
name,
"_objc_methname")) {
182 if (strstr(
name,
"_objc_classname")) {
185 if (strstr(
name,
"_objc_methtype")) {
197 struct MACH0_(obj_t) *mach0 = bin_to_mach0(bf,
bin);
218 if (strstr(ptr->
name,
"la_symbol_ptr")) {
352 rz_list_foreach (ret,
iter, sym) {
394 ut32 num_of_unnamed_class = 0;
396 struct MACH0_(obj_t) *mach0 = bin_to_mach0(bf,
bin);
414 bool is_classlist = strstr(
sections[
i].
name,
"__objc_classlist");
415 bool is_catlist = strstr(
sections[
i].
name,
"__objc_catlist");
417 if (!is_classlist && !is_catlist) {
431 ut8 *cursor = pointers;
434 for (; cursor < pointers_end; cursor += 8) {
452 (pointer_to_class, bf,
buf, klass,
false,
NULL, cache->
oi);
455 (pointer_to_class, bf,
buf, klass,
NULL, cache->
oi);
460 RZ_LOG_ERROR(
"CLASS ERROR AT 0x%llx, is_classlist %d\n", pointer_to_class, is_classlist);
470 num_of_unnamed_class++;
527 pj_ks(pj,
"uuid", uuidstr);
528 pj_ks(pj,
"cacheType", (cache->
hdr->
cacheType == 0) ?
"development" :
"production");
538 pj_k(pj,
"accelerator");
562 pj_k(pj,
"slideInfo");
572 pj_kn(pj,
"slide", slide);
591 pj_kn(pj,
"page_size", 4096);
616 pj_ks(pj,
"uuid", uuidstr);
623 char *last_slash = strrchr(
file,
'/');
624 if (last_slash && *last_slash) {
625 pj_ks(pj,
"name", last_slash + 1);
645 .desc =
"dyldcache bin plugin",
661 #ifndef RZ_PLUGIN_INCORE
RZ_API void rz_bin_symbol_free(RzBinSymbol *sym)
RZ_API void rz_bin_map_free(RzBinMap *map)
RZ_API void rz_bin_section_free(RzBinSection *bs)
RZ_API void rz_bin_virtual_file_free(RzBinVirtualFile *vfile)
static ut64 bin_obj_va2pa(ut64 p, ut32 *offset, ut32 *left, RzBinFile *bf)
static void sections_from_bin(RzList *ret, RzBinFile *bf, RzDyldBinImage *bin)
static RzList * classes(RzBinFile *bf)
static bool check_buffer(RzBuffer *buf)
static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb)
static RzList * symbols(RzBinFile *bf)
static void header(RzBinFile *bf)
void symbols_from_bin(RzDyldCache *cache, RzList *ret, RzBinFile *bf, RzDyldBinImage *bin, SetU *hash)
static void destroy(RzBinFile *bf)
RZ_API RzLibStruct rizin_plugin
static bool __is_data_section(const char *name)
static RzList * virtual_files(RzBinFile *bf)
static RzBinInfo * info(RzBinFile *bf)
static ut64 baddr(RzBinFile *bf)
static int prot2perm(int x)
static RzList * entries(RzBinFile *bf)
static RzList * maps(RzBinFile *bf)
RzBinPlugin rz_bin_plugin_dyldcache
static RzList * sections(RzBinFile *bf)
#define RZ_DYLDCACHE_VFILE_NAME_REBASED
static struct MACH0_(obj_t)
RZ_API ut64 rz_dyldcache_get_slide(RzDyldCache *cache)
RZ_API bool rz_dyldcache_check_magic(const char *magic)
RZ_API void rz_dyldcache_symbols_from_locsym(RzDyldCache *cache, RzDyldBinImage *bin, RzList *symbols, SetU *hash)
RZ_API void rz_dyldcache_free(RzDyldCache *cache)
RZ_API RzDyldCache * rz_dyldcache_new_buf(RzBuffer *buf)
RZ_API ut64 rz_dyldcache_va2pa(RzDyldCache *cache, uint64_t vaddr, ut32 *offset, ut32 *left)
RZ_API objc_cache_opt_info * rz_dyldcache_get_objc_opt_info(RzBinFile *bf, RzDyldCache *cache)
RZ_API RzBuffer * rz_dyldcache_new_rebasing_buf(RzDyldCache *cache)
RZ_API bool rz_dyldcache_needs_rebasing(RzDyldCache *cache)
RZ_API bool rz_dyldcache_range_needs_rebasing(RzDyldCache *cache, ut64 paddr, ut64 size)
size_t map(int syms, int left, int len)
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
RZ_API RZ_BORROW RzListIter * rz_list_push(RZ_NONNULL RzList *list, void *item)
Alias for rz_list_append.
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
struct section_t *MACH0_() get_sections(struct MACH0_(obj_t) *bin)
const struct symbol_t *MACH0_() get_symbols(struct MACH0_(obj_t) *bin)
void *MACH0_() mach0_free(struct MACH0_(obj_t) *mo)
void MACH0_() opts_set_default(struct MACH0_(opts_t) *options, RzBinFile *bf)
RZ_API void MACH0_() get_class_t(mach0_ut p, RzBinFile *bf, RzBuffer *buf, RzBinClass *klass, bool dupe, RzSkipList *relocs, objc_cache_opt_info *oi)
RZ_API void MACH0_() get_category_t(mach0_ut p, RzBinFile *bf, RzBuffer *buf, RzBinClass *klass, RzSkipList *relocs, objc_cache_opt_info *oi)
#define RZ_BIN_MACH0_SYMBOL_TYPE_LOCAL
#define RZ_BIN_BIND_LOCAL_STR
#define RZ_BIN_BIND_GLOBAL_STR
#define RZ_BIN_TYPE_FUNC_STR
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
RZ_API st64 rz_buf_fread_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL ut8 *buf, RZ_NONNULL const char *fmt, int n)
...
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
RZ_API RZ_OWN RzBuffer * rz_buf_new_slice(RzBuffer *b, ut64 offset, ut64 size)
Creates a new buffer from a slice of another buffer.
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
static ut64 rz_read_le64(const void *src)
RZ_API int rz_hex_bin2str(const ut8 *in, int len, char *out)
void(* RzListFree)(void *ptr)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API PJ * pj_k(PJ *j, const char *k)
RZ_API PJ * pj_end(PJ *j)
RZ_API const char * pj_string(PJ *pj)
RZ_API void pj_free(PJ *j)
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
RZ_API PJ * pj_kn(PJ *j, const char *k, ut64 n)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
int(* PrintfCallback)(const char *str,...) RZ_PRINTF_CHECK(1
RZ_API SetU * set_u_new(void)
RZ_API void set_u_free(SetU *s)
RZ_API void set_u_add(SetU *s, ut64 u)
uint32_t dofSectionsCount
uint32_t bottomUpListOffset
uint32_t dofSectionsOffset
uint32_t imageExtrasCount
uint32_t reExportListOffset
uint32_t initializersCount
uint32_t initializersOffset
uint32_t rangeTableOffset
uint32_t imagesExtrasOffset
uint64_t accelerateInfoAddr
uint64_t localSymbolsOffset
uint64_t codeSignatureSize
uint64_t codeSignatureOffset
uint32_t branchPoolsOffset
uint64_t localSymbolsSize
uint64_t accelerateInfoSize
uint64_t imagesTextOffset
uint32_t branchPoolsCount
XX curplugin == o->plugin.
Description of a single memory mapping into virtual memory from a binary.
RZ_NONNULL RzBuffer * buf
bool buf_owned
whether buf is owned and freed by this RzBinVirtualFile
RZ_OWN RZ_NONNULL char * name
RzDyldRebaseInfosEntry * entries
bool objc_opt_info_loaded
RzDyldRebaseInfos * rebase_infos
if(dbg->bits==RZ_SYS_BITS_64)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()