24 #define _XOPEN_SOURCE 500
25 #define _FILE_OFFSET_BITS 64
31 #include <sys/types.h>
36 #include <sys/ptrace.h>
59 while (tmpsection != 0x00) {
60 if ((tmpsection->
init <= addr) && (tmpsection->
end > addr)) {
62 return tmpsection->
end - addr;
64 tmpsection = tmpsection->
next;
78 unsigned long long int initz, endz,
size;
80 unsigned long int initz, endz,
size;
83 unsigned int counter=1;
85 unsigned int perms, t;
89 sprintf(mpath,
"/proc/%d/maps", pid);
90 fmaps = fopen(mpath,
"r");
93 perror(
"[!!] Error reading maps file");
97 while ( fgets ( line,
sizeof line, fmaps ) != NULL ) {
101 initz = strtoul(line, NULL, 16);
102 endz = strtoul(strchr(line,
'-')+1, NULL, 16);
105 delta=strchr(line,
' ')-line;
108 endz = strtoull(line + 9, NULL, 16);
109 initz = strtoull(line + 0, NULL, 16);
116 memset(hperms,0x00,5);
117 memcpy(hperms,line+delta,4);
118 for (t = 0; t < 4; t++) {
119 switch (line[t + delta]) {
140 name = strtok(NULL,
" ");
143 while(*name !=
'\0' && isspace(*name))
148 name[strlen(name) - 1] =
'\0';
151 if (!strncmp(
"[vsyscall]", name,10))
156 memset(zptr, 0x00,
sizeof(
struct section));
161 strcpy(zptr->
hperms, hperms);
163 strcpy(zptr->
name, name);
165 if (zfirst == 0x00) {
170 while (tmpsection->
next != 0x00) {
171 tmpsection = tmpsection->
next;
173 tmpsection->
next = zptr;
unsigned long long int init
int is_mapped(unsigned long int addr)
unsigned long long int end