Thread: windows hooks with other processes

  1. #1
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401

    windows hooks with other processes

    I remember reading somewhere that a way to get a windows hook into another process is to add your dll to the APIEntry list or something like that, and whenever a process is started, the dll is loaded with it. through that you can subclass and do whatever. is this how spy++ works? if it is, can someone direct me as to how to make such a dll? thanks.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    119
    What are you trying to do anyways? Just curious.... I probably won't be able to help you much....

    If you just want to subclass some programs Window procedure try calling SetWindowLong and replace the window proc with your own.

    -Futura

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Yes. The technique is called DLL Hooking. Jeffrey Richter demostrate DLL Hooking in his book.

    Programming Applications for Microsoft Windows by Jeffrey Richter

    Kuphryn

  4. #4
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    thanks kuphryn. codulation, windows prevents a process modifying the memory space of another process, so i cant just use SetWindowLong. Plus, how would i get the window handle? But it would be good if that method works, its nice and easy.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  5. #5
    Registered User
    Join Date
    Dec 2002
    Posts
    119
    Aw, c'mon don't give up so easily. You can get the window's handle with FindWindow() or EnumDesktopWindows()
    Then use DebugActiveProcess() to attatch to it- presto, you've got access to the process like it's your own and can freely use SetWindowLong(). BTW, this won't work with NT, 2k and up if the security descriptor for the target process don't allow debugging.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM
  2. windows service + hooks + dll
    By rotis23 in forum Windows Programming
    Replies: 5
    Last Post: 09-04-2003, 07:06 AM
  3. linux and windows lookup host processes
    By Lynux-Penguin in forum Tech Board
    Replies: 0
    Last Post: 08-31-2003, 11:54 PM
  4. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM
  5. Windows Hooks Q?
    By SyntaxBubble in forum Windows Programming
    Replies: 3
    Last Post: 03-03-2002, 10:20 AM