ImHex icon indicating copy to clipboard operation
ImHex copied to clipboard

Add support for Intel Hex files

Open Mikaz-fr opened this issue 4 years ago ā€¢ 5 comments

Thanks for the awesome tool.

Do you think it would be feasible to support input files using Intel Hex format ? It's a text based format combining binary hex at defined addresses, used for microcontrollers for example.

There are different python modules to support this format already like:

  • https://pypi.org/project/bincopy/
  • https://pypi.org/project/intelhex/

I could also find this page with detailed description of the format: https://www.keysight.com/main/editorial.jspx?ckey=25084%3Aatg%3Afaq&id=25084%3Aatg%3Afaq&nid=-35181.0.00&lc=ger&cc=DE I have no idea how much work it would be so just asking if that's something it would be considered.

Mikaz-fr avatar Jan 14 '21 08:01 Mikaz-fr

Hi! I considered adding it at the start but held off because when decoded, these files can place data anywhere in the entire address space. It should however be possible now to add it with a custom data provider (maybe it should be a plugin?). I'll look into it. Otherwise feel free to make a PR for it, I'll gladly review and merge this :)

WerWolv avatar Jan 14 '21 09:01 WerWolv

Yes that's the beauty of the format, is that the address space doesn't have to be continuous, multiple binary blobs at different address can be represented, with unmapped areas (or holes) in between. Sadly I don't have time to dive into plugin dev right now, maybe another time. It would still be a cool feature šŸ˜€

Mikaz-fr avatar Jan 14 '21 10:01 Mikaz-fr

Hi, Is there a guide or hint on creating a custom data provider?

AkhilTThomas avatar May 09 '22 07:05 AkhilTThomas

I never found time to look into this solution, but Iā€™d still be very interested to have intel hex support, either built it or via a plugin.

Mikaz-fr avatar May 09 '22 07:05 Mikaz-fr

@AkhilTThomas @Mikaz-fr

There are various providers in the builtin plugin to use as template. They are very simple, basically just a read and a write function you need to implement. I'm up for helping implement it as part of ImHex, I think the editor should be able to handle it now

If you need some more guidance, feel free to contact me on Discord @WerWolv#1337

WerWolv avatar May 09 '22 08:05 WerWolv

If this idea is still alive, it would be nice to include support for SREC (Motorola S-Record) too. It's pretty similar to IntelHex

cwichel avatar Aug 11 '22 15:08 cwichel

I actually tried to give implementing this a shot again a few days ago. I added some features to the hex editor view now that lets us mark certain regions of memory as "Invalid" and display ?? instead of an actual value. That's basically the groundwork needed to implement a Intel Hex and SREC provider since the data in those files does not need to be contiguous.

So if anybody wants to give it a shot and make a PR with an Intel Hex and/or SREC provider, it's absolutely possible as of now.

WerWolv avatar Aug 11 '22 18:08 WerWolv

Went ahead and implemented it myself now anyways. Both Intel Hex files and Motorola SREC files are supported (only for reading, not writing for now) https://github.com/WerWolv/ImHex/pull/670

WerWolv avatar Aug 12 '22 13:08 WerWolv

Amazing work @WerWolv, thanks a lot for your help and involvement in this tool. I had a try today and displaying files is fully functional, that's great. Maybe you want to advertise those formats are supported on the main page of the tool/readme as other people might be googling modern Hex Editor tools that support those :)

I'm already thinking of related feature requests like folding of undefined regions, jumping over defined/undefined regions or displaying a small overview of the regions to simplify usability. But I will open new "Issues" for those requests are this request is full-filled now. Thanks again for the great work !

Mikaz-fr avatar Aug 16 '22 12:08 Mikaz-fr