⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memoryreader.cpp

📁 基于VC++用来读指定进程内存数据的程序
💻 CPP
字号:
// MemoryReader.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "MemoryReader.h"

#include "MemReader.h"

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

//在编译成release时需要project-settings-使用静态MFC库
/////////////////////////////////////////////////////////////////////////////
// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		cerr << _T("Fatal Error: MFC initialization failed") << endl;
		nRetCode = 1;
	}
	else
	{
		// TODO: code your application's behavior here.
		//CString strHello;
		//strHello.LoadString(IDS_HELLO);
		//cout << (LPCTSTR)strHello << endl;
		int i;
		double j;
		char strBuffer[32];
		long int addr;
		int type;
		char procName[32];
		
		cout << "Reading data from TestMemory.exe..." << endl;
		MemReader mr("TestMemory.exe");

		mr.readMemory((LPCVOID)I_ADDR, (LPVOID)&i, 4);
		mr.readMemory((LPCVOID)STR_ADDR, (LPVOID)strBuffer, 32);

		cout << "i = " << i << endl;
		cout << "str = " << strBuffer << endl << endl;

		cout << "Process Name: ";
		cin >> procName;
		mr.setProcess(procName);
		cout << endl;

		while(true)
		{
			cout << "Address: ";
			cin.setf(ios_base::hex, ios_base::basefield);
			cin >> addr;
			cout << "type(1=int, 2=double, 3=string): ";
			cin.setf(ios_base::dec, ios_base::basefield);
			cin >> type;

			switch(type)
			{
				case 1:
					mr.readMemory((LPCVOID)addr, (LPVOID)&i, 4);
					cout << "int value: " << i << endl;
					break;
				case 2:
					mr.readMemory((LPCVOID)addr, (LPVOID)&j, 8);
					cout << "double value: " << j << endl;
					break;
				case 3:
					mr.readMemory((LPCVOID)addr, (LPVOID)strBuffer, 32);
					cout << "string: " << strBuffer << endl;
					break;
				default:
					cout << "type error!" << endl;
			}

			cout << endl;

		}

		//cout << "speed = " << mr.getSpeed() << endl;
		//cout << "gear = " << mr.getGear() << endl;

	}

	return nRetCode;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -