2
* Copyright (C) 2011 The Android Open Source Project
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
17
/* Process memory map. */
19
#ifndef _CORKSCREW_MAP_INFO_H
20
#define _CORKSCREW_MAP_INFO_H
22
#include <sys/types.h>
29
typedef struct map_info {
30
struct map_info* next;
35
void* data; // arbitrary data associated with the map by the user, initially NULL
39
/* Loads memory map from /proc/<tid>/maps. */
40
map_info_t* load_map_info_list(pid_t tid);
42
/* Frees memory map. */
43
void free_map_info_list(map_info_t* milist);
45
/* Finds the memory map that contains the specified address. */
46
const map_info_t* find_map_info(const map_info_t* milist, uintptr_t addr);
48
/* Returns true if the addr is in an readable map. */
49
bool is_readable_map(const map_info_t* milist, uintptr_t addr);
51
/* Returns true if the addr is in an executable map. */
52
bool is_executable_map(const map_info_t* milist, uintptr_t addr);
54
/* Acquires a reference to the memory map for this process.
55
* The result is cached and refreshed automatically.
56
* Make sure to release the map info when done. */
57
map_info_t* acquire_my_map_info_list();
59
/* Releases a reference to the map info for this process that was
60
* previous acquired using acquire_my_map_info_list(). */
61
void release_my_map_info_list(map_info_t* milist);
67
#endif // _CORKSCREW_MAP_INFO_H