将第二个程序的进程号写入第一个的ID中,同时将&i地址写在WriteProcessMemory中,调试可以发现,改变了第二个程序的i的值
#include<windows.h>
#include<tchar.h>
#include<Tlhelp32.h>
#define ID 4368
int _tmain()
{
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPHEAPLIST,ID);
if (hSnapshot == INVALID_HANDLE_VALUE)
{
_tprintf(L"%d\n", GetLastError());
return 0;
}
HEAPLIST32 hl = {0};
hl.dwSize = sizeof(hl);
Heap32ListFirst(hSnapshot,&hl);
do{
_tprintf(L"------------------------------------------------\n");
_tprintf(TEXT("ProcessID=%d,HeapID=%d\n"),hl.th32ProcessID,hl.th32HeapID);
HEAPENTRY32 he = {0};
he.dwSize = sizeof(he);
Heap32First(&he,hl.th32ProcessID,hl.th32HeapID);
do{
_tprintf(TEXT("Address=%0x\tSize=%0x\tflages=%0x\n"),he.dwAddress,he.dwBlockSize,
he.dwFlags);
} while (Heap32Next(&a