Click here to Skip to main content
15,896,482 members
Articles / Programming Languages / C++

Phishing applications: Security threats regarding the SetParent function

Rate me:
Please Sign up or sign in to vote.
4.62/5 (14 votes)
10 Nov 2011CPOL9 min read 29.4K   583   28  
This article explains how the SetParent function can be used to deceive users and incurs a catastrophe. Also, it suggests protection techniques against attacks presented here.
// MyStatic.cpp : implementation file
//

#include "stdafx.h"
#include "HiJack.h"
#include "MyStatic.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyStatic

CMyStatic::CMyStatic()
{
	m_nAlign = DT_LEFT;
}

CMyStatic::~CMyStatic()
{
}


BEGIN_MESSAGE_MAP(CMyStatic, CStatic)
	//{{AFX_MSG_MAP(CMyStatic)
	ON_WM_CTLCOLOR()
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyStatic message handlers

HBRUSH CMyStatic::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CStatic::OnCtlColor(pDC, pWnd, nCtlColor);
	
	if(pDC) {
		pDC->SetBkMode( TRANSPARENT );
	}
	return hbr;
}

void CMyStatic::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	CRect rect;
	GetWindowRect(rect);
	ScreenToClient(rect);
	dc.FillSolidRect( rect, ::GetSysColor( COLOR_3DFACE ) );
	
	CFont* pFont = GetFont();
	CFont* pOldFont = (CFont*)dc.SelectObject(pFont);
	CString szText;

	GetWindowText(szText);
	dc.DrawText( szText, rect, m_nAlign|DT_EDITCONTROL|DT_WORDBREAK );

	dc.SelectObject( pOldFont );
}

void CMyStatic::SetAlign(int nAlign)
{
	m_nAlign = nAlign;

}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
I started to write software since 1999 and have developed various products including security solutions and system utilities.

Microsoft Visual C++ MVP
Assistant Professor at the University of Virginia
Website: http://yongkwon.info

Comments and Discussions