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