3

I'm writing a plugin for IDA PRO with IDAPython and I need to make a dump of the full disassembled code with offsets.

I know I can export a html file and then parse it but I cannot call the GenerateFile function with the GENFLG_GENHTML flag from the script since that function only works from the gui

idc.GenerateFile(OFILE_LST, idc.GetInputFile()+'.html', 0, idc.BADADDR, GENFLG_GENHTML)

(when I run the plugin it gives me unhandled exception but if I write the same instruction from the IDA command line it works).

I can extract the .asm file but it is not useful to me because it does not contain the offsets. Are there any solutions?

  • Do you need an HTML, or just offsets and the ASM? – tmr232 Jan 8 '16 at 14:22
  • Also, what versions of IDA and IDAPython are you using? – tmr232 Jan 8 '16 at 14:22
  • @tmr232 I need the full disassembly with the offsets, the output format is not important as long i can parse it. I'm using IDA 6.6 – zemnl Jan 8 '16 at 15:06
2

You're currently passing a string as the second argument to GenerateFile(), but the second argument needs to be a file handle.

  • But that same function called from IDA command line works perfecly... – zemnl Jan 8 '16 at 15:14
  • That sounds like a nice feature offered by the GUI. However, to use the function from a script you should follow the correct calling convention. – Jason Geffner Jan 8 '16 at 15:15
  • So what shoud I do? Create/open a file f = open("file.html", "w") and then use f in GenerateFile? – zemnl Jan 8 '16 at 15:29
  • Use fopen(). – Jason Geffner Jan 8 '16 at 15:32
  • 1
    Great, looks like you can use Python's open() function then. – Jason Geffner Jan 8 '16 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.