74 eprintf(
"TODO: import librz/core/cmd_search.c /m implementation into rsearch\n");
99 rz_list_foreach (
s->kws,
iter, kw) {
108 if (
s->align && (
addr %
s->align)) {
112 if (!
s->contiguous) {
124 int ret =
s->callback(kw,
s->user,
addr);
128 return !ret || ret > 1 ? ret :
s->maxhits &&
s->nhits >=
s->maxhits ? 2
139 return s->maxhits &&
s->nhits >=
s->maxhits ? 2 : 1;
146 int longest = 0,
i, j;
149 const int old_nhits =
s->nhits;
150 rz_list_foreach (
s->kws,
iter, kw) {
169 rz_list_foreach (
s->kws,
iter, kw) {
189 rz_list_foreach (
s->kws,
iter, kw) {
197 while (j < kw->keyword_length && (
ut8)(left->
data[
i + j + 1] - left->
data[
i + j]) ==
a[j]) {
202 kw->
last +=
s->bckwrds ? 0 : 1;
207 return s->nhits - old_nhits;
221 while (j < kw->keyword_length && (
ut8)(
buf[
i + j + 1] -
buf[
i + j]) ==
a[j]) {
226 kw->
last +=
s->bckwrds ? 0 : 1;
231 return s->nhits - old_nhits;
240 if (
len < longest - 1) {
241 if (len1 < longest) {
244 left->
len = longest - 1;
245 memmove(left->
data, left->
data + len1 - longest + 1, longest - 1);
248 left->
len = longest - 1;
253 return s->nhits - old_nhits;
267 for (
i = 0;
i <
m;
i++) {
272 for (
i = 0;
i +
m <
len; ) {
317 }
else if (kw->
icase) {
330 return dist <=
s->distance;
345 }
else if (kw->
icase) {
346 while (j < kw->keyword_length &&
364 const int old_nhits =
s->nhits;
366 rz_list_foreach (
s->kws,
iter, kw) {
397 rz_list_foreach (
s->kws,
iter, kw) {
408 return s->nhits - old_nhits;
425 return s->nhits - old_nhits;
433 if (
len < longest - 1) {
434 if (len1 < longest) {
437 left->
len = longest - 1;
438 memmove(left->
data, left->
data + len1 - longest + 1, longest - 1);
441 left->
len = longest - 1;
446 return s->nhits - old_nhits;
454 s->distance = (dist > 0) ? dist : 0;
460 s->pattern_size =
size;
464 s->callback = callback;
473 if (
s->maxhits &&
s->nhits >=
s->maxhits) {
478 eprintf(
"rz_search_update: No search method defined\n");
520 rz_list_foreach (
s->kws,
iter, kw) {
RZ_API int rz_search_aes_update(RzSearch *s, ut64 from, const ut8 *buf, int len)
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 void rz_search_keyword_free(RzSearchKeyword *kw)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static int hit(RzSearchKeyword *kw, void *user, ut64 addr)
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_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_list_purge(RZ_NONNULL RzList *list)
Empties the list without freeing the list pointer.
void * malloc(size_t size)
RZ_API int rz_search_privkey_update(RzSearch *s, ut64 from, const ut8 *buf, int len)
RZ_API int rz_search_regexp_update(RzSearch *s, ut64 from, const ut8 *buf, int len)
void(* RzListFree)(void *ptr)
int(* RzSearchCallback)(RzSearchKeyword *kw, void *user, ut64 where)
#define RZ_SEARCH_DISTANCE_MAX
RZ_API void rz_search_string_prepare_backward(RzSearch *s)
RZ_API RzList * rz_search_find(RzSearch *s, ut64 addr, const ut8 *buf, int len)
RZ_API int rz_search_update(RzSearch *s, ut64 from, const ut8 *buf, long len)
RZ_API void rz_search_set_callback(RzSearch *s, RzSearchCallback(callback), void *user)
RZ_LIB_VERSION(rz_search)
RZ_API int rz_search_begin(RzSearch *s)
static bool brute_force_match(RzSearch *s, RzSearchKeyword *kw, const ut8 *buf, int i)
static int listcb(RzSearchKeyword *k, void *user, ut64 addr)
RZ_API int rz_search_set_mode(RzSearch *s, int mode)
RZ_API void rz_search_kw_reset(RzSearch *s)
RZ_API int rz_search_update_i(RzSearch *s, ut64 from, const ut8 *buf, long len)
RZ_API RzSearch * rz_search_new(int mode)
RZ_API int rz_search_hit_new(RzSearch *s, RzSearchKeyword *kw, ut64 addr)
RZ_API int rz_search_deltakey_update(RzSearch *s, ut64 from, const ut8 *buf, int len)
RZ_API int rz_search_mybinparse_update(RzSearch *s, ut64 from, const ut8 *buf, int len)
RZ_API int rz_search_set_string_limits(RzSearch *s, ut32 min, ut32 max)
RZ_API RzSearch * rz_search_free(RzSearch *s)
RZ_API void rz_search_reset(RzSearch *s, int mode)
RZ_API void rz_search_pattern_size(RzSearch *s, int size)
RZ_API int rz_search_kw_add(RzSearch *s, RzSearchKeyword *kw)
RZ_API void rz_search_set_distance(RzSearch *s, int dist)
RZ_API int rz_search_magic_update(RzSearch *s, ut64 from, const ut8 *buf, int len)
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
RZ_API int rz_search_strings_update(RzSearch *s, ut64 from, const ut8 *buf, int len)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()