-
-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add / (search) commands to newshell + rewrite of rz_search #4742
base: dev
Are you sure you want to change the base?
Conversation
RZ_API void rz_search_collection_free(RZ_NULLABLE RzSearchCollection *sc); | ||
RZ_API void rz_search_hit_free(RZ_NULLABLE RzSearchHit *hit); | ||
|
||
RZ_API RZ_OWN RzList /*<RzSearchHit *>*/ *rz_search_run(RZ_NONNULL RzSearchOpt *opt, RZ_NONNULL RzSearchCollection *col, RZ_NONNULL RzIO *io, RZ_NONNULL RzList /*<RzIOMap *>*/ *search_in); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe changing the search_in
parameter to void *
and infer the type based on some flag in opt
. This way we can use this function later to search other things then IO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not so sure about this, but maybe.
|
||
struct rz_search_collection_t { | ||
RzPVector /*<void *>*/ *collection; ///< Collection of elements to search in a buffer | ||
RzSearchOverCallback search_over; ///< Collection search over the collection callback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs are a little confusing. Is the search_over
callback called for every element in the collection above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the function takes the vector and uses it
|
||
typedef struct rz_search_hit_t { | ||
RzSearchKeyword *kw; | ||
ut64 addr; | ||
char *metadata; ///< Metadata for extra details (can be NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to save mostly the type of the search hit or the things to search for (I saw aes
and regex
). Maybe changing it to an enum (RzSearchMetaDataType type
) and a add a void *meta_data
to save more complex stuff. This way we can save allocation of simple strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it for the flags so we know it's hit.regex or hit.rsa etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see. What about hit_desc
then? Meta data seems kinda broad IMHO.
@@ -3,8 +3,174 @@ | |||
--- | |||
name: cmd_search | |||
commands: | |||
- name: "//" | |||
summary: Repeat the last seach |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
summary: Repeat the last seach | |
summary: Repeat the last search |
@@ -3745,16 +3792,18 @@ RZ_API int rz_core_config_init(RzCore *core) { | |||
SETOPTIONS(n, "auto", "rosections", "raw", NULL); | |||
|
|||
/* search */ | |||
SETCB("search.contiguous", "true", &cb_contiguous, "Accept contiguous/adjacent search hits"); | |||
SETICB("search.align", 0, &cb_searchalign, "Only catch aligned search hits"); | |||
SETB("search.progress", false, "Shows search progress (true: enable, false: disable)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
* | ||
* \return On success returns a valid pointer, otherwise NULL. | ||
*/ | ||
RZ_IPI RZ_OWN RzSearchCollection *rz_search_collection_new(RZ_NONNULL RzSearchOverCallback search_over, RZ_NULLABLE RzPVectorFree free) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RZ_IPI RZ_OWN RzSearchCollection *rz_search_collection_new(RZ_NONNULL RzSearchOverCallback search_over, RZ_NULLABLE RzPVectorFree free) { | |
RZ_IPI RZ_OWN RzSearchCollection *rz_search_collection_new(RZ_NONNULL RzSearchOverCallback search_over, RZ_NULLABLE RzPVectorFree element_free) { |
Or something similar.
Your checklist for this pull request
Detailed description
This is a complete rewrite of the legacy code which is too complicated to import into new-shell.
The goal is to refactor
rz_search
and implement the search command properly using pre-existing code like search of strings via rz_utils and more.