MCPcopy Create free account
hub / github.com/HyperDbg/HyperDbg / ScriptEngineParse

Function ScriptEngineParse

hyperdbg/script-engine/code/script-engine.c:342–696  ·  view source on GitHub ↗

* @brief The entry point of script engine * * @param str * @return PVOID */

Source from the content-addressed store, hash-verified

340 * @return PVOID
341 */
342PVOID
343ScriptEngineParse(char * str)
344{
345 char * ScriptSource = PlatformStrDup(str);
346
347 PSCRIPT_ENGINE_TOKEN_LIST Stack = NewTokenList();
348 PSCRIPT_ENGINE_TOKEN_LIST MatchedStack = NewTokenList();
349 PSYMBOL_BUFFER CodeBuffer = NewSymbolBuffer();
350
351 UserDefinedFunctionHead = malloc(sizeof(USER_DEFINED_FUNCTION_NODE));
352 PlatformZeroMemory(UserDefinedFunctionHead, sizeof(USER_DEFINED_FUNCTION_NODE));
353 UserDefinedFunctionHead->Name = PlatformStrDup("main");
354 UserDefinedFunctionHead->IdTable = (unsigned long long)NewTokenList();
355 UserDefinedFunctionHead->FunctionParameterIdTable = (unsigned long long)NewTokenList();
356 UserDefinedFunctionHead->TempMap = calloc(MAX_TEMP_COUNT, 1);
357 UserDefinedFunctionHead->VariableType = (unsigned long long)VARIABLE_TYPE_VOID;
358
359 CurrentUserDefinedFunction = UserDefinedFunctionHead;
360
361 SCRIPT_ENGINE_ERROR_TYPE Error = SCRIPT_ENGINE_ERROR_FREE;
362 char * ErrorMessage = NULL;
363
364 static INT FirstCall = 1;
365 if (FirstCall)
366 {
367 GlobalIdTable = NewTokenList();
368 FirstCall = 0;
369 }
370
371 PSCRIPT_ENGINE_TOKEN TopToken = NewUnknownToken();
372
373 int NonTerminalId;
374 int TerminalId;
375 int RuleId;
376 CHAR C;
377 BOOL WaitForWaitStatementBooleanExpression = FALSE;
378
379 //
380 // Initialize Scanner
381 //
382 InputIdx = 0;
383 CurrentLine = 0;
384 CurrentLineIdx = 0;
385
386 //
387 // End of File Token
388 //
389 PSCRIPT_ENGINE_TOKEN EndToken = NewToken(END_OF_STACK, "$");
390
391 //
392 // Start Token
393 //
394 PSCRIPT_ENGINE_TOKEN StartToken = NewToken(NON_TERMINAL, START_VARIABLE);
395
396 Push(Stack, EndToken);
397 Push(Stack, StartToken);
398
399 C = sgetc(ScriptSource);

Callers 2

ScriptEngineParseWrapperFunction · 0.85
ScriptEngineEvalWrapperFunction · 0.85

Calls 15

PlatformStrDupFunction · 0.85
NewTokenListFunction · 0.85
NewSymbolBufferFunction · 0.85
NewUnknownTokenFunction · 0.85
NewTokenFunction · 0.85
PushFunction · 0.85
sgetcFunction · 0.85
ScanFunction · 0.85
HandleErrorFunction · 0.85
RemoveTokenListFunction · 0.85
RemoveTokenFunction · 0.85
NewSymbolFunction · 0.85

Tested by

no test coverage detected