Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/articles/mfc-tutorials/)
-   -   Reveal the lost but saved password. (http://www.go4expert.com/articles/reveal-lost-saved-password-t2957/)

shabbir 11Feb2007 23:04

Reveal the lost but saved password.
This article will tell you how you can retrieve the text from any window. I will use the Notepad as the sample but you can even use the password input boxes. This is not about hacking the passwords but is for retrieving you lost but saved password which is not displayed in browser. There is no standard approach for changing or retrieving the text from existing windows.

How to go about it?

In windows every window has handle which is assigned when process of window is created. Which is unique across all processes. Window means not only top level windows but also buttons, text boxes and other controls. Handle is required to interact with these windows.

Finding a window handle

There are number of ways to find the window handle. For sample application of Notepad an API FindWindow() function is useful. It takes class name and window name as parameters and returns handle to the window. Spy++ (The bundle application with the Visual studio) is a good application to find the class name.

For Notepad the class name is 'notepad'.
Code: CPP

HWND hNotepad = ::FindWindow(_T("notepad"),NULL);
if(hNotepad == NULL)
    MessageBox(_T("No Notepad present"));

There are two child windows for main notepad window. When you are using your browser with spy its your choice and discretion as to what is the window and how its rendered with toolbars, status bars and menus but in notepad one is edit box and second one is a status bar. The control ID for the edit box is 0xf and Class Name for the Edit Box is 'edit'.

Using this control ID, child widow handle can retrieved as follows
Code: CPP

HWND hEdit =  ::GetDlgItem(hNotepad,0xf);

Get the text

Using windows message WM_SETTEXT and WM_GETTEXT you can get the text of the notepad or set it.
Code: CPP

TCHAR txtBuf[256];

This can be used with the passwords fields as well.

parvez.yu 6Mar2008 15:00

Re: Reveal the lost but saved password.
thanks i needed to recover my password

malleswari 7Mar2008 19:20

Re: Reveal the lost but saved password.
Your information is very helpful. I have tried to retrieve control IDs for password fields in various mails like yahoo mail, gmail etc. through Spy++ tool. But I'm unable to find them. Can we get control IDs for every field through Spy++ or is there any possibility for the people who prepared the site to hide the particular information from Spy++? After a lot of trials I've got control ID for password field of Gtalk login dialog, but got empty string after sending WM_GETTEXT message. What would be the reason for it? I'm able to retrieve information of username field in the same dialog. It would be grateful if you can clarify my doubts.

Thanks in advance,

All times are GMT +5.5. The time now is 17:18.