FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
map_info.h
1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/* Process memory map. */
18
19#ifndef _CORKSCREW_MAP_INFO_H
20#define _CORKSCREW_MAP_INFO_H
21
22#include <sys/types.h>
23#include <stdbool.h>
24#include <stdint.h>
25
26#ifdef __cplusplus
27extern "C"
28{
29#endif
30
31 typedef struct
32 {
33 struct map_info* next;
34 uintptr_t start;
35 uintptr_t end;
36 bool is_readable;
37 bool is_writable;
38 bool is_executable;
39 void* data; // arbitrary data associated with the map by the user, initially NULL
40 char name[];
41 } map_info_t;
42
43 /* Loads memory map from /proc/<tid>/maps. */
44 map_info_t* load_map_info_list(pid_t tid);
45
46 /* Frees memory map. */
47 void free_map_info_list(map_info_t* milist);
48
49 /* Finds the memory map that contains the specified address. */
50 const map_info_t* find_map_info(const map_info_t* milist, uintptr_t addr);
51
52 /* Returns true if the addr is in a readable map. */
53 bool is_readable_map(const map_info_t* milist, uintptr_t addr);
54 /* Returns true if the addr is in a writable map. */
55 bool is_writable_map(const map_info_t* milist, uintptr_t addr);
56 /* Returns true if the addr is in an executable map. */
57 bool is_executable_map(const map_info_t* milist, uintptr_t addr);
58
59 /* Acquires a reference to the memory map for this process.
60 * The result is cached and refreshed automatically.
61 * Make sure to release the map info when done. */
62 map_info_t* acquire_my_map_info_list();
63
64 /* Releases a reference to the map info for this process that was
65 * previous acquired using acquire_my_map_info_list(). */
66 void release_my_map_info_list(map_info_t* milist);
67
68 /* Flushes the cached memory map so the next call to
69 * acquire_my_map_info_list() gets fresh data. */
70 void flush_my_map_info_list();
71
72#ifdef __cplusplus
73}
74#endif
75
76#endif // _CORKSCREW_MAP_INFO_H