HyperDbg/hyperdbg/script-eval/code/ScriptEngineEval.c

2411 lines
73 KiB
C
Raw Normal View History

2022-06-29 16:13:40 -07:00
/**
* @file ScriptEngineEval.c
* @author M.H. Gholamrezaei (mh@hyperdbg.org)
* @author Sina Karvandi (sina@hyperdbg.org)
* @brief Shared Headers for Script engine
* @details
* @version 0.1
* @date 2020-10-22
*
* @copyright This project is released under the GNU Public License v3.
*
*/
#include "pch.h"
#include "../script-eval/header/ScriptEngineInternalHeader.h"
2022-06-29 16:13:40 -07:00
2022-06-30 15:31:34 -07:00
/**
* @brief Get the Pseudo reg value
*
* @param Symbol
* @param ActionBuffer
* @return UINT64
2022-06-30 15:31:34 -07:00
*/
2022-06-29 16:13:40 -07:00
UINT64
GetPseudoRegValue(PSYMBOL Symbol, PACTION_BUFFER ActionBuffer)
{
switch (Symbol->Value)
{
case PSEUDO_REGISTER_TID:
return ScriptEnginePseudoRegGetTid();
case PSEUDO_REGISTER_PID:
return ScriptEnginePseudoRegGetPid();
case PSEUDO_REGISTER_PNAME:
return (UINT64)ScriptEnginePseudoRegGetPname();
case PSEUDO_REGISTER_CORE:
return ScriptEnginePseudoRegGetCore();
case PSEUDO_REGISTER_PROC:
return ScriptEnginePseudoRegGetProc();
case PSEUDO_REGISTER_THREAD:
return ScriptEnginePseudoRegGetThread();
case PSEUDO_REGISTER_PEB:
return ScriptEnginePseudoRegGetPeb();
case PSEUDO_REGISTER_TEB:
return ScriptEnginePseudoRegGetTeb();
case PSEUDO_REGISTER_IP:
return ScriptEnginePseudoRegGetIp();
case PSEUDO_REGISTER_BUFFER:
2024-03-01 15:59:58 +09:00
if (ActionBuffer->CurrentAction != (UINT64)NULL)
2022-06-29 16:13:40 -07:00
{
return ScriptEnginePseudoRegGetBuffer(
(UINT64 *)ActionBuffer->CurrentAction);
}
else
{
2024-03-01 18:11:24 +09:00
return (UINT64)NULL;
2022-06-29 16:13:40 -07:00
}
case PSEUDO_REGISTER_CONTEXT:
return ActionBuffer->Context;
2023-11-15 13:44:57 +09:00
case PSEUDO_REGISTER_EVENT_TAG:
return ScriptEnginePseudoRegGetEventTag(ActionBuffer);
2023-11-15 13:44:57 +09:00
case PSEUDO_REGISTER_EVENT_ID:
return ScriptEnginePseudoRegGetEventId(ActionBuffer);
2023-11-15 13:44:57 +09:00
case PSEUDO_REGISTER_EVENT_STAGE:
2023-07-31 15:05:14 +09:00
return ScriptEnginePseudoRegGetEventStage(ActionBuffer);
case PSEUDO_REGISTER_TIME:
return ScriptEnginePseudoRegGetTime();
case PSEUDO_REGISTER_DATE:
return ScriptEnginePseudoRegGetDate();
2022-06-29 16:13:40 -07:00
case INVALID:
#ifdef SCRIPT_ENGINE_USER_MODE
ShowMessages("error in reading regesiter");
#endif // SCRIPT_ENGINE_USER_MODE
return INVALID;
2024-03-01 23:51:41 +09:00
default:
#ifdef SCRIPT_ENGINE_USER_MODE
ShowMessages("unknown pseudo-register");
#endif // SCRIPT_ENGINE_USER_MODE
return INVALID;
2022-06-29 16:13:40 -07:00
}
}
2022-06-30 15:31:34 -07:00
/**
* @brief Get the Value (reg, peseudo-reg, etc.)
*
* @param GuestRegs
* @param ActionBuffer
2024-07-24 21:25:55 +08:00
* @param ScriptGeneralRegisters
* @param Symbol
* @param ReturnReference
* @return UINT64
2022-06-30 15:31:34 -07:00
*/
2022-06-29 16:13:40 -07:00
UINT64
2024-07-24 21:25:55 +08:00
GetValue(PGUEST_REGS GuestRegs,
PACTION_BUFFER ActionBuffer,
PSCRIPT_ENGINE_GENERAL_REGISTERS ScriptGeneralRegisters,
PSYMBOL Symbol,
BOOLEAN ReturnReference)
2022-06-29 16:13:40 -07:00
{
switch (Symbol->Type)
{
case SYMBOL_GLOBAL_ID_TYPE:
if (ReturnReference)
2024-07-24 21:25:55 +08:00
return ((UINT64)(&ScriptGeneralRegisters->GlobalVariablesList[Symbol->Value]));
2022-06-29 16:13:40 -07:00
else
2024-07-24 21:25:55 +08:00
return ScriptGeneralRegisters->GlobalVariablesList[Symbol->Value];
2022-06-29 16:13:40 -07:00
case SYMBOL_NUM_TYPE:
if (ReturnReference)
return ((UINT64)&Symbol->Value);
else
return Symbol->Value;
case SYMBOL_REGISTER_TYPE:
if (ReturnReference)
2024-03-01 18:11:24 +09:00
return (UINT64)NULL; // Not reasonable, you should not dereference a register!
2022-06-29 16:13:40 -07:00
else
return GetRegValue(GuestRegs, (REGS_ENUM)Symbol->Value);
case SYMBOL_PSEUDO_REG_TYPE:
if (ReturnReference)
2024-03-01 18:11:24 +09:00
return (UINT64)NULL; // Not reasonable, you should not dereference a pseudo-register!
2022-06-29 16:13:40 -07:00
else
return GetPseudoRegValue(Symbol, ActionBuffer);
2024-07-24 21:25:55 +08:00
case SYMBOL_STACK_INDEX_TYPE:
2022-06-29 16:13:40 -07:00
if (ReturnReference)
2024-07-24 21:25:55 +08:00
return (UINT64)&ScriptGeneralRegisters->StackIndx;
2022-06-29 16:13:40 -07:00
else
2024-07-24 21:25:55 +08:00
return ScriptGeneralRegisters->StackIndx;
case SYMBOL_STACK_BASE_INDEX_TYPE:
2024-07-24 21:25:55 +08:00
if (ReturnReference)
return (UINT64)&ScriptGeneralRegisters->StackBaseIndx;
else
return ScriptGeneralRegisters->StackBaseIndx;
case SYMBOL_RETURN_VALUE_TYPE:
2024-07-24 21:25:55 +08:00
if (ReturnReference)
return (UINT64)&ScriptGeneralRegisters->ReturnValue;
else
return ScriptGeneralRegisters->ReturnValue;
2024-07-24 21:25:55 +08:00
case SYMBOL_TEMP_TYPE:
2024-07-24 21:25:55 +08:00
if (ReturnReference)
return (UINT64)&ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx + Symbol->Value];
2024-07-24 21:25:55 +08:00
else
return ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx + Symbol->Value];
2024-07-24 21:25:55 +08:00
2025-10-21 16:46:49 +08:00
case SYMBOL_REFERENCE_TEMP_TYPE:
return (UINT64)&ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx + Symbol->Value];
case SYMBOL_DEREFERENCE_TEMP_TYPE:
return *(UINT64 *)ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx + Symbol->Value];
case SYMBOL_FUNCTION_PARAMETER_ID_TYPE:
2024-07-24 21:25:55 +08:00
if (ReturnReference)
return (UINT64)&ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx - 3 - Symbol->Value];
2024-07-24 21:25:55 +08:00
else
return ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx - 3 - Symbol->Value];
2022-06-29 16:13:40 -07:00
}
2024-03-16 23:49:00 +09:00
//
// Shouldn't reach here
//
2024-03-17 19:28:10 +09:00
return NULL64_ZERO;
2022-06-29 16:13:40 -07:00
}
2022-06-30 15:31:34 -07:00
/**
* @brief Set the value
*
* @param GuestRegs
2024-07-24 21:25:55 +08:00
* @param ScriptGeneralRegisters
* @param Symbol
* @param Value
* @return VOID
2022-06-30 15:31:34 -07:00
*/
2022-06-29 16:13:40 -07:00
VOID
2024-07-24 21:25:55 +08:00
SetValue(PGUEST_REGS GuestRegs,
SCRIPT_ENGINE_GENERAL_REGISTERS * ScriptGeneralRegisters,
PSYMBOL Symbol,
UINT64 Value)
2022-06-29 16:13:40 -07:00
{
switch (Symbol->Type)
{
case SYMBOL_GLOBAL_ID_TYPE:
2024-07-24 21:25:55 +08:00
ScriptGeneralRegisters->GlobalVariablesList[Symbol->Value] = Value;
2022-06-29 16:13:40 -07:00
return;
case SYMBOL_REGISTER_TYPE:
2024-07-07 21:44:07 +09:00
SetRegValueUsingSymbol(GuestRegs, Symbol, Value);
2022-06-29 16:13:40 -07:00
return;
case SYMBOL_STACK_INDEX_TYPE:
2024-07-24 21:25:55 +08:00
ScriptGeneralRegisters->StackIndx = Value;
return;
case SYMBOL_STACK_BASE_INDEX_TYPE:
2024-07-24 21:25:55 +08:00
ScriptGeneralRegisters->StackBaseIndx = Value;
return;
case SYMBOL_RETURN_VALUE_TYPE:
2024-07-24 21:25:55 +08:00
ScriptGeneralRegisters->ReturnValue = Value;
return;
2024-07-24 21:25:55 +08:00
case SYMBOL_TEMP_TYPE:
ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx + Symbol->Value] = Value;
return;
2024-07-24 21:25:55 +08:00
2025-10-21 16:46:49 +08:00
case SYMBOL_DEREFERENCE_TEMP_TYPE:
*(UINT64 *)ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx + Symbol->Value] = Value;
return;
case SYMBOL_FUNCTION_PARAMETER_ID_TYPE:
ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackBaseIndx - 3 - Symbol->Value] = Value;
return;
}
2022-06-29 16:13:40 -07:00
}
2022-06-30 15:31:34 -07:00
/**
* @brief Get the operator name
*
* @param OperatorSymbol
* @param BufferForName
* @return VOID
2022-06-30 15:31:34 -07:00
*/
2022-06-29 16:13:40 -07:00
VOID
ScriptEngineGetOperatorName(PSYMBOL OperatorSymbol, CHAR * BufferForName)
{
switch (OperatorSymbol->Value)
{
case FUNC_POI:
memcpy(BufferForName, "poi", 3);
break;
case FUNC_DB:
memcpy(BufferForName, "db", 2);
break;
case FUNC_DD:
memcpy(BufferForName, "dd", 2);
break;
case FUNC_DW:
memcpy(BufferForName, "dw", 2);
break;
case FUNC_DQ:
memcpy(BufferForName, "dq", 2);
break;
case FUNC_HI:
memcpy(BufferForName, "hi", 2);
break;
case FUNC_LOW:
memcpy(BufferForName, "low", 3);
break;
2025-02-20 17:45:21 +01:00
case FUNC_POI_PA:
memcpy(BufferForName, "poi_pa", 6);
break;
case FUNC_DB_PA:
memcpy(BufferForName, "db_pa", 5);
break;
case FUNC_DD_PA:
memcpy(BufferForName, "dd_pa", 5);
break;
case FUNC_DW_PA:
memcpy(BufferForName, "dw_pa", 5);
break;
case FUNC_DQ_PA:
memcpy(BufferForName, "dq_pa", 5);
break;
case FUNC_HI_PA:
memcpy(BufferForName, "hi_pa", 5);
break;
case FUNC_LOW_PA:
memcpy(BufferForName, "low_pa", 6);
break;
2022-06-29 16:13:40 -07:00
default:
memcpy(BufferForName, "error", 5);
break;
}
}
2022-06-30 15:31:34 -07:00
/**
* @brief Execute the script buffer
*
2022-06-30 15:31:34 -07:00
* @param GuestRegs General purpose registers
* @param ActionDetail Detail of the specific action
2024-07-24 21:25:55 +08:00
* @param ScriptGeneralRegisters of core specific (and global) variable holders
2022-06-30 15:31:34 -07:00
* @param CodeBuffer The script buffer to be executed
* @param Indx Script Buffer index
* @param ErrorOperator Error in operator
* @return BOOL
2022-06-30 15:31:34 -07:00
*/
2022-06-29 16:13:40 -07:00
BOOL
2024-07-24 21:25:55 +08:00
ScriptEngineExecute(PGUEST_REGS GuestRegs,
ACTION_BUFFER * ActionDetail,
PSCRIPT_ENGINE_GENERAL_REGISTERS ScriptGeneralRegisters,
SYMBOL_BUFFER * CodeBuffer,
UINT64 * Indx,
SYMBOL * ErrorOperator)
2022-06-29 16:13:40 -07:00
{
PSYMBOL Operator;
PSYMBOL Src0;
PSYMBOL Src1;
PSYMBOL Src2;
PSYMBOL Des;
UINT64 SrcVal0;
UINT64 SrcVal1;
UINT64 SrcVal2;
UINT64 DesVal;
BOOL HasError = FALSE;
Operator = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*ErrorOperator = *Operator;
*Indx = *Indx + 1;
if (Operator->Type != SYMBOL_SEMANTIC_RULE_TYPE)
{
#ifdef SCRIPT_ENGINE_USER_MODE
ShowMessages("err, expecting operator type\n");
return HasError;
#endif // SCRIPT_ENGINE_USER_MODE
};
switch (Operator->Value)
{
case FUNC_ED:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-03-01 22:27:09 +09:00
DesVal = ScriptEngineFunctionEd(SrcVal1, (DWORD)SrcVal0, &HasError);
2022-06-29 16:13:40 -07:00
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_EB:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-03-01 21:02:52 +09:00
DesVal = ScriptEngineFunctionEb(SrcVal1, (BYTE)SrcVal0, &HasError);
2022-06-29 16:13:40 -07:00
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_EQ:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionEq(SrcVal1, SrcVal0, &HasError);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
2025-02-20 16:16:23 +01:00
case FUNC_ED_PA:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionEdPa(SrcVal1, (DWORD)SrcVal0, &HasError);
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
case FUNC_EB_PA:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionEbPa(SrcVal1, (BYTE)SrcVal0, &HasError);
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
case FUNC_EQ_PA:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionEqPa(SrcVal1, SrcVal0, &HasError);
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
2022-06-29 16:13:40 -07:00
case FUNC_INTERLOCKED_EXCHANGE:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionInterlockedExchange((volatile long long *)SrcVal1, SrcVal0, &HasError);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_INTERLOCKED_EXCHANGE_ADD:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionInterlockedExchangeAdd((volatile long long *)SrcVal1, SrcVal0, &HasError);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_INTERLOCKED_COMPARE_EXCHANGE:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal2 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionInterlockedCompareExchange((volatile long long *)SrcVal2, SrcVal1, SrcVal0, &HasError);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_EVENT_INJECT_ERROR_CODE:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal2 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-03-01 22:27:09 +09:00
ScriptEngineFunctionEventInjectErrorCode((UINT32)SrcVal2, (UINT32)SrcVal1, (UINT32)SrcVal0, &HasError);
break;
case FUNC_MEMCPY:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal2 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
2024-03-01 22:27:09 +09:00
ScriptEngineFunctionMemcpy(SrcVal2, SrcVal1, (UINT32)SrcVal0, &HasError);
break;
2025-02-20 15:48:22 +01:00
case FUNC_MEMCPY_PA:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal2 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
ScriptEngineFunctionMemcpyPa(SrcVal2, SrcVal1, (UINT32)SrcVal0, &HasError);
break;
2022-06-29 16:13:40 -07:00
case FUNC_SPINLOCK_LOCK_CUSTOM_WAIT:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
2024-03-01 22:27:09 +09:00
ScriptEngineFunctionSpinlockLockCustomWait((volatile long *)SrcVal1, (UINT32)SrcVal0, &HasError);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_EVENT_INJECT:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2024-03-01 22:27:09 +09:00
ScriptEngineFunctionEventInject((UINT32)SrcVal1, (UINT32)SrcVal0, &HasError);
break;
2022-06-29 16:13:40 -07:00
case FUNC_PAUSE:
ScriptEngineFunctionPause(ActionDetail,
GuestRegs);
break;
2022-06-29 16:13:40 -07:00
case FUNC_LBR_CHECK:
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionLbrCheck();
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
case FUNC_LBR_SAVE:
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionLbrSave();
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
case FUNC_LBR_PRINT:
2026-05-04 00:29:54 +02:00
case FUNC_LBR_DUMP:
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionLbrPrint();
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
case FUNC_LBR_RESTORE:
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionLbrRestore();
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
case FUNC_LBR_RESTORE_BY_FILTER:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionLbrRestoreByFilter((unsigned long long)SrcVal0);
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
2022-06-29 16:13:40 -07:00
case FUNC_FLUSH:
ScriptEngineFunctionFlush();
break;
2022-06-29 16:13:40 -07:00
2023-11-04 15:15:56 +09:00
case FUNC_EVENT_TRACE_INSTRUMENTATION_STEP:
case FUNC_EVENT_TRACE_INSTRUMENTATION_STEP_IN:
ScriptEngineFunctionEventTraceInstrumentationStep();
break;
case FUNC_EVENT_TRACE_STEP:
case FUNC_EVENT_TRACE_STEP_IN:
2023-11-15 13:44:57 +09:00
ScriptEngineFunctionEventTraceStepIn();
break;
2023-11-04 15:15:56 +09:00
case FUNC_EVENT_TRACE_STEP_OUT:
//
// To be implemented!
//
break;
2022-10-04 10:20:15 +09:00
case FUNC_EVENT_SC:
2022-06-29 16:13:40 -07:00
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
ScriptEngineFunctionShortCircuitingEvent(SrcVal0, ActionDetail);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_OR:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = SrcVal1 | SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_INC:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
DesVal = SrcVal0 + 1;
Des = Src0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_DEC:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
DesVal = SrcVal0 - 1;
Des = Src0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_XOR:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = SrcVal1 ^ SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_AND:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = SrcVal1 & SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_ASR:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = SrcVal1 >> SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_ASL:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = SrcVal1 << SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_ADD:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = SrcVal1 + SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_SUB:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = SrcVal1 - SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_MUL:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = SrcVal1 * SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_DIV:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
if (SrcVal0 == 0)
{
HasError = TRUE;
break;
2022-06-29 16:13:40 -07:00
}
DesVal = SrcVal1 / SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_MOD:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
if (SrcVal0 == 0)
{
HasError = TRUE;
break;
2022-06-29 16:13:40 -07:00
}
DesVal = SrcVal1 % SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_GT:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = (INT64)SrcVal1 > (INT64)SrcVal0;
2022-06-29 16:13:40 -07:00
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_LT:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = (INT64)SrcVal1 < (INT64)SrcVal0;
2022-06-29 16:13:40 -07:00
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_EGT:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = (INT64)SrcVal1 >= (INT64)SrcVal0;
2022-06-29 16:13:40 -07:00
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_ELT:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = (INT64)SrcVal1 <= (INT64)SrcVal0;
2022-06-29 16:13:40 -07:00
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_EQUAL:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = SrcVal1 == SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_NEQ:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = SrcVal1 != SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_POI:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-07-24 21:25:55 +08:00
DesVal = ScriptEngineKeywordPoi((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
2022-06-29 16:13:40 -07:00
&HasError);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_DB:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-07-24 21:25:55 +08:00
DesVal = ScriptEngineKeywordDb((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
2022-06-29 16:13:40 -07:00
&HasError);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_DD:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-07-24 21:25:55 +08:00
DesVal = ScriptEngineKeywordDd((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
2022-06-29 16:13:40 -07:00
&HasError);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_DW:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-07-24 21:25:55 +08:00
DesVal = ScriptEngineKeywordDw((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
2022-06-29 16:13:40 -07:00
&HasError);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_DQ:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-07-24 21:25:55 +08:00
DesVal = ScriptEngineKeywordDq((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
2022-06-29 16:13:40 -07:00
&HasError);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_POI_PA:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineKeywordPoiPa((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
&HasError);
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
case FUNC_DB_PA:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineKeywordDbPa((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
&HasError);
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
case FUNC_DD_PA:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineKeywordDdPa((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
&HasError);
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
case FUNC_DW_PA:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineKeywordDwPa((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
&HasError);
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
case FUNC_DQ_PA:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineKeywordDqPa((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
&HasError);
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
2022-06-29 16:13:40 -07:00
case FUNC_NOT:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ~SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_REFERENCE:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
//
// It's reference, we need an address
//
2024-07-24 21:25:55 +08:00
SrcVal0 = GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, TRUE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_PHYSICAL_TO_VIRTUAL:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-07-24 21:25:55 +08:00
DesVal = ScriptEngineFunctionPhysicalToVirtual(GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE));
2022-06-29 16:13:40 -07:00
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_VIRTUAL_TO_PHYSICAL:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-07-24 21:25:55 +08:00
DesVal = ScriptEngineFunctionVirtualToPhysical(GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE));
2022-06-29 16:13:40 -07:00
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_CHECK_ADDRESS:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
if (ScriptEngineFunctionCheckAddress(SrcVal0, sizeof(BYTE)))
DesVal = 1; // TRUE
else
DesVal = 0; // FALSE
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_STRLEN:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
if (Src0->Type == SYMBOL_STRING_TYPE)
{
*Indx =
*Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src0->Len) /
sizeof(SYMBOL));
SrcVal0 = (UINT64)&Src0->Value;
}
else
{
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
}
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionStrlen((const char *)SrcVal0);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_DISASSEMBLE_LEN:
case FUNC_DISASSEMBLE_LEN64:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-03-01 18:11:24 +09:00
DesVal = ScriptEngineFunctionDisassembleLen((PVOID)SrcVal0, FALSE);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
case FUNC_DISASSEMBLE_LEN32:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-03-01 18:11:24 +09:00
DesVal = ScriptEngineFunctionDisassembleLen((PVOID)SrcVal0, TRUE);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
2022-06-29 16:13:40 -07:00
case FUNC_WCSLEN:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
if (Src0->Type == SYMBOL_WSTRING_TYPE)
{
*Indx =
*Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src0->Len) /
sizeof(SYMBOL));
SrcVal0 = (UINT64)&Src0->Value;
}
else
{
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
}
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionWcslen((const wchar_t *)SrcVal0);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
2025-06-02 11:26:48 +02:00
case FUNC_MICROSLEEP:
2025-06-04 20:10:20 +02:00
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
2025-06-02 11:26:48 +02:00
*Indx = *Indx + 1;
SrcVal0 =
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
ScriptEngineFunctionMicroSleep(SrcVal0);
break;
2025-06-03 10:00:08 +02:00
case FUNC_RDTSC:
2025-06-04 20:10:20 +02:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
2025-06-03 10:00:08 +02:00
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionRdtsc();
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2025-06-04 20:10:20 +02:00
2025-06-03 10:00:08 +02:00
break;
case FUNC_RDTSCP:
2025-06-04 20:10:20 +02:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
2025-06-03 10:00:08 +02:00
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionRdtscp();
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
2022-06-29 16:13:40 -07:00
case FUNC_INTERLOCKED_INCREMENT:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionInterlockedIncrement((volatile long long *)SrcVal0, &HasError);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_INTERLOCKED_DECREMENT:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionInterlockedDecrement((volatile long long *)SrcVal0, &HasError);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_NEG:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = -(INT64)SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_HI:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-07-24 21:25:55 +08:00
DesVal = ScriptEngineKeywordHi((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
2022-06-29 16:13:40 -07:00
&HasError);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_LOW:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-07-24 21:25:55 +08:00
DesVal = ScriptEngineKeywordLow((PUINT64)GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE),
2022-06-29 16:13:40 -07:00
&HasError);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_MOV:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = SrcVal0;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_PRINT:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
//
// Call the target function
//
ScriptEngineFunctionPrint(ActionDetail->Tag,
ActionDetail->ImmediatelySendTheResults,
SrcVal0);
break;
2022-06-29 16:13:40 -07:00
case FUNC_TEST_STATEMENT:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
//
// Call the target function
//
ScriptEngineFunctionTestStatement(ActionDetail->Tag,
ActionDetail->ImmediatelySendTheResults,
SrcVal0);
break;
2022-06-29 16:13:40 -07:00
case FUNC_SPINLOCK_LOCK:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
//
// Call the target function
//
ScriptEngineFunctionSpinlockLock((volatile LONG *)SrcVal0, &HasError);
break;
2022-06-29 16:13:40 -07:00
case FUNC_SPINLOCK_UNLOCK:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
//
// Call the target function
//
ScriptEngineFunctionSpinlockUnlock((volatile LONG *)SrcVal0, &HasError);
break;
2022-06-29 16:13:40 -07:00
2023-10-22 01:14:36 +09:00
case FUNC_EVENT_ENABLE:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2023-10-22 01:14:36 +09:00
ScriptEngineFunctionEventEnable(SrcVal0);
break;
2022-06-29 16:13:40 -07:00
case FUNC_EVENT_DISABLE:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
2023-10-22 01:14:36 +09:00
ScriptEngineFunctionEventDisable(SrcVal0);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
2023-10-22 01:14:36 +09:00
case FUNC_EVENT_CLEAR:
2022-06-29 16:13:40 -07:00
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
2023-10-22 01:14:36 +09:00
ScriptEngineFunctionEventClear(SrcVal0);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
case FUNC_FORMATS:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
//
// Call the target function
//
ScriptEngineFunctionFormats(
ActionDetail->Tag,
ActionDetail->ImmediatelySendTheResults,
SrcVal0);
break;
2022-06-29 16:13:40 -07:00
case FUNC_JZ:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
if (SrcVal1 == 0)
*Indx = SrcVal0;
break;
2022-06-29 16:13:40 -07:00
case FUNC_JNZ:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
2022-06-29 16:13:40 -07:00
if (SrcVal1 != 0)
*Indx = SrcVal0;
break;
2022-06-29 16:13:40 -07:00
case FUNC_JMP:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2022-06-29 16:13:40 -07:00
*Indx = SrcVal0;
break;
2022-06-29 16:13:40 -07:00
case FUNC_PUSH:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackIndx] = SrcVal0;
2024-07-24 21:25:55 +08:00
ScriptGeneralRegisters->StackIndx++;
break;
case FUNC_POP:
2024-07-24 21:25:55 +08:00
ScriptGeneralRegisters->StackIndx--;
SrcVal0 = ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackIndx];
2024-07-24 21:25:55 +08:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, SrcVal0);
break;
case FUNC_CALL:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
*Indx = *Indx + 1;
ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackIndx] = *Indx;
2024-07-24 21:25:55 +08:00
ScriptGeneralRegisters->StackIndx++;
*Indx = SrcVal0;
break;
case FUNC_RET:
2024-07-24 21:25:55 +08:00
ScriptGeneralRegisters->StackIndx--;
*Indx = ScriptGeneralRegisters->StackBuffer[ScriptGeneralRegisters->StackIndx];
break;
2023-09-16 03:54:56 +08:00
case FUNC_STRCMP:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
if (Src0->Type == SYMBOL_STRING_TYPE)
{
*Indx =
*Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src0->Len) /
sizeof(SYMBOL));
SrcVal0 = (UINT64)&Src0->Value;
}
else
{
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
}
2023-09-16 03:54:56 +08:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
if (Src1->Type == SYMBOL_STRING_TYPE)
{
*Indx =
*Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src1->Len) /
sizeof(SYMBOL));
SrcVal1 = (UINT64)&Src1->Value;
}
else
{
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
}
2023-09-16 03:54:56 +08:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionStrcmp((const char *)SrcVal1, (const char *)SrcVal0);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2023-09-16 03:54:56 +08:00
break;
2023-09-20 12:06:10 +08:00
case FUNC_WCSCMP:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
if (Src0->Type == SYMBOL_WSTRING_TYPE)
{
*Indx =
*Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src0->Len) /
sizeof(SYMBOL));
SrcVal0 = (UINT64)&Src0->Value;
}
else
{
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
}
2023-09-20 12:06:10 +08:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
if (Src1->Type == SYMBOL_WSTRING_TYPE)
{
*Indx =
*Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src1->Len) /
sizeof(SYMBOL));
SrcVal1 = (UINT64)&Src1->Value;
}
else
{
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
}
2023-09-20 12:06:10 +08:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionWcscmp((const wchar_t *)SrcVal1, (const wchar_t *)SrcVal0);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2023-09-20 12:06:10 +08:00
break;
2023-09-29 23:39:13 +08:00
case FUNC_MEMCMP:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
2023-09-29 23:39:13 +08:00
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
if (Src1->Type == SYMBOL_STRING_TYPE)
{
*Indx =
*Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src1->Len) /
sizeof(SYMBOL));
SrcVal1 = (UINT64)&Src1->Value;
}
else
{
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
}
2023-09-29 23:39:13 +08:00
Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
if (Src2->Type == SYMBOL_STRING_TYPE)
{
*Indx =
*Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src2->Len) /
sizeof(SYMBOL));
SrcVal2 = (UINT64)&Src2->Value;
}
else
{
SrcVal2 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
}
2023-09-29 23:39:13 +08:00
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionMemcmp((const char *)SrcVal2, (const char *)SrcVal1, SrcVal0);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
2023-09-29 23:39:13 +08:00
break;
case FUNC_STRNCMP:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
if (Src1->Type == SYMBOL_STRING_TYPE)
{
*Indx =
*Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src1->Len) /
sizeof(SYMBOL));
SrcVal1 = (UINT64)&Src1->Value;
}
else
{
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
}
Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
if (Src2->Type == SYMBOL_STRING_TYPE)
{
*Indx =
*Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src2->Len) /
sizeof(SYMBOL));
SrcVal2 = (UINT64)&Src2->Value;
}
else
{
SrcVal2 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
}
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionStrncmp((const char *)SrcVal2, (const char *)SrcVal1, SrcVal0);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
case FUNC_WCSNCMP:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
SrcVal0 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src0, FALSE);
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-06-14 02:56:07 +08:00
if (Src1->Type == SYMBOL_WSTRING_TYPE)
{
*Indx =
*Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src1->Len) /
sizeof(SYMBOL));
SrcVal1 = (UINT64)&Src1->Value;
}
else
{
SrcVal1 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src1, FALSE);
}
Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-06-14 02:56:07 +08:00
if (Src2->Type == SYMBOL_WSTRING_TYPE)
{
*Indx =
*Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src2->Len) /
sizeof(SYMBOL));
SrcVal2 = (UINT64)&Src2->Value;
}
else
{
SrcVal2 =
2024-07-24 21:25:55 +08:00
GetValue(GuestRegs, ActionDetail, ScriptGeneralRegisters, Src2, FALSE);
}
Des = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
DesVal = ScriptEngineFunctionWcsncmp((const wchar_t *)SrcVal2, (const wchar_t *)SrcVal1, SrcVal0);
2024-07-24 21:25:55 +08:00
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
break;
2022-06-29 16:13:40 -07:00
case FUNC_PRINTF:
Src0 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
//
// Call the target function
//
*Indx =
*Indx + ((SIZE_SYMBOL_WITHOUT_LEN + Src0->Len) /
2022-06-29 16:13:40 -07:00
sizeof(SYMBOL));
Src1 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + 1;
2024-03-01 22:27:09 +09:00
Src2 = NULL;
2022-06-29 16:13:40 -07:00
if (Src1->Value > 0)
{
Src2 = (PSYMBOL)((unsigned long long)CodeBuffer->Head +
(unsigned long long)(*Indx * sizeof(SYMBOL)));
*Indx = *Indx + Src1->Value;
}
ScriptEngineFunctionPrintf(
GuestRegs,
ActionDetail,
2024-07-24 21:25:55 +08:00
ScriptGeneralRegisters,
2022-06-29 16:13:40 -07:00
ActionDetail->Tag,
ActionDetail->ImmediatelySendTheResults,
(char *)&Src0->Value,
Src1->Value,
Src2,
2024-07-24 21:25:55 +08:00
(BOOLEAN *)&HasError);
2022-06-29 16:13:40 -07:00
break;
2022-06-29 16:13:40 -07:00
}
//
// Return the result of whether error detected or not
//
return HasError;
2022-06-29 16:13:40 -07:00
}