forked from GJDuck/e9patch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe9json.h
More file actions
122 lines (110 loc) · 2.63 KB
/
e9json.h
File metadata and controls
122 lines (110 loc) · 2.63 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* e9json.h
* Copyright (C) 2020 National University of Singapore
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __E9JSON_H
#define __E9JSON_H
#include <cstdint>
#include <cstdio>
#include "e9trampoline.h"
/*
* Supported methods.
*/
enum Method
{
METHOD_UNKNOWN,
METHOD_BINARY,
METHOD_EMIT,
METHOD_INSTRUCTION,
METHOD_OPTION,
METHOD_PATCH,
METHOD_RESERVE,
METHOD_TRAMPOLINE,
};
/*
* Supported parameters.
*/
enum ParamName
{
PARAM_UNKNOWN,
PARAM_ABSOLUTE,
PARAM_ADDRESS,
PARAM_BYTES,
PARAM_FILENAME,
PARAM_FORMAT,
PARAM_INIT,
PARAM_LENGTH,
PARAM_MAPPING_SIZE,
PARAM_METADATA,
PARAM_MMAP,
PARAM_MODE,
PARAM_NAME,
PARAM_OFFSET,
PARAM_PROTECTION,
PARAM_TEMPLATE,
PARAM_TRAMPOLINE,
// Special option names:
PARAM_OPTION_DISABLE_B1,
PARAM_OPTION_DISABLE_B2,
PARAM_OPTION_DISABLE_T1,
PARAM_OPTION_DISABLE_T2,
PARAM_OPTION_DISABLE_T3,
};
/*
* Supported formats.
*/
enum Format
{
FORMAT_BINARY,
FORMAT_PATCH,
FORMAT_PATCH_GZ,
FORMAT_PATCH_BZIP2,
FORMAT_PATCH_XZ
};
/*
* Parameter values.
*/
union ParamValue
{
bool boolean; // Boolean
int64_t integer; // Integer
const char *string; // String
Trampoline *trampoline; // Trampoline template
Metadata *metadata; // Instruction metadata
};
/*
* Parameters.
*/
struct Param
{
ParamName name; // Parameter name
ParamValue value; // Parameter value
};
/*
* Messages.
*/
#define PARAM_MAX 8
struct Message
{
Method method; // Message method
size_t lineno; // Line number
unsigned id; // Message ID
unsigned num_params; // Length of `params'.
Param params[PARAM_MAX]; // Message params
};
bool getMessage(FILE *stream, size_t lineno, Message &msg);
const char *getMethodString(Method method);
#endif