Re: How does PeekMessage really work?



Thanks for your links!

It's a good idea to analyze messages in WndProc or have a hook, say
WH_CALLWNDPROC for this purpose. But unfortunately it's too late to analyze a
message when it's already retrieved from the send-message queue because if I
don't want to handle it NOW - I cannot just return it to the queue, its
impossible.

"Malachy Moses" wrote:

On Sep 9, 9:39 am, Denis Adamchuk
<DenisAdamc...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Malachy, thanks for your explanation.

I've carefully read the article by Raymond.

In the OldNewThing discussion I found a similar question about inter-thread
sent messages which are kept in a "separate place". This one is very
important for me now but it is still unanswered:
"Can I retrieve sent messages as if they were posted messages, and then
dispatch them? I would like to be able to filter out, for example, Shatter
attacks. "

In other words I would like to disable sent messages to be processed
(dispatched) within PeekMessage or allow it only for group of messages
(filter by ID).


< snip >

I don't have an answer for you, but I have some more information.

First, there might be a real name for the "separate place" mentioned
in Raymond Chen's blog. The name might be "send-message queue", and
the thread that sent the message might have a correspondingly-named
"reply-message queue". Both of these queues are distinctly different
from the so-called "message queue" that is serviced by GetMessage and
PeekMessage. Here are two links that talk about these topics, and
about the algorithm that the Windows system uses to service these
three queues.

"Sending Messages to a Window" at http://www.jamajm.com/e-books/cpprichter/HTML/ch26d.htm
"Waking a Thread" at
http://ymei.freeshell.org/gopher/Book/Programming%20Applications%20for%20MS%20Windows%204thed/ch26e.htm

Second, with respect to protection against shatter attacks, I think
the right place to do this is inside the WinProc itself. The WinProc
will get all messages, regardless of how they are sent/posted. Inside
the WinProc, you sill need to determine the origin of the message
(thread ID, maybe). Windows must somehow know of the origin, since
Windows needs to know where to send the LRESULT of your WinProc. I
don't know how to get the originating thread ID, however. It would be
nice if the API had a GetOriginOfMSg function, or if the MSG structure
included this information, but it doesn't. You probably will need to
look to undocumented Windows internals. Probably, the internal
structure for MSG must have some sort of identifier on where to send
the LRESULT, so that it ends up in the correct thread's reply-message
queue (per new terminology above).

Third, when I am trying to figure out how Windows works internally, I
often look at the source code for the WINE windows emulator. This
often provides good hints to me on what Windows is probably doing. In
your case, the files you might want to start with are windows/queue.c
and windows/message.c . See the explanation of the WINE messaging sub-
system, at the bottom of this link:

"Chapter 10. Windowing system" at http://www.winehq.org/site/docs/winedev-guide/c3764

Good luck. If you find an answer, please let us know.

.



Relevant Pages

  • Re: How does PeekMessage really work?
    ... I've carefully read the article by Raymond. ... "reply-message queue". ... the right place to do this is inside the WinProc itself. ... Windows must somehow know of the origin, ...
    (microsoft.public.vc.mfc)
  • RE: Problems Printing After XP Upgrade from 98SE
    ... following steps to clean the printer subsystem completely on the ... Windows NT Fax Monitor ... AppleTalk Printing Devices ... | workstation, but if I do that, I'll have to create the queue and re-share ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: as400 print que on windows 2003
    ... If the firewall doesn't fix your problem, try using RPM Select from ... The culprit may be the Windows Firewall. ... configuring TCP print services on another device (you can use Windows ... and the printer queue name exsists with no special characters. ...
    (comp.sys.ibm.as400.misc)
  • Re: Delaying events for fixed amounts of time.
    ... amount of time after the *FIRST* event with a given key arrives. ... I have anything Windows has to offer. ... Pause for, say, 250ms each time through the loop ... Have a queue of keys, each time a new key arrives, add it to the end ...
    (comp.programming.threads)
  • RE: Problems Printing After XP Upgrade from 98SE
    ... Can you print any local print jobs correctly in the system which ... Does the issue occur on only one Windows XP client or all other Windows ... | all of the jobs from the queue and print a test page from XP, ... |> Use the net.exe command to establish a persistent connection. ...
    (microsoft.public.windowsxp.help_and_support)

Quantcast