[Lazarus] SendMessage Bug Work Around.

Sven Barth pascaldragon at googlemail.com
Mon Apr 26 18:45:46 CEST 2010


Am 26.04.2010 10:59, schrieb Michael Schnell:
> On 04/23/2010 05:37 PM, Duncan Parsons wrote:
>> Note in http://msdn.microsoft.com/en-us/library/ms644950(VS.85).aspx
>> where it says 'The sending thread is blocked until the receiving thread
>> processes the message. However, the sending thread will process incoming
>> nonqueued messages while waiting for its message to be processed.'
>>
> I did read this, but in fact I can't understand the meaning. If the
> thread stops in "Send Message", it obviously is not in a
> "waitForMessage" function. At what code would it start running if a
> message to be processed arrives ?
>
> -Michael
>

Hi!

I don't know how big your interest is in this topic, but you might take 
a look at the source code of ReactOS. There you can see what's happening 
inside a SendMessage.

To speed up your research I've looked a bit by myself:

SendMessage(W) is defined in dll\win32\user32\windows\message.c. After 
some preparing (and checking whether it the message can be send directly 
(same thread)) it finally calls NtUserSendMessage which is defined in 
subsystems\win32\win32k\ntuser\message.c.
There it jumps around a bit in internal function (co_IntDoSendMessage => 
co_IntSendMessage => co_IntSendMessageTimeout => 
co_IntSendMessageTimeoutSingle) to finally pass the message into the 
message queue using co_MsqSendMessage which is defined in 
subsystems\win32\win32k\ntuser\msgqueue.c.
If you look there you'll see a KeWaitForSingleObject or a 
KeWaitForMultipleObjects which basically waits for an event which is 
initialized in this function. This event might signal the completion of 
the message passing (I haven't studied the code in detail though, so the 
last assumption might be wrong).

Regards,
Sven




More information about the Lazarus mailing list