Hello Madshi!
Using latest release of MadCollection 2.7.8 released December, 2013 (and also tried old release from 2012), I call CreateIpcQueue() or CreateIpcQueueEx(..., 16) to specify multiple worker threads for the IPC. The problem is that the callback thread is almost always the same one, and since my app can take a couple seconds to return an IPC answer, the hooked app freezes unusable. It is fine if the callbacks are properly called on different worker threads (at peak, about 10 IPC messages per second are generated, so 16 threads are more than enough).
Really strange - this behavior depends on which app the SendIpcMessage() is called from! I am hooking browser apps, hooking the Winsock API 'WSASend', and in the hook proc for this, I call SendIpcMessage(). Get this:
1) On IE, the IPC callback is called on different threads, and it is fine.
2) On Chrome, the IPC callback is called on the same thread (only the second time is it different, then it goes back to the first thread for all the rest)
3) On Firefox, same as #2, but the API being hooked is 'send' instead of 'WSASend'.
Madshi, how does SendIpcMessage() determine which worker thread to call the IPC callback on? It seems to be getting confused in Chrome and Firefox.
Thanks,
David
IPC not calling back on multiple threads
Re: IPC not calling back on multiple threads
I'm not sure but it might have to do with sandbox limitations stopping madCodeHook from reading some internal information. I suppose this problem occurs on all OSs and all PCs and isn't limited to just one specific PC, correct? If so, could you create a small test project with which I could reproduce the problem? That would help greatly, thanks!
-
- Posts: 380
- Joined: Sat Dec 11, 2004 2:11 am
- Location: San Francisco Bay Area, CA USA
- Contact:
Re: IPC not calling back on multiple threads
Hi Madshi,
Please find a stripped down EXE and DLL (32 bit only) with source code: http://dcsoft.com/private/ipcthread2.zip
The EXE displays a line each time the IPC callback is called, with the thread id. Please let us know how it goes! Good luck.
The symptoms occur on many PC's but I've only been able to try this stripped down sample on the one 32-bit machine I have, due to not being able to sign the driver (for 64 bit). If it doesn't repro immediately for you, please let me know.
Thanks,
David
Please find a stripped down EXE and DLL (32 bit only) with source code: http://dcsoft.com/private/ipcthread2.zip
The EXE displays a line each time the IPC callback is called, with the thread id. Please let us know how it goes! Good luck.
The symptoms occur on many PC's but I've only been able to try this stripped down sample on the one 32-bit machine I have, due to not being able to sign the driver (for 64 bit). If it doesn't repro immediately for you, please let me know.
Thanks,
David
Re: IPC not calling back on multiple threads
Thanks, I'll have a look at this.
-
- Posts: 380
- Joined: Sat Dec 11, 2004 2:11 am
- Location: San Francisco Bay Area, CA USA
- Contact:
Re: IPC not calling back on multiple threads
Thanks for your tremendous (offline) help Madshi! The root cause is Chrome/Firefox are using a single thread to call WSASend/send; therefore the IPC calls are similarly single threaded. It's not a MCH problem after all.
Thanks,
David
Thanks,
David