Blame winpr/libwinpr/utils/corkscrew/map_info.h

Packit 1fb8d4
/*
Packit 1fb8d4
 * Copyright (C) 2011 The Android Open Source Project
Packit 1fb8d4
 *
Packit 1fb8d4
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit 1fb8d4
 * you may not use this file except in compliance with the License.
Packit 1fb8d4
 * You may obtain a copy of the License at
Packit 1fb8d4
 *
Packit 1fb8d4
 *      http://www.apache.org/licenses/LICENSE-2.0
Packit 1fb8d4
 *
Packit 1fb8d4
 * Unless required by applicable law or agreed to in writing, software
Packit 1fb8d4
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 1fb8d4
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 1fb8d4
 * See the License for the specific language governing permissions and
Packit 1fb8d4
 * limitations under the License.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
/* Process memory map. */
Packit 1fb8d4
Packit 1fb8d4
#ifndef _CORKSCREW_MAP_INFO_H
Packit 1fb8d4
#define _CORKSCREW_MAP_INFO_H
Packit 1fb8d4
Packit 1fb8d4
#include <sys/types.h>
Packit 1fb8d4
#include <stdbool.h>
Packit 1fb8d4
#include <stdint.h>
Packit 1fb8d4
Packit 1fb8d4
#ifdef __cplusplus
Packit Service 5a9772
extern "C"
Packit Service 5a9772
{
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit Service 5a9772
	typedef struct map_info
Packit Service 5a9772
	{
Packit Service 5a9772
		struct map_info* next;
Packit Service 5a9772
		uintptr_t start;
Packit Service 5a9772
		uintptr_t end;
Packit Service 5a9772
		bool is_readable;
Packit Service 5a9772
		bool is_writable;
Packit Service 5a9772
		bool is_executable;
Packit Service 5a9772
		void* data; // arbitrary data associated with the map by the user, initially NULL
Packit Service 5a9772
		char name[];
Packit Service 5a9772
	} map_info_t;
Packit 1fb8d4
Packit Service 5a9772
	/* Loads memory map from /proc/<tid>/maps. */
Packit Service 5a9772
	map_info_t* load_map_info_list(pid_t tid);
Packit 1fb8d4
Packit Service 5a9772
	/* Frees memory map. */
Packit Service 5a9772
	void free_map_info_list(map_info_t* milist);
Packit 1fb8d4
Packit Service 5a9772
	/* Finds the memory map that contains the specified address. */
Packit Service 5a9772
	const map_info_t* find_map_info(const map_info_t* milist, uintptr_t addr);
Packit 1fb8d4
Packit Service 5a9772
	/* Returns true if the addr is in a readable map. */
Packit Service 5a9772
	bool is_readable_map(const map_info_t* milist, uintptr_t addr);
Packit Service 5a9772
	/* Returns true if the addr is in a writable map. */
Packit Service 5a9772
	bool is_writable_map(const map_info_t* milist, uintptr_t addr);
Packit Service 5a9772
	/* Returns true if the addr is in an executable map. */
Packit Service 5a9772
	bool is_executable_map(const map_info_t* milist, uintptr_t addr);
Packit 1fb8d4
Packit Service 5a9772
	/* Acquires a reference to the memory map for this process.
Packit Service 5a9772
	 * The result is cached and refreshed automatically.
Packit Service 5a9772
	 * Make sure to release the map info when done. */
Packit Service 5a9772
	map_info_t* acquire_my_map_info_list();
Packit 1fb8d4
Packit Service 5a9772
	/* Releases a reference to the map info for this process that was
Packit Service 5a9772
	 * previous acquired using acquire_my_map_info_list(). */
Packit Service 5a9772
	void release_my_map_info_list(map_info_t* milist);
Packit 1fb8d4
Packit Service 5a9772
	/* Flushes the cached memory map so the next call to
Packit Service 5a9772
	 * acquire_my_map_info_list() gets fresh data. */
Packit Service 5a9772
	void flush_my_map_info_list();
Packit 1fb8d4
Packit 1fb8d4
#ifdef __cplusplus
Packit 1fb8d4
}
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit 1fb8d4
#endif // _CORKSCREW_MAP_INFO_H