Through /proc file system , it's probable to read memory mappings with /proc/PID_PROCESS/maps , but is there any native APIs that dedicated for this function in C/C++ ?
i.e to find out memory address that are writable and readable for process with PID 9322:
%> awk -F "-| " '$3 ~ /rw/ { print $1 " " $2}' /proc/9322/maps
0804e000 0804f000
085ed000 0860e000
b7707000 b7708000
b7864000 b7865000
b7865000 b7868000
b7897000 b7898000
b78b6000 b78b7000
bfd2e000 bfd50000
And those address are passed into my program , but now i want to integrate this function directly into my C++ program.
For most effectiveness , if i want to support for other *BSD system , i would not be able to take advantage of /proc system , and i think there should some method to generate e.g /proc/1/maps directly without reading them again there , correct if i'm wrong ^_^
Read the proc file like you read normal file.
eg.