-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
76 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef __IS_MAPPED | ||
#define __IS_MAPPED | ||
|
||
#include <stdio.h> | ||
|
||
int is_mapped(void *addr) { | ||
int res = 1; | ||
|
||
FILE *maps = __setmntent("/proc/self/maps", "r"); | ||
if (maps != NULL) { | ||
char *line_of_maps = NULL; | ||
size_t len_of_maps = 0; | ||
while (getline(&line_of_maps, &len_of_maps, maps) != -1) { | ||
unsigned long int maddr; | ||
sscanf(line_of_maps, "%lx", &maddr); | ||
if ((unsigned long int)addr == maddr) { | ||
res = 0; | ||
break; | ||
} | ||
} | ||
} | ||
fclose(maps); | ||
|
||
return res; | ||
} | ||
|
||
#endif /* __IS_MAPPED */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters