-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend.h
106 lines (82 loc) · 1.66 KB
/
backend.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef BACKEND_H_INCLUDED
#define BACKEND_H_INCLUDED
#include <elf.h>
#include "tree.h"
const int VAR_MAX_CUNT = 100;
const int MAX_CODE_LEN = 2048;
const int MAX_FUNC_CUNT = 100;
const int SIZE_OF_REG = 8;
enum def_flag
{
UNDEFINED = 0,
DEFINED = 1
};
enum param_flag
{
NOT_FUNC_PARAM = 0,
FUNC_PARAM = 1
};
enum while_flag
{
NOT_IN_WHILE = 0,
IN_WHILE = 1,
};
enum std_funcs
{
SCAN_HASH = 2031059512,
PRINT_HASH = -1817107093,
SQRT_HASH = 786779368,
STD_FUNC_DETECTED,
STD_FUNC_NOT_DETECTED
};
struct ELFfile
{
unsigned char code[MAX_CODE_LEN] = {};
int ip = 0;
Elf64_Ehdr ehdr = {};
Elf64_Phdr phdr = {};
FILE* exe_file = {};
};
struct func_jmp_mas
{
int func_hash = 0;
int func_ip = 0;
};
struct JMPtable
{
func_jmp_mas func_jmp[MAX_FUNC_CUNT] = {};
int tmp_func = 0;
};
struct var_list
{
int var_hash = 0;
int var_value = 0;
int def_flag = UNDEFINED;
int param_flag = NOT_FUNC_PARAM;
};
struct var_lists
{
var_list* var = NULL;
int free = 1;
int while_flag = NOT_IN_WHILE;
};
int ELFCtor (ELFfile* fdata);
int GenerateELFFile (Node* node);
int VisitWriteCommands (Node* node, var_lists* vr_lists, ELFfile* fdata, JMPtable* jtable);
int FindVariable (var_lists* vr_list, int hash);
int FindFunction (JMPtable* jtable, int hash);
void FixPhdr (ELFfile* fdata);
int murmurHash (char* key, unsigned int len);
#endif
/*
// zvOnit = return
// krasivEe = while
// tortbl = if
// lattE = else
// word_stress = {
// for_weak_people = }
//
//
//
//
*/