Click here to Skip to main content
15,891,607 members
Articles / Desktop Programming / MFC

Adding high score capability to MS Solitaire

Rate me:
Please Sign up or sign in to vote.
4.70/5 (16 votes)
25 Jul 2007CPOL14 min read 44.1K   713   18  
An application that manages MS Solitaire high scores by reading and writing Solitaire memory
#ifndef _PROCESSQUERY_H
#define _PROCESSQUERY_H

#pragma once

// definitions
#define PROCESS_OPEN_FLAGS PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION|PROCESS_TERMINATE

//////////////////////////////////////////////////////////////////////////////////
// Class CProcessQuery
// is a class that enumerates processes, gets IDs and reads\writes
// process memory. It can be argued that the functions here should have
// been all static, since the object is never changed.
//
// Author: Asa Meltzer
// Date: 07/2007
class CProcessQuery
{
public:
// Construction
	CProcessQuery();
	virtual ~CProcessQuery();
// Operations
	int GetProcessId(const char* const szName) const;
	HANDLE CreateNewProcess(const CString& szFullPath, BOOL bShowWindow = TRUE);
	HANDLE GetProcessHandle(const char* const szName) const;
	HANDLE GetProcessHandle(int pid) const;
	// return the address where the value is
	long FindValueInProcessMem(HANDLE hProcess, long lAddrStart, long lAddrEnd, long lVal) const;
	long ReadProcessAddress(HANDLE hProcess, long lAddr) const;
	void WriteProcessAddress(HANDLE hProcess, long lAddr, long lVal) const;
	void CloseProcess(HANDLE hProcess) const;
	void KillProcess(HANDLE hProcess) const;
	CString GetExecutablePath() const;
// variables
	const static int NAME_LEN = 512;
private:
	int FindProcessId(const char* szName) const;
	BOOL IsProcessId(DWORD pid, const char* szName) const;
};

#endif

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
Software Developer
Israel Israel
Software designer and programmer.
Programming languages:
MFC, C++, Java , C#, VB and sometimes C and assembly.

Comments and Discussions