35 ht_up_insert(o->
up, va, vec);
39 if (xrefs_to == *
addr) {
81 const char *notify =
"Analyzing code to find selfref references";
104 bool isMsgRef =
false;
106 RzVector *vec = ht_up_find(o->
up, namePtr, rfound);
107 if (!*rfound || !vec) {
124 if (cnt > 1 || ref == 0 || ref ==
UT64_MAX) {
128 return isMsgRef ? ref - 8 : ref;
141 size_t maxsize =
RZ_MAX(ss_const, ss_selrefs);
146 const size_t word_size = objc->
word_size;
148 RZ_LOG_ERROR(
"aao: Cannot read the whole const section %zu\n", ss_const);
151 for (
off = 0;
off + word_size < ss_const;
off += word_size) {
159 RZ_LOG_ERROR(
"aao: Cannot read the whole selrefs section\n");
162 for (
off = 0;
off + word_size < ss_selrefs;
off += word_size) {
182 RZ_LOG_WARN(
"aao is experimental on 32bit binaries\n");
188 const char *
name =
s->name;
189 if (strstr(
name,
"__objc_data")) {
191 }
else if (strstr(
name,
"__objc_selrefs")) {
193 }
else if (strstr(
name,
"__objc_msgrefs")) {
195 }
else if (strstr(
name,
"__objc_const")) {
218 RZ_LOG_DEBUG(
"Could not find necessary Objective-C sections...\n");
226 const char *notify =
"Parsing metadata in ObjC to find hidden xrefs";
229 size_t total_xrefs = 0;
230 bool readSuccess =
true;
239 if (!readSuccess ||
isInvalid(classRoVA)) {
243 if (!readSuccess ||
isInvalid(classMethodsVA)) {
254 if (classMethodsVA >
to || classMethodsVA + 0xfffff <
to) {
255 RZ_LOG_WARN(
"objc: the input binary might be malformed or this could be a bug.\n");
277 rz_list_foreach (
list,
iter, xref) {
290 size_t total_words = 0;
291 const size_t word_size = objc->
word_size;
292 for (
ut64 a = va_selrefs;
a < ss_selrefs;
a += word_size) {
296 rz_core_notify_done(core,
"Found %zu objc xrefs in %zu dwords.", total_xrefs, total_words);
303 if (!auto_analysis) {
static void objc_analyze(RzCore *core)
static bool objc_find_refs(RzCore *core)
const size_t objc2ClassMethImpOffs
const size_t objc2ClassSize
static void kv_array_free(HtUPKv *kv)
static void core_objc_free(RzCoreObjc *o)
static bool isValid(ut64 addr)
static RzCoreObjc * core_objc_new(RzCore *core)
static ut32 readDword(RzCoreObjc *objc, ut64 addr, bool *success)
static bool isInvalid(ut64 addr)
const size_t objc2ClassMethSize
RZ_API bool cmd_analysis_objc(RzCore *core, bool auto_analysis)
static bool objc_build_refs(RzCoreObjc *objc)
static bool inBetween(RzBinSection *s, ut64 addr)
static void array_add(RzCoreObjc *o, ut64 va, ut64 xrefs_to)
const size_t objc2ClassInfoOffs
const size_t objc2ClassBaseMethsOffs
static ut64 getRefPtr(RzCoreObjc *o, ut64 classMethodsVA, bool *rfound)
static ut64 readQword(RzCoreObjc *objc, ut64 addr, bool *success)
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_sections(RZ_NONNULL RzBin *bin)
RzList * sections(RzBinFile *bf)
RZ_API bool rz_core_analysis_refs(RZ_NONNULL RzCore *core, size_t nbytes)
Analyze xrefs and prints the result.
RZ_IPI void rz_core_analysis_esil_default(RzCore *core)
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API RzConfigNode * rz_config_set_i(RzConfig *cfg, RZ_NONNULL const char *name, const ut64 i)
RZ_API RZ_BORROW const char * rz_config_get(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API bool rz_cons_is_breaked(void)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API const KEY_TYPE bool * found
RZ_API void rz_core_notify_begin(RZ_NONNULL RzCore *core, RZ_NONNULL const char *format,...)
Prints a message definining the beginning of a task.
RZ_API void rz_core_notify_done(RZ_NONNULL RzCore *core, RZ_NONNULL const char *format,...)
Prints a message definining the end of a task which succeeded.
static void list(RzEgg *egg)
void * calloc(size_t number, size_t size)
@ RZ_ANALYSIS_XREF_TYPE_CODE
#define rz_return_val_if_fail(expr, val)
static ut32 rz_read_le32(const void *src)
static ut64 rz_read_le64(const void *src)
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
#define RZ_LOG_WARN(fmtstr,...)
#define RZ_LOG_DEBUG(fmtstr,...)
#define RZ_LOG_ERROR(fmtstr,...)
#define RZ_BETWEEN(x, y, z)
RZ_API void * rz_vector_push(RzVector *vec, void *x)
#define rz_vector_foreach(vec, it)
RZ_API void rz_vector_free(RzVector *vec)
RZ_API RzVector * rz_vector_new(size_t elem_size, RzVectorFree free, void *free_user)
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
RZ_API RzList * rz_analysis_xrefs_get_to(RzAnalysis *analysis, ut64 addr)
RZ_API bool rz_analysis_xrefs_set(RzAnalysis *analysis, ut64 from, ut64 to, RzAnalysisXRefType type)