Re: Which process posts this window message ?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



See below...
On Thu, 10 Dec 2009 13:53:22 -0800, "David Ching" <dc@xxxxxxxxxxxxxxxxxxxxxx> wrote:

"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:1lt1i5hlg4g43dut7fk69hgkmeapv41koe@xxxxxxxxxx
I can imagine some very complicated, fragile, and potentially very
dangerous mechanisms
for detecting this, but they would involve DLL injection which would then
"hook" (but not
in the legitimage SetWindowsHookEx) all SendMessage/PostMessage/etc. calls
and if one of
them was targeted to a function in a forbidden app, doing something to
return immediately
to the caller. The real risk here is if there were any change whatsoever
to the
mechanisms you were running roughshod over (say, a drive-by update), then
every program on
the system would cease working. Not A Place You Want To Be.

I wouldn't deploy it, but API hooking is a great way of debugging who the
heck posted the unwanted message. I've done this and saved the client many
hours of billable time in addition to a large portion of my hair! ;)
****
Yes, API hooking was what I was referring to. While a fine short-term solution, to
implement the solution as a permanent solution seems risky.
****

Windows apps should be architected so they can withstand windows messages
from anyone. If it is important to validate the sender, a private mechanism
must be used between the sender and the app. For example, if you don't want
another app to post WM_CLOSE to your window so that your app terminates,
don't terminate when WM_CLOSE (or any other Windows message you can't
defend) is received.
****
You can only carry this so far. While WM_CLOSE could be defended against, there are lots
of other messages I could use to implement a D-O-S, such as messages to child windows to
delete items from list boxes, etc. So from a security viewpoint, only API hooking can
solve the problem, but it is not a really good solution in the long term.
*****

For example, one of my apps only terminates when a second instance is
launched with a "/kill" command-line switch specified, the second instance
then knows how to kill the first instance.
****
And there's my technique of putting a GUID in the front of a WM_COPYDATA packet to ensure
that only valid packets are processed. The problem is that each of these is a very
focused solution. The only general solution is API hooking. And the problem with that is
that it seems very high-risk to impose it system-wide as a permanent state.
joe
****

-- David
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Windows.. its like coming home!
    ... gradual transition, especially in going from OS 9 to OS X. ... They needed something that could compete with Windows, ... mean by the "2 of every app" comment before - Apple took whatever apps ... I've found that because the Dock shows applications rather than windows, ...
    (comp.sys.mac.advocacy)
  • Re: Windows.. its like coming home!
    ... gradual transition, especially in going from OS 9 to OS X. ... They needed something that could compete with Windows, ... mean by the "2 of every app" comment before - Apple took whatever apps ... I've found that because the Dock shows applications rather than windows, ...
    (comp.sys.mac.advocacy)
  • RE: Beginners Questions
    ... We do use Windows form on the presentation layer which is on ... terminal server and call web services on the business logic side. ... of using "proxy" authentication on SQL Server. ... > I have written an app with a Windows Forms UI that is deployed to clients ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: Frustration level with Windows -- ARG!
    ... I can have an app sieze and you can go take a ten ... That is MS-Outlook, not Windows. ... to the processes tab, not the applications tab. ... and it tries to stop them "gently" if it can, before resorting to kill -9. ...
    (comp.sys.mac.advocacy)
  • Re: DOS applications ?
    ... A DOS batch file runs dos programs sequentially and can run ... command prompt window and keep the second command ... Windows APIs to do it. ... A 16-bit DOS app running on pure MS-DOS cannot launch another app ...
    (microsoft.public.vc.mfc)