WndProc (Mouse Input Hook) Problem menu

User Tag List

Results 1 to 11 of 11
  1. #1
    Amrok's Avatar Banned
    Reputation
    4
    Join Date
    Apr 2009
    Posts
    59
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    WndProc (Mouse Input Hook) Problem

    Hi,

    i've drawn a small square into wow via endscene hook.. Now i'd like to hook WoW's input event to determine if my rect was clicked and do nothing if it returned true.

    I DONT WANT TO USE GLOBAL HOOKS.

    Does sb. know how to do that? I think my Detour would look like

    Code:
    typedef LRESULT(WINAPI* MyWndProcType)(int,WPARAM,LPARAM);
    MyWndProcType pWndProcHook = Detour(WndProcAddr, WndProcHook);
    
    LRESULT WINAPI WndProcHook( int WndCode, WPARAM wParam, LPARAM lParam )
    {
          // Check here
    
          return pWndProcHook( WndCode, wParam, lParam );
    }
    But i'm not sure how to set up (get the address of wndproc) in another process...
    Last edited by Amrok; 10-28-2011 at 12:14 PM.

    WndProc (Mouse Input Hook) Problem
  2. #2
    swooshy's Avatar Member
    Reputation
    2
    Join Date
    Dec 2009
    Posts
    24
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could do it completly without hooks eg: GetAsyncKeyState

  3. #3
    Amrok's Avatar Banned
    Reputation
    4
    Join Date
    Apr 2009
    Posts
    59
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would i stop wow from executing the click then?

  4. #4
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by swooshy View Post
    You could do it completly without hooks eg: GetAsyncKeyState
    Yuck.

    Anyway, getting the window procedure is pretty easy. From memory you can just get their D3D device then call the function to retrieve the parameters used to create the device. One of the members of that structure should be the window handle.

    EDIT:

    Here you go:
    http://msdn.microsoft.com/en-us/library/windows/desktop/bb174382(v=vs.85).aspx

  5. #5
    Amrok's Avatar Banned
    Reputation
    4
    Join Date
    Apr 2009
    Posts
    59
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you! Okay now i've got access to the HWND.. GetMessage will do the job then. But HOW do i prevent the click then if my gui was clicked?

  6. #6
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Amrok View Post
    Thank you! Okay now i've got access to the HWND.. GetMessage will do the job then. But HOW do i prevent the click then if my gui was clicked?
    Just don't call your trampoline (i.e. WoW's original WndProc) and then obviously the input will never be passed to WoW. I'm pretty sure that will work.

    Too lazy to pull up my old injected base code. I used SetWindowLongPtr though I think, I'm not sure whether you're doing that or using a detour, but I don't think it should make a difference anyway. (A detour is actually a lot easier because you don't have to worry about hook chains, but then that comes at the cost of having to modify WoW's .text section.)

  7. #7
    Amrok's Avatar Banned
    Reputation
    4
    Join Date
    Apr 2009
    Posts
    59
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just don't call your trampoline (i.e. WoW's original WndProc) and then obviously the input will never be passed to WoW. I'm pretty sure that will work.
    I'm still not sure how u mean that...

    For now i've only got the HWND of wow.

    Example
    Code:
    HWND GetHWNDFromD3DDevice( LPDIRECT3DDEVICE9 pDevice )
    {
    	D3DDEVICE_CREATION_PARAMETERS pParams;
    	pDevice->GetCreationParameters( &pParams );
    	return pParams.hFocusWindow;
    }
    This function is called once in the EndScene Hook and the HWND is stored in my module.

    Thats all i got for now.

    EDIT: i'm dumb. Should totally L2R all the text b4 posting...
    Last edited by Amrok; 10-28-2011 at 01:56 PM.

  8. #8
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Once you have the window handle you need to get the window procedure and then either subclass it, or detour it, depending which route you want to go. Both have their pros and cons. From there you can control whether input is passed down the chain or not.

  9. #9
    andy012345's Avatar Active Member
    Reputation
    59
    Join Date
    Oct 2007
    Posts
    124
    Thanks G/R
    0/7
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just thought I'd hop in here since I have a hook for a different game that prevents clicks into it when over UI.

    I detour it, if I want to give the click to the client, at the end I give it back to the original function, if not, you should call DefWindowProc.

    Although my game uses a static address for the handler for procedures, so I can't help you with getting the pointer

  10. #10
    suicidity's Avatar Contributor
    Reputation
    207
    Join Date
    Oct 2006
    Posts
    1,439
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    WNDPROC	g_gameWndProc;
    
    
    {	// In your hook function
    	g_gameWndProc = ( WNDPROC )SetWindowLongA( GAME_HWND, GWL_WNDPROC, ( LONG )WindowProc );
    }
    
    {	// In your unhook function
    	SetWindowLongA( GAME_HWND, GWL_WNDPROC, ( LONG )g_gameWndProc );
    }
    
    
    LRESULT CALLBACK WindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam )
    {
    	tagMSG msg = { hWnd, Msg, wParam, lParam };
    
    
    	if ( g_pInput->ProcessMessage( msg ) ) // This is my message handler
    		return NULL;
    
    
    	return CallWindowProc( g_gameWndProc, hWnd, Msg, wParam, lParam );
    }
    That's how I do it, hf.


  11. #11
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by suicidity View Post
    Code:
    WNDPROC    g_gameWndProc;
    
    
    {    // In your hook function
        g_gameWndProc = ( WNDPROC )SetWindowLongA( GAME_HWND, GWL_WNDPROC, ( LONG )WindowProc );
    }
    
    {    // In your unhook function
        SetWindowLongA( GAME_HWND, GWL_WNDPROC, ( LONG )g_gameWndProc );
    }
    
    
    LRESULT CALLBACK WindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam )
    {
        tagMSG msg = { hWnd, Msg, wParam, lParam };
    
    
        if ( g_pInput->ProcessMessage( msg ) ) // This is my message handler
            return NULL;
    
    
        return CallWindowProc( g_gameWndProc, hWnd, Msg, wParam, lParam );
    }
    That's how I do it, hf.

    Yep, that should work for most games.

    Some games may require a bit of extra work (I seem to remember the UT3 engine calling SetWindowLongPtr and inserting itself on top of the hook chain for some stupid reason, so if you're injecting at process creation time you may need to also hook that API, but it's relatively easy to do).

Similar Threads

  1. Put ideas to get rid of Input Limit Problem
    By Dant3x1986 in forum D3 Gold profiles
    Replies: 4
    Last Post: 08-12-2012, 06:07 PM
  2. Input limit problem
    By v3rtical in forum D3 Gold profiles
    Replies: 7
    Last Post: 08-12-2012, 02:30 PM
  3. Is there a way to disable actual mouse input when a AutoIt script is running?
    By Simonzi in forum Diablo 3 Bots Questions & Requests
    Replies: 4
    Last Post: 06-22-2012, 06:45 PM
  4. D3D Hook problem
    By Master674 in forum WoW Memory Editing
    Replies: 5
    Last Post: 09-20-2011, 12:04 PM
  5. PostMessage to simulate mouse input
    By Anadrol in forum Programming
    Replies: 7
    Last Post: 09-13-2009, 11:33 AM
All times are GMT -5. The time now is 09:42 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search