mirror of
https://github.com/HyperDbg/HyperDbg.git
synced 2026-07-09 17:19:26 +00:00
fix #587 to add functions with no input and return a number
This commit is contained in:
parent
686e445c9b
commit
a8f259fbad
8 changed files with 873 additions and 764 deletions
|
|
@ -14,9 +14,11 @@ New release of the HyperDbg Debugger.
|
|||
- Added Architectural LBR support to the HyperTrace module
|
||||
- Added the '!lbr' command for performing different Last Branch Record (LBR) operations ([link](https://docs.hyperdbg.org/commands/extension-commands/lbr))
|
||||
- Added the '!lbrdump' command for dumping saved Last Branch Record (LBR) entries ([link](https://docs.hyperdbg.org/commands/extension-commands/lbrdmp))
|
||||
- Added **lbr_save()** and **lbr_print()** functions in the script engine ([link](https://docs.hyperdbg.org/commands/scripting-language/functions/tracing/lbr_save))([link](https://docs.hyperdbg.org/commands/scripting-language/functions/tracing/lbr_print))
|
||||
- Added **lbr_save()** and **lbr_print()** functions in the script engine ([link](https://docs.hyperdbg.org/commands/scripting-language/functions/tracing/lbr/lbr_save))([link](https://docs.hyperdbg.org/commands/scripting-language/functions/tracing/lbr/lbr_print))
|
||||
- Added mock application for compiling SDK for Linux
|
||||
- Add '!help' alias for the '.help' command
|
||||
- Added **lbr_check()** and **lbr_restore()** functions in the script engine ([link](https://docs.hyperdbg.org/commands/scripting-language/functions/tracing/lbr/lbr_check))([link](https://docs.hyperdbg.org/commands/scripting-language/functions/tracing/lbr/lbr_restore))
|
||||
- Added **lbr_restore_by_filter(filter)** function in the script engine ([link](https://docs.hyperdbg.org/commands/scripting-language/functions/tracing/lbr/lbr_restore_by_filter))
|
||||
|
||||
### Changed
|
||||
- Fix the problem of not applying the EAX index in the CPUID event extension command ([link](https://docs.hyperdbg.org/commands/extension-commands/cpuid#parameters))
|
||||
|
|
|
|||
|
|
@ -45,6 +45,6 @@ object ScriptConstantTypes {
|
|||
|
||||
object ScriptEvalFunc {
|
||||
object ScriptOperators extends ChiselEnum {
|
||||
val sFuncUndefined, sFuncInc, sFuncDec, sFuncReference, sFuncOr, sFuncXor, sFuncAnd, sFuncAsr, sFuncAsl, sFuncAdd, sFuncSub, sFuncMul, sFuncDiv, sFuncMod, sFuncGt, sFuncLt, sFuncEgt, sFuncElt, sFuncEqual, sFuncNeq, sFuncJmp, sFuncJz, sFuncJnz, sFuncMov, sFuncStart_of_do_while, sFuncStart_of_do_while_commands, sFuncEnd_of_do_while, sFuncStart_of_for, sFuncFor_inc_dec, sFuncStart_of_for_ommands, sFuncEnd_of_if, sFuncIgnore_lvalue, sFuncPush, sFuncPop, sFuncCall, sFuncRet, sFuncPrint, sFuncFormats, sFuncEvent_enable, sFuncEvent_disable, sFuncEvent_clear, sFuncTest_statement, sFuncSpinlock_lock, sFuncSpinlock_unlock, sFuncEvent_sc, sFuncMicrosleep, sFuncPrintf, sFuncPause, sFuncFlush, sFuncEvent_trace_step, sFuncEvent_trace_step_in, sFuncEvent_trace_step_out, sFuncEvent_trace_instrumentation_step, sFuncEvent_trace_instrumentation_step_in, sFuncLbr_check, sFuncRdtsc, sFuncRdtscp, sFuncLbr_save, sFuncLbr_dump, sFuncLbr_print, sFuncLbr_restore, sFuncSpinlock_lock_custom_wait, sFuncEvent_inject, sFuncPoi, sFuncDb, sFuncDd, sFuncDw, sFuncDq, sFuncNeg, sFuncHi, sFuncLow, sFuncNot, sFuncCheck_address, sFuncDisassemble_len, sFuncDisassemble_len32, sFuncDisassemble_len64, sFuncInterlocked_increment, sFuncInterlocked_decrement, sFuncPhysical_to_virtual, sFuncVirtual_to_physical, sFuncPoi_pa, sFuncHi_pa, sFuncLow_pa, sFuncDb_pa, sFuncDd_pa, sFuncDw_pa, sFuncDq_pa, sFuncLbr_restore_by_filter, sFuncEd, sFuncEb, sFuncEq, sFuncInterlocked_exchange, sFuncInterlocked_exchange_add, sFuncEb_pa, sFuncEd_pa, sFuncEq_pa, sFuncInterlocked_compare_exchange, sFuncStrlen, sFuncStrcmp, sFuncMemcmp, sFuncStrncmp, sFuncWcslen, sFuncWcscmp, sFuncEvent_inject_error_code, sFuncMemcpy, sFuncMemcpy_pa, sFuncWcsncmp = Value
|
||||
val sFuncUndefined, sFuncInc, sFuncDec, sFuncReference, sFuncOr, sFuncXor, sFuncAnd, sFuncAsr, sFuncAsl, sFuncAdd, sFuncSub, sFuncMul, sFuncDiv, sFuncMod, sFuncGt, sFuncLt, sFuncEgt, sFuncElt, sFuncEqual, sFuncNeq, sFuncJmp, sFuncJz, sFuncJnz, sFuncMov, sFuncStart_of_do_while, sFuncStart_of_do_while_commands, sFuncEnd_of_do_while, sFuncStart_of_for, sFuncFor_inc_dec, sFuncStart_of_for_ommands, sFuncEnd_of_if, sFuncIgnore_lvalue, sFuncPush, sFuncPop, sFuncCall, sFuncRet, sFuncPrint, sFuncFormats, sFuncEvent_enable, sFuncEvent_disable, sFuncEvent_clear, sFuncTest_statement, sFuncSpinlock_lock, sFuncSpinlock_unlock, sFuncEvent_sc, sFuncMicrosleep, sFuncPrintf, sFuncPause, sFuncFlush, sFuncEvent_trace_step, sFuncEvent_trace_step_in, sFuncEvent_trace_step_out, sFuncEvent_trace_instrumentation_step, sFuncEvent_trace_instrumentation_step_in, sFuncRdtsc, sFuncRdtscp, sFuncLbr_save, sFuncLbr_dump, sFuncLbr_print, sFuncLbr_restore, sFuncLbr_check, sFuncSpinlock_lock_custom_wait, sFuncEvent_inject, sFuncPoi, sFuncDb, sFuncDd, sFuncDw, sFuncDq, sFuncNeg, sFuncHi, sFuncLow, sFuncNot, sFuncCheck_address, sFuncDisassemble_len, sFuncDisassemble_len32, sFuncDisassemble_len64, sFuncInterlocked_increment, sFuncInterlocked_decrement, sFuncPhysical_to_virtual, sFuncVirtual_to_physical, sFuncPoi_pa, sFuncHi_pa, sFuncLow_pa, sFuncDb_pa, sFuncDd_pa, sFuncDw_pa, sFuncDq_pa, sFuncLbr_restore_by_filter, sFuncEd, sFuncEb, sFuncEq, sFuncInterlocked_exchange, sFuncInterlocked_exchange_add, sFuncEb_pa, sFuncEd_pa, sFuncEq_pa, sFuncInterlocked_compare_exchange, sFuncStrlen, sFuncStrcmp, sFuncMemcmp, sFuncStrncmp, sFuncWcslen, sFuncWcscmp, sFuncEvent_inject_error_code, sFuncMemcpy, sFuncMemcpy_pa, sFuncWcsncmp = Value
|
||||
}
|
||||
}
|
||||
|
|
@ -148,13 +148,13 @@ static const char *const SymbolTypeNames[] = {
|
|||
#define FUNC_EVENT_TRACE_STEP_OUT 51
|
||||
#define FUNC_EVENT_TRACE_INSTRUMENTATION_STEP 52
|
||||
#define FUNC_EVENT_TRACE_INSTRUMENTATION_STEP_IN 53
|
||||
#define FUNC_LBR_CHECK 54
|
||||
#define FUNC_RDTSC 55
|
||||
#define FUNC_RDTSCP 56
|
||||
#define FUNC_LBR_SAVE 57
|
||||
#define FUNC_LBR_DUMP 58
|
||||
#define FUNC_LBR_PRINT 59
|
||||
#define FUNC_LBR_RESTORE 60
|
||||
#define FUNC_RDTSC 54
|
||||
#define FUNC_RDTSCP 55
|
||||
#define FUNC_LBR_SAVE 56
|
||||
#define FUNC_LBR_DUMP 57
|
||||
#define FUNC_LBR_PRINT 58
|
||||
#define FUNC_LBR_RESTORE 59
|
||||
#define FUNC_LBR_CHECK 60
|
||||
#define FUNC_SPINLOCK_LOCK_CUSTOM_WAIT 61
|
||||
#define FUNC_EVENT_INJECT 62
|
||||
#define FUNC_POI 63
|
||||
|
|
@ -257,13 +257,13 @@ static const char *const FunctionNames[] = {
|
|||
"FUNC_EVENT_TRACE_STEP_OUT",
|
||||
"FUNC_EVENT_TRACE_INSTRUMENTATION_STEP",
|
||||
"FUNC_EVENT_TRACE_INSTRUMENTATION_STEP_IN",
|
||||
"FUNC_LBR_CHECK",
|
||||
"FUNC_RDTSC",
|
||||
"FUNC_RDTSCP",
|
||||
"FUNC_LBR_SAVE",
|
||||
"FUNC_LBR_DUMP",
|
||||
"FUNC_LBR_PRINT",
|
||||
"FUNC_LBR_RESTORE",
|
||||
"FUNC_LBR_CHECK",
|
||||
"FUNC_SPINLOCK_LOCK_CUSTOM_WAIT",
|
||||
"FUNC_EVENT_INJECT",
|
||||
"FUNC_POI",
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,19 +1,19 @@
|
|||
#pragma once
|
||||
#ifndef PARSE_TABLE_H
|
||||
#define PARSE_TABLE_H
|
||||
#define RULES_COUNT 283
|
||||
#define RULES_COUNT 284
|
||||
#define TERMINAL_COUNT 128
|
||||
#define NONETERMINAL_COUNT 63
|
||||
#define START_VARIABLE "S"
|
||||
#define MAX_RHS_LEN 15
|
||||
#define KEYWORD_LIST_LENGTH 120
|
||||
#define KEYWORD_LIST_LENGTH 121
|
||||
#define OPERATORS_ONE_OPERAND_LIST_LENGTH 3
|
||||
#define OPERATORS_TWO_OPERAND_LIST_LENGTH 16
|
||||
#define REGISTER_MAP_LIST_LENGTH 120
|
||||
#define PSEUDO_REGISTER_MAP_LIST_LENGTH 16
|
||||
#define SCRIPT_VARIABLE_TYPE_LIST_LENGTH 10
|
||||
#define ASSIGNMENT_OPERATOR_LIST_LENGTH 10
|
||||
#define SEMANTIC_RULES_MAP_LIST_LENGTH 165
|
||||
#define SEMANTIC_RULES_MAP_LIST_LENGTH 166
|
||||
#define THREEOPFUNC1_LENGTH 1
|
||||
#define THREEOPFUNC2_LENGTH 3
|
||||
#define TWOOPFUNC1_LENGTH 8
|
||||
|
|
@ -26,8 +26,8 @@
|
|||
#define THREEOPFUNC4_LENGTH 1
|
||||
#define ONEOPFUNC4_LENGTH 1
|
||||
#define TWOOPFUNC4_LENGTH 1
|
||||
#define ZEROOPFUNC1_LENGTH 8
|
||||
#define ZEROOPFUNC2_LENGTH 6
|
||||
#define ZEROOPFUNC1_LENGTH 7
|
||||
#define ZEROOPFUNC2_LENGTH 7
|
||||
#define VARARGFUNC1_LENGTH 1
|
||||
extern const struct _SCRIPT_ENGINE_TOKEN Lhs[RULES_COUNT];
|
||||
extern const struct _SCRIPT_ENGINE_TOKEN Rhs[RULES_COUNT][MAX_RHS_LEN];
|
||||
|
|
@ -60,11 +60,11 @@ extern const SYMBOL_MAP PseudoRegisterMapList[];
|
|||
extern const char* ScriptVariableTypeList[];
|
||||
|
||||
|
||||
#define LALR_RULES_COUNT 109
|
||||
#define LALR_TERMINAL_COUNT 78
|
||||
#define LALR_RULES_COUNT 117
|
||||
#define LALR_TERMINAL_COUNT 86
|
||||
#define LALR_NONTERMINAL_COUNT 26
|
||||
#define LALR_MAX_RHS_LEN 9
|
||||
#define LALR_STATE_COUNT 307
|
||||
#define LALR_STATE_COUNT 332
|
||||
extern const struct _SCRIPT_ENGINE_TOKEN LalrLhs[RULES_COUNT];
|
||||
extern const struct _SCRIPT_ENGINE_TOKEN LalrRhs[RULES_COUNT][MAX_RHS_LEN];
|
||||
extern const unsigned int LalrRhsSize[RULES_COUNT];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
# ZeroOpFunc2 no input and returns a number
|
||||
.ZeroOpFunc2->rdtsc rdtscp lbr_save lbr_dump lbr_print lbr_restore lbr_check
|
||||
|
||||
# OneOpFunc1 input is a number and returns a number.
|
||||
.OneOpFunc1->poi db dd dw dq neg hi low not check_address strlen wcslen disassemble_len disassemble_len32 disassemble_len64 interlocked_increment interlocked_decrement reference physical_to_virtual virtual_to_physical poi_pa hi_pa low_pa db_pa dd_pa dw_pa dq_pa
|
||||
.OneOpFunc1->poi db dd dw dq neg hi low not check_address strlen wcslen disassemble_len disassemble_len32 disassemble_len64 interlocked_increment interlocked_decrement reference physical_to_virtual virtual_to_physical poi_pa hi_pa low_pa db_pa dd_pa dw_pa dq_pa lbr_restore_by_filter
|
||||
|
||||
# TwoOpFunc1 inputs are two numbers and returns a number.
|
||||
.TwoOpFunc1->ed eb eq interlocked_exchange interlocked_exchange_add wcscmp eb_pa ed_pa eq_pa
|
||||
|
|
@ -82,7 +85,7 @@ E10->* E12 @POI
|
|||
E10->& E12 @REFERENCE
|
||||
|
||||
|
||||
|
||||
E12->.ZeroOpFunc2 ( ) @.ZeroOpFunc2
|
||||
E12->.OneOpFunc1 ( EXP ) @.OneOpFunc1
|
||||
E12->.TwoOpFunc1 ( EXP , EXP ) @.TwoOpFunc2
|
||||
E12->.ThreeOpFunc1 ( EXP , EXP , EXP ) @.ThreeOpFunc1
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@
|
|||
# TwoOpFunc4 the two inputs are numbers or wstrings and returns a number.
|
||||
.TwoOpFunc4->wcscmp
|
||||
|
||||
.ZeroOpFunc1->pause flush event_trace_step event_trace_step_in event_trace_step_out event_trace_instrumentation_step event_trace_instrumentation_step_in lbr_check
|
||||
.ZeroOpFunc1->pause flush event_trace_step event_trace_step_in event_trace_step_out event_trace_instrumentation_step event_trace_instrumentation_step_in
|
||||
|
||||
# ZeroOpFunc2 no input and returns a number
|
||||
.ZeroOpFunc2->rdtsc rdtscp lbr_save lbr_dump lbr_print lbr_restore
|
||||
.ZeroOpFunc2->rdtsc rdtscp lbr_save lbr_dump lbr_print lbr_restore lbr_check
|
||||
|
||||
.VarArgFunc1->printf
|
||||
|
||||
|
|
|
|||
|
|
@ -734,13 +734,19 @@ ScriptEngineExecute(PGUEST_REGS GuestRegs,
|
|||
|
||||
ScriptEngineFunctionPause(ActionDetail,
|
||||
GuestRegs);
|
||||
|
||||
break;
|
||||
|
||||
case FUNC_LBR_CHECK:
|
||||
|
||||
//
|
||||
// To be implemented!
|
||||
//
|
||||
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:
|
||||
|
|
@ -752,6 +758,7 @@ ScriptEngineExecute(PGUEST_REGS GuestRegs,
|
|||
DesVal = ScriptEngineFunctionLbrSave();
|
||||
|
||||
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
|
||||
|
||||
break;
|
||||
|
||||
case FUNC_LBR_PRINT:
|
||||
|
|
@ -764,6 +771,7 @@ ScriptEngineExecute(PGUEST_REGS GuestRegs,
|
|||
DesVal = ScriptEngineFunctionLbrPrint();
|
||||
|
||||
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
|
||||
|
||||
break;
|
||||
|
||||
case FUNC_LBR_RESTORE:
|
||||
|
|
@ -775,6 +783,7 @@ ScriptEngineExecute(PGUEST_REGS GuestRegs,
|
|||
DesVal = ScriptEngineFunctionLbrRestore();
|
||||
|
||||
SetValue(GuestRegs, ScriptGeneralRegisters, Des, DesVal);
|
||||
|
||||
break;
|
||||
|
||||
case FUNC_LBR_RESTORE_BY_FILTER:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue