forked from LibertyGlobal/memcr
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmemcr.h
More file actions
100 lines (84 loc) · 2.09 KB
/
memcr.h
File metadata and controls
100 lines (84 loc) · 2.09 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
/*
* Copyright (C) 2022 Liberty Global Service B.V.
* Copyright (C) 2025 Marcin Mikula <marcin.mikula@tooxla.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2
* of the license.
*
* 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 library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MEMCR_H__
#define __MEMCR_H__
#include <stdint.h>
#include <assert.h>
#ifndef GIT_VERSION
#define GIT_VERSION "unknown"
#endif
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif
typedef enum {
PARASITE_FLAG_NONE = 0,
PARASITE_FLAG_USE_PAGEMAP = 1
} parasite_args_flags;
struct parasite_args {
struct sockaddr_un addr;
unsigned long gid;
unsigned char flags;
char padding[1];
};
/* size must be CPU word aligned for ptrace() peek/poke */
static_assert(sizeof(struct parasite_args) % sizeof(unsigned long) == 0, "invalid size");
typedef enum {
CMD_MPROTECT = 1,
CMD_GET_PAGES,
CMD_SET_PAGES,
CMD_END,
} memcr_cmd;
struct vm_mprotect {
unsigned long addr;
size_t len;
unsigned long prot;
} __attribute__((packed));
struct vm_region {
unsigned long addr;
unsigned long len;
};
#define VM_REGION_TX 0x01
typedef enum {
REGION_REQ_MEM = 0,
REGION_REQ_PAGEMAP = 1
} memcr_region_req_type;
struct vm_region_req {
union {
struct {
struct vm_region vmr;
char flags;
} mem;
struct {
unsigned long long seek;
unsigned long len;
} pagemap;
} u;
memcr_region_req_type type;
} __attribute__((packed));
struct target_context {
pid_t pid;
unsigned long *pc;
unsigned long *sp;
unsigned long *code;
unsigned long code_size;
unsigned long stack[16];
uint64_t sigset;
unsigned long *blob;
};
#endif