WerWolv / ImHex

🔍 A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.

Home Page:https://imhex.werwolv.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature] CLI run pattern against file without GUI

Zekfad opened this issue · comments

What feature would you like to see?

ImHex has a powerful Pattern Language that really makes it easy to define structures and work with binary data.
I'd like to run pattern against file via cli (using std::file we can modify and save files to disk), this would make it a good use case for extracting data from a big set of files without manually opening and running pattern against it.

Maybe a standalone cli tool for pattern language execution only?

How will this feature be useful to you and others?

Such a feature would make it easy to integrate pattern language into scripting tools. The most prominent case is to use pattern language to extract data from binary archives, without need of writing independent tool for it (and maintaining pattern, visual analysis tool, consistency).

Request Type

  • I can provide a PoC for this feature or am willing to work on it myself and submit a PR

Additional context?

I see pattern language as a powerful tool, but now its limited to hex editor itself only. Also existing CLI options are not documented in web doc nor does many issues have info on that.

commented

Hey! We already have this kind of feature both in ImHex and standalone.
If you build the pattern language yourself, you have the option to enable the plcli tool during build which exposes much of the pattern language's functionality to the command line.
The same interface is also accessible with ImHex using imhex --pl <arguments to the plcli>

Hi, @WerWolv, thank you for response!
Haven't seen any mentions in docs about it, but that's really nice to hear!
Will definitely try it today!

@WerWolv, Is there any way to get current filename besides using define in --pl mode as the hex lib is not available here?

Edit: I checked define and don't see a way to define a macro with value, e.g -D A=B not working.