HyperDbg Debugger
Loading...
Searching...
No Matches
ScriptEngineEval.c File Reference

Shared Headers for Script engine. More...

#include "pch.h"
#include "../script-eval/header/ScriptEngineInternalHeader.h"

Functions

UINT64 GetPseudoRegValue (PSYMBOL Symbol, PACTION_BUFFER ActionBuffer)
 Get the Pseudo reg value.
UINT64 GetValue (PGUEST_REGS GuestRegs, PACTION_BUFFER ActionBuffer, PSCRIPT_ENGINE_GENERAL_REGISTERS ScriptGeneralRegisters, PSYMBOL Symbol, BOOLEAN ReturnReference)
 Get the Value (reg, peseudo-reg, etc.).
VOID SetValue (PGUEST_REGS GuestRegs, SCRIPT_ENGINE_GENERAL_REGISTERS *ScriptGeneralRegisters, PSYMBOL Symbol, UINT64 Value)
 Set the value.
VOID ScriptEngineGetOperatorName (PSYMBOL OperatorSymbol, CHAR *BufferForName)
 Get the operator name.
BOOL ScriptEngineExecute (PGUEST_REGS GuestRegs, ACTION_BUFFER *ActionDetail, PSCRIPT_ENGINE_GENERAL_REGISTERS ScriptGeneralRegisters, SYMBOL_BUFFER *CodeBuffer, UINT64 *Indx, SYMBOL *ErrorOperator)
 Execute the script buffer.

Detailed Description

Shared Headers for Script engine.

Author
M.H. Gholamrezaei (mh@hy.nosp@m.perd.nosp@m.bg.or.nosp@m.g)
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.1
Date
2020-10-22

Function Documentation

◆ GetPseudoRegValue()

UINT64 GetPseudoRegValue ( PSYMBOL Symbol,
PACTION_BUFFER ActionBuffer )

Get the Pseudo reg value.

Parameters
Symbol
ActionBuffer
Returns
UINT64
25{
26 switch (Symbol->Value)
27 {
33 return (UINT64)ScriptEnginePseudoRegGetPname();
47 if (ActionBuffer->CurrentAction != (UINT64)NULL)
48 {
50 (UINT64 *)ActionBuffer->CurrentAction);
51 }
52 else
53 {
54 return (UINT64)NULL;
55 }
57 return ActionBuffer->Context;
59 return ScriptEnginePseudoRegGetEventTag(ActionBuffer);
61 return ScriptEnginePseudoRegGetEventId(ActionBuffer);
63 return ScriptEnginePseudoRegGetEventStage(ActionBuffer);
68 case INVALID:
69#ifdef SCRIPT_ENGINE_USER_MODE
70 ShowMessages("error in reading regesiter");
71#endif // SCRIPT_ENGINE_USER_MODE
72 return INVALID;
73 default:
74#ifdef SCRIPT_ENGINE_USER_MODE
75 ShowMessages("unknown pseudo-register");
76#endif // SCRIPT_ENGINE_USER_MODE
77 return INVALID;
78 }
79}
UINT64 ScriptEnginePseudoRegGetProc()
Implementation of $proc pseudo-register.
Definition PseudoRegisters.c:93
CHAR * ScriptEnginePseudoRegGetPname()
Implementation of $pname pseudo-register.
Definition PseudoRegisters.c:76
UINT64 ScriptEnginePseudoRegGetThread()
Implementation of $thread pseudo-register.
Definition PseudoRegisters.c:110
UINT64 ScriptEnginePseudoRegGetCore()
Implementation of $core pseudo-register.
Definition PseudoRegisters.c:42
UINT64 ScriptEnginePseudoRegGetDate()
Implementation of date pseudo-register.
Definition PseudoRegisters.c:407
UINT64 ScriptEnginePseudoRegGetTime()
Implementation of time pseudo-register.
Definition PseudoRegisters.c:386
UINT64 ScriptEnginePseudoRegGetEventStage(PACTION_BUFFER ActionBuffer)
Implementation of stage pseudo-register.
Definition PseudoRegisters.c:369
UINT64 ScriptEnginePseudoRegGetIp()
Implementation of $ip pseudo-register.
Definition PseudoRegisters.c:291
UINT64 ScriptEnginePseudoRegGetPeb()
Implementation of $peb pseudo-register.
Definition PseudoRegisters.c:127
UINT64 ScriptEnginePseudoRegGetBuffer(UINT64 *CorrespondingAction)
Implementation of $buffer pseudo-register.
Definition PseudoRegisters.c:312
UINT64 ScriptEnginePseudoRegGetTeb()
Implementation of $teb pseudo-register.
Definition PseudoRegisters.c:274
UINT64 ScriptEnginePseudoRegGetTid()
Implementation of $tid pseudo-register.
Definition PseudoRegisters.c:25
UINT64 ScriptEnginePseudoRegGetPid()
Implementation of $pid pseudo-register.
Definition PseudoRegisters.c:59
UINT64 ScriptEnginePseudoRegGetEventTag(PACTION_BUFFER ActionBuffer)
Implementation of $tag pseudo-register.
Definition PseudoRegisters.c:333
UINT64 ScriptEnginePseudoRegGetEventId(PACTION_BUFFER ActionBuffer)
Implementation of $id pseudo-register.
Definition PseudoRegisters.c:351
#define PSEUDO_REGISTER_IP
Definition ScriptEngineCommonDefinitions.h:465
#define PSEUDO_REGISTER_CONTEXT
Definition ScriptEngineCommonDefinitions.h:467
#define PSEUDO_REGISTER_DATE
Definition ScriptEngineCommonDefinitions.h:471
#define PSEUDO_REGISTER_THREAD
Definition ScriptEngineCommonDefinitions.h:462
#define PSEUDO_REGISTER_PROC
Definition ScriptEngineCommonDefinitions.h:461
#define PSEUDO_REGISTER_PNAME
Definition ScriptEngineCommonDefinitions.h:459
#define PSEUDO_REGISTER_CORE
Definition ScriptEngineCommonDefinitions.h:460
#define PSEUDO_REGISTER_EVENT_TAG
Definition ScriptEngineCommonDefinitions.h:468
#define PSEUDO_REGISTER_PEB
Definition ScriptEngineCommonDefinitions.h:463
#define PSEUDO_REGISTER_TEB
Definition ScriptEngineCommonDefinitions.h:464
#define PSEUDO_REGISTER_EVENT_ID
Definition ScriptEngineCommonDefinitions.h:469
#define PSEUDO_REGISTER_BUFFER
Definition ScriptEngineCommonDefinitions.h:466
#define PSEUDO_REGISTER_PID
Definition ScriptEngineCommonDefinitions.h:457
#define INVALID
Definition ScriptEngineCommonDefinitions.h:92
#define PSEUDO_REGISTER_EVENT_STAGE
Definition ScriptEngineCommonDefinitions.h:470
#define PSEUDO_REGISTER_TID
Definition ScriptEngineCommonDefinitions.h:458
#define PSEUDO_REGISTER_TIME
Definition ScriptEngineCommonDefinitions.h:472
NULL()
Definition test-case-generator.py:530
long long unsigned Context
Definition ScriptEngineCommonDefinitions.h:39
long long unsigned CurrentAction
Definition ScriptEngineCommonDefinitions.h:37
long long unsigned Value
Definition ScriptEngineCommonDefinitions.h:9

◆ GetValue()

UINT64 GetValue ( PGUEST_REGS GuestRegs,
PACTION_BUFFER ActionBuffer,
PSCRIPT_ENGINE_GENERAL_REGISTERS ScriptGeneralRegisters,
PSYMBOL Symbol,
BOOLEAN ReturnReference )

Get the Value (reg, peseudo-reg, etc.).

Parameters
GuestRegs
ActionBuffer
ScriptGeneralRegisters
Symbol
ReturnReference
Returns
UINT64
97{
98 switch (Symbol->Type)
99 {
101
102 if (ReturnReference)
103 return ((UINT64)(&ScriptGeneralRegisters->GlobalVariablesList[Symbol->Value]));
104 else
105 return ScriptGeneralRegisters->GlobalVariablesList[Symbol->Value];
106
107 case SYMBOL_NUM_TYPE:
108
109 if (ReturnReference)
110 return ((UINT64)&Symbol->Value);
111 else
112 return Symbol->Value;
113
115
116 if (ReturnReference)
117 return (UINT64)NULL; // Not reasonable, you should not dereference a register!
118 else
119 return GetRegValue(GuestRegs, (REGS_ENUM)Symbol->Value);
120
122
123 if (ReturnReference)
124 return (UINT64)NULL; // Not reasonable, you should not dereference a pseudo-register!
125 else
126 return GetPseudoRegValue(Symbol, ActionBuffer);
127
129 if (ReturnReference)
130 return (UINT64)&ScriptGeneralRegisters->StackIndx;
131 else
132 return ScriptGeneralRegisters->StackIndx;
133
135 if (ReturnReference)
136 return (UINT64)&ScriptGeneralRegisters->StackBaseIndx;
137 else
138 return ScriptGeneralRegisters->StackBaseIndx;
139
141 if (ReturnReference)
142 return (UINT64)&ScriptGeneralRegisters->ReturnValue;
143 else
144 return ScriptGeneralRegisters->ReturnValue;
145
146 case SYMBOL_TEMP_TYPE:
147
148 if (ReturnReference)
149 return (UINT64)&ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx + Symbol->Value];
150 else
151 return ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx + Symbol->Value];
152
154
155 return (UINT64)&ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx + Symbol->Value];
156
158
159 return *(UINT64 *)ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx + Symbol->Value];
160
162
163 if (ReturnReference)
164 return (UINT64)&ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx - 3 - Symbol->Value];
165 else
166 return ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx - 3 - Symbol->Value];
167 }
168
169 //
170 // Shouldn't reach here
171 //
172 return NULL64_ZERO;
173}
UINT64 GetRegValue(PGUEST_REGS GuestRegs, REGS_ENUM RegId)
Get the register value.
Definition Regs.c:40
UINT64 GetPseudoRegValue(PSYMBOL Symbol, PACTION_BUFFER ActionBuffer)
Get the Pseudo reg value.
Definition ScriptEngineEval.c:24
#define NULL64_ZERO
Definition BasicTypes.h:111
#define SYMBOL_STACK_INDEX_TYPE
Definition ScriptEngineCommonDefinitions.h:58
#define SYMBOL_REGISTER_TYPE
Definition ScriptEngineCommonDefinitions.h:47
REGS_ENUM
Definition ScriptEngineCommonDefinitions.h:315
#define SYMBOL_TEMP_TYPE
Definition ScriptEngineCommonDefinitions.h:50
#define SYMBOL_GLOBAL_ID_TYPE
Definition ScriptEngineCommonDefinitions.h:44
#define SYMBOL_FUNCTION_PARAMETER_ID_TYPE
Definition ScriptEngineCommonDefinitions.h:55
#define SYMBOL_REFERENCE_TEMP_TYPE
Definition ScriptEngineCommonDefinitions.h:62
#define SYMBOL_STACK_BASE_INDEX_TYPE
Definition ScriptEngineCommonDefinitions.h:59
#define SYMBOL_DEREFERENCE_TEMP_TYPE
Definition ScriptEngineCommonDefinitions.h:64
#define SYMBOL_PSEUDO_REG_TYPE
Definition ScriptEngineCommonDefinitions.h:48
#define SYMBOL_RETURN_VALUE_TYPE
Definition ScriptEngineCommonDefinitions.h:60
#define SYMBOL_NUM_TYPE
Definition ScriptEngineCommonDefinitions.h:46
UINT64 * GlobalVariablesList
Definition BasicTypes.h:225
UINT64 StackIndx
Definition BasicTypes.h:226
UINT64 * StackBuffer
Definition BasicTypes.h:224
UINT64 StackBaseIndx
Definition BasicTypes.h:227
UINT64 ReturnValue
Definition BasicTypes.h:228
long long unsigned Type
Definition ScriptEngineCommonDefinitions.h:7

