HyperDbg Debugger
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1
12
#pragma once
13
14
#ifndef COMMON_H
15
# define COMMON_H
16
21
# define SYMBOL_BUFFER_INIT_SIZE 64
22
26
# define TOKEN_VALUE_MAX_LEN 8
27
31
# define TOKEN_LIST_INIT_SIZE 256
32
36
typedef
enum
TOKEN_TYPE
37
{
38
LOCAL_ID
,
39
LOCAL_UNRESOLVED_ID
,
40
GLOBAL_ID
,
41
GLOBAL_UNRESOLVED_ID
,
42
DECIMAL
,
43
STATE_ID
,
44
HEX
,
45
OCTAL
,
46
BINARY
,
47
SPECIAL_TOKEN
,
48
KEYWORD
,
49
WHITE_SPACE
,
50
COMMENT
,
51
REGISTER
,
52
PSEUDO_REGISTER
,
53
NON_TERMINAL
,
54
SEMANTIC_RULE
,
55
END_OF_STACK
,
56
EPSILON
,
57
TEMP
,
58
STRING
,
59
WSTRING
,
60
INPUT_VARIABLE_TYPE
,
61
HANDLED_VARIABLE_TYPE
,
62
FUNCTION_TYPE
,
63
FUNCTION_PARAMETER_ID
,
64
STACK_TEMP
,
65
UNKNOWN
66
}
TOKEN_TYPE
;
67
71
typedef
struct
_TOKEN
72
{
73
TOKEN_TYPE
Type
;
74
char
*
Value
;
75
unsigned
int
Len
;
76
unsigned
int
MaxLen
;
77
}
TOKEN
, *
PTOKEN
;
78
82
typedef
struct
_TOKEN_LIST
83
{
84
PTOKEN
*
Head
;
85
unsigned
int
Pointer
;
86
unsigned
int
Size
;
87
}
TOKEN_LIST
, *
PTOKEN_LIST
;
88
90
// PTOKEN related functions //
92
PTOKEN
93
NewUnknownToken
(
void
);
94
95
PTOKEN
96
NewToken
(
TOKEN_TYPE
Type,
char
*
Value
);
97
98
void
99
RemoveToken
(
PTOKEN
* Token);
100
101
void
102
PrintToken
(
PTOKEN
Token);
103
104
void
105
AppendByte
(
PTOKEN
Token,
char
c);
106
107
void
108
AppendWchar
(
PTOKEN
Token,
wchar_t
c);
109
110
PTOKEN
111
CopyToken
(
PTOKEN
Token);
112
113
PTOKEN
114
NewTemp
(
PSCRIPT_ENGINE_ERROR_TYPE
,
PUSER_DEFINED_FUNCTION_NODE
);
115
116
PTOKEN
117
NewStackTemp
(
PSCRIPT_ENGINE_ERROR_TYPE
);
118
119
void
120
FreeTemp
(
PTOKEN
Temp);
121
122
void
123
CleanTempList
(
void
);
124
125
void
126
CleanStackTempList
(
void
);
127
129
// TOKEN_LIST related functions //
131
132
PTOKEN_LIST
133
NewTokenList
(
void
);
134
135
void
136
RemoveTokenList
(
PTOKEN_LIST
TokenList);
137
138
void
139
PrintTokenList
(
PTOKEN_LIST
TokenList);
140
141
PTOKEN_LIST
142
Push
(
PTOKEN_LIST
TokenList,
PTOKEN
Token);
143
144
PTOKEN
145
Pop
(
PTOKEN_LIST
TokenList);
146
147
PTOKEN
148
Top
(
PTOKEN_LIST
TokenList);
149
150
char
151
IsNoneTerminal
(
PTOKEN
Token);
152
153
char
154
IsSemanticRule
(
PTOKEN
Token);
155
156
char
157
IsEqual
(
const
PTOKEN
Token1,
const
PTOKEN
Token2);
158
159
int
160
GetNonTerminalId
(
PTOKEN
Token);
161
162
int
163
GetTerminalId
(
PTOKEN
Token);
164
165
int
166
LalrGetNonTerminalId
(
PTOKEN
Token);
167
168
int
169
LalrGetTerminalId
(
PTOKEN
Token);
170
172
// Util Functions //
174
175
char
176
IsHex
(
char
c);
177
178
char
179
IsDecimal
(
char
c);
180
181
char
182
IsLetter
(
char
c);
183
184
char
185
IsUnderscore
(
char
c);
186
187
char
188
IsBinary
(
char
c);
189
190
char
191
IsOctal
(
char
c);
192
193
void
194
SetType
(
unsigned
long
long
* Val,
unsigned
char
Type);
195
196
unsigned
long
long
197
DecimalToInt
(
char
* str);
198
199
unsigned
long
long
200
DecimalToSignedInt
(
char
* str);
201
202
unsigned
long
long
203
HexToInt
(
char
* str);
204
205
unsigned
long
long
206
OctalToInt
(
char
* str);
207
208
unsigned
long
long
209
BinaryToInt
(
char
* str);
210
211
void
212
RotateLeftStringOnce
(
char
* str);
213
215
// Semantic Rule Related Functions //
217
218
char
219
IsType1Func
(
PTOKEN
Operator);
220
221
char
222
IsType2Func
(
PTOKEN
Operator);
223
224
char
225
IsType4Func
(
PTOKEN
Operator);
226
227
char
228
IsType5Func
(
PTOKEN
Operator);
229
230
char
231
IsType6Func
(
PTOKEN
Operator);
232
233
char
234
IsType7Func
(
PTOKEN
Operator);
235
236
char
237
IsType8Func
(
PTOKEN
Operator);
238
239
char
240
IsType9Func
(
PTOKEN
Operator);
241
242
char
243
IsType10Func
(
PTOKEN
Operator);
244
245
char
246
IsType11Func
(
PTOKEN
Operator);
247
248
char
249
IsType12Func
(
PTOKEN
Operator);
250
251
char
252
IsType13Func
(
PTOKEN
Operator);
253
254
char
255
IsType14Func
(
PTOKEN
Operator);
256
257
char
258
IsType15Func
(
PTOKEN
Operator);
259
260
char
261
IsTwoOperandOperator
(
PTOKEN
Operator);
262
263
char
264
IsOneOperandOperator
(
PTOKEN
Operator);
265
266
char
267
IsVariableType
(
PTOKEN
Operator);
268
269
#endif
// !COMMON_H
Value
RequestedActionOfThePacket Value(0x1) 00000000
IsUnderscore
char IsUnderscore(char c)
Checks whether input char is underscore (_) or not.
Definition
common.c:572
PTOKEN
struct _TOKEN * PTOKEN
IsType6Func
char IsType6Func(PTOKEN Operator)
Checks whether this Token type is TwoOpFunc1.
Definition
common.c:858
Pop
PTOKEN Pop(PTOKEN_LIST TokenList)
Removes last Token of a TokenList and returns it.
Definition
common.c:485
IsLetter
char IsLetter(char c)
Checks whether input char belongs to alphabet set or not.
Definition
common.c:555
IsNoneTerminal
char IsNoneTerminal(PTOKEN Token)
Checks whether this Token is noneterminal NoneTerminal token starts with capital letter.
Definition
common.c:1081
Top
PTOKEN Top(PTOKEN_LIST TokenList)
Returns last Token of a TokenList.
Definition
common.c:506
OctalToInt
unsigned long long OctalToInt(char *str)
Converts an octal string to integer.
Definition
common.c:1481
IsType2Func
char IsType2Func(PTOKEN Operator)
Checks whether this Token type is OneOpFunc2.
Definition
common.c:758
AppendWchar
void AppendWchar(PTOKEN Token, wchar_t c)
Appends wchar_t to the token value.
Definition
common.c:272
IsType10Func
char IsType10Func(PTOKEN Operator)
Checks whether this Token type is TwoOpFunc3.
Definition
common.c:938
IsType1Func
char IsType1Func(PTOKEN Operator)
Checks whether this Token type is OneOpFunc1.
Definition
common.c:738
BinaryToInt
unsigned long long BinaryToInt(char *str)
Converts a binary string to integer.
Definition
common.c:1503
RotateLeftStringOnce
void RotateLeftStringOnce(char *str)
Rotate a character array to the left by one time.
Definition
common.c:1524
IsType9Func
char IsType9Func(PTOKEN Operator)
Checks whether this Token type is OneOpFunc3.
Definition
common.c:918
IsType11Func
char IsType11Func(PTOKEN Operator)
Checks whether this Token type is ThreeOpFunc3.
Definition
common.c:958
LalrGetTerminalId
int LalrGetTerminalId(PTOKEN Token)
Gets the Terminal Id object.
Definition
common.c:1241
PrintTokenList
void PrintTokenList(PTOKEN_LIST TokenList)
Prints each Token inside a TokenList.
Definition
common.c:406
IsType4Func
char IsType4Func(PTOKEN Operator)
Checks whether this Token type is VarArgFunc1.
Definition
common.c:818
IsType15Func
char IsType15Func(PTOKEN Operator)
Checks whether this Token type is ThreeOpFunc4.
Definition
common.c:1038
SetType
void SetType(unsigned long long *Val, unsigned char Type)
Set the Type object.
Definition
common.c:1381
NewTemp
PTOKEN NewTemp(PSCRIPT_ENGINE_ERROR_TYPE, PUSER_DEFINED_FUNCTION_NODE)
Allocates a new temporary variable and returns it.
Definition
common.c:621
IsEqual
char IsEqual(const PTOKEN Token1, const PTOKEN Token2)
Checks whether the value and type of Token1 and Token2 are the same.
Definition
common.c:1337
IsOneOperandOperator
char IsOneOperandOperator(PTOKEN Operator)
Checks whether this Token type is OperatorsOneOperandList.
Definition
common.c:798
AppendByte
void AppendByte(PTOKEN Token, char c)
Appends char to the token value.
Definition
common.c:231
FreeTemp
void FreeTemp(PTOKEN Temp)
Frees the memory allocated by Temp.
Definition
common.c:691
IsType12Func
char IsType12Func(PTOKEN Operator)
Checks whether this Token type is OneOpFunc4.
Definition
common.c:978
IsOctal
char IsOctal(char c)
Checks whether input char belongs to octal digit-set or not.
Definition
common.c:606
RemoveTokenList
void RemoveTokenList(PTOKEN_LIST TokenList)
Removes allocated memory of a TOKEN_LIST.
Definition
common.c:386
TOKEN
struct _TOKEN TOKEN
read tokens from input stored in this structure
IsType8Func
char IsType8Func(PTOKEN Operator)
Checks whether this Token type is ThreeOpFunc1.
Definition
common.c:898
DecimalToInt
unsigned long long DecimalToInt(char *str)
Converts an decimal string to a integer.
Definition
common.c:1393
PTOKEN_LIST
struct _TOKEN_LIST * PTOKEN_LIST
RemoveToken
void RemoveToken(PTOKEN *Token)
Removes allocated memory of a token.
Definition
common.c:104
Push
PTOKEN_LIST Push(PTOKEN_LIST TokenList, PTOKEN Token)
Adds Token to the last empty position of TokenList.
Definition
common.c:424
HexToInt
unsigned long long HexToInt(char *str)
Converts an hexadecimal string to integer.
Definition
common.c:1448
IsType13Func
char IsType13Func(PTOKEN Operator)
Checks whether this Token type is TwoOpFunc4.
Definition
common.c:998
NewStackTemp
PTOKEN NewStackTemp(PSCRIPT_ENGINE_ERROR_TYPE)
Allocates a new temporary variable in stack and returns it.
Definition
common.c:660
CopyToken
PTOKEN CopyToken(PTOKEN Token)
Copies a PTOKEN.
Definition
common.c:312
TOKEN_TYPE
TOKEN_TYPE
enumerates possible types for token
Definition
common.h:37
INPUT_VARIABLE_TYPE
@ INPUT_VARIABLE_TYPE
Definition
common.h:60
END_OF_STACK
@ END_OF_STACK
Definition
common.h:55
KEYWORD
@ KEYWORD
Definition
common.h:48
EPSILON
@ EPSILON
Definition
common.h:56
STACK_TEMP
@ STACK_TEMP
Definition
common.h:64
TEMP
@ TEMP
Definition
common.h:57
LOCAL_UNRESOLVED_ID
@ LOCAL_UNRESOLVED_ID
Definition
common.h:39
FUNCTION_TYPE
@ FUNCTION_TYPE
Definition
common.h:62
HANDLED_VARIABLE_TYPE
@ HANDLED_VARIABLE_TYPE
Definition
common.h:61
UNKNOWN
@ UNKNOWN
Definition
common.h:65
SEMANTIC_RULE
@ SEMANTIC_RULE
Definition
common.h:54
WHITE_SPACE
@ WHITE_SPACE
Definition
common.h:49
LOCAL_ID
@ LOCAL_ID
Definition
common.h:38
PSEUDO_REGISTER
@ PSEUDO_REGISTER
Definition
common.h:52
WSTRING
@ WSTRING
Definition
common.h:59
COMMENT
@ COMMENT
Definition
common.h:50
GLOBAL_UNRESOLVED_ID
@ GLOBAL_UNRESOLVED_ID
Definition
common.h:41
SPECIAL_TOKEN
@ SPECIAL_TOKEN
Definition
common.h:47
REGISTER
@ REGISTER
Definition
common.h:51
OCTAL
@ OCTAL
Definition
common.h:45
HEX
@ HEX
Definition
common.h:44
GLOBAL_ID
@ GLOBAL_ID
Definition
common.h:40
FUNCTION_PARAMETER_ID
@ FUNCTION_PARAMETER_ID
Definition
common.h:63
BINARY
@ BINARY
Definition
common.h:46
STRING
@ STRING
Definition
common.h:58
DECIMAL
@ DECIMAL
Definition
common.h:42
NON_TERMINAL
@ NON_TERMINAL
Definition
common.h:53
STATE_ID
@ STATE_ID
Definition
common.h:43
LalrGetNonTerminalId
int LalrGetNonTerminalId(PTOKEN Token)
Gets the Non Terminal Id object.
Definition
common.c:1224
IsVariableType
char IsVariableType(PTOKEN Operator)
Checks whether this Token type is VariableType.
Definition
common.c:1059
IsType14Func
char IsType14Func(PTOKEN Operator)
Checks whether this Token type is ThreeOpFunc2.
Definition
common.c:1018
CleanTempList
void CleanTempList(void)
Resets the temporary variables map.
Definition
common.c:709
IsType5Func
char IsType5Func(PTOKEN Operator)
Checks whether this Token type is ZeroOpFunc1.
Definition
common.c:838
CleanStackTempList
void CleanStackTempList(void)
Resets the stack temporary variables map.
Definition
common.c:723
IsBinary
char IsBinary(char c)
Checks whether input char belongs to binary digit-set or not.
Definition
common.c:589
NewToken
PTOKEN NewToken(TOKEN_TYPE Type, char *Value)
Definition
common.c:60
GetNonTerminalId
int GetNonTerminalId(PTOKEN Token)
Gets the Non Terminal Id object.
Definition
common.c:1112
GetTerminalId
int GetTerminalId(PTOKEN Token)
Gets the Terminal Id object.
Definition
common.c:1129
IsType7Func
char IsType7Func(PTOKEN Operator)
Checks whether this Token type is TwoOpFunc2.
Definition
common.c:878
IsTwoOperandOperator
char IsTwoOperandOperator(PTOKEN Operator)
Checks whether this Token type is OperatorsTwoOperandList.
Definition
common.c:778
IsDecimal
char IsDecimal(char c)
Checks whether input char belongs to decimal digit-set or not.
Definition
common.c:540
IsSemanticRule
char IsSemanticRule(PTOKEN Token)
Checks whether this Token is semantic rule SemanticRule token starts with '@'.
Definition
common.c:1097
IsHex
char IsHex(char c)
Checks whether input char belongs to hexadecimal digit-set or not.
Definition
common.c:525
DecimalToSignedInt
unsigned long long DecimalToSignedInt(char *str)
Converts an decimal string to a signed integer.
Definition
common.c:1414
NewUnknownToken
PTOKEN NewUnknownToken(void)
Allocates a new token.
Definition
common.c:20
NewTokenList
PTOKEN_LIST NewTokenList(void)
Definition
common.c:349
TOKEN_LIST
struct _TOKEN_LIST TOKEN_LIST
this structure is a dynamic container of TOKENS
PrintToken
void PrintToken(PTOKEN Token)
Prints token @detail prints value and type of token.
Definition
common.c:119
PSCRIPT_ENGINE_ERROR_TYPE
enum _SCRIPT_ENGINE_ERROR_TYPE * PSCRIPT_ENGINE_ERROR_TYPE
_TOKEN_LIST
this structure is a dynamic container of TOKENS
Definition
common.h:83
_TOKEN_LIST::Pointer
unsigned int Pointer
Definition
common.h:85
_TOKEN_LIST::Size
unsigned int Size
Definition
common.h:86
_TOKEN_LIST::Head
PTOKEN * Head
Definition
common.h:84
_TOKEN
read tokens from input stored in this structure
Definition
common.h:72
_TOKEN::Len
unsigned int Len
Definition
common.h:75
_TOKEN::MaxLen
unsigned int MaxLen
Definition
common.h:76
_TOKEN::Value
char * Value
Definition
common.h:74
_TOKEN::Type
TOKEN_TYPE Type
Definition
common.h:73
USER_DEFINED_FUNCTION_NODE
Definition
ScriptEngineCommonDefinitions.h:43
hyperdbg
script-engine
header
common.h
Generated by
1.11.0