50 for (
ut32 i = 0;
i < pool_size; ++
i) {
67 RZ_LOG_ERROR(
"basefind: cannot get RzIODesc from core.\n");
73 RZ_LOG_ERROR(
"basefind: cannot allocate RzBinFile structure.\n");
80 RZ_LOG_ERROR(
"basefind: filesize exeeds memory size (UT64_MAX).\n");
124 RZ_LOG_ERROR(
"basefind: cannot find strings in binary with a minimum size of %u.\n", min_string_len);
131 RZ_LOG_ERROR(
"basefind: cannot allocate BaseFindArray.\n");
138 RZ_LOG_ERROR(
"basefind: cannot allocate array of addresses.\n");
149 array->
ptr[
i] =
string->paddr;
167 HtUU *
map = ht_uu_new0();
169 RZ_LOG_ERROR(
"basefind: cannot allocate hashmap for pointer.\n");
193 if (address < bfd->
start || address >=
bfd->end) {
204 if (
b->score ==
a->score) {
205 if (
b->candidate ==
a->candidate) {
207 }
else if (
b->candidate <
a->candidate) {
211 }
else if (
b->score <
a->score) {
241 RZ_LOG_ERROR(
"basefind: cannot allocate RzBaseFindScore.\n");
251 RZ_LOG_ERROR(
"basefind: cannot append new score to the scores list.\n");
282 void *user = ui_info->
user;
287 for (
ut32 i = 0;
i < pool_size; ++
i) {
294 if (!callback(&th_info, user)) {
340 HtUU *pointers =
NULL;
341 size_t pool_size = 1;
352 RZ_LOG_ERROR(
"basefind: supported pointer sizes are 32 and 64 bits.\n");
354 }
else if (!core->file) {
355 RZ_LOG_ERROR(
"basefind: the file was not opened via RzCore.\n");
357 }
else if (base_start >= base_end) {
358 RZ_LOG_ERROR(
"basefind: start address is greater or equal to end address.\n");
360 }
else if (alignment < 1) {
361 RZ_LOG_ERROR(
"basefind: the alignment is set to zero bytes.\n");
363 }
else if (
options->min_score < 1) {
364 RZ_LOG_ERROR(
"basefind: the minimum score is set to zero.\n");
366 }
else if (
options->min_string_len < 1) {
367 RZ_LOG_ERROR(
"basefind: the minimum string length is set to zero.\n");
372 RZ_LOG_WARN(
"basefind: the alignment is less than 0x%x bytes, "
373 "which may result in a very slow search.\n",
379 goto rz_basefind_end;
384 goto rz_basefind_end;
389 RZ_LOG_ERROR(
"basefind: cannot allocate new scores list.\n");
390 goto rz_basefind_end;
395 RZ_LOG_ERROR(
"basefind: cannot allocate thread pool.\n");
396 goto rz_basefind_end;
402 RZ_LOG_ERROR(
"basefind: cannot allocate thread lock.\n");
403 goto rz_basefind_end;
409 ut64 sector_size = (((base_end - base_start) + pool_size - 1) / pool_size);
410 for (
size_t i = 0;
i < pool_size; ++
i) {
413 RZ_LOG_ERROR(
"basefind: cannot allocate BaseFindThreadData.\n");
415 goto rz_basefind_end;
431 goto rz_basefind_end;
443 goto rz_basefind_end;
458 for (
ut32 i = 0;
i < pool_size; ++
i) {
473 for (
ut32 i = 0;
i < pool_size; ++
i) {
486 ht_uu_free(pointers);
RZ_API RZ_OWN RzList * rz_basefind(RZ_NONNULL RzCore *core, RZ_NONNULL RzBaseFindOpt *options)
Calculates a list of possible base addresses candidates using the strings position.
static bool basefind_array_has(const BaseFindArray *array, ut64 value)
static void basefind_set_thread_info(BaseFindThreadData *bftd, RzBaseFindThreadInfo *th_info, ut32 thread_idx)
struct basefind_thread_data_t BaseFindThreadData
struct basefind_data_t BaseFindData
static HtUU * basefind_create_pointer_map(RzCore *core, ut32 pointer_size)
static void basefind_array_free(BaseFindArray *array)
static int basefind_score_compare(const RzBaseFindScore *a, const RzBaseFindScore *b)
static bool basefind_pointer_map_iter(BaseFindData *bfd, const ut64 address, const ut64 hits)
static void basefind_stop_all_search_threads(RzThreadPool *pool)
static void * basefind_thread_runner(BaseFindThreadData *bftd)
static void * basefind_thread_ui(BaseFindUIInfo *ui_info)
static RzBinFile * basefind_new_bin_file(RzCore *core)
struct basefind_addresses_t BaseFindArray
struct basefind_ui_info_t BaseFindUIInfo
static BaseFindArray * basefind_create_array_of_addresses(RzCore *core, ut32 min_string_len)
static bool create_thread_interval(RzThreadPool *pool, BaseFindThreadData *bfd)
RZ_API RZ_OWN RzList * rz_bin_file_strings(RZ_NONNULL RzBinFile *bf, size_t min_length, bool raw_strings)
Generates a RzList struct containing RzBinString from a given RzBinFile.
RZ_API RzBinFile * rz_bin_cur(RzBin *bin)
RZ_API bool rz_config_get_b(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 static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
size_t map(int syms, int left, int len)
checking print the parsed form of the magic use in n conjunction with m to debug a new magic file n before installing it n output MIME type strings(--mime-type and\n"
" --mime-encoding)\n") OPT('s'
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 void rz_list_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp)
Sorts via merge sort or via insertion sort a list.
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
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.
RZ_API void rz_th_free(RZ_NULLABLE RzThread *th)
Frees a RzThread structure.
RZ_API RZ_OWN void * rz_th_get_user(RZ_NONNULL RzThread *th)
Returns user pointer of thread.
RZ_API RZ_OWN RzThread * rz_th_new(RZ_NONNULL RzThreadFunction function, RZ_NULLABLE void *user)
Creates and starts a new thread.
RZ_API bool rz_th_wait(RZ_NONNULL RzThread *th)
Awaits indefinetely for a thread to join.
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")
static const char struct stat static buf struct stat static buf static vhangup int options
#define rz_return_val_if_fail(expr, val)
bool(* RzBaseFindThreadInfoCb)(const RzBaseFindThreadInfo *th_info, void *user)
#define RZ_BASEFIND_BASE_ALIGNMENT
RZ_API RZ_OWN RzBuffer * rz_buf_new_with_io_fd(RZ_NONNULL void *iob, int fd)
Creates a new buffer wrapping a file descriptor accessed through RzIOBind.
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
static ut64 rz_read_ble64(const void *src, bool big_endian)
static ut32 rz_read_ble32(const void *src, bool big_endian)
RZ_API ut64 rz_io_desc_size(RzIODesc *desc)
RZ_API ut64 rz_io_size(RzIO *io)
RZ_API RzIODesc * rz_io_desc_get(RzIO *io, int fd)
RZ_API int rz_io_pread_at(RzIO *io, ut64 paddr, ut8 *buf, int len)
void(* RzListFree)(void *ptr)
int(* RzListComparator)(const void *value, const void *list_data)
#define RZ_LOG_VERBOSE(fmtstr,...)
#define RZ_LOG_INFO(fmtstr,...)
#define RZ_LOG_WARN(fmtstr,...)
#define RZ_LOG_DEBUG(fmtstr,...)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API int rz_sys_usleep(int usecs)
Sleep for usecs microseconds.
void *(* RzThreadFunction)(void *user)
RzBaseFindThreadInfoCb callback
ut32 n_threads
Total number of search threads.
ut64 current_address
Thread related search address (current).
ut32 percentage
Progress made by the search thread.
ut64 begin_address
Thread related search address (start).
ut32 thread_idx
Sesarch thread number.
ut64 end_address
Thread related search address (end).
ut64 candidate
Candidate physical base address.
ut32 score
Score of the candidate address.
XX curplugin == o->plugin.
RzThreadPool is a structure which handles n-threads threads.
RZ_API void rz_th_lock_leave(RZ_NONNULL RzThreadLock *thl)
Releases a RzThreadLock structure.
RZ_API void rz_th_lock_free(RZ_NULLABLE RzThreadLock *thl)
Frees a RzThreadLock structure.
RZ_API RZ_OWN RzThreadLock * rz_th_lock_new(bool recursive)
Allocates and initialize a RzThreadLock structure.
RZ_API void rz_th_lock_enter(RZ_NONNULL RzThreadLock *thl)
Acquires a RzThreadLock structure.
RZ_API void rz_th_pool_free(RZ_NULLABLE RzThreadPool *pool)
Kills (and frees) the threads and frees the RzThreadPool struct.
RZ_API RZ_BORROW RzThread * rz_th_pool_get_thread(RZ_NONNULL RzThreadPool *pool, size_t index)
Returns the n-th thread in the thread pool.
RZ_API bool rz_th_pool_wait(RZ_NONNULL RzThreadPool *pool)
Waits the end of all the threads in the thread pool.
RZ_API bool rz_th_pool_add_thread(RZ_NONNULL RzThreadPool *pool, RZ_NONNULL RzThread *thread)
Adds a thread to the thread pool.
RZ_API size_t rz_th_pool_size(RZ_NONNULL RzThreadPool *pool)
Returns the thread pool size.
RZ_API RZ_OWN RzThreadPool * rz_th_pool_new(size_t max_threads)
returns a new RzThreadPool structure with a pool of thread
RZ_API RZ_OWN RzAtomicBool * rz_atomic_bool_new(bool value)
Initialize a thread safe bool type container.
RZ_API bool rz_atomic_bool_get(RZ_NONNULL RzAtomicBool *tbool)
Gets the current value hold by the RzAtomicBool structure.
RZ_API void rz_atomic_bool_free(RZ_NULLABLE RzAtomicBool *tbool)
Frees a RzAtomicBool structure.
RZ_API void rz_atomic_bool_set(RZ_NONNULL RzAtomicBool *tbool, bool value)
Sets the value int the RzAtomicBool structure.
static void lock(volatile int *lk)
void error(const char *msg)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()