Topic created on: March 25, 2011 16:21 CDT by
dolex 
.
I'm using IDA 6.0 with IDAPython 1.4.3, and I need to create thread from the .py script.
My code looks like this:
import time, thread
def test_proc(msg):
while True:
print msg
time.sleep(1)
thread.start_new_thread(test_proc, ("Test", ))
But it doesn't work properly: created thread freezes immediately after the script execution.
So, anybody knows some working solution, to run background thread from python code in IDA?
If you are trying to make a socket server out of IDA then you can use the code IDAconnector.hpp from IDA Sync as a reference (http://www.openrce.org/downloads/details/2).
The crucial lines are:
// create an invisble window for hooking messages received by our socket.
if ((socket_hwnd = CreateWindowEx(0, "STATIC", PLUGIN_NAME, 0, 0, 0, 0, 0, 0, 0, 0, 0)) == NULL)
...
// register the callback function for our invisible window.
if (SetWindowLong(socket_hwnd, GWL_WNDPROC, (long) socket_proc_wrapper) == 0)
...
// make the socket a non-blocking asynchronous socket hooked with our socket_proc handler.
if (WSAAsyncSelect(connection, socket_hwnd, SOCKET_MSG, FD_READ | FD_CLOSE) == SOCKET_ERROR)
You can make these calls from Python as well.
-pedram
|