-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathprocfs.h
87 lines (79 loc) · 2.67 KB
/
procfs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* CreateRemoteThread for Linux
*
* Copyright (c) 2018, ilammy
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*/
#ifndef LINUX_CRT_PROCFS_H
#define LINUX_CRT_PROCFS_H
#include <stdbool.h>
#include <sys/types.h>
/**
* struct memory_region - mapped memory region of another process
* @vaddr_low: virtual address of the first byte of the region (inclusive)
* @vaddr_high: virtual address of the last byte of the region (exclusive)
* @readable: region mapped as readable in another process
* @writeable: region mapped as writeable in another process
* @executable: region mapped as executable in another process
* @content: pointer to the read-only mapping of that memory
* in the current process
*/
struct memory_region {
unsigned long vaddr_low;
unsigned long vaddr_high;
bool readable;
bool writeable;
bool executable;
const void *content;
};
/**
* struct library - mapped library of another process
* @regions: mapped regions of the library
* @region_count: number of mapped regions
*/
struct library {
struct memory_region *regions;
size_t region_count;
};
/**
* map_remote_library() - map a library of another process into current one
* @pid: PID of the remote process
* @library_name: name of the library to remap
* @library_map: mapped library will be stored here
*
* Returns: zero on success, negative value on error.
*/
int map_remote_library(pid_t pid, const char *library_name,
struct library *library_map);
/**
* unmap_remote_library() - free previously mapped library
* @library_map: mapping to free
*/
void unmap_remote_library(struct library *library_map);
/**
* write_remote_memory() - write remote process memory
* @pid: PID of the remote process
* @vaddr: virtual address in the remote process
* @data: local buffer to write
* @size: size of the buffer to write
*
* The remote process must be traced and stopped for this to work.
*
* Returns: zero on success, negative value on error.
*/
int write_remote_memory(pid_t pid, unsigned long vaddr,
const void *data, size_t size);
#endif /* LINUX_CRT_PROCFS_H */