idfake: improve debug output with syscall return value
[rofl0r-debuglib.git] / process_maps.h
blobe86ac0773c3f55f218d795b8b87e1c412ce1a108
1 #ifndef PROCESS_MAPS_H
2 #define PROCESS_MAPS_H
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
8 #include <stdint.h>
9 #include <stddef.h>
10 #include <unistd.h>
11 #include "../lib/include/sblist.h"
13 typedef enum {
14 MDP_R = 1 << 0,
15 MDP_W = 1 << 1,
16 MDP_X = 1 << 2,
17 MDP_P = 1 << 3, //private (copy on write)
18 MDP_S = 1 << 4, //shared
19 } map_data_perms;
21 typedef struct {
22 void* start;
23 void* end;
24 } map_data_address;
26 typedef struct {
27 unsigned char major;
28 unsigned char minor;
29 } map_data_dev;
31 typedef struct {
32 map_data_address address;
33 uint64_t inode;
34 uint64_t offset;
35 char* pathname;
36 map_data_dev dev;
37 unsigned char perms;
38 } map_data;
40 /* returns a sblist (or NULL) containing map_data members by parsing /proc/pid/maps */
41 sblist* process_maps_get(pid_t pid);
42 /* free the memory claimed by process_maps_get */
43 void process_maps_free(sblist* maps);
44 /* generates a readable string from a permission byte */
45 void process_maps_perms_str(unsigned char perms, char* outbuf5);
46 /* returns a mapdata* for the map the addr is contained in, or NULL */
47 map_data* find_map_for_addr(sblist* maps, void* addr);
48 /* returns size of a mapping */
49 size_t process_map_size(map_data* map);
51 #ifdef __cplusplus
53 #endif
55 #pragma RcB2 DEP "process_maps.c"
57 #endif