1

Is it possible to produce recompilable C code using IDA pro?

What I mean:

I can export binary into C pseudocode using "produce file" feature. But, the code is not recompilable. First, defs.h file is not present (I don't know if this comes with my ida pro license). I assume this file has all the typedefs, etc. I can use something like defs.h. Then I can fix definitions by removing or replacing "__fastcall" and "__noreturn" (I just added #define __fastcall to ignore this) (I don't if any other replacements required). And remove functions like _gmon_start__, etc. Then I can include required libraries.

Is there a way to all automate this (or is there an elegant way to do this)?

R4444
  • 1,807
  • 10
  • 30
  • 2
    Short answer - AFAIK there is no publicly available way to automate the process. – fpmurphy Apr 24 '20 at 17:09
  • thanks for your comment @fpmurphy – R4444 Apr 24 '20 at 17:15
  • 1
    No, the decompiler is not 100% accurate, so you will have to read the assembly... – MindLerp Apr 25 '20 at 03:39
  • BTW, nowadays I tend to use Gidra and Retdec rather than the IDA Decompiler to produce pseudo-C code. – fpmurphy Apr 25 '20 at 04:54
  • yes, voted it as a duplicate, thanks. But, the question was answered 6 years ago, and I was wondering if any progress has been made since then, also, my question tends to - is there any script to automate this process btw thanks @MindLerp and fpmurphy – R4444 Apr 25 '20 at 13:11
  • in my experience, in contrast to Ghidra and retdec, IDA almost never produces correct looking, but incorrect code. But, IDA often needs your help in defining structures, and sometimes just fails loudly. So any „real“ target will need manual work that far exceeds removing a couple of compiler stub functions. – manduca Apr 30 '20 at 19:29

0 Answers0