Click here to Skip to main content
15,885,244 members
Articles / Programming Languages / C++

PasswordSpy - Retrieving lost passwords using Windows hooks

Rate me:
Please Sign up or sign in to vote.
4.84/5 (66 votes)
16 Dec 20037 min read 647.1K   14.7K   252  
A practical application of setting Windows hooks
#pragma once

#include "HookDllInterface.h"
#include "OSInfo.h"
#include "PopupTipWnd.h"

class CPwdSpyDlg : public CDialog, public CHookDllInterface
{
// Construction
public:
	CPwdSpyDlg(CWnd *pParent = NULL);
	virtual ~CPwdSpyDlg();

// Dialog Data
	//{{AFX_DATA(CPwdSpyDlg)
	enum { IDD = IDD_PWDSPY_DIALOG };
	CStatic	m_ctrlLook;
	CString	m_strMousePos;
	CString	m_strPwd;
	CString	m_strWndClass;
	CString	m_strHwnd;
	CString	m_strIsPwd;
	CString	m_strCaption;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CPwdSpyDlg)
	public:
	virtual BOOL PreTranslateMessage(MSG *pMsg);
	protected:
	virtual void DoDataExchange(CDataExchange *pDX);
	//}}AFX_VIRTUAL

// Implementation
protected:
	static UINT s_wmActivateApp;

	bool m_bIsLooking, m_bAlwaysOnTop, m_bScanEx;
	HICON m_hIconLarge, m_hIconSmall;
	HICON m_hIconBlank, m_hIconScan;
	HCURSOR m_hCursorScan, m_hCursorPrev;
	HWND m_hWndPrev;
	int m_nScanLevel;
	COSInfo m_osi;
	CPopupTipWnd m_wndPopupTip;

	// Since ScanEx is async, these hold data we need later
	HWND m_hWndScanEx;
	CPoint m_ptScanEx;

	void StartLooking(void);
	void StopLooking(void);
	void OnAlwaysOnTop();
	void Scan(CPoint point);
	static HWND SmallestWindowFromPoint(const POINT &point);
	static void InvertBorder(const HWND hWnd);

	// Generated message map functions
	//{{AFX_MSG(CPwdSpyDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg BOOL OnCopyData(CWnd *pWnd, COPYDATASTRUCT *pCopyDataStruct);
	//}}AFX_MSG
	afx_msg LRESULT OnActivateApp(WPARAM wParam, LPARAM lParam);
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions