CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2010
    Posts
    24

    Lightbulb Hook Message GetText In TextBox

    I am writing Hack game Wow.exe,i want get UserName and password when gamer type it,but i dont get hWnd for textbox ,beacause i want hook message WM_GETTEXT for wow.exe,can you help me ?
    Code:
    LRESULT  CALLBACK GetMesgProc(int nCode, WPARAM wParam, LPARAM lParam) {
    	PMSG pmsg;
    	if (nCode < 0) 
    		return CallNextHookEx(hNextHook, nCode, wParam, lParam);
    	pmsg = (PMSG)lParam;
    	switch (pmsg->message) {
    		 case WM_GETTEXT:  //i want get text but dont Handle of Textbox password 
                                               break;
    	};
    	return CallNextHookEx(hNextHook, nCode,wParam, lParam);
    }

  2. #2
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: Hook Message GetText In TextBox

    What do you mean by Hack game ? Are you saying you want to capture the user name & password inside a third party game program ? if so, do you that it is illegal to do so ?
    Regards,
    Ramkrishna Pawar

  3. #3
    Join Date
    Feb 2010
    Posts
    24

    Re: Hook Message GetText In TextBox

    yes,i am sorry,i found on google hook message WM_Gettext dont get text when user input password and username


    There is two different ways a window can handle its text. Either let system handle it or handle it themself. If the system handles it it will store the text passed to CreateWindow/CreateWindowEx in a dedicated memory area. This is returned by GetWindowText or by sending WM_GETTEXT. However the window/control can handle it themselfs, which is pretty common for a control to do. In that case the control handles the WM_GETTEXT and WM_GETTEXTLENGTH messages and returns whatever text they want/use.

    So when you send a WM_GETTEXT message, if the window/control doesn't handle that message itself, Windows will return the string stored in the dedicated memory area when the window was created, and it will replace it if a WM_SETTEXT message is sent. This is the default behaviour.

    Now, if you use the GetWindowText function it will send a WM_GETTEXT message if the window you're requesting the text for have been created by the same process that calls GetWindowText. But if you use GetWindowText on a control in another process it will return the text stored in this special memory area and not send a WM_GETTEXT message. The reason for this is simply because if GetWindowText would send the message to a window that is hung it would never return, hence hanging the process that call the function. That would cause a huge problem for such things as the task switcher that would hang if one window is hung. A hung application/window shouldn't cause problems for other applications/windows.

    This is also the reason you can get different values using GetWindowText and sending WM_GETTEXT to a control. The control was created with a call to CreateWindow or CreateWindowEx with one text (that will be returned by GetWindowText) and then handles the WM_GETTEXT message itself and returns something else. So if you want to be sure to get the correct text you should use WM_GETTEXT for other processes, however you should also be aware that if the window/control in question is hung SendMessage will never return. So the best approach is to use SendMessageTimeout instead of SendMessage.

    __________________

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured