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

Function CodeGen

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

* @brief Script Engine code generator * * @param MatchedStack * @param CodeBuffer * @param Operator * @param Error * @param ScriptSource the script source string * @return VOID */

Source from the content-addressed store, hash-verified

706 * @return VOID
707 */
708void
709CodeGen(PSCRIPT_ENGINE_TOKEN_LIST MatchedStack, PSYMBOL_BUFFER CodeBuffer, PSCRIPT_ENGINE_TOKEN Operator, PSCRIPT_ENGINE_ERROR_TYPE Error, char ** ScriptSource)
710{
711 PSCRIPT_ENGINE_TOKEN Op0 = NULL;
712 PSCRIPT_ENGINE_TOKEN Op1 = NULL;
713 PSCRIPT_ENGINE_TOKEN Op2 = NULL;
714 PSCRIPT_ENGINE_TOKEN Temp = NULL;
715
716 PSYMBOL OperatorSymbol = NULL;
717 PSYMBOL Op0Symbol = NULL;
718 PSYMBOL Op1Symbol = NULL;
719 PSYMBOL Op2Symbol = NULL;
720 PSYMBOL TempSymbol = NULL;
721 VARIABLE_TYPE * VariableType = NULL;
722 VARIABLE_TYPE * PointerVariableType = NULL;
723
724 //
725 // It is in user-defined function if CurrentFunctionSymbol is not null
726 //
727 OperatorSymbol = ToSymbol(Operator, Error);
728
729#ifdef _SCRIPT_ENGINE_CODEGEN_DBG_EN
730 //
731 // Print Debug Info
732 //
733 printf("Operator :\n");
734 PrintToken(Operator);
735 printf("\n");
736
737 printf("Semantic Stack:\n");
738 PrintTokenList(MatchedStack);
739 printf("\n");
740
741 printf("Code Buffer:\n");
742 PrintSymbolBuffer((PVOID)CodeBuffer);
743 printf(".\n.\n.\n\n");
744#endif
745
746 while (TRUE)
747 {
748 if (!strcmp(Operator->Value, "@INCLUDE"))
749 {
750 char * IncludeFilePath;
751 char FullPath[MAX_PATH_LEN];
752 char * IncludeFileBuffer;
753 BOOLEAN IncludedPath = FALSE;
754
755 Temp = Pop(MatchedStack);
756 IncludeFilePath = Temp->Value;
757
758 ResolveIncludePath(IncludeFilePath, FullPath);
759
760 if (!FileExists(FullPath))
761 {
762 *Error = SCRIPT_ENGINE_ERROR_SYNTAX;
763 break;
764 }
765

Callers 2

ScriptEngineParseFunction · 0.85

Calls 15

ToSymbolFunction · 0.85
PrintTokenFunction · 0.85
PrintTokenListFunction · 0.85
PrintSymbolBufferFunction · 0.85
PopFunction · 0.85
ResolveIncludePathFunction · 0.85
FileExistsFunction · 0.85
ParseIncludeFileFunction · 0.85
PlatformStrDupFunction · 0.85
InsertStrNewFunction · 0.85
HandleTypeFunction · 0.85
NewSymbolFunction · 0.85

Tested by

no test coverage detected