How WH_CALLWNDPROCRET Works
Like the WH_CALLWNDPROC
hook, the WH_CALLWNDPROCRET
hook is used to intercept messages sent through the various
SendMessage function types. However,
WH_CALLWNDPROCRET
intercepts its messages later
than WH_CALLWNDPROC
does: whereas the latter
intercepts messages before they are processed by their window
procedure, the former intercepts messages only after the window
procedure has processed them. As a result, you once again cannot
modify or discard the message intercepted through this hook, in this
case because message processing is largely complete.
You can use this hook to monitor sent messages, similar to the
WH_CALLWNDPROC
hook. However, the
WH_CALLWNDPROCRET
hook provides extra information
that WH_CALLWNDPROC
does not. First, it makes
available the return value of the call to the
SendMessage function. Second, the
wParam
specifies whether the sent message
originates from the same process in which the hook is installed, or
from another process. An application could use this hook to listen
for a specific message that is broadcast from another application and
take some action based on receiving that message.
You can use this hook as a thread-specific hook, or you can place it in a dynamic link library (DLL) and use it as a system-wide hook. A thread-specific hook intercepts all messages within the thread in which it is installed. When a hook is installed as a system-wide hook, it has to be placed in a DLL. This DLL is injected into every process so that ...
Get Subclassing and Hooking with Visual Basic now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.