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
66
79
89
91// PTOKEN related functions //
94NewUnknownToken(void);
95
98
99VOID
101
102VOID
104
105VOID
107
108VOID
109AppendWchar(PSCRIPT_ENGINE_TOKEN Token, wchar_t c);
110
113
116
117VOID
119
122
125
127// SCRIPT_ENGINE_TOKEN_LIST related functions //
129
131NewTokenList(void);
132
133VOID
135
136VOID
138
141
144
147
149TopIndexed(PSCRIPT_ENGINE_TOKEN_LIST TokenList, int Index);
150
151char
153
154char
156
157char
158IsEqual(const PSCRIPT_ENGINE_TOKEN Token1, const PSCRIPT_ENGINE_TOKEN Token2);
159
160int
162
163int
165
166int
168
169int
171
173// Util Functions //
175
176char
177IsHex(char c);
178
179char
180IsDecimal(char c);
181
182char
183IsLetter(char c);
184
185char
186IsUnderscore(char c);
187
188char
189IsBinary(char c);
190
191char
192IsOctal(char c);
193
194VOID
195SetType(unsigned long long * Val, unsigned char Type);
196
197unsigned long long
198DecimalToInt(char * str);
199
200unsigned long long
201DecimalToSignedInt(char * str);
202
203unsigned long long
204HexToInt(char * str);
205
206unsigned long long
207OctalToInt(char * str);
208
209unsigned long long
210BinaryToInt(char * str);
211
212VOID
213RotateLeftStringOnce(char * str);
214
216// Semantic Rule Related Functions //
218
219char
221
222char
224
225char
227
228char
230
231char
233
234char
236
237char
239
240char
242
243char
245
246char
248
249char
251
252char
254
255char
257
258char
260
261char
263
264char
266
267char
269
270char
272
277{
278 char * Name;
279 long long unsigned Address;
280 long long unsigned VariableType;
281 long long unsigned ParameterNumber;
282 long long unsigned MaxTempNumber;
283 long long unsigned LocalVariableNumber;
284 long long unsigned IdTable;
285 long long unsigned FunctionParameterIdTable;
286 char * TempMap;
289
298
299#endif // !COMMON_H
char CHAR
Definition BasicTypes.h:33
RequestedActionOfThePacket Value(0x1) 00000000
char IsUnderscore(char c)
Checks whether input char is underscore (_) or not.
Definition common.c:606
struct _SCRIPT_ENGINE_TOKEN * PSCRIPT_ENGINE_TOKEN
struct _INCLUDE_NODE INCLUDE_NODE
Include file linked list node.
VOID PrintToken(PSCRIPT_ENGINE_TOKEN Token)
Prints token.
Definition common.c:132
char IsType9Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is OneOpFunc3.
Definition common.c:889
char IsType4Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is VarArgFunc1.
Definition common.c:789
char IsLetter(char c)
Checks whether input char belongs to alphabet set or not.
Definition common.c:589
PSCRIPT_ENGINE_TOKEN Top(PSCRIPT_ENGINE_TOKEN_LIST TokenList)
Returns last Token of a TokenList.
Definition common.c:523
char IsType2Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is OneOpFunc2.
Definition common.c:729
int LalrGetNonTerminalId(PSCRIPT_ENGINE_TOKEN Token)
Gets the Non Terminal Id object.
Definition common.c:1227
char IsType6Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is TwoOpFunc1.
Definition common.c:829
unsigned long long OctalToInt(char *str)
Converts an octal string to integer.
Definition common.c:1492
char IsType1Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is OneOpFunc1.
Definition common.c:709
PSCRIPT_ENGINE_TOKEN CopyToken(PSCRIPT_ENGINE_TOKEN Token)
Copies a PTOKEN.
Definition common.c:326
PSCRIPT_ENGINE_TOKEN NewUnknownToken(void)
Allocates a new token.
Definition common.c:20
char IsType12Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is OneOpFunc4.
Definition common.c:949
char IsType14Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is ThreeOpFunc2.
Definition common.c:989
PSCRIPT_ENGINE_TOKEN TopIndexed(PSCRIPT_ENGINE_TOKEN_LIST TokenList, int Index)
Returns the token at a specific index from the top of the token list.
Definition common.c:543
VOID PrintTokenList(PSCRIPT_ENGINE_TOKEN_LIST TokenList)
Prints each Token inside a TokenList.
Definition common.c:423
unsigned long long BinaryToInt(char *str)
Converts a binary string to integer.
Definition common.c:1514
char IsAssignmentOperator(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is assignment operator.
Definition common.c:1049
PSCRIPT_ENGINE_TOKEN NewTemp(PSCRIPT_ENGINE_ERROR_TYPE)
Allocates a new temporary variable and returns it.
Definition common.c:655
char IsType10Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is TwoOpFunc3.
Definition common.c:909
struct _SCRIPT_ENGINE_TOKEN SCRIPT_ENGINE_TOKEN
read tokens from input stored in this structure
int LalrGetTerminalId(PSCRIPT_ENGINE_TOKEN Token)
Gets the Terminal Id object.
Definition common.c:1244
char IsType16Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is ZeroOpFunc2.
Definition common.c:1029
struct _SCRIPT_ENGINE_TOKEN_LIST * PSCRIPT_ENGINE_TOKEN_LIST
VOID AppendWchar(PSCRIPT_ENGINE_TOKEN Token, wchar_t c)
Appends wchar_t to the token value.
Definition common.c:285
PSCRIPT_ENGINE_TOKEN_LIST Push(PSCRIPT_ENGINE_TOKEN_LIST TokenList, PSCRIPT_ENGINE_TOKEN Token)
Adds Token to the last empty position of TokenList.
Definition common.c:441
char IsType15Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is ThreeOpFunc4.
Definition common.c:1009
char IsTwoOperandOperator(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is OperatorsTwoOperandList.
Definition common.c:749
VOID RemoveTokenList(PSCRIPT_ENGINE_TOKEN_LIST TokenList)
Removes allocated memory of a SCRIPT_ENGINE_TOKEN_LIST.
Definition common.c:402
struct _INCLUDE_NODE * PINCLUDE_NODE
PSCRIPT_ENGINE_TOKEN NewToken(SCRIPT_ENGINE_TOKEN_TYPE Type, char *Value)
Allocates a new token with given type and value.
Definition common.c:69
char IsSemanticRule(PSCRIPT_ENGINE_TOKEN Token)
Checks whether this Token is semantic rule SemanticRule token starts with '@'.
Definition common.c:1086
char IsType7Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is TwoOpFunc2.
Definition common.c:849
VOID AppendByte(PSCRIPT_ENGINE_TOKEN Token, CHAR c)
Appends char to the token value.
Definition common.c:243
char IsOctal(char c)
Checks whether input char belongs to octal digit-set or not.
Definition common.c:640
PSCRIPT_ENGINE_TOKEN Pop(PSCRIPT_ENGINE_TOKEN_LIST TokenList)
Removes last Token of a TokenList and returns it.
Definition common.c:502
char IsEqual(const PSCRIPT_ENGINE_TOKEN Token1, const PSCRIPT_ENGINE_TOKEN Token2)
Checks whether the value and type of Token1 and Token2 are the same.
Definition common.c:1347
int GetTerminalId(PSCRIPT_ENGINE_TOKEN Token)
Gets the Terminal Id object.
Definition common.c:1118
PSCRIPT_ENGINE_TOKEN_LIST NewTokenList(void)
Allocates a new SCRIPT_ENGINE_TOKEN_LIST.
Definition common.c:364
char IsType13Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is TwoOpFunc4.
Definition common.c:969
VOID FreeTemp(PSCRIPT_ENGINE_TOKEN Temp)
Frees the memory allocated by Temp.
Definition common.c:693
VOID SetType(unsigned long long *Val, unsigned char Type)
Set the Type object.
Definition common.c:1392
unsigned long long DecimalToInt(char *str)
Converts an decimal string to a integer.
Definition common.c:1404
VARIABLE_TYPE * HandleType(PSCRIPT_ENGINE_TOKEN_LIST PtokenStack)
Return a variable type based on the token stack.
Definition type.c:41
unsigned long long HexToInt(char *str)
Converts an hexadecimal string to integer.
Definition common.c:1459
char IsOneOperandOperator(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is OperatorsOneOperandList.
Definition common.c:769
char IsType11Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is ThreeOpFunc3.
Definition common.c:929
char IsType8Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is ThreeOpFunc1.
Definition common.c:869
enum _SCRIPT_ENGINE_TOKEN_TYPE SCRIPT_ENGINE_TOKEN_TYPE
enumerates possible types for token
_SCRIPT_ENGINE_TOKEN_TYPE
enumerates possible types for token
Definition common.h:37
@ END_OF_STACK
Definition common.h:55
@ KEYWORD
Definition common.h:48
@ DEFERENCE_TEMP
Definition common.h:63
@ EPSILON
Definition common.h:56
@ TEMP
Definition common.h:57
@ LOCAL_UNRESOLVED_ID
Definition common.h:39
@ SCRIPT_VARIABLE_TYPE
Definition common.h:62
@ UNKNOWN
Definition common.h:64
@ 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
@ FUNCTION_ID
Definition common.h:60
@ OCTAL
Definition common.h:45
@ HEX
Definition common.h:44
@ GLOBAL_ID
Definition common.h:40
@ FUNCTION_PARAMETER_ID
Definition common.h:61
@ 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
char IsBinary(char c)
Checks whether input char belongs to binary digit-set or not.
Definition common.c:623
VOID RemoveToken(PSCRIPT_ENGINE_TOKEN *Token)
Removes allocated memory of a token.
Definition common.c:116
int GetNonTerminalId(PSCRIPT_ENGINE_TOKEN Token)
Gets the Non Terminal Id object.
Definition common.c:1101
char IsNoneTerminal(PSCRIPT_ENGINE_TOKEN Token)
Checks whether this Token is noneterminal NoneTerminal token starts with capital letter.
Definition common.c:1070
VARIABLE_TYPE * GetCommonVariableType(VARIABLE_TYPE *Ty1, VARIABLE_TYPE *Ty2)
Returns the common variable type between two types.
Definition type.c:188
char IsDecimal(char c)
Checks whether input char belongs to decimal digit-set or not.
Definition common.c:574
struct _SCRIPT_ENGINE_TOKEN_LIST SCRIPT_ENGINE_TOKEN_LIST
this structure is a dynamic container of TOKENS
struct _USER_DEFINED_FUNCTION_NODE USER_DEFINED_FUNCTION_NODE
User-defined function linked list node.
struct _USER_DEFINED_FUNCTION_NODE * PUSER_DEFINED_FUNCTION_NODE
char IsHex(char c)
Checks whether input char belongs to hexadecimal digit-set or not.
Definition common.c:559
unsigned long long DecimalToSignedInt(char *str)
Converts an decimal string to a signed integer.
Definition common.c:1425
char IsType5Func(PSCRIPT_ENGINE_TOKEN Operator)
Checks whether this Token type is ZeroOpFunc1.
Definition common.c:809
VOID RotateLeftStringOnce(char *str)
Rotate a character array to the left by one time.
Definition common.c:1536
Include file linked list node.
Definition common.h:294
struct _INCLUDE_NODE * NextNode
Definition common.h:296
char * FilePath
Definition common.h:295
this structure is a dynamic container of TOKENS
Definition common.h:84
unsigned int Pointer
Definition common.h:86
unsigned int Size
Definition common.h:87
PSCRIPT_ENGINE_TOKEN * Head
Definition common.h:85
read tokens from input stored in this structure
Definition common.h:71
unsigned int MaxLen
Definition common.h:75
unsigned long long VariableMemoryIdx
Definition common.h:77
unsigned int Len
Definition common.h:74
SCRIPT_ENGINE_TOKEN_TYPE Type
Definition common.h:72
char * Value
Definition common.h:73
VARIABLE_TYPE * VariableType
Definition common.h:76
User-defined function linked list node.
Definition common.h:277
long long unsigned Address
Definition common.h:279
long long unsigned IdTable
Definition common.h:284
char * TempMap
Definition common.h:286
long long unsigned VariableType
Definition common.h:280
long long unsigned MaxTempNumber
Definition common.h:282
char * Name
Definition common.h:278
struct _USER_DEFINED_FUNCTION_NODE * NextNode
Definition common.h:287
long long unsigned ParameterNumber
Definition common.h:281
long long unsigned FunctionParameterIdTable
Definition common.h:285
long long unsigned LocalVariableNumber
Definition common.h:283
enum _SCRIPT_ENGINE_ERROR_TYPE * PSCRIPT_ENGINE_ERROR_TYPE
struct _VARIABLE_TYPE VARIABLE_TYPE