-
Read Shadowed Passwords
Hi,
You know those shadowed passwords (i.e. *****). Im trying to create a program that allows you to recover stored passwords, such as dialup connection as such. BTW the reason im creating this program is coz i always forget the password if i dont have to type them in.
What i have so for;
1. Not alot
2. You can find these using Spy++ by viewing the messages sent and received by the text box.
3. I need to send message WM_GetText
But what i would like to know is how can i find the handle of the textbox by letting the user drag a picture over the text box (like in spy++) and what parameters do i need to use and where can i find these?
:confused:
-
You need the FindWindowEx function.
Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Usage:
Code:
hParentWindow = FindWindowEx(0, 0, "ClassName", "WindowName")
' The EDIT Class is used to find Textboxes. vbNullString specifies
' that we don't care what it is, e.g: In this example, we don't care
' what the text of the window is
hChildWindow = FindWindowEx(hParentWindow, 0, "Edit", vbNullString)
-
You can use the WindowFromPoint API call:
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Where X and Y are the mouse coordinates when the user clicks the textbox.
Better still you could install a low level mouse hook and pop up a menu when the user right clicks over a textbox with the password char set with the unhidden password therein. The EventVB.dll at http://www.merrioncomputing.com/Download/index.htm is the easiest way to do this.
e.g. in your application's main form:
'--[Declarations]----------------------------------------------
Private WithEvents ApiLink As EventVB.APIFunctions
Private WithEvents enHandler As EnumHandler
Private mNotifyIcon As ApiNotifyIcon
'--[Form_Load]-------------------------------------------------
Private Sub Form_Load()
'\\ Link the api dispenser
Set ApiLink = New EventVB.APIFunctions
Set enHandler = ApiLink.EventhandlerLink
'\\ Start the shell notify icon bit
Set mNotifyIcon = New ApiNotifyIcon
With mNotifyIcon
Set .NotifyWindow = mwnd
Dim mIcon As ApiIcon
Set mIcon = New ApiIcon
mIcon.hIcon = Me.Icon.Handle
Set .Icon = mIcon
.ToolTip = "Password Unhider"
.SetNotifyIcon
End With
'\\ Hook the keyboard proc...
Call enHandler.StartHook(WH_MOUSE_LL, ApiLink.AppModuleHandle, 0)
If enHandler.HookIdByType(WH_MOUSE_LL) = 0 Then
MsgBox "Failed to hook mouse", vbCritical, "Fatal error"
End If
End Sub
'--[Form_Terminate]-------------------------------------------------
Private Sub Form_Terminate()
'\\ Remove icon from system tray
mNotifyIcon.UnsetNotifyIcon
'\\ And clear all the object references
Set mNotifyIcon = Nothing
Set enHandler = Nothing
Set ApiLink = Nothing
End Sub
'--[Mouse Event]-----------------------------------------------------
Private Sub enHandler_HOOKPROCMOUSELL(Action As EventVB.enHookCode, wParam As EventVB.WindowMessages, lParam As EventVB.ApiLLMOUSEHOOKSTRUCT, lMsgRet As Long)
Dim wnd As ApiWindow
Dim sText As String
Dim TargethWnd As Long
TargethWnd = WindowFromPoint(lParam.pt.X, lParam.pt.Y)
Set wnd = New ApiWindow
wnd.hwnd = TargethWnd
If TargethWnd <> Me.hwnd Then
If wParam = WM_RBUTTONDOWN Then
mnuPopup.Text = wnd.WindowText
Popupmenu mnuPopup
End If
End If
End If
End Sub
And there you have it - a system tray sitting always on the right mouse click password decoder.
HTH,
Duncan