rizinorg / cutter

Free and Open Source Reverse Engineering Platform powered by rizin
https://cutter.re
GNU General Public License v3.0
15.32k stars 1.14k forks source link

Can we able to convert the hex file to C code for PIC 16F #3348

Open Velvizhiarulmozhivarma-eaton opened 1 month ago

Velvizhiarulmozhivarma-eaton commented 1 month ago

I dumped the hex file and tried to convert hex file to C code with PIC uc - PIC16F family. By selecting the Pic controller, it shows invalid, and my graph and disassembly is not generated properly. I have attached a image for your reference.

My doubt is whether the cutter will support PIC16F or not? ![Uploading MicrosoftTeams-image (3).png…]()

karliss commented 1 month ago

I don't see any images

Velvizhiarulmozhivarma-eaton commented 1 month ago

Okay. I will provide it. Can you please clarify whether you support decompilation of PIC 16F code using Cutter

Velvizhiarulmozhivarma-eaton commented 1 month ago

Hexfile for PIC16F

karliss commented 1 month ago

One step at a time. First you need to get a proper disassembly and only then you can consider fancier functionality like decompilation.

As can be seen hexdump you have opened the .hex file as raw binary and inspecting the bytes within .hex file instead of the bytes that .hex file represents. To open a hex file you need to choose the ihex:// IO mode in the initial window

image image

Afterwards you will also have to choose appropriate architecture and CPU family in the load option window image

Use the microchip documentation to find out whether your specific pic16 classifies as midrange or baseline. Seems like there are groups of 16F in both categories.

karliss commented 1 month ago

Once you have that done you should get better disassembly. Don't use the parsing/disassembly sidepanel within hexdump tab it doesn't do what you probably want. Use the disassembly tab instead.

As for decompilation looks like currently the rizin ghidra plugin doesn't have the mapping between rizin and ghidra architectures. https://github.com/rizinorg/rz-ghidra/blob/733ad009bd603a9ea03d386d2781acff7a150ee2/src/ArchMap.cpp#L71

Velvizhiarulmozhivarma-eaton commented 1 month ago

I have followed the above-mentioned steps and got a disassembly code and Hexdump code and the decompiler remains empty I will provide the image below.

Could you please explain the steps to be followed to get the C code from the hex file

Velvizhiarulmozhivarma-eaton commented 1 month ago

Disassemby

Velvizhiarulmozhivarma-eaton commented 1 month ago

Hexdump

Velvizhiarulmozhivarma-eaton commented 1 month ago

And my Decompiler tab remains empty could please guide me how to get decompiled code and from that how to extract the C code. Decompiler