Open simonlindholm opened 5 years ago
would love to know if this is a thing
@m4xw has done some work on IDA integration: https://git.m4xw.net/n64/mips2c https://git.m4xw.net/n64/mips2c-ida-plugin
@m4xw has done some work on IDA integration: https://git.m4xw.net/n64/mips2c https://git.m4xw.net/n64/mips2c-ida-plugin
is it finished? and how do I use it with ida?
its usable if you can deal with hardcoded paths and other stuff like that. Theres some limitations for the analysis options tho, enabling stack vars in IDA will currently cause a parsing error etc. (kernel 1/2 options) You can just run those lines https://git.m4xw.net/n64/ida-n64-rom-loader/-/blob/master/majoras_mask_loader.py#L12-14 This is equal to the MIPS specific options here (as well as Kernel options, really just run those lines ideally and load the file manually. Its possible to set it before opening the elf tho, but i guess figure that yourself)
Also after analysis is done, u need to run (sanity stuff, ida can be whacky) https://git.m4xw.net/n64/ida-n64-rom-loader/-/blob/master/cleanup_ops.py
Make sure to use the rebase branch on m2c https://git.m4xw.net/n64/mips2c/-/tree/rebase https://git.m4xw.net/n64/mips2c-ida-plugin goes to IDA_Folder\plugins\mips2c_ida\ Then move ghida.py from IDA_Folder\plugins\mips2c_ida\ghida.py to IDA_Folder\plugins\ghida.py Edit hardcoded paths in IDA_Folder\plugins\mips2c_ida\lib.py https://git.m4xw.net/n64/mips2c-ida-plugin/-/blob/master/lib.py#L204-256 I currently run everything proxied through WSL, Tested with IDA 7.0, don't have a license for newer so never tested.
If you did everything right, right click asm in a function -> Decompile function with Ghida (never felt the need to rebrand) If you follow the naming schemes right, it will also add rodata to the export, all the logic is handled in the whacky code in lib.py You can tweak it as desired. Ideally this can be extra buttons later on. If you get weird parse errors in m2c, check that all functions are defined correctly. I did a yolo helper for that here https://git.m4xw.net/n64/ida-n64-rom-loader/-/blob/master/mips_function_finder.py
Generally you find a bunch of useful stuff in https://git.m4xw.net/n64/ida-n64-rom-loader/
Mind you, only I am using it, so i was lazy on the qol stuff. Context script is also set via lib.py, if u get any funky stuff, right click -> clear cache (also required when updating the context etc or if you rename stuff). Theres 1 cache for mips2c and one cache in ghida.
If theres interest of other people, we could improve it significantly, but as u can tell, its not really for end user consumption.
If you did everything right, you should have a window like this
Theres tons of improvement possibilities from stack var support for local names to struct creation & streaming from the asm via stdin etc etc etc
Is this only for n64 roms? Im trying to decompile a elf64 for MIPS relocatable elf64
On Tue, Apr 20, 2021 at 1:30 PM m4xw @.***> wrote:
its usable if you can deal with hardcoded paths and other stuff like that. Theres some limitations for the analysis options tho, enabling stack vars in IDA will currently cause a parsing error etc. (kernel 1/2 options) You can just run those lines https://git.m4xw.net/n64/ida-n64-rom-loader/-/blob/master/majoras_mask_loader.py#L12-14 This is equal to the MIPS specific options here (as well as Kernel options, really just run those lines ideally and load the file manually. Its possible to set it before opening the elf tho, but i guess figure that yourself) [image: grafik] https://user-images.githubusercontent.com/13141469/115431134-41f45580-a205-11eb-9c84-84418925a04d.png
Also after analysis is done, u need to run (sanity stuff, ida can be whacky) https://git.m4xw.net/n64/ida-n64-rom-loader/-/blob/master/cleanup_ops.py
Make sure to use the rebase branch on m2c https://git.m4xw.net/n64/mips2c/-/tree/rebase https://git.m4xw.net/n64/mips2c-ida-plugin goes to IDA_Folder\plugins\mips2c_ida Then move ghida.py from IDA_Folder\plugins\mips2c_ida\ghida.py to IDA_Folder\plugins\ghida.py Edit hardcoded paths in IDA_Folder\plugins\mips2c_ida\lib.py https://git.m4xw.net/n64/mips2c-ida-plugin/-/blob/master/lib.py#L204-256 I currently run everything proxied through WSL, Tested with IDA 7.0, don't have a license for newer so never tested.
If you did everything right, right click asm in a function -> Decompile function with Ghida (never felt the need to rebrand) If you follow the naming schemes right, it will also add rodata to the export, all the logic is handled in the whacky code in lib.py You can tweak it as desired. Ideally this can be extra buttons later on. If you get weird parse errors in m2c, check that all functions are defined correctly. I did a yolo helper for that here https://git.m4xw.net/n64/ida-n64-rom-loader/-/blob/master/mips_function_finder.py
Generally you find a bunch of useful stuff in https://git.m4xw.net/n64/ida-n64-rom-loader/
Mind you, only I am using it, so i was lazy on the qol stuff. Context script is also set via lib.py, if u get any funky stuff, right click -> clear cache (also required when updating the context etc or if you rename stuff). Theres 1 cache for mips2c and one cache in ghida.
If theres interest of other people, we could improve it significantly, but as u can tell, its not really for end user consumption.
If you did everything right, you should have a window like this [image: grafik] https://user-images.githubusercontent.com/13141469/115432111-4f5e0f80-a206-11eb-888a-4e4dafff58f0.png
Theres tons of improvement possibilities from stack var support for local names to struct creation & streaming from the asm via stdin etc etc etc
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/matt-kempster/mips_to_c/issues/39#issuecomment-823421302, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWR6LPEYP4EFPYAII3HL7LTJWT27ANCNFSM4HSHGRKQ .
if m2c supports it, then it should work with the elf loader in IDA too, but you will have the very same restrictions. I only tested the N64 integration.
And radare2/Cutter. See also r2ghidra-dec project.