OALabs / hashdb-ida

HashDB API hash lookup plugin for IDA Pro
BSD 3-Clause "New" or "Revised" License
296 stars 39 forks source link

Asynchronous requests #12

Closed anthonyprintup closed 3 years ago

anthonyprintup commented 3 years ago

When performing requests the UI (especially with large IAT scans) the UI is frozen and IDA is unusable while the requests are performed. To fix this we should use asyncio's Futures.

Example combined with add_done_callback: image image

More elegant alternatives would include the use of async libraries such as:

herrcore commented 3 years ago

I'm curious how this would work with IDA... specifically if it locks the python command line?

anthonyprintup commented 3 years ago

I'm not sure, but the python core libraries are loaded into IDA when it starts up - so I assume the environment/interpreter is setup like normal. Then again, I've never seen async operations in IDA plugins so there might be a good reason why...

We would use add_done_callback with a timeout on the task, and when the request is completed (future.set_result), it should call the callback (to my understanding). In the callback we would do everything we do at this time (format the database, show a dialogue for the user, etc.).

I'm curious how this would work with IDA... specifically if it locks the python command line?

Since it's async, it shouldn't block anything.

anthonyprintup commented 3 years ago

So, the async stuff turned out to be a bummer (coroutines, makes sense).

But, we got this! 4xuBsvT5dN

With a bit of magic, this is totally doable (rip Py 2.7 support?)!

herrcore commented 3 years ago

Yasss! This is pretty exciting : ))

Also, I'll kill the py 2.7 feature request for now... python 3 is the future I guess. Unless we hear a lot of screaming, long live Python 3.

anthonyprintup commented 3 years ago

After a few days of tinkering, I finally got a promising POC. Looking forward to start implementing it this weekend.

KrMX1rF47B