Language grammar
Language Grammar of Script Engine
HyperDbg operates based on the following grammar.

Language Grammar

1
# ThreeOpFunc1 inputs are three numbers and returns a number.
2
.ThreeOpFunc1->interlocked_compare_exchange
3
4
5
# TwoOpFunc1 inputs are two numbers and returns a number.
6
.TwoOpFunc1->ed eb eq interlocked_exchange interlocked_exchange_add
7
8
# TwoOpFunc2 inputs are two numbers and returns no value
9
.TwoOpFunc2->spinlock_lock_custom_wait
10
11
12
13
# OneOpFunc1 input is a number and returns a number.
14
.OneOpFunc1->poi db dd dw dq neg hi low not check_address strlen wcslen interlocked_exchange_increment interlocked_exchange_decrement
15
16
# OneOpFunc2 input is a number.
17
.OneOpFunc2->print formats disable_event enable_event test_statement spinlock_lock spinlock_unlock
18
19
.ZeroOpFunc1->pause
20
21
.VarArgFunc1->printf
22
23
.OperatorsTwoOperand->or xor and asr asl add sub mul div mod gt lt egt elt equal neq
24
.OperatorsOneOperand->inc dec
25
26
.SemantiRules->start_of_if jmp jz jnz jmp_to_end_and_jzcompleted end_of_if start_of_while end_of_while vargstart mov start_of_do_while start_of_do_while_commands end_of_do_while start_of_for for_inc_dec start_of_for_ommands end_of_if ignore_lvalue
27
28
.Registers->rax eax ax ah al rcx ecx cx ch cl rdx edx dx dh dl rbx ebx bx bh bl rsp esp sp spl rbp ebp bp bpl rsi esi si sil rdi edi di dil r8 r8d r8w r8h r8l r9 r9d r9w r9h r9l r10 r10d r10w r10h r10l r11 r11d r11w r11h r11l r12 r12d r12w r12h r12l r13 r13d r13w r13h r13l r14 r14d r14w r14h r14l r15 r15d r15w r15h r15l ds es fs gs cs ss rflags eflags flags rip eip ip idtr ldtr gdtr tr cr0 cr2 cr3 cr4 cr8 dr0 dr1 dr2 dr3 dr6 dr7
29
30
.PseudoRegisters->pid tid proc thread peb teb ip buffer context
31
32
S->STATEMENT S
33
S->eps
34
35
STATEMENT->IF_STATEMENT
36
STATEMENT->WHILE_STATEMENT
37
STATEMENT->DO_WHILE_STATEMENT
38
STATEMENT->FOR_STATEMENT
39
STATEMENT->ASSIGN_STATEMENT ;
40
STATEMENT->CALL_FUNC_STATEMENT ;
41
STATEMENT->break @BREAK ;
42
STATEMENT->continue @CONTINUE ;
43
44
45
46
ASSIGN_STATEMENT->L_VALUE = EXPRESSION @MOV NULL
47
CALL_FUNC_STATEMENT->.OneOpFunc2 ( EXPRESSION @.OneOpFunc2 )
48
CALL_FUNC_STATEMENT->.VarArgFunc1 ( STRING @VARGSTART VA @.VarArgFunc1 )
49
CALL_FUNC_STATEMENT->.ZeroOpFunc1 ( @.ZeroOpFunc1 )
50
CALL_FUNC_STATEMENT->.TwoOpFunc2 ( EXPRESSION , EXPRESSION @.TwoOpFunc2 )
51
CALL_FUNC_STATEMENT->@IGNORE_LVALUE .TwoOpFunc1 ( EXPRESSION , EXPRESSION @.TwoOpFunc1 )
52
VA->, EXPRESSION VA
53
VA->eps
54
55
IF_STATEMENT->if @START_OF_IF ( BOOLEAN_EXPRESSION ) @JZ { S } ELSIF_STATEMENT ELSE_STATEMENT @END_OF_IF END_OF_IF
56
ELSIF_STATEMENT->elsif @JMP_TO_END_AND_JZCOMPLETED ( BOOLEAN_EXPRESSION ) @JZ { S } ELSIF_STATEMENT
57
ELSIF_STATEMENT->@JMP_TO_END_AND_JZCOMPLETED ELSIF_STATEMENT'
58
ELSIF_STATEMENT'->eps
59
ELSE_STATEMENT->else { S }
60
ELSE_STATEMENT->eps
61
END_OF_IF->eps
62
63
64
65
WHILE_STATEMENT->while @START_OF_WHILE ( BOOLEAN_EXPRESSION ) @START_OF_WHILE_COMMANDS { S @END_OF_WHILE }
66
DO_WHILE_STATEMENT->do @START_OF_DO_WHILE { S } while ( BOOLEAN_EXPRESSION ) @END_OF_DO_WHILE ;
67
68
FOR_STATEMENT->for ( SIMPLE_ASSIGNMENT ; @START_OF_FOR BOOLEAN_EXPRESSION ; @FOR_INC_DEC INC_DEC ) { @START_OF_FOR_COMMANDS S @END_OF_FOR }
69
SIMPLE_ASSIGNMENT->L_VALUE = EXPRESSION @MOV SIMPLE_ASSIGNMENT'
70
SIMPLE_ASSIGNMENT->eps
71
SIMPLE_ASSIGNMENT'->eps
72
73
74
INC_DEC->L_VALUE INC_DEC'
75
INC_DEC'->++ @INC INC'
76
INC_DEC'->-- @DEC DEC'
77
INC'->eps
78
DEC'->eps
79
INC_DEC'->eps
80
81
BOOLEAN_EXPRESSION->eps
82
83
84
EXPRESSION->E1 E0'
85
E0'->| E1 @OR E0'
86
E0'->eps
87
88
89
E1->E2 E1'
90
E1'->^ E2 @XOR E1'
91
E1'->eps
92
93
E2->E3 E2'
94
E2'->& E3 @AND E2'
95
E2'->eps
96
97
E3->E4 E3'
98
E3'->>> E4 @ASR E3'
99
E3'->eps
100
101
E4->E5 E4'
102
E4'-><< E5 @ASL E4'
103
E4'->eps
104
105
E5->E6 E5'
106
E5'->+ E6 @ADD E5'
107
E5'->eps
108
109
E6->E7 E6'
110
E6'->- E7 @SUB E6'
111
E6'->eps
112
113
E7->E8 E7'
114
E7'->* E8 @MUL E7'
115
E7'->eps
116
117
E8->E9 E8'
118
E8'->/ E9 @DIV E8'
119
E8'->eps
120
121
122
E9->E10 E9'
123
E9'->% E10 @MOD E9'
124
E9'->eps
125
126
127
128
129
E10->E12
130
131
132
133
E12->.OneOpFunc1 ( EXPRESSION @.OneOpFunc1 )
134
E12->.TwoOpFunc1 ( EXPRESSION , EXPRESSION @.TwoOpFunc1 )
135
E12->.ThreeOpFunc1 ( EXPRESSION , EXPRESSION , EXPRESSION @.ThreeOpFunc1 )
136
137
138
E12->( EXPRESSION )
139
140
141
# Types must have '_' at the first
142
E12->@PUSH _register
143
E12->@PUSH _id
144
145
146
# numbers
147
E12->@PUSH _hex
148
E12->@PUSH _decimal
149
E12->@PUSH _octal
150
E12->@PUSH _binary
151
152
153
E12->@PUSH _pseudo_register
154
155
E12->- E12 @NEG E13
156
E12->+ E12 E13
157
E12->~ E12 @NOT E13
158
159
E13->eps
160
161
162
STRING->@PUSH _string
163
L_VALUE->@PUSH _id
164
L_VALUE->@PUSH _register
165
NULL->eps
166
Copied!
Copy link
Edit on GitHub