◆ ScriptEngineExecute()

BOOL ScriptEngineExecute ( PGUEST_REGS GuestRegs,
ACTION_BUFFER * ActionDetail,
PSCRIPT_ENGINE_GENERAL_REGISTERS ScriptGeneralRegisters,
SYMBOL_BUFFER * CodeBuffer,
UINT64 * Indx,
SYMBOL * ErrorOperator )

Execute the script buffer.

Parameters
GuestRegsGeneral purpose registers
ActionDetailDetail of the specific action
ScriptGeneralRegistersof core specific (and global) variable holders
CodeBufferThe script buffer to be executed
IndxScript Buffer index
ErrorOperatorError in operator
Returns
BOOL
303{
304 PSYMBOL Operator;
305 PSYMBOL Src0;
306 PSYMBOL Src1;
307 PSYMBOL Src2;
308
309 PSYMBOL Des;
310 UINT64 SrcVal0;
311 UINT64 SrcVal1;
312 UINT64 SrcVal2;
313
314 UINT64 DesVal;
315 BOOL HasError = FALSE;
316
317 Operator = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
318 (unsigned long long)(*Indx * sizeof(SYMBOL)));
319
320 *ErrorOperator = *Operator;
321
322 *Indx = *Indx + 1;
323
324 if (Operator->Type != SYMBOL_SEMANTIC_RULE_TYPE)
325 {
326#ifdef SCRIPT_ENGINE_USER_MODE
327 ShowMessages("err, expecting operator type\n");
328 return HasError;
329#endif // SCRIPT_ENGINE_USER_MODE
330 };
331
332 switch (Operator->Value)
333 {
334 case FUNC_ED:
335
336 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
337 (unsigned long long)(*Indx * sizeof(SYMBOL)));
338
339 *Indx = *Indx + 1;
340
341 SrcVal0 =
342 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
343
344 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
345 (unsigned long long)(*Indx * sizeof(SYMBOL)));
346
347 *Indx = *Indx + 1;
348
349 SrcVal1 =
350 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
351
352 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
353 (unsigned long long)(*Indx * sizeof(SYMBOL)));
354
355 *Indx = *Indx + 1;
356
357 DesVal = ScriptEngineFunctionEd(SrcVal1, (DWORD)SrcVal0, &HasError);
358
359 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
360
361 break;
362
363 case FUNC_EB:
364
365 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
366 (unsigned long long)(*Indx * sizeof(SYMBOL)));
367
368 *Indx = *Indx + 1;
369
370 SrcVal0 =
371 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
372
373 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
374 (unsigned long long)(*Indx * sizeof(SYMBOL)));
375
376 *Indx = *Indx + 1;
377
378 SrcVal1 =
379 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
380
381 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
382 (unsigned long long)(*Indx * sizeof(SYMBOL)));
383
384 *Indx = *Indx + 1;
385
386 DesVal = ScriptEngineFunctionEb(SrcVal1, (BYTE)SrcVal0, &HasError);
387
388 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
389
390 break;
391
392 case FUNC_EQ:
393
394 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
395 (unsigned long long)(*Indx * sizeof(SYMBOL)));
396 *Indx = *Indx + 1;
397
398 SrcVal0 =
399 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
400
401 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
402 (unsigned long long)(*Indx * sizeof(SYMBOL)));
403
404 *Indx = *Indx + 1;
405
406 SrcVal1 =
407 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
408
409 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
410 (unsigned long long)(*Indx * sizeof(SYMBOL)));
411
412 *Indx = *Indx + 1;
413
414 DesVal = ScriptEngineFunctionEq(SrcVal1, SrcVal0, &HasError);
415
416 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
417
418 break;
419
420 case FUNC_ED_PA:
421
422 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
423 (unsigned long long)(*Indx * sizeof(SYMBOL)));
424
425 *Indx = *Indx + 1;
426
427 SrcVal0 =
428 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
429
430 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
431 (unsigned long long)(*Indx * sizeof(SYMBOL)));
432
433 *Indx = *Indx + 1;
434
435 SrcVal1 =
436 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
437
438 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
439 (unsigned long long)(*Indx * sizeof(SYMBOL)));
440
441 *Indx = *Indx + 1;
442
443 DesVal = ScriptEngineFunctionEdPa(SrcVal1, (DWORD)SrcVal0, &HasError);
444
445 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
446
447 break;
448
449 case FUNC_EB_PA:
450
451 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
452 (unsigned long long)(*Indx * sizeof(SYMBOL)));
453
454 *Indx = *Indx + 1;
455
456 SrcVal0 =
457 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
458
459 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
460 (unsigned long long)(*Indx * sizeof(SYMBOL)));
461
462 *Indx = *Indx + 1;
463
464 SrcVal1 =
465 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
466
467 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
468 (unsigned long long)(*Indx * sizeof(SYMBOL)));
469
470 *Indx = *Indx + 1;
471
472 DesVal = ScriptEngineFunctionEbPa(SrcVal1, (BYTE)SrcVal0, &HasError);
473
474 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
475
476 break;
477
478 case FUNC_EQ_PA:
479
480 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
481 (unsigned long long)(*Indx * sizeof(SYMBOL)));
482 *Indx = *Indx + 1;
483
484 SrcVal0 =
485 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
486
487 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
488 (unsigned long long)(*Indx * sizeof(SYMBOL)));
489
490 *Indx = *Indx + 1;
491
492 SrcVal1 =
493 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
494
495 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
496 (unsigned long long)(*Indx * sizeof(SYMBOL)));
497
498 *Indx = *Indx + 1;
499
500 DesVal = ScriptEngineFunctionEqPa(SrcVal1, SrcVal0, &HasError);
501
502 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
503
504 break;
505
507
508 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
509 (unsigned long long)(*Indx * sizeof(SYMBOL)));
510
511 *Indx = *Indx + 1;
512
513 SrcVal0 =
514 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
515
516 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
517 (unsigned long long)(*Indx * sizeof(SYMBOL)));
518
519 *Indx = *Indx + 1;
520
521 SrcVal1 =
522 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
523
524 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
525 (unsigned long long)(*Indx * sizeof(SYMBOL)));
526 *Indx = *Indx + 1;
527
528 DesVal = ScriptEngineFunctionInterlockedExchange((volatile long long *)SrcVal1, SrcVal0, &HasError);
529
530 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
531
532 break;
533
535
536 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
537 (unsigned long long)(*Indx * sizeof(SYMBOL)));
538
539 *Indx = *Indx + 1;
540
541 SrcVal0 =
542 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
543
544 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
545 (unsigned long long)(*Indx * sizeof(SYMBOL)));
546
547 *Indx = *Indx + 1;
548
549 SrcVal1 =
550 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
551
552 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
553 (unsigned long long)(*Indx * sizeof(SYMBOL)));
554
555 *Indx = *Indx + 1;
556
557 DesVal = ScriptEngineFunctionInterlockedExchangeAdd((volatile long long *)SrcVal1, SrcVal0, &HasError);
558
559 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
560
561 break;
562
564
565 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
566 (unsigned long long)(*Indx * sizeof(SYMBOL)));
567
568 *Indx = *Indx + 1;
569
570 SrcVal0 =
571 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
572
573 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
574 (unsigned long long)(*Indx * sizeof(SYMBOL)));
575 *Indx = *Indx + 1;
576
577 SrcVal1 =
578 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
579
580 Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
581 (unsigned long long)(*Indx * sizeof(SYMBOL)));
582
583 *Indx = *Indx + 1;
584
585 SrcVal2 =
586 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
587
588 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
589 (unsigned long long)(*Indx * sizeof(SYMBOL)));
590 *Indx = *Indx + 1;
591
592 DesVal = ScriptEngineFunctionInterlockedCompareExchange((volatile long long *)SrcVal2, SrcVal1, SrcVal0, &HasError);
593
594 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
595
596 break;
597
599
600 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
601 (unsigned long long)(*Indx * sizeof(SYMBOL)));
602
603 *Indx = *Indx + 1;
604
605 SrcVal0 =
606 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
607
608 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
609 (unsigned long long)(*Indx * sizeof(SYMBOL)));
610 *Indx = *Indx + 1;
611
612 SrcVal1 =
613 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
614
615 Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
616 (unsigned long long)(*Indx * sizeof(SYMBOL)));
617
618 *Indx = *Indx + 1;
619
620 SrcVal2 =
621 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
622
623 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
624 (unsigned long long)(*Indx * sizeof(SYMBOL)));
625 *Indx = *Indx + 1;
626
627 ScriptEngineFunctionEventInjectErrorCode((UINT32)SrcVal2, (UINT32)SrcVal1, (UINT32)SrcVal0, &HasError);
628
629 break;
630
631 case FUNC_MEMCPY:
632
633 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
634 (unsigned long long)(*Indx * sizeof(SYMBOL)));
635
636 *Indx = *Indx + 1;
637
638 SrcVal0 =
639 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
640
641 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
642 (unsigned long long)(*Indx * sizeof(SYMBOL)));
643 *Indx = *Indx + 1;
644
645 SrcVal1 =
646 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
647
648 Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
649 (unsigned long long)(*Indx * sizeof(SYMBOL)));
650
651 *Indx = *Indx + 1;
652
653 SrcVal2 =
654 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
655
656 ScriptEngineFunctionMemcpy(SrcVal2, SrcVal1, (UINT32)SrcVal0, &HasError);
657
658 break;
659
660 case FUNC_MEMCPY_PA:
661
662 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
663 (unsigned long long)(*Indx * sizeof(SYMBOL)));
664
665 *Indx = *Indx + 1;
666
667 SrcVal0 =
668 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
669
670 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
671 (unsigned long long)(*Indx * sizeof(SYMBOL)));
672 *Indx = *Indx + 1;
673
674 SrcVal1 =
675 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
676
677 Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
678 (unsigned long long)(*Indx * sizeof(SYMBOL)));
679
680 *Indx = *Indx + 1;
681
682 SrcVal2 =
683 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
684
685 ScriptEngineFunctionMemcpyPa(SrcVal2, SrcVal1, (UINT32)SrcVal0, &HasError);
686
687 break;
688
690
691 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
692 (unsigned long long)(*Indx * sizeof(SYMBOL)));
693
694 *Indx = *Indx + 1;
695
696 SrcVal0 =
697 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
698
699 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
700 (unsigned long long)(*Indx * sizeof(SYMBOL)));
701
702 *Indx = *Indx + 1;
703
704 SrcVal1 =
705 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
706
707 ScriptEngineFunctionSpinlockLockCustomWait((volatile long *)SrcVal1, (UINT32)SrcVal0, &HasError);
708
709 break;
710
712
713 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
714 (unsigned long long)(*Indx * sizeof(SYMBOL)));
715
716 *Indx = *Indx + 1;
717
718 SrcVal0 =
719 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
720
721 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
722 (unsigned long long)(*Indx * sizeof(SYMBOL)));
723
724 *Indx = *Indx + 1;
725
726 SrcVal1 =
727 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
728
729 ScriptEngineFunctionEventInject((UINT32)SrcVal1, (UINT32)SrcVal0, &HasError);
730
731 break;
732
733 case FUNC_PAUSE:
734
735 ScriptEngineFunctionPause(ActionDetail,
736 GuestRegs);
737
738 break;
739
740 case FUNC_LBR_CHECK:
741
742 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
743 (unsigned long long)(*Indx * sizeof(SYMBOL)));
744 *Indx = *Indx + 1;
745
747
748 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
749
750 break;
751
752 case FUNC_LBR_SAVE:
753
754 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
755 (unsigned long long)(*Indx * sizeof(SYMBOL)));
756 *Indx = *Indx + 1;
757
759
760 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
761
762 break;
763
764 case FUNC_LBR_PRINT:
765 case FUNC_LBR_DUMP:
766
767 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
768 (unsigned long long)(*Indx * sizeof(SYMBOL)));
769 *Indx = *Indx + 1;
770
772
773 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
774
775 break;
776
777 case FUNC_LBR_RESTORE:
778
779 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
780 (unsigned long long)(*Indx * sizeof(SYMBOL)));
781 *Indx = *Indx + 1;
782
784
785 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
786
787 break;
788
790
791 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
792 (unsigned long long)(*Indx * sizeof(SYMBOL)));
793 *Indx = *Indx + 1;
794
795 SrcVal0 =
796 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
797
798 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
799 (unsigned long long)(*Indx * sizeof(SYMBOL)));
800 *Indx = *Indx + 1;
801
802 DesVal = ScriptEngineFunctionLbrRestoreByFilter((unsigned long long)SrcVal0);
803
804 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
805
806 break;
807
808 case FUNC_FLUSH:
809
811
812 break;
813
816
818
819 break;
820
823
825
826 break;
827
829
830 //
831 // To be implemented!
832 //
833
834 break;
835
836 case FUNC_EVENT_SC:
837
838 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
839 (unsigned long long)(*Indx * sizeof(SYMBOL)));
840 *Indx = *Indx + 1;
841
842 SrcVal0 =
843 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
844
845 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
846 (unsigned long long)(*Indx * sizeof(SYMBOL)));
847 *Indx = *Indx + 1;
848
849 ScriptEngineFunctionShortCircuitingEvent(SrcVal0, ActionDetail);
850
851 break;
852
853 case FUNC_OR:
854
855 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
856 (unsigned long long)(*Indx * sizeof(SYMBOL)));
857
858 *Indx = *Indx + 1;
859
860 SrcVal0 =
861 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
862
863 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
864 (unsigned long long)(*Indx * sizeof(SYMBOL)));
865
866 *Indx = *Indx + 1;
867
868 SrcVal1 =
869 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
870
871 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
872 (unsigned long long)(*Indx * sizeof(SYMBOL)));
873
874 *Indx = *Indx + 1;
875
876 DesVal = SrcVal1 | SrcVal0;
877
878 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
879
880 break;
881
882 case FUNC_INC:
883
884 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
885 (unsigned long long)(*Indx * sizeof(SYMBOL)));
886 *Indx = *Indx + 1;
887
888 SrcVal0 =
889 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
890
891 DesVal = SrcVal0 + 1;
892
893 Des = Src0;
894
895 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
896
897 break;
898
899 case FUNC_DEC:
900
901 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
902 (unsigned long long)(*Indx * sizeof(SYMBOL)));
903 *Indx = *Indx + 1;
904
905 SrcVal0 =
906 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
907
908 DesVal = SrcVal0 - 1;
909
910 Des = Src0;
911
912 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
913
914 break;
915
916 case FUNC_XOR:
917
918 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
919 (unsigned long long)(*Indx * sizeof(SYMBOL)));
920 *Indx = *Indx + 1;
921
922 SrcVal0 =
923 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
924
925 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
926 (unsigned long long)(*Indx * sizeof(SYMBOL)));
927
928 *Indx = *Indx + 1;
929
930 SrcVal1 =
931 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
932
933 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
934 (unsigned long long)(*Indx * sizeof(SYMBOL)));
935 *Indx = *Indx + 1;
936
937 DesVal = SrcVal1 ^ SrcVal0;
938
939 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
940
941 break;
942
943 case FUNC_AND:
944
945 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
946 (unsigned long long)(*Indx * sizeof(SYMBOL)));
947 *Indx = *Indx + 1;
948
949 SrcVal0 =
950 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
951
952 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
953 (unsigned long long)(*Indx * sizeof(SYMBOL)));
954 *Indx = *Indx + 1;
955
956 SrcVal1 =
957 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
958
959 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
960 (unsigned long long)(*Indx * sizeof(SYMBOL)));
961 *Indx = *Indx + 1;
962
963 DesVal = SrcVal1 & SrcVal0;
964
965 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
966
967 break;
968
969 case FUNC_ASR:
970
971 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
972 (unsigned long long)(*Indx * sizeof(SYMBOL)));
973 *Indx = *Indx + 1;
974
975 SrcVal0 =
976 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
977
978 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
979 (unsigned long long)(*Indx * sizeof(SYMBOL)));
980 *Indx = *Indx + 1;
981
982 SrcVal1 =
983 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
984
985 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
986 (unsigned long long)(*Indx * sizeof(SYMBOL)));
987 *Indx = *Indx + 1;
988
989 DesVal = SrcVal1 >> SrcVal0;
990
991 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
992
993 break;
994
995 case FUNC_ASL:
996
997 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
998 (unsigned long long)(*Indx * sizeof(SYMBOL)));
999 *Indx = *Indx + 1;
1000
1001 SrcVal0 =
1002 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1003
1004 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1005 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1006
1007 *Indx = *Indx + 1;
1008
1009 SrcVal1 =
1010 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
1011
1012 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1013 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1014
1015 *Indx = *Indx + 1;
1016
1017 DesVal = SrcVal1 << SrcVal0;
1018
1019 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1020
1021 break;
1022
1023 case FUNC_ADD:
1024
1025 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1026 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1027 *Indx = *Indx + 1;
1028
1029 SrcVal0 =
1030 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1031
1032 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1033 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1034 *Indx = *Indx + 1;
1035
1036 SrcVal1 =
1037 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
1038
1039 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1040 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1041 *Indx = *Indx + 1;
1042
1043 DesVal = SrcVal1 + SrcVal0;
1044
1045 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1046
1047 break;
1048
1049 case FUNC_SUB:
1050
1051 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1052 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1053
1054 *Indx = *Indx + 1;
1055
1056 SrcVal0 =
1057 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1058
1059 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1060 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1061
1062 *Indx = *Indx + 1;
1063
1064 SrcVal1 =
1065 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
1066
1067 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1068 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1069 *Indx = *Indx + 1;
1070
1071 DesVal = SrcVal1 - SrcVal0;
1072
1073 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1074
1075 break;
1076
1077 case FUNC_MUL:
1078
1079 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1080 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1081 *Indx = *Indx + 1;
1082
1083 SrcVal0 =
1084 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1085
1086 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1087 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1088 *Indx = *Indx + 1;
1089
1090 SrcVal1 =
1091 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
1092
1093 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1094 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1095 *Indx = *Indx + 1;
1096
1097 DesVal = SrcVal1 * SrcVal0;
1098
1099 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1100
1101 break;
1102
1103 case FUNC_DIV:
1104
1105 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1106 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1107 *Indx = *Indx + 1;
1108
1109 SrcVal0 =
1110 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1111
1112 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1113 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1114 *Indx = *Indx + 1;
1115
1116 SrcVal1 =
1117 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
1118
1119 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1120 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1121
1122 *Indx = *Indx + 1;
1123
1124 if (SrcVal0 == 0)
1125 {
1126 HasError = TRUE;
1127 break;
1128 }
1129
1130 DesVal = SrcVal1 / SrcVal0;
1131
1132 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1133
1134 break;
1135
1136 case FUNC_MOD:
1137
1138 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1139 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1140 *Indx = *Indx + 1;
1141
1142 SrcVal0 =
1143 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1144
1145 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1146 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1147 *Indx = *Indx + 1;
1148
1149 SrcVal1 =
1150 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
1151
1152 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1153 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1154 *Indx = *Indx + 1;
1155
1156 if (SrcVal0 == 0)
1157 {
1158 HasError = TRUE;
1159 break;
1160 }
1161
1162 DesVal = SrcVal1 % SrcVal0;
1163
1164 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1165
1166 break;
1167
1168 case FUNC_GT:
1169
1170 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1171 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1172 *Indx = *Indx + 1;
1173
1174 SrcVal0 =
1175 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1176
1177 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1178 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1179 *Indx = *Indx + 1;
1180
1181 SrcVal1 =
1182 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
1183
1184 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1185 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1186 *Indx = *Indx + 1;
1187
1188 DesVal = (INT64)SrcVal1 > (INT64)SrcVal0;
1189
1190 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1191
1192 break;
1193
1194 case FUNC_LT:
1195
1196 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1197 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1198 *Indx = *Indx + 1;
1199
1200 SrcVal0 =
1201 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1202
1203 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1204 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1205 *Indx = *Indx + 1;
1206
1207 SrcVal1 =
1208 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
1209
1210 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1211 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1212 *Indx = *Indx + 1;
1213
1214 DesVal = (INT64)SrcVal1 < (INT64)SrcVal0;
1215
1216 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1217
1218 break;
1219
1220 case FUNC_EGT:
1221
1222 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1223 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1224 *Indx = *Indx + 1;
1225
1226 SrcVal0 =
1227 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1228
1229 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1230 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1231 *Indx = *Indx + 1;
1232
1233 SrcVal1 =
1234 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
1235
1236 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1237 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1238 *Indx = *Indx + 1;
1239
1240 DesVal = (INT64)SrcVal1 >= (INT64)SrcVal0;
1241
1242 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1243
1244 break;
1245
1246 case FUNC_ELT:
1247
1248 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1249 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1250 *Indx = *Indx + 1;
1251
1252 SrcVal0 =
1253 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1254
1255 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1256 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1257 *Indx = *Indx + 1;
1258
1259 SrcVal1 =
1260 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
1261
1262 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1263 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1264
1265 *Indx = *Indx + 1;
1266
1267 DesVal = (INT64)SrcVal1 <= (INT64)SrcVal0;
1268
1269 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1270
1271 break;
1272
1273 case FUNC_EQUAL:
1274
1275 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1276 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1277 *Indx = *Indx + 1;
1278
1279 SrcVal0 =
1280 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1281
1282 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1283 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1284
1285 *Indx = *Indx + 1;
1286
1287 SrcVal1 =
1288 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
1289
1290 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1291 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1292 *Indx = *Indx + 1;
1293
1294 DesVal = SrcVal1 == SrcVal0;
1295
1296 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1297
1298 break;
1299
1300 case FUNC_NEQ:
1301
1302 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1303 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1304
1305 *Indx = *Indx + 1;
1306
1307 SrcVal0 =
1308 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1309
1310 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1311 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1312
1313 *Indx = *Indx + 1;
1314
1315 SrcVal1 =
1316 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
1317
1318 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1319 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1320 *Indx = *Indx + 1;
1321
1322 DesVal = SrcVal1 != SrcVal0;
1323
1324 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1325
1326 break;
1327
1328 case FUNC_POI:
1329
1330 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1331 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1332 *Indx = *Indx + 1;
1333
1334 SrcVal0 =
1335 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1336
1337 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1338 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1339
1340 *Indx = *Indx + 1;
1341
1342 DesVal = ScriptEngineKeywordPoi((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
1343 &HasError);
1344 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1345
1346 break;
1347
1348 case FUNC_DB:
1349
1350 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1351 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1352 *Indx = *Indx + 1;
1353
1354 SrcVal0 =
1355 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1356
1357 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1358 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1359 *Indx = *Indx + 1;
1360
1361 DesVal = ScriptEngineKeywordDb((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
1362 &HasError);
1363 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1364
1365 break;
1366
1367 case FUNC_DD:
1368
1369 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1370 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1371 *Indx = *Indx + 1;
1372
1373 SrcVal0 =
1374 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1375
1376 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1377 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1378 *Indx = *Indx + 1;
1379
1380 DesVal = ScriptEngineKeywordDd((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
1381 &HasError);
1382
1383 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1384
1385 break;
1386
1387 case FUNC_DW:
1388
1389 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1390 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1391
1392 *Indx = *Indx + 1;
1393
1394 SrcVal0 =
1395 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1396
1397 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1398 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1399
1400 *Indx = *Indx + 1;
1401
1402 DesVal = ScriptEngineKeywordDw((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
1403 &HasError);
1404 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1405
1406 break;
1407
1408 case FUNC_DQ:
1409
1410 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1411 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1412 *Indx = *Indx + 1;
1413
1414 SrcVal0 =
1415 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1416
1417 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1418 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1419
1420 *Indx = *Indx + 1;
1421
1422 DesVal = ScriptEngineKeywordDq((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
1423 &HasError);
1424 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1425
1426 break;
1427
1428 case FUNC_POI_PA:
1429
1430 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1431 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1432 *Indx = *Indx + 1;
1433
1434 SrcVal0 =
1435 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1436
1437 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1438 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1439
1440 *Indx = *Indx + 1;
1441
1442 DesVal = ScriptEngineKeywordPoiPa((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
1443 &HasError);
1444 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1445
1446 break;
1447
1448 case FUNC_DB_PA:
1449
1450 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1451 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1452 *Indx = *Indx + 1;
1453
1454 SrcVal0 =
1455 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1456
1457 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1458 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1459 *Indx = *Indx + 1;
1460
1461 DesVal = ScriptEngineKeywordDbPa((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
1462 &HasError);
1463 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1464
1465 break;
1466
1467 case FUNC_DD_PA:
1468
1469 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1470 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1471 *Indx = *Indx + 1;
1472
1473 SrcVal0 =
1474 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1475
1476 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1477 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1478 *Indx = *Indx + 1;
1479
1480 DesVal = ScriptEngineKeywordDdPa((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
1481 &HasError);
1482
1483 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1484
1485 break;
1486
1487 case FUNC_DW_PA:
1488
1489 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1490 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1491
1492 *Indx = *Indx + 1;
1493
1494 SrcVal0 =
1495 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1496
1497 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1498 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1499
1500 *Indx = *Indx + 1;
1501
1502 DesVal = ScriptEngineKeywordDwPa((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
1503 &HasError);
1504 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1505
1506 break;
1507
1508 case FUNC_DQ_PA:
1509
1510 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1511 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1512 *Indx = *Indx + 1;
1513
1514 SrcVal0 =
1515 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1516
1517 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1518 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1519
1520 *Indx = *Indx + 1;
1521
1522 DesVal = ScriptEngineKeywordDqPa((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
1523 &HasError);
1524 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1525
1526 break;
1527
1528 case FUNC_NOT:
1529
1530 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1531 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1532 *Indx = *Indx + 1;
1533
1534 SrcVal0 =
1535 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1536
1537 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1538 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1539
1540 *Indx = *Indx + 1;
1541
1542 DesVal = ~SrcVal0;
1543
1544 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1545
1546 break;
1547
1548 case FUNC_REFERENCE:
1549
1550 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1551 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1552
1553 *Indx = *Indx + 1;
1554
1555 //
1556 // It's reference, we need an address
1557 //
1558 SrcVal0 = GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, TRUE);
1559
1560 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1561 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1562 *Indx = *Indx + 1;
1563
1564 DesVal = SrcVal0;
1565
1566 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1567
1568 break;
1569
1571
1572 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1573 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1574 *Indx = *Indx + 1;
1575
1576 SrcVal0 =
1577 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1578
1579 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1580 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1581 *Indx = *Indx + 1;
1582
1583 DesVal = ScriptEngineFunctionPhysicalToVirtual(GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE));
1584
1585 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1586
1587 break;
1588
1590
1591 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1592 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1593 *Indx = *Indx + 1;
1594
1595 SrcVal0 =
1596 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1597
1598 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1599 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1600 *Indx = *Indx + 1;
1601
1602 DesVal = ScriptEngineFunctionVirtualToPhysical(GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE));
1603
1604 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1605
1606 break;
1607
1608 case FUNC_CHECK_ADDRESS:
1609
1610 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1611 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1612 *Indx = *Indx + 1;
1613
1614 SrcVal0 =
1615 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1616
1617 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1618 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1619 *Indx = *Indx + 1;
1620
1621 if (ScriptEngineFunctionCheckAddress(SrcVal0, sizeof(BYTE)))
1622 DesVal = 1; // TRUE
1623 else
1624 DesVal = 0; // FALSE
1625
1626 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1627
1628 break;
1629
1630 case FUNC_STRLEN:
1631
1632 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1633 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1634 *Indx = *Indx + 1;
1635
1636 if (Src0->Type == SYMBOL_STRING_TYPE)
1637 {
1638 *Indx =
1639 *Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src0->Len) /
1640 sizeof(SYMBOL));
1641 SrcVal0 = (UINT64)&Src0->Value;
1642 }
1643 else
1644 {
1645 SrcVal0 =
1646 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1647 }
1648
1649 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1650 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1651 *Indx = *Indx + 1;
1652
1653 DesVal = ScriptEngineFunctionStrlen((const char *)SrcVal0);
1654
1655 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1656
1657 break;
1658
1661
1662 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1663 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1664 *Indx = *Indx + 1;
1665
1666 SrcVal0 =
1667 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1668
1669 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1670 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1671 *Indx = *Indx + 1;
1672
1674
1675 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1676
1677 break;
1678
1680
1681 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1682 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1683 *Indx = *Indx + 1;
1684
1685 SrcVal0 =
1686 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1687
1688 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1689 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1690 *Indx = *Indx + 1;
1691
1692 DesVal = ScriptEngineFunctionDisassembleLen((PVOID)SrcVal0, TRUE);
1693
1694 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1695
1696 break;
1697
1698 case FUNC_WCSLEN:
1699
1700 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1701 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1702 *Indx = *Indx + 1;
1703
1704 if (Src0->Type == SYMBOL_WSTRING_TYPE)
1705 {
1706 *Indx =
1707 *Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src0->Len) /
1708 sizeof(SYMBOL));
1709 SrcVal0 = (UINT64)&Src0->Value;
1710 }
1711 else
1712 {
1713 SrcVal0 =
1714 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1715 }
1716
1717 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1718 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1719 *Indx = *Indx + 1;
1720
1721 DesVal = ScriptEngineFunctionWcslen((const wchar_t *)SrcVal0);
1722
1723 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1724
1725 break;
1726
1727 case FUNC_MICROSLEEP:
1728 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1729 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1730 *Indx = *Indx + 1;
1731
1732 SrcVal0 =
1733 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1734
1736 break;
1737
1738 case FUNC_RDTSC:
1739
1740 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1741 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1742 *Indx = *Indx + 1;
1743
1744 DesVal = ScriptEngineFunctionRdtsc();
1745
1746 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1747
1748 break;
1749
1750 case FUNC_RDTSCP:
1751
1752 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1753 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1754 *Indx = *Indx + 1;
1755
1756 DesVal = ScriptEngineFunctionRdtscp();
1757
1758 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1759 break;
1760
1762
1763 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1764 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1765 *Indx = *Indx + 1;
1766
1767 SrcVal0 =
1768 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1769
1770 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1771 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1772
1773 *Indx = *Indx + 1;
1774
1775 DesVal = ScriptEngineFunctionInterlockedIncrement((volatile long long *)SrcVal0, &HasError);
1776
1777 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1778
1779 break;
1780
1782
1783 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1784 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1785 *Indx = *Indx + 1;
1786
1787 SrcVal0 =
1788 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1789
1790 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1791 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1792 *Indx = *Indx + 1;
1793
1794 DesVal = ScriptEngineFunctionInterlockedDecrement((volatile long long *)SrcVal0, &HasError);
1795
1796 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1797
1798 break;
1799
1800 case FUNC_NEG:
1801
1802 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1803 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1804
1805 *Indx = *Indx + 1;
1806
1807 SrcVal0 =
1808 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1809
1810 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1811 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1812 *Indx = *Indx + 1;
1813
1814 DesVal = -(INT64)SrcVal0;
1815
1816 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1817
1818 break;
1819
1820 case FUNC_HI:
1821
1822 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1823 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1824 *Indx = *Indx + 1;
1825
1826 SrcVal0 =
1827 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1828
1829 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1830 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1831 *Indx = *Indx + 1;
1832
1833 DesVal = ScriptEngineKeywordHi((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
1834 &HasError);
1835 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1836
1837 break;
1838
1839 case FUNC_LOW:
1840
1841 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1842 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1843
1844 *Indx = *Indx + 1;
1845
1846 SrcVal0 =
1847 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1848
1849 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1850 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1851
1852 *Indx = *Indx + 1;
1853
1854 DesVal = ScriptEngineKeywordLow((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
1855 &HasError);
1856 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1857
1858 break;
1859
1860 case FUNC_MOV:
1861
1862 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1863 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1864 *Indx = *Indx + 1;
1865
1866 SrcVal0 =
1867 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1868
1869 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1870 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1871 *Indx = *Indx + 1;
1872
1873 DesVal = SrcVal0;
1874
1875 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
1876
1877 break;
1878
1879 case FUNC_PRINT:
1880
1881 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1882 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1883
1884 *Indx = *Indx + 1;
1885
1886 SrcVal0 =
1887 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1888
1889 //
1890 // Call the target function
1891 //
1892 ScriptEngineFunctionPrint(ActionDetail->Tag,
1893 ActionDetail->ImmediatelySendTheResults,
1894 SrcVal0);
1895 break;
1896
1898 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1899 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1900 *Indx = *Indx + 1;
1901 SrcVal0 =
1902 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1903
1904 //
1905 // Call the target function
1906 //
1908 ActionDetail->ImmediatelySendTheResults,
1909 SrcVal0);
1910 break;
1911
1912 case FUNC_SPINLOCK_LOCK:
1913 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1914 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1915 *Indx = *Indx + 1;
1916
1917 SrcVal0 =
1918 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1919
1920 //
1921 // Call the target function
1922 //
1923 ScriptEngineFunctionSpinlockLock((volatile LONG *)SrcVal0, &HasError);
1924
1925 break;
1926
1928 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1929 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1930 *Indx = *Indx + 1;
1931 SrcVal0 =
1932 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1933
1934 //
1935 // Call the target function
1936 //
1937 ScriptEngineFunctionSpinlockUnlock((volatile LONG *)SrcVal0, &HasError);
1938
1939 break;
1940
1941 case FUNC_EVENT_ENABLE:
1942
1943 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1944 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1945 *Indx = *Indx + 1;
1946 SrcVal0 =
1947 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1948
1950
1951 break;
1952
1953 case FUNC_EVENT_DISABLE:
1954
1955 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1956 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1957 *Indx = *Indx + 1;
1958 SrcVal0 =
1959 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1960
1962
1963 break;
1964
1965 case FUNC_EVENT_CLEAR:
1966
1967 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1968 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1969 *Indx = *Indx + 1;
1970 SrcVal0 =
1971 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1972
1974
1975 break;
1976
1977 case FUNC_FORMATS:
1978
1979 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1980 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1981 *Indx = *Indx + 1;
1982 SrcVal0 =
1983 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
1984
1985 //
1986 // Call the target function
1987 //
1989 ActionDetail->Tag,
1990 ActionDetail->ImmediatelySendTheResults,
1991 SrcVal0);
1992
1993 break;
1994
1995 case FUNC_JZ:
1996
1997 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
1998 (unsigned long long)(*Indx * sizeof(SYMBOL)));
1999 *Indx = *Indx + 1;
2000 SrcVal0 =
2001 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2002
2003 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2004 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2005 *Indx = *Indx + 1;
2006
2007 SrcVal1 =
2008 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2009
2010 if (SrcVal1 == 0)
2011 *Indx = SrcVal0;
2012
2013 break;
2014
2015 case FUNC_JNZ:
2016
2017 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2018 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2019
2020 *Indx = *Indx + 1;
2021 SrcVal0 =
2022 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2023
2024 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2025 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2026
2027 *Indx = *Indx + 1;
2028 SrcVal1 =
2029 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2030
2031 if (SrcVal1 != 0)
2032 *Indx = SrcVal0;
2033
2034 break;
2035
2036 case FUNC_JMP:
2037
2038 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2039 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2040 *Indx = *Indx + 1;
2041 SrcVal0 =
2042 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2043
2044 *Indx = SrcVal0;
2045
2046 break;
2047
2048 case FUNC_PUSH:
2049 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2050 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2051 *Indx = *Indx + 1;
2052
2053 SrcVal0 =
2054 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2055
2056 ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackIndx] = SrcVal0;
2057 ScriptGeneralRegisters->StackIndx++;
2058
2059 break;
2060
2061 case FUNC_POP:
2062 ScriptGeneralRegisters->StackIndx--;
2063
2064 SrcVal0 = ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackIndx];
2065
2066 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2067 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2068 *Indx = *Indx + 1;
2069 SetValue(GuestRegs, ScriptGeneralRegisters, Des, SrcVal0);
2070
2071 break;
2072
2073 case FUNC_CALL:
2074 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2075 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2076 SrcVal0 =
2077 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2078
2079 *Indx = *Indx + 1;
2080
2081 ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackIndx] = *Indx;
2082
2083 ScriptGeneralRegisters->StackIndx++;
2084
2085 *Indx = SrcVal0;
2086 break;
2087
2088 case FUNC_RET:
2089
2090 ScriptGeneralRegisters->StackIndx--;
2091
2092 *Indx = ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackIndx];
2093 break;
2094 case FUNC_STRCMP:
2095
2096 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2097 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2098
2099 *Indx = *Indx + 1;
2100
2101 if (Src0->Type == SYMBOL_STRING_TYPE)
2102 {
2103 *Indx =
2104 *Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src0->Len) /
2105 sizeof(SYMBOL));
2106 SrcVal0 = (UINT64)&Src0->Value;
2107 }
2108 else
2109 {
2110 SrcVal0 =
2111 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2112 }
2113
2114 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2115 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2116
2117 *Indx = *Indx + 1;
2118
2119 if (Src1->Type == SYMBOL_STRING_TYPE)
2120 {
2121 *Indx =
2122 *Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src1->Len) /
2123 sizeof(SYMBOL));
2124 SrcVal1 = (UINT64)&Src1->Value;
2125 }
2126 else
2127 {
2128 SrcVal1 =
2129 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2130 }
2131
2132 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2133 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2134
2135 *Indx = *Indx + 1;
2136
2137 DesVal = ScriptEngineFunctionStrcmp((const char *)SrcVal1, (const char *)SrcVal0);
2138
2139 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2140
2141 break;
2142
2143 case FUNC_WCSCMP:
2144
2145 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2146 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2147
2148 *Indx = *Indx + 1;
2149
2150 if (Src0->Type == SYMBOL_WSTRING_TYPE)
2151 {
2152 *Indx =
2153 *Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src0->Len) /
2154 sizeof(SYMBOL));
2155 SrcVal0 = (UINT64)&Src0->Value;
2156 }
2157 else
2158 {
2159 SrcVal0 =
2160 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2161 }
2162
2163 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2164 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2165
2166 *Indx = *Indx + 1;
2167
2168 if (Src1->Type == SYMBOL_WSTRING_TYPE)
2169 {
2170 *Indx =
2171 *Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src1->Len) /
2172 sizeof(SYMBOL));
2173 SrcVal1 = (UINT64)&Src1->Value;
2174 }
2175 else
2176 {
2177 SrcVal1 =
2178 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2179 }
2180
2181 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2182 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2183
2184 *Indx = *Indx + 1;
2185
2186 DesVal = ScriptEngineFunctionWcscmp((const wchar_t *)SrcVal1, (const wchar_t *)SrcVal0);
2187
2188 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2189
2190 break;
2191
2192 case FUNC_MEMCMP:
2193
2194 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2195 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2196
2197 *Indx = *Indx + 1;
2198
2199 SrcVal0 =
2200 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2201
2202 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2203 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2204
2205 *Indx = *Indx + 1;
2206
2207 if (Src1->Type == SYMBOL_STRING_TYPE)
2208 {
2209 *Indx =
2210 *Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src1->Len) /
2211 sizeof(SYMBOL));
2212 SrcVal1 = (UINT64)&Src1->Value;
2213 }
2214 else
2215 {
2216 SrcVal1 =
2217 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2218 }
2219
2220 Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2221 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2222
2223 *Indx = *Indx + 1;
2224
2225 if (Src2->Type == SYMBOL_STRING_TYPE)
2226 {
2227 *Indx =
2228 *Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src2->Len) /
2229 sizeof(SYMBOL));
2230 SrcVal2 = (UINT64)&Src2->Value;
2231 }
2232 else
2233 {
2234 SrcVal2 =
2235 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
2236 }
2237
2238 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2239 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2240
2241 *Indx = *Indx + 1;
2242
2243 DesVal = ScriptEngineFunctionMemcmp((const char *)SrcVal2, (const char *)SrcVal1, SrcVal0);
2244
2245 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2246
2247 break;
2248
2249 case FUNC_STRNCMP:
2250
2251 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2252 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2253
2254 *Indx = *Indx + 1;
2255
2256 SrcVal0 =
2257 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2258
2259 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2260 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2261
2262 *Indx = *Indx + 1;
2263
2264 if (Src1->Type == SYMBOL_STRING_TYPE)
2265 {
2266 *Indx =
2267 *Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src1->Len) /
2268 sizeof(SYMBOL));
2269 SrcVal1 = (UINT64)&Src1->Value;
2270 }
2271 else
2272 {
2273 SrcVal1 =
2274 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2275 }
2276
2277 Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2278 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2279
2280 *Indx = *Indx + 1;
2281
2282 if (Src2->Type == SYMBOL_STRING_TYPE)
2283 {
2284 *Indx =
2285 *Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src2->Len) /
2286 sizeof(SYMBOL));
2287 SrcVal2 = (UINT64)&Src2->Value;
2288 }
2289 else
2290 {
2291 SrcVal2 =
2292 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
2293 }
2294
2295 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2296 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2297
2298 *Indx = *Indx + 1;
2299
2300 DesVal = ScriptEngineFunctionStrncmp((const char *)SrcVal2, (const char *)SrcVal1, SrcVal0);
2301
2302 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2303
2304 break;
2305
2306 case FUNC_WCSNCMP:
2307
2308 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2309 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2310
2311 *Indx = *Indx + 1;
2312
2313 SrcVal0 =
2314 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2315
2316 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2317 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2318
2319 *Indx = *Indx + 1;
2320
2321 if (Src1->Type == SYMBOL_WSTRING_TYPE)
2322 {
2323 *Indx =
2324 *Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src1->Len) /
2325 sizeof(SYMBOL));
2326 SrcVal1 = (UINT64)&Src1->Value;
2327 }
2328 else
2329 {
2330 SrcVal1 =
2331 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2332 }
2333
2334 Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2335 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2336
2337 *Indx = *Indx + 1;
2338
2339 if (Src2->Type == SYMBOL_WSTRING_TYPE)
2340 {
2341 *Indx =
2342 *Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src2->Len) /
2343 sizeof(SYMBOL));
2344 SrcVal2 = (UINT64)&Src2->Value;
2345 }
2346 else
2347 {
2348 SrcVal2 =
2349 GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
2350 }
2351
2352 Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2353 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2354
2355 *Indx = *Indx + 1;
2356
2357 DesVal = ScriptEngineFunctionWcsncmp((const wchar_t *)SrcVal2, (const wchar_t *)SrcVal1, SrcVal0);
2358
2359 SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2360
2361 break;
2362
2363 case FUNC_PRINTF:
2364
2365 Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2366 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2367 *Indx = *Indx + 1;
2368
2369 //
2370 // Call the target function
2371 //
2372
2373 *Indx =
2374 *Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src0->Len) /
2375 sizeof(SYMBOL));
2376
2377 Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2378 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2379
2380 *Indx = *Indx + 1;
2381
2382 Src2 = NULL;
2383
2384 if (Src1->Value > 0)
2385 {
2386 Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
2387 (unsigned long long)(*Indx * sizeof(SYMBOL)));
2388
2389 *Indx = *Indx + Src1->Value;
2390 }
2391
2393 GuestRegs,
2394 ActionDetail,
2395 ScriptGeneralRegisters,
2396 ActionDetail->Tag,
2397 ActionDetail->ImmediatelySendTheResults,
2398 (char *)&Src0->Value,
2399 Src1->Value,
2400 Src2,
2401 (BOOLEAN *)&HasError);
2402
2403 break;
2404 }
2405
2406 //
2407 // Return the result of whether error detected or not
2408 //
2409 return HasError;
2410}
long long ScriptEngineFunctionInterlockedIncrement(long long volatile *Addend, BOOL *HasError)
Implementation of interlocked_exchange_increment function.
Definition Functions.c:925
BOOLEAN ScriptEngineFunctionEqPa(UINT64 Address, QWORD Value, BOOL *HasError)
Implementation of eq function (Physical Memory).
Definition Functions.c:165
UINT64 ScriptEngineFunctionRdtsc()
Implementation of rdtsc function.
Definition Functions.c:841
VOID ScriptEngineFunctionEventTraceInstrumentationStep()
Implementation of event_trace_instrumentation_step function.
Definition Functions.c:1987
VOID ScriptEngineFunctionSpinlockUnlock(volatile LONG *Lock, BOOL *HasError)
Implementation of spinlock_unlock function.
Definition Functions.c:678
BOOLEAN ScriptEngineFunctionEbPa(UINT64 Address, BYTE Value, BOOL *HasError)
Implementation of eb function (Physical Memory).
Definition Functions.c:249
UINT64 ScriptEngineFunctionRdtscp()
Implementation of rdtscp function.
Definition Functions.c:851
VOID ScriptEngineFunctionEventInjectErrorCode(UINT32 InterruptionType, UINT32 Vector, UINT32 ErrorCode, BOOL *HasError)
Implementation of event_inject_error_code function.
Definition Functions.c:1836
long long ScriptEngineFunctionInterlockedDecrement(long long volatile *Addend, BOOL *HasError)
Implementation of interlocked_exchange_decrement function.
Definition Functions.c:953
BOOLEAN ScriptEngineFunctionLbrRestore()
Implementation of lbr_restore function.
Definition Functions.c:2099
BOOLEAN ScriptEngineFunctionEd(UINT64 Address, DWORD Value, BOOL *HasError)
Implementation of ed function.
Definition Functions.c:87
UINT64 ScriptEngineFunctionPhysicalToVirtual(UINT64 Address)
Convert physical address to virtual address.
Definition Functions.c:573
VOID ScriptEngineFunctionShortCircuitingEvent(UINT64 State, ACTION_BUFFER *ActionDetail)
Implementation of event_ignore function.
Definition Functions.c:1188
VOID ScriptEngineFunctionSpinlockLock(volatile LONG *Lock, BOOL *HasError)
Implementation of spinlock_lock function.
Definition Functions.c:649
VOID ScriptEngineFunctionPause(ACTION_BUFFER *ActionDetail, PGUEST_REGS GuestRegs)
Implementation of pause function.
Definition Functions.c:1089
BOOLEAN ScriptEngineFunctionEdPa(UINT64 Address, DWORD Value, BOOL *HasError)
Implementation of ed function (Physical Memory).
Definition Functions.c:207
UINT64 ScriptEngineFunctionStrcmp(const char *Address1, const char *Address2)
Implementation of strcmp function.
Definition Functions.c:1873
BOOLEAN ScriptEngineFunctionCheckAddress(UINT64 Address, UINT32 Length)
Check whether the address is valid or not.
Definition Functions.c:290
UINT64 ScriptEngineFunctionWcscmp(const wchar_t *Address1, const wchar_t *Address2)
Implementation of wcscmp function.
Definition Functions.c:1920
long long ScriptEngineFunctionInterlockedExchange(long long volatile *Target, long long Value, BOOL *HasError)
Implementation of interlocked_exchange function.
Definition Functions.c:866
UINT64 ScriptEngineFunctionVirtualToPhysical(UINT64 Address)
Definition Functions.c:549
UINT64 ScriptEngineFunctionWcsncmp(const wchar_t *Address1, const wchar_t *Address2, size_t Num)
Implementation of wcsncmp function.
Definition Functions.c:1944
VOID ScriptEngineFunctionSpinlockLockCustomWait(volatile long *Lock, unsigned MaxWait, BOOL *HasError)
Implementation of spinlock_lock_custom_wait function.
Definition Functions.c:708
VOID ScriptEngineFunctionEventDisable(UINT64 EventId)
Implementation of event_disable function.
Definition Functions.c:1036
VOID ScriptEngineFunctionMemcpyPa(UINT64 Destination, UINT64 Source, UINT32 Num, BOOL *HasError)
A VMX-compatible equivalent of memcpy function in C for physical memory.
Definition Functions.c:453
BOOLEAN ScriptEngineFunctionLbrSave()
Implementation of lbr_save function.
Definition Functions.c:2033
VOID ScriptEngineFunctionMicroSleep(UINT64 Us)
Implementation of microsleep function.
Definition Functions.c:825
VOID ScriptEngineFunctionEventEnable(UINT64 EventId)
Implementation of event_enable function.
Definition Functions.c:1014
UINT64 ScriptEngineFunctionDisassembleLen(PVOID Address, BOOLEAN Is32Bit)
Implementation of disassemble_len function.
Definition Functions.c:759
UINT64 ScriptEngineFunctionStrlen(const char *Address)
Implementation of strlen function.
Definition Functions.c:736
long long ScriptEngineFunctionInterlockedCompareExchange(long long volatile *Destination, long long ExChange, long long Comperand, BOOL *HasError)
Implementation of interlocked_compare_exchange function.
Definition Functions.c:983
BOOLEAN ScriptEngineFunctionEq(UINT64 Address, QWORD Value, BOOL *HasError)
Implementation of eq function.
Definition Functions.c:48
VOID ScriptEngineFunctionPrintf(PGUEST_REGS GuestRegs, ACTION_BUFFER *ActionDetail, SCRIPT_ENGINE_GENERAL_REGISTERS *ScriptGeneralRegisters, UINT64 Tag, BOOLEAN ImmediateMessagePassing, char *Format, UINT64 ArgCount, PSYMBOL FirstArg, BOOLEAN *HasError)
Implementation of printf function.
Definition Functions.c:1571
VOID ScriptEngineFunctionFlush()
Implementation of flush function.
Definition Functions.c:1163
UINT64 ScriptEngineFunctionMemcmp(const char *Address1, const char *Address2, size_t Count)
Implementation of memcmp function.
Definition Functions.c:1967
UINT64 ScriptEngineFunctionWcslen(const wchar_t *Address)
Implementation of wcslen function.
Definition Functions.c:780
VOID ScriptEngineFunctionPrint(UINT64 Tag, BOOLEAN ImmediateMessagePassing, UINT64 Value)
Implementation of print function.
Definition Functions.c:599
VOID ScriptEngineFunctionEventInject(UINT32 InterruptionType, UINT32 Vector, BOOL *HasError)
Implementation of event_inject function.
Definition Functions.c:1798
BOOLEAN ScriptEngineFunctionLbrCheck()
Implementation of lbr_check function.
Definition Functions.c:2079
VOID ScriptEngineFunctionEventClear(UINT64 EventId)
Implementation of event_clear function.
Definition Functions.c:1058
VOID ScriptEngineFunctionEventTraceStepIn()
Implementation of event_trace_step_in function.
Definition Functions.c:2011
BOOLEAN ScriptEngineFunctionEb(UINT64 Address, BYTE Value, BOOL *HasError)
Implementation of eb function.
Definition Functions.c:126
VOID ScriptEngineFunctionTestStatement(UINT64 Tag, BOOLEAN ImmediateMessagePassing, UINT64 Value)
Implementation of test_statement function.
Definition Functions.c:627
UINT64 ScriptEngineFunctionStrncmp(const char *Address1, const char *Address2, size_t Num)
Implementation of strcmp function.
Definition Functions.c:1897
long long ScriptEngineFunctionInterlockedExchangeAdd(long long volatile *Addend, long long Value, BOOL *HasError)
Implementation of interlocked_exchange_add function.
Definition Functions.c:896
BOOLEAN ScriptEngineFunctionLbrPrint()
Implementation of lbr_print function.
Definition Functions.c:2056
VOID ScriptEngineFunctionFormats(UINT64 Tag, BOOLEAN ImmediateMessagePassing, UINT64 Value)
Implementation of formats function.
Definition Functions.c:1226
VOID ScriptEngineFunctionMemcpy(UINT64 Destination, UINT64 Source, UINT32 Num, BOOL *HasError)
A VMX-compatible equivalent of memcpy function in C.
Definition Functions.c:323
BOOLEAN ScriptEngineFunctionLbrRestoreByFilter(UINT64 FilterOptions)
Implementation of lbr_restore_by_filter function.
Definition Functions.c:2119
WORD ScriptEngineKeywordDw(PUINT64 Address, BOOL *HasError)
Implementation of dw keyword.
Definition Keywords.c:203
DWORD ScriptEngineKeywordDdPa(PUINT64 Address, BOOL *HasError)
Implementation of dd keyword.
Definition Keywords.c:425
BYTE ScriptEngineKeywordDb(PUINT64 Address, BOOL *HasError)
Implementation of db keyword.
Definition Keywords.c:135
WORD ScriptEngineKeywordLow(PUINT64 Address, BOOL *HasError)
Implementation of low keyword.
Definition Keywords.c:101
UINT64 ScriptEngineKeywordPoi(PUINT64 Address, BOOL *HasError)
Implementation of poi keyword.
Definition Keywords.c:33
WORD ScriptEngineKeywordHi(PUINT64 Address, BOOL *HasError)
Implementation of hi keyword.
Definition Keywords.c:67
DWORD ScriptEngineKeywordDd(PUINT64 Address, BOOL *HasError)
Implementation of dd keyword.
Definition Keywords.c:169
QWORD ScriptEngineKeywordDqPa(PUINT64 Address, BOOL *HasError)
Implementation of dq keyword.
Definition Keywords.c:499
BYTE ScriptEngineKeywordDbPa(PUINT64 Address, BOOL *HasError)
Implementation of db keyword.
Definition Keywords.c:388
QWORD ScriptEngineKeywordDq(PUINT64 Address, BOOL *HasError)
Implementation of dq keyword.
Definition Keywords.c:237
UINT64 ScriptEngineKeywordPoiPa(PUINT64 Address, BOOL *HasError)
Implementation of poi_pa keyword.
Definition Keywords.c:277
WORD ScriptEngineKeywordDwPa(PUINT64 Address, BOOL *HasError)
Implementation of dw keyword.
Definition Keywords.c:462
VOID SetValue(PGUEST_REGS GuestRegs, SCRIPT_ENGINE_GENERAL_REGISTERS *ScriptGeneralRegisters, PSYMBOL Symbol, UINT64 Value)
Set the value.
Definition ScriptEngineEval.c:185
UINT64 GetValue(PGUEST_REGS GuestRegs, PACTION_BUFFER ActionBuffer, PSCRIPT_ENGINE_GENERAL_REGISTERS ScriptGeneralRegisters, PSYMBOL Symbol, BOOLEAN ReturnReference)
Get the Value (reg, peseudo-reg, etc.).
Definition ScriptEngineEval.c:92
int BOOL
Definition BasicTypes.h:25
UCHAR BOOLEAN
Definition BasicTypes.h:35
long LONG
Definition BasicTypes.h:28
void * PVOID
Definition BasicTypes.h:56
unsigned char BYTE
Definition BasicTypes.h:40
#define TRUE
Definition BasicTypes.h:114
#define FALSE
Definition BasicTypes.h:113
unsigned long DWORD
Definition BasicTypes.h:38
unsigned int UINT32
Definition BasicTypes.h:54
#define FUNC_DQ
Definition ScriptEngineCommonDefinitions.h:164
#define FUNC_EQ
Definition ScriptEngineCommonDefinitions.h:187
#define FUNC_DD
Definition ScriptEngineCommonDefinitions.h:162
#define FUNC_EVENT_CLEAR
Definition ScriptEngineCommonDefinitions.h:137
#define FUNC_MUL
Definition ScriptEngineCommonDefinitions.h:108
#define FUNC_RDTSC
Definition ScriptEngineCommonDefinitions.h:151
#define FUNC_CALL
Definition ScriptEngineCommonDefinitions.h:131
#define FUNC_LBR_CHECK
Definition ScriptEngineCommonDefinitions.h:157
#define SYMBOL_WSTRING_TYPE
Definition ScriptEngineCommonDefinitions.h:54
#define FUNC_EVENT_TRACE_STEP_OUT
Definition ScriptEngineCommonDefinitions.h:148
#define FUNC_EVENT_DISABLE
Definition ScriptEngineCommonDefinitions.h:136
struct SYMBOL * PSYMBOL
#define FUNC_INTERLOCKED_EXCHANGE_ADD
Definition ScriptEngineCommonDefinitions.h:189
#define FUNC_HI
Definition ScriptEngineCommonDefinitions.h:166
#define FUNC_STRCMP
Definition ScriptEngineCommonDefinitions.h:195
#define FUNC_DISASSEMBLE_LEN32
Definition ScriptEngineCommonDefinitions.h:171
#define FUNC_JMP
Definition ScriptEngineCommonDefinitions.h:117
#define FUNC_GT
Definition ScriptEngineCommonDefinitions.h:111
#define FUNC_MOV
Definition ScriptEngineCommonDefinitions.h:120
#define FUNC_ED_PA
Definition ScriptEngineCommonDefinitions.h:191
#define FUNC_MEMCPY
Definition ScriptEngineCommonDefinitions.h:201
#define FUNC_EVENT_SC
Definition ScriptEngineCommonDefinitions.h:141
#define FUNC_EGT
Definition ScriptEngineCommonDefinitions.h:113
#define FUNC_STRLEN
Definition ScriptEngineCommonDefinitions.h:194
#define FUNC_SUB
Definition ScriptEngineCommonDefinitions.h:107
#define FUNC_PRINTF
Definition ScriptEngineCommonDefinitions.h:143
#define FUNC_POP
Definition ScriptEngineCommonDefinitions.h:130
#define FUNC_EVENT_INJECT_ERROR_CODE
Definition ScriptEngineCommonDefinitions.h:200
#define FUNC_FORMATS
Definition ScriptEngineCommonDefinitions.h:134
#define FUNC_INC
Definition ScriptEngineCommonDefinitions.h:98
#define FUNC_SPINLOCK_UNLOCK
Definition ScriptEngineCommonDefinitions.h:140
#define FUNC_CHECK_ADDRESS
Definition ScriptEngineCommonDefinitions.h:169
#define FUNC_INTERLOCKED_INCREMENT
Definition ScriptEngineCommonDefinitions.h:173
#define FUNC_ASR
Definition ScriptEngineCommonDefinitions.h:104
#define FUNC_LBR_RESTORE
Definition ScriptEngineCommonDefinitions.h:156
#define FUNC_DB
Definition ScriptEngineCommonDefinitions.h:161
#define FUNC_WCSCMP
Definition ScriptEngineCommonDefinitions.h:199
#define FUNC_ASL
Definition ScriptEngineCommonDefinitions.h:105
#define FUNC_VIRTUAL_TO_PHYSICAL
Definition ScriptEngineCommonDefinitions.h:176
#define FUNC_PRINT
Definition ScriptEngineCommonDefinitions.h:133
#define FUNC_FLUSH
Definition ScriptEngineCommonDefinitions.h:145
#define SIZE_SYMBOL_WITHOUT_LEN
Definition ScriptEngineCommonDefinitions.h:13
#define FUNC_PAUSE
Definition ScriptEngineCommonDefinitions.h:144
#define FUNC_RET
Definition ScriptEngineCommonDefinitions.h:132
#define FUNC_LOW
Definition ScriptEngineCommonDefinitions.h:167
#define FUNC_INTERLOCKED_DECREMENT
Definition ScriptEngineCommonDefinitions.h:174
#define FUNC_LBR_SAVE
Definition ScriptEngineCommonDefinitions.h:153
#define FUNC_DD_PA
Definition ScriptEngineCommonDefinitions.h:181
#define FUNC_EVENT_TRACE_STEP
Definition ScriptEngineCommonDefinitions.h:146
#define FUNC_DISASSEMBLE_LEN64
Definition ScriptEngineCommonDefinitions.h:172
#define FUNC_ELT
Definition ScriptEngineCommonDefinitions.h:114
#define FUNC_POI
Definition ScriptEngineCommonDefinitions.h:160
#define FUNC_OR
Definition ScriptEngineCommonDefinitions.h:101
#define FUNC_LBR_RESTORE_BY_FILTER
Definition ScriptEngineCommonDefinitions.h:184
#define FUNC_RDTSCP
Definition ScriptEngineCommonDefinitions.h:152
#define FUNC_DW_PA
Definition ScriptEngineCommonDefinitions.h:182
#define FUNC_DW
Definition ScriptEngineCommonDefinitions.h:163
#define FUNC_XOR
Definition ScriptEngineCommonDefinitions.h:102
#define FUNC_PHYSICAL_TO_VIRTUAL
Definition ScriptEngineCommonDefinitions.h:175
#define FUNC_MEMCMP
Definition ScriptEngineCommonDefinitions.h:196
#define FUNC_DB_PA
Definition ScriptEngineCommonDefinitions.h:180
#define FUNC_SPINLOCK_LOCK
Definition ScriptEngineCommonDefinitions.h:139
#define FUNC_DISASSEMBLE_LEN
Definition ScriptEngineCommonDefinitions.h:170
#define FUNC_EVENT_INJECT
Definition ScriptEngineCommonDefinitions.h:159
#define FUNC_PUSH
Definition ScriptEngineCommonDefinitions.h:129
#define FUNC_REFERENCE
Definition ScriptEngineCommonDefinitions.h:100
#define FUNC_EQ_PA
Definition ScriptEngineCommonDefinitions.h:192
#define FUNC_ADD
Definition ScriptEngineCommonDefinitions.h:106
#define FUNC_POI_PA
Definition ScriptEngineCommonDefinitions.h:177
#define FUNC_LBR_DUMP
Definition ScriptEngineCommonDefinitions.h:154
#define FUNC_EB_PA
Definition ScriptEngineCommonDefinitions.h:190
#define FUNC_NEQ
Definition ScriptEngineCommonDefinitions.h:116
#define FUNC_NEG
Definition ScriptEngineCommonDefinitions.h:165
#define FUNC_WCSNCMP
Definition ScriptEngineCommonDefinitions.h:203
#define FUNC_EVENT_TRACE_INSTRUMENTATION_STEP_IN
Definition ScriptEngineCommonDefinitions.h:150
#define FUNC_MICROSLEEP
Definition ScriptEngineCommonDefinitions.h:142
#define SYMBOL_STRING_TYPE
Definition ScriptEngineCommonDefinitions.h:51
#define FUNC_JZ
Definition ScriptEngineCommonDefinitions.h:118
#define FUNC_EQUAL
Definition ScriptEngineCommonDefinitions.h:115
#define FUNC_EVENT_TRACE_INSTRUMENTATION_STEP
Definition ScriptEngineCommonDefinitions.h:149
#define FUNC_LT
Definition ScriptEngineCommonDefinitions.h:112
#define SYMBOL_SEMANTIC_RULE_TYPE
Definition ScriptEngineCommonDefinitions.h:49
#define FUNC_DIV
Definition ScriptEngineCommonDefinitions.h:109
#define FUNC_MEMCPY_PA
Definition ScriptEngineCommonDefinitions.h:202
#define FUNC_EVENT_ENABLE
Definition ScriptEngineCommonDefinitions.h:135
#define FUNC_TEST_STATEMENT
Definition ScriptEngineCommonDefinitions.h:138
#define FUNC_AND
Definition ScriptEngineCommonDefinitions.h:103
#define FUNC_NOT
Definition ScriptEngineCommonDefinitions.h:168
#define FUNC_DQ_PA
Definition ScriptEngineCommonDefinitions.h:183
#define FUNC_ED
Definition ScriptEngineCommonDefinitions.h:185
#define FUNC_INTERLOCKED_EXCHANGE
Definition ScriptEngineCommonDefinitions.h:188
#define FUNC_WCSLEN
Definition ScriptEngineCommonDefinitions.h:198
#define FUNC_DEC
Definition ScriptEngineCommonDefinitions.h:99
#define FUNC_EVENT_TRACE_STEP_IN
Definition ScriptEngineCommonDefinitions.h:147
#define FUNC_MOD
Definition ScriptEngineCommonDefinitions.h:110
#define FUNC_EB
Definition ScriptEngineCommonDefinitions.h:186
#define FUNC_STRNCMP
Definition ScriptEngineCommonDefinitions.h:197
#define FUNC_LBR_PRINT
Definition ScriptEngineCommonDefinitions.h:155
#define FUNC_SPINLOCK_LOCK_CUSTOM_WAIT
Definition ScriptEngineCommonDefinitions.h:158
#define FUNC_JNZ
Definition ScriptEngineCommonDefinitions.h:119
#define FUNC_INTERLOCKED_COMPARE_EXCHANGE
Definition ScriptEngineCommonDefinitions.h:193
long long unsigned Tag
Definition ScriptEngineCommonDefinitions.h:36
char ImmediatelySendTheResults
Definition ScriptEngineCommonDefinitions.h:38
PSYMBOL Head
Definition ScriptEngineCommonDefinitions.h:23
Definition ScriptEngineCommonDefinitions.h:6
long long unsigned Len
Definition ScriptEngineCommonDefinitions.h:8

