📚 OpenRCE is preserved as a read-only archive. Launched at RECon Montreal in 2005. Registration and posting are disabled.








Flag: Tornado! Hurricane!

 Forums >>  IDA Pro  >>  Multi-threaded IDA plugins

Topic created on: June 18, 2005 02:08 CDT by hoglund .

Some of you may have noticed that IDA plugins do not appear to be thread-safe.  I often use a separate thread to manage a dialog box or other separate UI component in my plug-ins.  The multi-threaded nature of the access to the main IDA database can cause problems.  For example, I have noticed weird behavior when I drag the sizing bar between the the log window and the main window - a "bTree errror".  This has to be due to lack of locking or multi-threaded protection on the core IDA database.

  pedram     June 18, 2005 08:19.34 CDT
Yes indeed. The first issue I came across when using a seperate thread to handle my UI component is that none of the IDA hot-keys work while the thread/UI is running. I've since learned my lesson and stick to IDA's GUI routines or export data from IDA into a GUI.

  JCRoberts     June 21, 2005 18:15.51 CDT
Greg, your assumption is pretty much accurate. IDA is fairly strictly single threaded. All my attempts at multi-threaded stuff have resulted in hair loss.

JCR

  nohaven     July 5, 2005 19:15.01 CDT
Could this be worked around by having one thread that accesses the IDA database and other threads that post requests to it via APCs (assuming you're using it on Windows) or through some other message passing mechanism.  A little clumsy to be certain, but nevertheless it may lend itself well to working around the thread safety issues.  You can make it less of a pain to deal with by having it so that your interactions with the database from the context of other threads are all performed asynchronously (such as by having callbacks issued from the context of the database thread).  If you build a nice abstraction you can design it in such a way that should IDA ever get around to making the existing API thread safe, you wont have to change a single line of database interaction code and can simply rip out your message passing scheme and call into the database directly.

Anyway, assuming it's possible, this is something that most have probably already considered or implemented, but if not, someone may find it worthwhile to consider.  Or I could just be full of it... :)

  dzzie     July 8, 2005 21:26.51 CDT
I wonder how safe it is to spawn a single apartment threaded COM object such as a vb6 dll, then in the dll open an async socket which is used to send/receive intermittant commands.

I have this type of setup running with a VBscript IDA plugin, which has the main script UI running in a seperate process, sending commands and pulling data over the socket.

Threading Guru i am not, it works, I assume COM handles the thread syncronization and that since vb6 only supports single apt thread that it should be realtivly safe?


  asotirov     June 23, 2006 20:49.23 CDT
Spoonm's IDARub simulates mutli-threaded processing of network events by using window messages. I don't remember the url for the IDArub page though. His presentation should be up at http://recon.cx when they update the site.

  p0l     June 23, 2006 21:22.46 CDT
Here's the IDARub URL: http://www.metasploit.com/users/spoonm/idarub/

The source code for the plugin is not yet available though.

  gera     June 23, 2006 23:45.57 CDT
I was also going to point to IDARub. From what I understood, they are sending messages to IDA's main window, and they hook the WindowProc (which is quite likely hookable with IDA's API, given IDA's "hookability").

And then, I do have a plugin using multiple threads and never have a problem, however, the structure of my plugin may be a little bit different: It's a debugger plugin, where the main thread (IDA's) sets, clears and respondes to breakpoints gathering information that it feeds into some Sets and then triggers a redraw event to the other thread. The second thread is responsible for controlling an OpenGL window, and only pulls information from the Sets, never accessing IDA's database. However, this second thread logs messages to IDA's system/log pane, and I never had a problem with this.

  pedram     June 24, 2006 00:10.22 CDT
IDARub utilizes the same exact method as IDA Sync, an open source plugin I wrote some time ago. The "IDA Connector" class found in the source code was also used by Andrew Hintz to write OllySync:

http://www.openrce.org/downloads/details/2/IDA_Sync

  spoonm   June 28, 2006 01:55.41 CDT
I just pushed out an updated copy of IdaRub with source code, so you can check out how it's doing the async communication.

It creates it's own hidden window (and associated window handler).  It doesn't use IDA's window, there is no hooking going on.

I have some much more cracked out ideas for doing synchronization between the main IDA thread (the only one really safe for calling the SDK) and any other threads, involving messages handlers and some synchronization trickery, but I'll have to try to prototype it out.

Anyway, source code is up now at:

http://www.metasploit.com/users/spoonm/idarub

Note: Registration is required to post to the forums.

There are 31,328 total registered users.


Recently Created Topics
[help] Unpacking VMP...
Mar/12
Reverse Engineering ...
Jul/06
let 'IDAPython' impo...
Sep/24
set 'IDAPython' as t...
Sep/24
GuessType return une...
Sep/20
About retrieving the...
Sep/07
How to find specific...
Aug/15
How to get data depe...
Jul/07
Identify RVA data in...
May/06
Question about memor...
Dec/12


Recent Forum Posts
Finding the procedur...
rolEYder
Question about debbu...
rolEYder
Identify RVA data in...
sohlow
let 'IDAPython' impo...
sohlow
How to find specific...
hackgreti
Problem with ollydbg
sh3dow
How can I write olly...
sh3dow
New LoadMAP plugin v...
mefisto...
Intel pin in loaded ...
djnemo
OOP_RE tool available?
Bl4ckm4n


Recent Blog Entries
halsten
Mar/14
Breaking IonCUBE VM

oleavr
Oct/24
Anatomy of a code tracer

hasherezade
Sep/24
IAT Patcher - new tool for ...

oleavr
Aug/27
CryptoShark: code tracer ba...

oleavr
Jun/25
Build a debugger in 5 minutes

More ...


Recent Blog Comments
nieo on:
Mar/22
IAT Patcher - new tool for ...

djnemo on:
Nov/17
Kernel debugger vs user mod...

acel on:
Nov/14
Kernel debugger vs user mod...

pedram on:
Dec/21
frida.github.io: scriptable...

capadleman on:
Jun/19
Using NtCreateThreadEx for ...

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit