Intercepting messages

This is a discussion on Intercepting messages within the Windows Programming forums, part of the Platform Specific Boards category; Is it possible to intercept to messages that belong to other processes? Both GetMessage and PeekMessage have the capability to ...

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    8

    Intercepting messages

    Is it possible to intercept to messages that belong to other processes? Both GetMessage and PeekMessage have the capability to get messages from other handles (this is in reference to the second parameter). I was able to get another program's handle (Minesweeper) using FindWindow and use it in PeekMessage and GetMessage, however neither of them were picking up any messages. Then I tried opening the program up with "PROCESS_ALL_ACCESS" privileges for OpenProcess, then using that handle. Neither of these methods worked, so I am wondering, is there any way to get messages that belong to other processes? Maybe a rundll32 injection or CreateRemoteThread method?

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,854
    GetMessage() and PeekMessage() can only get messages for windows they own.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You can set a windows message hook with SetWindowsHookEx. Specifically, you will be interested in WH_CALLWNDPROC and WH_GETMESSAGE. To hook messages belonging to other processes, the hook procedure must be in a DLL. You can search the board and the web for examples.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Spy++ view messages posted/sent to a control, or from it?
    By hanhao in forum Windows Programming
    Replies: 2
    Last Post: 06-24-2007, 11:07 PM
  2. Sending windows messages
    By Ideswa in forum Windows Programming
    Replies: 2
    Last Post: 03-02-2006, 12:27 PM
  3. Intercepting Window Messages?
    By amnesiasoft in forum Windows Programming
    Replies: 5
    Last Post: 10-27-2003, 12:45 PM
  4. ListBox items and intercepting messages
    By Mithoric in forum Windows Programming
    Replies: 2
    Last Post: 08-26-2003, 05:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21