◆ ScriptEngineGetOperatorName()

VOID ScriptEngineGetOperatorName ( PSYMBOL OperatorSymbol,
CHAR * BufferForName )

Get the operator name.

Parameters
OperatorSymbol
BufferForName
Returns
VOID
234{
235 switch (OperatorSymbol->Value)
236 {
237 case FUNC_POI:
238 memcpy(BufferForName, "poi", 3);
239 break;
240 case FUNC_DB:
241 memcpy(BufferForName, "db", 2);
242 break;
243 case FUNC_DD:
244 memcpy(BufferForName, "dd", 2);
245 break;
246 case FUNC_DW:
247 memcpy(BufferForName, "dw", 2);
248 break;
249 case FUNC_DQ:
250 memcpy(BufferForName, "dq", 2);
251 break;
252 case FUNC_HI:
253 memcpy(BufferForName, "hi", 2);
254 break;
255 case FUNC_LOW:
256 memcpy(BufferForName, "low", 3);
257 break;
258 case FUNC_POI_PA:
259 memcpy(BufferForName, "poi_pa", 6);
260 break;
261 case FUNC_DB_PA:
262 memcpy(BufferForName, "db_pa", 5);
263 break;
264 case FUNC_DD_PA:
265 memcpy(BufferForName, "dd_pa", 5);
266 break;
267 case FUNC_DW_PA:
268 memcpy(BufferForName, "dw_pa", 5);
269 break;
270 case FUNC_DQ_PA:
271 memcpy(BufferForName, "dq_pa", 5);
272 break;
273 case FUNC_HI_PA:
274 memcpy(BufferForName, "hi_pa", 5);
275 break;
276 case FUNC_LOW_PA:
277 memcpy(BufferForName, "low_pa", 6);
278 break;
279 default:
280 memcpy(BufferForName, "error", 5);
281 break;
282 }
283}
#define FUNC_LOW_PA
Definition ScriptEngineCommonDefinitions.h:179
#define FUNC_HI_PA
Definition ScriptEngineCommonDefinitions.h:178

