allocate buffer for temporary variables

This commit is contained in:
SinaKarvandi 2022-01-27 23:49:26 +03:30
parent 84b93ef2a6
commit 22b17d1ac1
5 changed files with 53 additions and 11 deletions

View file

@ -22,6 +22,7 @@
//
extern UINT64 * g_ScriptGlobalVariables;
extern UINT64 * g_ScriptLocalVariables;
extern UINT64 * g_ScriptTempVariables;
//
// *********************** Pdb parse wrapper ***********************
@ -285,6 +286,17 @@ ScriptEngineEvalWrapper(PGUEST_REGS GuestRegs,
RtlZeroMemory(g_ScriptLocalVariables, MAX_VAR_COUNT * sizeof(UINT64));
}
//
// Allocate temp variables holder, actually in reality each core should
// have its own set of temp variables but as we never run multi-core scripts
// in user-mode, thus, it's okay to just have one buffer for temp variables
//
if (!g_ScriptTempVariables)
{
g_ScriptTempVariables = (UINT64 *)malloc(MAX_TEMP_COUNT * sizeof(UINT64));
RtlZeroMemory(g_ScriptTempVariables, MAX_TEMP_COUNT * sizeof(UINT64));
}
//
// Run Parser
//
@ -295,9 +307,8 @@ ScriptEngineEvalWrapper(PGUEST_REGS GuestRegs,
//
//PrintSymbolBuffer(CodeBuffer);
UINT64 g_TempList[MAX_TEMP_COUNT] = {0};
ACTION_BUFFER ActionBuffer = {0};
SYMBOL ErrorSymbol = {0};
ACTION_BUFFER ActionBuffer = {0};
SYMBOL ErrorSymbol = {0};
if (CodeBuffer->Message == NULL)
{
@ -315,7 +326,7 @@ ScriptEngineEvalWrapper(PGUEST_REGS GuestRegs,
//
// Fill the variables list for this run
//
VariablesList.TempList = g_TempList;
VariablesList.TempList = g_ScriptTempVariables;
VariablesList.GlobalVariablesList = g_ScriptGlobalVariables;
VariablesList.LocalVariablesList = g_ScriptLocalVariables;