IDA Pro, Python and Qt

IDA Pro 6.0 implements a cross-platform UI with the use of Qt framework. The good thing about it is that plugin writers can also develop cross-platform UI directly with Qt. But what about script writers?

In this blog post we are going to illustrate how to use PySide to create UI interfaces for IDA Pro using IDAPython.

ipq_intro

Background

In previous versions of IDA Pro it was possible to create custom UIs with the create_tform()/display_tform() APIs, nonetheless the code was platform specific. On MS Windows, the programmer receives an HWND of the parent form and then populates it with custom controls and then handles the window messages from a custom WindowProc().

Since previously only an MS Windows UI existed, users could not create complex UIs on other platforms and were bound to use IDA Pro SDK/form related functions such as AskUsingForm().

With IDA Pro 6.0, C++ plugin writers can directly use the Qt SDK to develop a cross-platform UI. Please refer to the qwindow same in the IDA Pro SDK.

Script writers can also use Python Qt bindings to achieve the same result.

Python bindings for the Qt framework

We evaluated both PySide and PyQt and found that both bindings work fine with IDA Pro 6.0 (We had to compile them with –DQT_NAMESPACE=QT and had to add one method to pass a QWidget* from C++ to Python).

While PyQt is much more mature and adopted by many users, we opted for PySide which works equally well and has a less restrictive license.

Writing a Hello world UI using IDAPython and PySide

In order to write a UI from IDAPython, you have to subclass the idaapi.PluginForm class. This class which essentially wraps the create_tform()/display_tform() and provides some helper functions (such as passing to Python a QWidget* that can be used by PySide as the parent widget).

A sample code will make things clearer:

ipq_hello_code

After running this script, we get this form:

ipq_hello

And of course, the form can be docked as any other built-in form. While this example is so simple, users can now create much more elaborate and complex UIs. No surprise about it but now plugin development using scripts (IDAPython) is becoming more interesting than before.

We plan to release, soon, an IDA Pro 6.0 update (bug fix release) along with IDAPython 1.4.3 (and a custom build of PySide) which are needed to run the sample code used in this post.

And lastly, for those interested to learn more about IDA Pro and its latest features you can benefit from the IDA Pro training taking place in December.

We hope that you found this blog post useful. All comments and suggestions are welcome.

This entry was posted in IDA Pro. Bookmark the permalink.

15 Responses to IDA Pro, Python and Qt

  1. Pingback: Tweets that mention IDA Pro, Python and Qt | Hex Blog -- Topsy.com

  2. Dinesh Venkatesan says:

    Very Impressive 0xEB. Once again thanks for interesting blogs.. Please continue to write more blogs.

  3. Elias Bachaalany says:

    Hello Dinesh,

    Thank you for the encouragement, much appreciated.

    Pranam,
    Elias

  4. Dinesh Venkatesan says:

    Is there any plan to release Linux plugin for IDA Python. Currently I see only Mac and Windows plugins.

  5. Elias Bachaalany says:

    Hello Dinesh,

    It exists for Linux too and is shipped with IDA Pro. We will update the google code page and include a build for Linux too.

  6. Dinesh Venkatesan says:

    Hi Elias, Thank you very much :)

  7. Tim Morgenstern says:

    Dear Sir,

    I would like to ask if there’s any way to execute an external program from within an idc script?
    My goal would be to ultimately modify code inside IDA Pro and export as a binary patch file.
    To achieve this, I want to execute GCC with a file I write from within the script (using savefile()).

    Thank you in advance,

    Kind regards,

    Tim

  8. Ilfak Guilfanov says:

    Tim,

    Please contact support for technical questions, thank you!

    Ilfak

  9. Pingback: IDA & Qt: Under the hood | Hex Blog

  10. Andy says:

    Dear Sir,
    I would like to ask how can i change a hexadecimal file into a assembly language?Perhaps button”code”can work out this qustion,
    but this button is eneditable?I’m sorry that as a Chinese student perhaps i cannot describe my queation precisely.
    Thank you in advance,

    Kind regards,

    Andy

  11. Pingback: Precompiled PySide binaries for IDA Pro | Hex Blog

  12. Dinesh Venkatesan says:

    Hi Elias,

    Today, I saw that you have uploaded the Linux version of it in google code page. I have tried with IDA6.1 demo version for Linux. It works beautifully. You guys are really doing a great job. Thank you very much.

    With Regards,
    Dinesh Venkatesan.

  13. Isaac S says:

    So i have IDA ver 6.2 and python working a-ok

    I just downloaded PySide and am trying to run your test hello world script above and keep getting this error:

    DLL load failed: The specified procedure could not be found.
    Traceback (most recent call last):
    File “C:\Program Files\IDA Demo 6.2\python\idaapi.py”, line 498, in IDAPython_ExecScript
    execfile(script, g)
    File “C:/Users/CrimsonOne/Desktop/testgui.py”, line 14, in
    from PySide import *
    ImportError: DLL load failed: The specified procedure could not be found.

    I was wondering if you knew what causes this or if there was a simple fix?