Rizin
unix-like reverse engineering framework and cli tools
bfile_string.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2022 deroad <wargio@libero.it>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_bin.h>
5 #include <rz_util/rz_log.h>
7 
8 #define UTIL_STR_SCAN_OPT_BUFFER_SIZE 2048
9 #define RAW_FILE_ALIGNMENT 0x10000
10 
11 typedef struct search_interval_t {
15 
16 typedef struct shared_data_t {
19  HtUP *strings_db;
21 
22 typedef struct search_thread_data_t {
25  size_t min_length;
31 
34  st64 ret = rz_buf_read_at(sd->bf->buf, addr, buf, size);
36  return ret;
37 }
38 
39 static bool shared_ht_up_insert(SharedData *sd, const ut64 key, void *value) {
41  bool ret = ht_up_insert(sd->strings_db, key, value);
43  return ret;
44 }
45 
47  if (s->has_strings || s->is_data) {
48  return true;
49  } else if (!s->name) {
50  return false;
51  }
52  // Rust binaries contains the _const section which is a data section.
53  return strstr(s->name, "_const") != NULL;
54 }
55 
58  if (!dst) {
60  RZ_LOG_ERROR("bin_file_strings: cannot allocate RzBinString.\n");
61  return NULL;
62  }
63 
64  dst->string = src->string;
65  dst->size = src->size;
66  dst->length = src->length;
67  dst->type = src->type;
68  dst->paddr = src->addr;
69  dst->vaddr = src->addr;
70 
71  // variables has been transfered to RzBinString
72  free(src);
73  return dst;
74 }
75 
76 static RzList *string_scan_range(SearchThreadData *std, const ut64 paddr, const ut64 size) {
78  if (!found) {
79  return NULL;
80  }
81 
82  RzUtilStrScanOptions scan_opt = {
84  .max_uni_blocks = 4,
85  .min_str_length = std->min_length,
86  .prefer_big_endian = false,
87  .check_ascii_freq = std->check_ascii_freq,
88  };
89 
90  ut8 *buf = calloc(size, 1);
91  if (!buf) {
92  RZ_LOG_ERROR("bin_file_strings: cannot allocate string seac buffer.\n");
93  return NULL;
94  }
95 
96  shared_data_read_at(std->shared, paddr, buf, size);
97 
98  ut64 end = paddr + size;
99  int count = rz_scan_strings_raw(buf, found, &scan_opt, paddr, end, std->encoding);
100  free(buf);
101 
102  if (count <= 0) {
104  }
105  return found;
106 }
107 
109  SearchInterval *itv = NULL;
110  RzDetectedString *detected = NULL;
111  ut64 paddr = 0, psize = 0;
112  bool loop = true;
113  RzBinFile *bf = std->shared->bf; // this data is always RO
114 
115  do {
116  itv = rz_th_queue_pop(std->intervals, false);
117  if (!itv) {
118  break;
119  }
120  paddr = itv->paddr;
121  psize = itv->psize;
122  free(itv);
123  RZ_LOG_DEBUG("[%p] searching between [0x%08" PFMT64x " : 0x%08" PFMT64x "]\n", std, paddr, paddr + psize);
124 
125  RzList *list = string_scan_range(std, paddr, psize);
126  while (list && rz_atomic_bool_get(std->loop)) {
127  detected = rz_list_pop_head(list);
128  if (!detected) {
129  break;
130  }
131 
132  RzBinString *bstr = to_bin_string(detected);
133  if (!bstr || !rz_list_append(std->results, bstr)) {
134  rz_bin_string_free(bstr);
135  loop = false;
136  break;
137  } else if (!bf->o) {
138  continue;
139  }
140 
141  // find virt address.
142  bstr->paddr += bf->o->boffset;
143  bstr->vaddr = rz_bin_object_p2v(bf->o, bstr->paddr);
144 
145  shared_ht_up_insert(std->shared, bstr->vaddr, bstr);
146  }
147 
149  } while (loop && rz_atomic_bool_get(std->loop));
150 
151  RZ_LOG_DEBUG("[%p] died\n", std);
152  return NULL;
153 }
154 
156  if (!std) {
157  return;
158  }
159  rz_list_free(std->results);
161  free(std);
162 }
163 
164 static void interrupt_thread(RzThread *thread) {
165  if (!thread) {
166  return;
167  }
169  rz_atomic_bool_set(std->loop, false);
170  rz_th_wait(thread);
171 }
172 
173 static void interrupt_pool(RzThreadPool *pool) {
174  size_t pool_size = rz_th_pool_size(pool);
175  for (size_t i = 0; i < pool_size; ++i) {
176  RzThread *th = rz_th_pool_get_thread(pool, i);
177  interrupt_thread(th);
178  }
179 }
180 
181 static bool create_string_search_thread(RzThreadPool *pool, size_t min_length, RzThreadQueue *intervals, SharedData *shared) {
183  RzBinPlugin *plugin = rz_bin_file_cur_plugin(shared->bf);
184  bool check_ascii_freq = false;
185 
186  if (!min_length) {
187  min_length = plugin && plugin->minstrlen > 0 ? plugin->minstrlen : 4;
188  }
189 
190  if (shared->bf->rbin) {
192  check_ascii_freq = shared->bf->rbin->strseach_check_ascii_freq;
193  }
194 
196  if (!std) {
197  RZ_LOG_ERROR("bin_file_strings: cannot allocate SearchThreadData.\n");
198  return false;
199  }
200 
202  if (!std->results) {
204  return false;
205  }
206  std->shared = shared;
207  std->check_ascii_freq = check_ascii_freq;
208  std->encoding = encoding;
209  std->intervals = intervals;
210  std->min_length = min_length;
211  std->loop = rz_atomic_bool_new(true);
212 
214  if (!thread) {
215  RZ_LOG_ERROR("bin_file_strings: cannot allocate RzThread\n");
217  return false;
218  } else if (!rz_th_pool_add_thread(pool, thread)) {
219  RZ_LOG_ERROR("bin_file_strings: cannot add thread to pool\n");
220  interrupt_thread(thread);
222  rz_th_free(thread);
223  return false;
224  }
225  return true;
226 }
227 
228 static int string_compare_sort(const RzBinString *a, const RzBinString *b) {
229  if (b->paddr > a->paddr) {
230  return -1;
231  } else if (b->paddr < a->paddr) {
232  return 1;
233  } else if (b->vaddr > a->vaddr) {
234  return -1;
235  } else if (b->vaddr < a->vaddr) {
236  return 1;
237  }
238  return 0;
239 }
240 
241 static void string_scan_range_cfstring(RzBinFile *bf, HtUP *strings_db, RzList *results, const RzBinSection *section) {
242  // load objc/swift strings from CFstring table section
243 
244  RzBinObject *o = bf->o;
245  const int bits = o->info ? o->info->bits : 32;
246  const int cfstr_size = (bits == 64) ? 32 : 16;
247  const int cfstr_offs = (bits == 64) ? 16 : 8;
248 
249  ut8 *sbuf = calloc(section->size, 1);
250  if (!sbuf) {
251  RZ_LOG_ERROR("bin_file_strings: cannot allocate RzBinString.\n");
252  return;
253  }
254 
255  rz_buf_read_at(bf->buf, section->paddr + cfstr_offs, sbuf, section->size);
256  for (ut64 i = 0; i < section->size; i += cfstr_size) {
257  ut8 *buf = sbuf;
258  ut8 *p = buf + i;
259  if ((i + ((bits == 64) ? 8 : 4)) >= section->size) {
260  break;
261  }
262 
263  ut64 cfstr_vaddr = section->vaddr + i;
264  ut64 cstr_vaddr = (bits == 64) ? rz_read_le64(p) : rz_read_le32(p);
265  if (!cstr_vaddr || cstr_vaddr == UT64_MAX) {
266  continue;
267  }
268 
269  RzBinString *s = ht_up_find(strings_db, cstr_vaddr, NULL);
270  if (!s) {
271  continue;
272  }
273 
275  if (!bs) {
276  RZ_LOG_ERROR("bin_file_strings: cannot allocate RzBinString\n");
277  break;
278  }
279 
280  bs->type = s->type;
281  bs->length = s->length;
282  bs->size = s->size;
283  bs->ordinal = s->ordinal;
284  bs->vaddr = cfstr_vaddr;
285  bs->paddr = rz_bin_object_v2p(o, bs->vaddr);
286  bs->string = rz_str_newf("cstr.%s", s->string);
287  rz_list_append(results, bs);
288  ht_up_insert(strings_db, bs->vaddr, bs);
289  }
290  free(sbuf);
291 }
292 
293 static void scan_cfstring_table(RzBinFile *bf, HtUP *strings_db, RzList *results, ut64 max_interval) {
294  RzListIter *iter = NULL;
296  RzBinObject *o = bf->o;
297  if (!o) {
298  return;
299  }
300  rz_list_foreach (o->sections, iter, section) {
301  if (!section->name || section->paddr >= bf->size) {
302  continue;
303  } else if (max_interval && section->size > max_interval) {
304  RZ_LOG_WARN("bin_file_strings: search interval size (0x%" PFMT64x
305  ") exeeds bin.maxstrbuf (0x%" PFMT64x "), skipping it.\n",
306  section->size, max_interval);
307  continue;
308  }
309 
310  if (strstr(section->name, "__cfstring")) {
311  string_scan_range_cfstring(bf, strings_db, results, section);
312  }
313  }
314 }
315 
325 RZ_API RZ_OWN RzList /*<RzBinString *>*/ *rz_bin_file_strings(RZ_NONNULL RzBinFile *bf, size_t min_length, bool raw_strings) {
327 
328  HtUP *strings_db = NULL;
329  RzList *results = NULL;
330  RzThreadQueue *intervals = NULL;
331  RzThreadPool *pool = NULL;
333  ut64 max_interval = 0;
334  size_t pool_size = 1;
335 
336  if (min_length < 1) {
337  min_length = 4;
338  }
339 
340  if (bf->rbin) {
341  max_interval = bf->rbin->maxstrbuf;
342  }
343 
345  if (!pool) {
346  RZ_LOG_ERROR("bin_file_strings: cannot allocate thread pool.\n");
347  goto fail;
348  }
349  pool_size = rz_th_pool_size(pool);
350 
351  lock = rz_th_lock_new(false);
352  if (!lock) {
353  RZ_LOG_ERROR("bin_file_strings: cannot allocate thread lock.\n");
354  goto fail;
355  }
356 
358  if (!intervals) {
359  RZ_LOG_ERROR("bin_file_strings: cannot allocate intervals queue.\n");
360  goto fail;
361  }
362 
363  strings_db = ht_up_new0();
364  if (!strings_db) {
365  RZ_LOG_ERROR("bin_file_strings: cannot allocate string map.\n");
366  goto fail;
367  }
368 
369  if (raw_strings) {
370  // returns all the strings found on the RzBinFile
371  ut64 section_size = bf->size / pool_size;
372  if (section_size & (RAW_FILE_ALIGNMENT - 1)) {
373  section_size += RAW_FILE_ALIGNMENT;
374  section_size &= ~(RAW_FILE_ALIGNMENT - 1);
375  }
376  if (!section_size) {
377  section_size += RAW_FILE_ALIGNMENT;
378  }
379 
380  if (max_interval && section_size > max_interval) {
381  RZ_LOG_WARN("bin_file_strings: search interval size (0x%" PFMT64x
382  ") exeeds bin.maxstrbuf (0x%" PFMT64x "), skipping it.\n",
383  section_size, max_interval);
384  goto fail;
385  }
386 
387  for (ut64 from = 0; from < bf->size; from += section_size) {
389  if (!itv) {
390  RZ_LOG_ERROR("bin_file_strings: cannot allocate SearchInterval.\n");
391  goto fail;
392  }
393 
394  itv->paddr = from;
395  itv->psize = section_size;
396  if ((itv->paddr + itv->psize) > bf->size) {
397  itv->psize = bf->size - itv->paddr;
398  }
399 
400  if (!rz_th_queue_push(intervals, itv, true)) {
401  free(itv);
402  RZ_LOG_ERROR("bin_file_strings: cannot append SearchInterval to list.\n");
403  goto fail;
404  }
405  }
406  } else if (bf->o && !rz_list_empty(bf->o->sections)) {
407  // returns only the strings found on the RzBinFile but within the data section
408  RzListIter *iter = NULL;
410  RzBinObject *o = bf->o;
411  rz_list_foreach (o->sections, iter, section) {
412  if (section->paddr >= bf->size) {
413  continue;
414  } else if (max_interval && section->size > max_interval) {
415  RZ_LOG_WARN("bin_file_strings: search interval size (0x%" PFMT64x
416  ") exeeds bin.maxstrbuf (0x%" PFMT64x "), skipping it.\n",
417  section->size, max_interval);
418  continue;
419  }
420 
421  if (!is_data_section(bf, section)) {
422  continue;
423  }
424 
426  if (!itv) {
427  RZ_LOG_ERROR("bin_file_strings: cannot allocate SearchInterval.\n");
428  goto fail;
429  }
430 
431  itv->paddr = section->paddr;
432  itv->psize = section->size;
433  if ((itv->paddr + itv->psize) > bf->size) {
434  itv->psize = bf->size - itv->paddr;
435  }
436 
437  if (!rz_th_queue_push(intervals, itv, true)) {
438  free(itv);
439  RZ_LOG_ERROR("bin_file_strings: cannot append SearchInterval to list.\n");
440  goto fail;
441  }
442  }
443  }
444 
445  SharedData shared = {
446  .lock = lock,
447  .bf = bf,
448  .strings_db = strings_db,
449  };
450 
451  RZ_LOG_VERBOSE("bin_file_strings: using %u threads\n", (ut32)pool_size);
452  for (size_t i = 0; i < pool_size; ++i) {
453  if (!create_string_search_thread(pool, min_length, intervals, &shared)) {
454  interrupt_pool(pool);
455  goto fail;
456  }
457  }
458 
459  rz_th_pool_wait(pool);
460 
461  results = rz_list_newf(rz_bin_string_free);
462  if (!results) {
463  RZ_LOG_ERROR("bin_file_strings: cannot allocate results list.\n");
464  goto fail;
465  }
466 
467  for (ut32 i = 0; i < pool_size; ++i) {
468  RzThread *th = rz_th_pool_get_thread(pool, i);
469  if (!th) {
470  continue;
471  }
473  if (std) {
474  rz_list_join(results, std->results);
475  }
476  }
477 
478  if (!raw_strings) {
479  scan_cfstring_table(bf, strings_db, results, max_interval);
480  }
482 
483  {
484  RzListIter *it;
485  RzBinString *bstr;
486  ut32 ordinal = 0;
487  rz_list_foreach (results, it, bstr) {
488  bstr->ordinal = ordinal;
489  ordinal++;
490  }
491  }
492 
493 fail:
494  if (pool) {
495  for (ut32 i = 0; i < pool_size; ++i) {
496  RzThread *th = rz_th_pool_get_thread(pool, i);
497  if (!th) {
498  continue;
499  }
502  }
503  rz_th_pool_free(pool);
504  }
505  ht_up_free(strings_db);
507  rz_th_queue_free(intervals);
508  return results;
509 }
lzma_index ** i
Definition: index.h:629
lzma_index * src
Definition: index.h:567
RZ_API RzBinPlugin * rz_bin_file_cur_plugin(RzBinFile *bf)
Definition: bfile.c:348
#define UTIL_STR_SCAN_OPT_BUFFER_SIZE
Definition: bfile_string.c:8
static void scan_cfstring_table(RzBinFile *bf, HtUP *strings_db, RzList *results, ut64 max_interval)
Definition: bfile_string.c:293
static RzBinString * to_bin_string(RzDetectedString *src)
Definition: bfile_string.c:56
static void interrupt_pool(RzThreadPool *pool)
Definition: bfile_string.c:173
static bool is_data_section(RzBinFile *a, RzBinSection *s)
Definition: bfile_string.c:46
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.
Definition: bfile_string.c:325
struct search_thread_data_t SearchThreadData
#define RAW_FILE_ALIGNMENT
Definition: bfile_string.c:9
static void bin_file_string_search_free(SearchThreadData *std)
Definition: bfile_string.c:155
struct search_interval_t SearchInterval
static void * search_string_thread_runner(SearchThreadData *std)
Definition: bfile_string.c:108
static int string_compare_sort(const RzBinString *a, const RzBinString *b)
Definition: bfile_string.c:228
static st64 shared_data_read_at(SharedData *sd, ut64 addr, ut8 *buf, ut64 size)
Definition: bfile_string.c:32
static bool create_string_search_thread(RzThreadPool *pool, size_t min_length, RzThreadQueue *intervals, SharedData *shared)
Definition: bfile_string.c:181
static void interrupt_thread(RzThread *thread)
Definition: bfile_string.c:164
static RzList * string_scan_range(SearchThreadData *std, const ut64 paddr, const ut64 size)
Definition: bfile_string.c:76
struct shared_data_t SharedData
static bool shared_ht_up_insert(SharedData *sd, const ut64 key, void *value)
Definition: bfile_string.c:39
static void string_scan_range_cfstring(RzBinFile *bf, HtUP *strings_db, RzList *results, const RzBinSection *section)
Definition: bfile_string.c:241
RZ_API void rz_bin_string_free(void *_str)
Definition: bin.c:192
int bits(struct state *s, int need)
Definition: blast.c:72
RZ_API ut64 rz_bin_object_v2p(RZ_NONNULL RzBinObject *obj, ut64 vaddr)
Convert virtual address to offset in the file according to binary mappings.
Definition: bobj.c:1015
RZ_API ut64 rz_bin_object_p2v(RZ_NONNULL RzBinObject *obj, ut64 paddr)
Convert offset in the file to virtual address according to binary mappings.
Definition: bobj.c:970
static int value
Definition: cmd_api.c:93
#define RZ_API
#define NULL
Definition: cris-opc.c:27
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
Definition: sflib.h:98
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 key
Definition: sflib.h:118
uint32_t ut32
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
RZ_API const KEY_TYPE bool * found
Definition: ht_inc.h:130
voidpf void uLong size
Definition: ioapi.h:138
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
void * p
Definition: libc.cpp:67
static void list(RzEgg *egg)
Definition: rz-gg.c:52
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
RZ_API void rz_list_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp)
Sorts via merge sort or via insertion sort a list.
Definition: list.c:743
RZ_API bool rz_list_join(RZ_NONNULL RzList *list1, RZ_NONNULL RzList *list2)
Joins 2 list into one (list2 pointer needs to be freed by the user)
Definition: list.c:209
RZ_API RZ_OWN void * rz_list_pop_head(RZ_NONNULL RzList *list)
Removes and returns the first element of the list.
Definition: list.c:401
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
RZ_API void rz_th_free(RZ_NULLABLE RzThread *th)
Frees a RzThread structure.
Definition: thread.c:246
RZ_API RZ_OWN void * rz_th_get_user(RZ_NONNULL RzThread *th)
Returns user pointer of thread.
Definition: thread.c:263
RZ_API RZ_OWN RzThread * rz_th_new(RZ_NONNULL RzThreadFunction function, RZ_NULLABLE void *user)
Creates and starts a new thread.
Definition: thread.c:198
RZ_API bool rz_th_wait(RZ_NONNULL RzThread *th)
Awaits indefinetely for a thread to join.
Definition: thread.c:231
void * calloc(size_t number, size_t size)
Definition: malloc.c:102
char * dst
Definition: lz4.h:724
static RzSocket * s
Definition: rtr.c:28
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
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.
Definition: buf.c:1136
static ut32 rz_read_le32(const void *src)
Definition: rz_endian.h:239
static ut64 rz_read_le64(const void *src)
Definition: rz_endian.h:266
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11
int(* RzListComparator)(const void *value, const void *list_data)
Definition: rz_list.h:33
#define RZ_LOG_VERBOSE(fmtstr,...)
Definition: rz_log.h:52
#define RZ_LOG_WARN(fmtstr,...)
Definition: rz_log.h:56
#define RZ_LOG_DEBUG(fmtstr,...)
Definition: rz_log.h:49
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
RZ_API RzStrEnc rz_str_enc_string_as_type(RZ_NULLABLE const char *enc)
converts an encoding name to RzStrEnc
Definition: str.c:86
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RzStrEnc
Definition: rz_str.h:19
@ RZ_STRING_ENC_GUESS
Definition: rz_str.h:33
RZ_API int rz_scan_strings_raw(RZ_NONNULL const ut8 *buf, RZ_NONNULL RzList *list, RZ_NONNULL const RzUtilStrScanOptions *opt, const ut64 from, const ut64 to, RzStrEnc type)
Look for strings in an RzBuffer.
Definition: str_search.c:362
RZ_API void rz_detected_string_free(RzDetectedString *str)
Definition: str_search.c:73
void *(* RzThreadFunction)(void *user)
Definition: rz_th.h:28
#define RZ_THREAD_POOL_ALL_CORES
Definition: rz_th.h:19
#define RZ_THREAD_QUEUE_UNLIMITED
Definition: rz_th.h:20
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define RZ_NONNULL
Definition: rz_types.h:64
#define RZ_FREE_CUSTOM(x, y)
Definition: rz_types.h:375
#define PFMT64x
Definition: rz_types.h:393
#define st64
Definition: rz_types_base.h:10
#define UT64_MAX
Definition: rz_types_base.h:86
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
Definition: sfsocketcall.h:123
#define b(i)
Definition: sha256.c:42
#define a(i)
Definition: sha256.c:41
size_t buf_size
Maximum size of a detected string.
Definition: rz_str_search.h:28
XX curplugin == o->plugin.
Definition: rz_bin.h:298
RzBinObject * o
Definition: rz_bin.h:305
struct rz_bin_t * rbin
Definition: rz_bin.h:316
RzBuffer * buf
Definition: rz_bin.h:303
ut64 boffset
Definition: rz_bin.h:262
RzBinInfo * info
Definition: rz_bin.h:287
RzList * sections
Definition: rz_bin.h:267
ut32 ordinal
Definition: rz_bin.h:755
char * string
Definition: rz_bin.h:752
bool strseach_check_ascii_freq
Definition: rz_bin.h:361
char * strenc
Definition: rz_bin.h:357
RzThreadPool is a structure which handles n-threads threads.
Definition: thread_pool.c:12
RzThreadQueue is a thread-safe queue that can be listened on from multiple threads.
Definition: thread_queue.c:17
Definition: thread.h:84
RzThreadQueue * intervals
Definition: bfile_string.c:23
SharedData * shared
Definition: bfile_string.c:28
RzAtomicBool * loop
Definition: bfile_string.c:29
uint32_t size
RzThreadLock * lock
Definition: bfile_string.c:17
HtUP * strings_db
Definition: bfile_string.c:19
RzBinFile * bf
Definition: bfile_string.c:18
uv_loop_t * loop
Definition: main.c:7
#define fail(test)
Definition: tests.h:29
RZ_API void rz_th_lock_leave(RZ_NONNULL RzThreadLock *thl)
Releases a RzThreadLock structure.
Definition: thread_lock.c:75
RZ_API void rz_th_lock_free(RZ_NULLABLE RzThreadLock *thl)
Frees a RzThreadLock structure.
Definition: thread_lock.c:89
RZ_API RZ_OWN RzThreadLock * rz_th_lock_new(bool recursive)
Allocates and initialize a RzThreadLock structure.
Definition: thread_lock.c:14
RZ_API void rz_th_lock_enter(RZ_NONNULL RzThreadLock *thl)
Acquires a RzThreadLock structure.
Definition: thread_lock.c:45
RZ_API void rz_th_pool_free(RZ_NULLABLE RzThreadPool *pool)
Kills (and frees) the threads and frees the RzThreadPool struct.
Definition: thread_pool.c:117
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.
Definition: thread_pool.c:158
RZ_API bool rz_th_pool_wait(RZ_NONNULL RzThreadPool *pool)
Waits the end of all the threads in the thread pool.
Definition: thread_pool.c:170
RZ_API bool rz_th_pool_add_thread(RZ_NONNULL RzThreadPool *pool, RZ_NONNULL RzThread *thread)
Adds a thread to the thread pool.
Definition: thread_pool.c:138
RZ_API size_t rz_th_pool_size(RZ_NONNULL RzThreadPool *pool)
Returns the thread pool size.
Definition: thread_pool.c:189
RZ_API RZ_OWN RzThreadPool * rz_th_pool_new(size_t max_threads)
returns a new RzThreadPool structure with a pool of thread
Definition: thread_pool.c:96
RZ_API bool rz_th_queue_push(RZ_NONNULL RzThreadQueue *queue, RZ_NONNULL void *user, bool tail)
Pushes a new element into the queue.
Definition: thread_queue.c:75
RZ_API void rz_th_queue_free(RZ_NULLABLE RzThreadQueue *queue)
Frees a RzThreadQueue structure.
Definition: thread_queue.c:55
RZ_API RZ_OWN void * rz_th_queue_pop(RZ_NONNULL RzThreadQueue *queue, bool tail)
Removes an element from the queue, but does not awaits when empty.
Definition: thread_queue.c:102
RZ_API RZ_OWN RzThreadQueue * rz_th_queue_new(size_t max_size, RZ_NULLABLE RzListFree qfree)
Allocates and initializes a new fifo queue.
Definition: thread_queue.c:32
RZ_API RZ_OWN RzAtomicBool * rz_atomic_bool_new(bool value)
Initialize a thread safe bool type container.
Definition: thread_types.c:24
RZ_API bool rz_atomic_bool_get(RZ_NONNULL RzAtomicBool *tbool)
Gets the current value hold by the RzAtomicBool structure.
Definition: thread_types.c:54
RZ_API void rz_atomic_bool_free(RZ_NULLABLE RzAtomicBool *tbool)
Frees a RzAtomicBool structure.
Definition: thread_types.c:39
RZ_API void rz_atomic_bool_set(RZ_NONNULL RzAtomicBool *tbool, bool value)
Sets the value int the RzAtomicBool structure.
Definition: thread_types.c:68
static void lock(volatile int *lk)
Definition: malloc.c:61
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58