Script engine evaluation wrapper.
316{
318
319
320
321
323 {
325
327 {
328 ShowMessages(
"err, could not allocate memory for user-mode global variables");
329
330 return;
331 }
332
334 }
335
336
337
338
339
340
342 {
344
346 {
348
349 ShowMessages(
"err, could not allocate memory for user-mode local variables");
350
351 return;
352 }
353
355 }
356
357
358
359
360
361
363 {
365
367 {
370
371 ShowMessages(
"err, could not allocate memory for user-mode temp variables");
372
373 return;
374 }
375
377 }
378
379
380
381
383
384#ifdef _SCRIPT_ENGINE_CODEEXEC_DBG_EN
385
386
387
389#endif
390
393
394
395
396
397
399 if (StackBuffer == NULL)
400 {
403
404 ShowMessages(
"err, could not allocate memory for user-mode stack buffer");
405
406 return;
407 }
409 StackBuffer->
Size = 0;
412 if (StackBuffer->
Head == NULL)
413 {
416 free(StackBuffer);
417 ShowMessages(
"err, could not allocate memory for user-mode stack buffer");
418
419 return;
420 }
422
429
430 if (CodeBuffer->
Message == NULL)
431 {
432#ifdef _SCRIPT_ENGINE_CODEEXEC_DBG_EN
433 printf("\nScriptEngineExecute:\n");
434#endif
436 for (; i < CodeBuffer->
Pointer;)
437 {
438
439
440
441
446
447
448
449
453
454#ifdef _SCRIPT_ENGINE_CODEEXEC_DBG_EN
455 printf("Address = %lld, StackIndx = %lld, StackBaseIndx = %lld\n", i, StackIndx, StackBaseIndx);
457 (
unsigned long long)(i *
sizeof(
SYMBOL)));
458 printf(
"Function = %s\n", FunctionNames[Operator->
Value]);
459 printf("Stack Buffer:\n");
460 for (
UINT64 j = 0; j < StackIndx; j++)
461 {
463 (
unsigned long long)(j *
sizeof(
SYMBOL)));
464
465 printf(
"StackIndx = %lld, Value = %lld", j, StackSymbol->
Value);
466
468 {
469 printf(", Type = SYMBOL_RETURN_ADDRESS_TYPE");
470 }
471
472 if (j == StackBaseIndx)
473 {
474 printf(" <===== StackBaseIndx");
475 }
476 printf("\n");
477 }
478 printf("\n");
479#endif
480
481
482
483
485 &ActionBuffer,
486 &VariablesList,
487 CodeBuffer,
488 &i,
489 StackBuffer,
490 &StackIndx,
491 &StackBaseIndx,
492 &ErrorSymbol,
493 &ReturnValue) ==
TRUE)
494 {
495 ShowMessages(
"err, ScriptEngineExecute, function = %s\n",
496 FunctionNames[ErrorSymbol.
Value]);
499 break;
500 }
502 {
506 break;
507 }
509 {
510 ShowMessages(
"err, exceeding the max execution count\n");
513 break;
514 }
515
516 EXECUTENUMBER++;
517 }
518#ifdef _SCRIPT_ENGINE_CODEEXEC_DBG_EN
519 printf("Address = %lld, StackIndx = %lld, StackBaseIndx = %lld\n", i, StackIndx, StackBaseIndx);
520#endif
521 }
522 else
523 {
525 }
526
528
529 return;
530}
#define MAX_VAR_COUNT
Definition Constants.h:574
#define MAX_EXECUTION_COUNT
Definition Constants.h:570
#define MAX_TEMP_COUNT
Definition Constants.h:566
#define MAX_STACK_BUFFER_COUNT
Definition Constants.h:568
struct SYMBOL_BUFFER * PSYMBOL_BUFFER
#define SYMBOL_RETURN_ADDRESS_TYPE
Definition ScriptEngineCommonDefinitions.h:66
BOOL ScriptEngineExecute(PGUEST_REGS GuestRegs, ACTION_BUFFER *ActionDetail, SCRIPT_ENGINE_VARIABLES_LIST *VariablesList, SYMBOL_BUFFER *CodeBuffer, UINT64 *Indx, SYMBOL_BUFFER *StackBuffer, UINT64 *StackIndx, UINT64 *StackBaseIndx, SYMBOL *ErrorOperator, UINT64 *ReturnValue)
Execute the script buffer.
Definition ScriptEngineEval.c:288
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
UINT64 * g_ScriptGlobalVariables
Holder of script engines global variables.
Definition Global.h:23
UINT64 * g_ScriptLocalVariables
Holder of local variables for script engine.
Definition globals.h:336
UINT64 * g_ScriptTempVariables
Holder of temp variables for script engine.
Definition globals.h:342
PVOID ScriptEngineParse(char *str)
The entry point of script engine.
Definition script-engine.c:267
void RemoveSymbolBuffer(PVOID SymbolBuffer)
Frees the memory allocated by SymbolBuffer.
Definition script-engine.c:2725
List of different variables.
Definition BasicTypes.h:118
UINT64 * GlobalVariablesList
Definition BasicTypes.h:120
UINT64 * LocalVariablesList
Definition BasicTypes.h:121
UINT64 * TempList
Definition BasicTypes.h:119
Definition ScriptEngineCommonDefinitions.h:34
long long unsigned Context
Definition ScriptEngineCommonDefinitions.h:38
long long unsigned Tag
Definition ScriptEngineCommonDefinitions.h:35
long long unsigned CurrentAction
Definition ScriptEngineCommonDefinitions.h:36
char ImmediatelySendTheResults
Definition ScriptEngineCommonDefinitions.h:37
Definition ScriptEngineCommonDefinitions.h:21
char * Message
Definition ScriptEngineCommonDefinitions.h:25
unsigned int Pointer
Definition ScriptEngineCommonDefinitions.h:23
PSYMBOL Head
Definition ScriptEngineCommonDefinitions.h:22
unsigned int Size
Definition ScriptEngineCommonDefinitions.h:24
Definition ScriptEngineCommonDefinitions.h:6
long long unsigned Value
Definition ScriptEngineCommonDefinitions.h:10
long long unsigned Type
Definition ScriptEngineCommonDefinitions.h:7