Such as 0 x00000 x0000f free 0, 0 x00fff x0ffff occupies 0,
Pray god to solve! (preferably a Windows, Linux also line)
CodePudding user response:
#include
#include
//memory page size (4 k)
# define PAGE_SIZE 4096
//[PM_START_ADDRESS, PM_END_ADDRESS) is a 32-bit process can access the virtual address space of the
# define PM_START_ADDRESS 0 x10000
# define PM_END_ADDRESS 0 x7fff0000
Int main (int arg c, char * argv [])
{
//process ID
Uint32_t pid=13236;
//open the process
HANDLE hProcess=OpenProcess (PROCESS_VM_READ, false, pid);
If (hProcess) {
//buffer
Char * page=malloc (PAGE_SIZE);
if (! Page) {
The CloseHandle (hProcess);
return -1;
}
//testing process memory can be read range
Uint64_t start=0;
Uint64_t end=PM_START_ADDRESS;
For (; End//read success
If (ReadProcessMemory (hProcess, (LPCVOID) end, page, PAGE_SIZE, NULL)) {
if (! Start) start=end;
}
//read failure
The else {
If (start) {
Printf (" 0 x % wisco 0 x % wisco \ n ", start, end);
Start=0;
}
}
}
If (start) printf (" 0 x % wisco 0 x % wisco \ n ", start, end);
Free (page);
The CloseHandle (hProcess);
}
return 0;
}
I can only think of this way, look forward to better way downstairs,