-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremote_fork.h
More file actions
86 lines (64 loc) · 1.44 KB
/
remote_fork.h
File metadata and controls
86 lines (64 loc) · 1.44 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
#ifndef REMOTE_FORK_H
#define REMOTE_FORK_H
#include <stdio.h>
#include <pmparser.h>
#include <stdbool.h>
#include <sys/user.h>
/* ---------- DEFINITIONS ---------- */
#define SYS_PAGE_SIZE 4096
#define FORCED_VDSO_TRANSFER false
/* ---------- ENUMS ---------- */
enum ForkLocation {
Parent = 1,
Child = 2,
};
/* ---------- STRUCTS ---------- */
typedef struct Result {
enum ForkLocation loc;
int raise_result;
pid_t pid;
} Result;
typedef struct ProcessState {
size_t brk_address;
} ProcessState;
enum CommandType {
PROCESS_STATE = 1,
MAPPING = 2,
REMAP = 3,
RESUME_WITH_REGISTERS = 4,
};
typedef struct Mapping {
char name[20];
bool readable;
bool writable;
bool executable;
void* addr;
size_t size;
} Mapping;
typedef struct Remap {
char name[20];
size_t addr;
size_t size;
} Remap;
typedef struct ResumeWithRegisters {
struct user_regs_struct user;
} ResumeWithRegisters;
typedef struct Command {
enum CommandType type;
union cmds {
ProcessState ps;
Mapping mp;
Remap rm;
ResumeWithRegisters rwr;
} cmds;
} Command;
/* ---------- MAIN FUNCTIONS ---------- */
Result const remote_fork(FILE* out);
pid_t receive_fork(FILE* in, __int32_t pass_to_child);
__int32_t wait_for_exit(pid_t child);
// /*All in one*/
// void yoyo(char* addr);
/* ---------- UTILS ---------- */
/*A hacky way to throw an error and stops the entire program.*/
extern int raise_error(char* msg);
#endif // REMOTE_FORK_H