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

Performing a hex dump of another process's memory

Rate me:
Please Sign up or sign in to vote.
4.61/5 (27 votes)
6 Sep 20035 min read 232.3K   9.7K   85  
An article on examining process memory
/*
 Program Name: TCHScroll.h
 Programmer: Timothy Carpenter, 
	(c) Copyright 2003 San Diego
 Description: C++ Windows Horizontal scrollbar manager.
 Platform: Win XP Home VisualC++ 6.0, Pentium
*/
// TCHScroll.cpp: implementation of the TCHScroll class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "TCHScroll.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

TCHScroll::TCHScroll()
{
	m_iScrollPos = 0;
}

TCHScroll::~TCHScroll()
{

}

LRESULT TCHScroll::wmHScroll(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	int nHscrollInc;
	switch (GET_WM_HSCROLL_CODE(wParam, lParam))
	{
	case SB_LINEUP:
		nHscrollInc = -1;
		break;
	case SB_LINEDOWN:
		nHscrollInc = 1;
		break;
	case SB_PAGEUP:
		nHscrollInc = -8;
		break;
	case SB_PAGEDOWN:
		nHscrollInc = 8;
		break;
	case SB_THUMBPOSITION:
		nHscrollInc = GET_WM_HSCROLL_POS(wParam, lParam) - m_iScrollPos;
		break;
	case SB_THUMBTRACK:
		nHscrollInc = GET_WM_HSCROLL_POS(wParam, lParam) - m_iScrollPos;
		break;
	default:
		nHscrollInc = 0;
	}

    nHscrollInc = max(-m_iScrollPos,
            min(nHscrollInc, m_iScrollMax - m_iScrollPos));
	if(nHscrollInc)
	{
		m_iScrollPos += nHscrollInc;
		ScrollWindow(hWnd, -m_xChar * nHscrollInc, 0, NULL, NULL);
		SetScrollPos(hWnd, SB_HORZ, m_iScrollPos, TRUE);
		UpdateWindow(hWnd);
	}
	return 0l;
}

void TCHScroll::mSetup(HWND hWnd, int xMaxPixWidth, int xClient, int xChar)
{
	//Char width in pixels
	m_xChar = xChar;
	//Max scroll value in chars
	m_iScrollMax = max(0, 1 + ((xMaxPixWidth - xClient) / m_xChar));
	m_iScrollPos = min(m_iScrollPos, m_iScrollMax);
	SetScrollRange (hWnd, SB_HORZ, 0, m_iScrollMax, FALSE);
	SetScrollPos   (hWnd, SB_HORZ, m_iScrollPos, TRUE);
}

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
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