◆ SetValue()

VOID SetValue ( PGUEST_REGS GuestRegs,
SCRIPT_ENGINE_GENERAL_REGISTERS * ScriptGeneralRegisters,
PSYMBOL Symbol,
UINT64 Value )

Set the value.

Parameters
GuestRegs
ScriptGeneralRegisters
Symbol
Value
Returns
VOID
189{
190 switch (Symbol->Type)
191 {
193 ScriptGeneralRegisters->GlobalVariablesList[Symbol->Value] = Value;
194 return;
196 SetRegValueUsingSymbol(GuestRegs, Symbol, Value);
197 return;
198
200 ScriptGeneralRegisters->StackIndx = Value;
201 return;
202
204 ScriptGeneralRegisters->StackBaseIndx = Value;
205 return;
206
208 ScriptGeneralRegisters->ReturnValue = Value;
209 return;
210
211 case SYMBOL_TEMP_TYPE:
212 ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx + Symbol->Value] = Value;
213 return;
214
216 *(UINT64 *)ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx + Symbol->Value] = Value;
217 return;
218
220 ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx - 3 - Symbol->Value] = Value;
221 return;
222 }
223}
BOOLEAN SetRegValueUsingSymbol(PGUEST_REGS GuestRegs, PSYMBOL Symbol, UINT64 Value)
Set the register value.
Definition Regs.c:2035
RequestedActionOfThePacket Value(0x1) 00000000