直接修改内存数据

来源:互联网 发布:财务报表软件 编辑:程序博客网 时间:2024/05/02 23:02

下面是修改进程的某片地址的数据:

#include<stdlib.h>#include<stdio.h>#include<Windows.h>#include<TlHelp32.h>#define NAME "mspaint.exx"  //要修改的进程名void read(){HANDLE hpro = NULL;PROCESSENTRY32 pe32 = { 0 };pe32.dwSize = sizeof(pe32);HANDLE hprocess = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);BOOL res = Process32First(hprocess, &pe32);while (res){if (strcmp(NAME, pe32.szExeFile)){hpro = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);break;}printf("%s\n", pe32.szExeFile);res = Process32Next(hprocess, &pe32);}//修改上面进程的数据,下面的地址是这个进程使用的地址int *p = malloc(4);int *pfind = 0xde52580;int size = 0;//标识读取了几个字节ReadProcessMemory(hpro,pfind,p,4,&size);//读取进程句柄}void write(){HANDLE hpro = NULL;PROCESSENTRY32 pe32 = { 0 };pe32.dwSize = sizeof(pe32);HANDLE hprocess = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);BOOL res = Process32First(hprocess, &pe32);while (res){if (strcmp(NAME, pe32.szExeFile)){hpro = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);break;}printf("%s\n", pe32.szExeFile);res = Process32Next(hprocess, &pe32);}//修改上面进程的数据,下面的地址是这个进程使用的地址int *p = malloc(4);int *pfind = 0xde52580;int size = 0;//标识读取了几个字节WriteProcessMemory(hpro, pfind, p, 4, &size);//写进程句柄}void main(){read();write();system("pause");}


0 0
原创粉丝点击