SendIpcMessage and windows messages

c++ / delphi package - dll injection and api hooking
Post Reply
immer000
Posts: 22
Joined: Tue Sep 04, 2012 12:05 am

SendIpcMessage and windows messages

Post by immer000 »

I've been facing the following problem :
When SendIpcMessage gets called from a window procedure, I get a stack overflow if I specify bHandleMessages = TRUE on Windows 8.
SendIpcMessage calls GetMetroPath which itself calls PeekMessage / TranslateMessage / DispatchMessage. The window procedure then gets called again with the same message, SendIpcMessage gets called again, etc...

Setting bHandleMessages = FALSE fixes the problem, but it's not always great to do so... is there any way to detect whether we are inside a window procedure already ?
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: SendIpcMessage and windows messages

Post by madshi »

What does "When SendIpcMessage gets called from a window procedure" mean exactly? Does it mean that you send every single message that arrives at a certain window procedure via IPC?

One solution would be to use a TLS (thread local storage) variable to store whether you're alright "inside" of SendIpcMessage. If you are, don't call it again.
immer000
Posts: 22
Joined: Tue Sep 04, 2012 12:05 am

Re: SendIpcMessage and windows messages

Post by immer000 »

Hooked application's window message handler calls some API I have hooked. In my hook callback I call SendIpcMessage.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: SendIpcMessage and windows messages

Post by madshi »

Hmmmm... In any case, TLS should help.
Post Reply