逆向工程:内存注入笔记

#include
	//点击按钮
	CDialogEx::OnOK();
	//进程id
	DWORD pid = 3440;
	//注入内存地址
	DWORD ammo = 0x1A5D151F;
	//注入代码
	char wcodeA[] = {0x90, 0x90, 0x90, 0x90, 0x90, 0x90};
	//原始代码
	char oldwcodeA[] = { 0x89, 0x86, 0xCC, 0x00, 0x00, 0x00 };
	//根据pid获取句柄
	HANDLE hd = OpenProcess(PROCESS_ALL_ACCESS, false, pid);
	//获取复选框状态
	if (((CButton*)GetDlgItem(infiniteAmmo))->GetCheck()) {
		MessageBoxA(NULL, "无限子弹开启", "确认", MB_OK);
		//开始注入
		WriteProcessMemory(hd, (LPVOID)ammo, wcodeA, sizeof(wcodeA), NULL);
	}
	else {
		MessageBoxA(NULL, "无限子弹关闭", "确认", MB_OK);
		//还原代码
		WriteProcessMemory(hd, (LPVOID)ammo, oldwcodeA, sizeof(oldwcodeA), NULL);
	}	

你可能感兴趣的:(笔记)