-
Notifications
You must be signed in to change notification settings - Fork 1
/
meta.h
90 lines (71 loc) · 1.45 KB
/
meta.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
88
89
#ifndef _META_H
#define _META_H
#include <stdint.h>
#define CTRL_NEW (0x10)
#define CTRL_DFF (0x20)
#define CTRL_DFX (0x30)
#define CTRL_CPY (0x40)
#define CTRL_DEL (0x50)
#define PATCH_COPY (0x01)
#define PATCH_INSERT (0x02)
#define uint8(p) (*(uint8_t *)(p))
#define uint16(p) (*(uint16_t *)(p))
#define uint32(p) (*(uint32_t *)(p))
struct NEW {
dr_t name;
dr_t data;
};
struct DFF {
dr_t name;
dr_t patch;
};
struct DFX {
dr_t name;
dr_t namea;
dr_t patch;
};
struct DEL {
dr_t name;
};
struct CPY {
dr_t name;
dr_t namea;
};
struct CTRL {
uint8_t act;
union {
struct NEW new;
struct DFF dff;
struct DFX dfx;
struct DEL del;
struct CPY cpy;
} u;
};
struct COPY {
uint32_t pos;
uint32_t size;
};
struct INSERT {
const uint8_t *p;
uint32_t size;
};
struct PATCH {
uint8_t act;
union {
struct COPY copy;
struct INSERT insert;
} u;
};
void ctrl_new(drb_t *drb, struct NEW *c);
void ctrl_dff(drb_t *drb, struct DFF *c);
void ctrl_dfx(drb_t *drb, struct DFX *c);
void ctrl_del(drb_t *drb, struct DEL *c);
void ctrl_cpy(drb_t *drb, struct CPY *c);
void ctrl_destroy(struct CTRL *ctrl);
void patch_total(drb_t *drb, int size);
void patch_copy(drb_t *drb, struct COPY *copy);
void patch_insert(drb_t *drb, struct INSERT *insert);
const uint8_t *ctrl_read(const uint8_t *p, struct CTRL *ctrl);
const uint8_t *patch_total_read(const uint8_t *p, uint32_t *size);
const uint8_t *patch_read(const uint8_t *p, struct PATCH *patch);
#endif