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

Script engine parser and wrapper functions. More...

#include "pch.h"

Functions

UINT64 ScriptEngineWrapperGetInstructionPointer ()
 Get current ip from the debugger frame.
 
UINT64 ScriptEngineWrapperGetAddressOfReservedBuffer (PDEBUGGER_EVENT_ACTION Action)
 Get the address of reserved buffer.
 
VOID ScriptEngineUpdateTargetCoreDateTime (PROCESSOR_DEBUGGING_STATE *DbgState)
 Create and update the target core date and time.
 
UINT64 ScriptEngineGetTargetCoreTime ()
 Update core's date time and return time.
 
UINT64 ScriptEngineGetTargetCoreDate ()
 Update core's date time and return date.
 

Detailed Description

Script engine parser and wrapper functions.

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

Function Documentation

◆ ScriptEngineGetTargetCoreDate()

UINT64 ScriptEngineGetTargetCoreDate ( )

Update core's date time and return date.

Returns
UINT64
110{
111 ULONG CurrentCore = KeGetCurrentProcessorNumberEx(NULL);
112 PROCESSOR_DEBUGGING_STATE * DbgState = &g_DbgState[CurrentCore];
113
114 //
115 // Update the core's date time
116 //
118
119 //
120 // Return the date
121 //
122 return (UINT64)&DbgState->DateTimeHolder.DateBuffer;
123}
unsigned __int64 UINT64
Definition BasicTypes.h:21
unsigned long ULONG
Definition BasicTypes.h:37
VOID ScriptEngineUpdateTargetCoreDateTime(PROCESSOR_DEBUGGING_STATE *DbgState)
Create and update the target core date and time.
Definition ScriptEngine.c:58
PROCESSOR_DEBUGGING_STATE * g_DbgState
Save the state and variables related to debugging on each to logical core.
Definition Global.h:17
CHAR DateBuffer[12]
Definition State.h:154
Saves the debugger state.
Definition State.h:165
DATE_TIME_HOLDER DateTimeHolder
Definition State.h:173

◆ ScriptEngineGetTargetCoreTime()

UINT64 ScriptEngineGetTargetCoreTime ( )

Update core's date time and return time.

Returns
UINT64
88{
89 ULONG CurrentCore = KeGetCurrentProcessorNumberEx(NULL);
90 PROCESSOR_DEBUGGING_STATE * DbgState = &g_DbgState[CurrentCore];
91
92 //
93 // Update the core's date time
94 //
96
97 //
98 // Return the time
99 //
100 return (UINT64)&DbgState->DateTimeHolder.TimeBuffer;
101}
CHAR TimeBuffer[14]
Definition State.h:153

◆ ScriptEngineUpdateTargetCoreDateTime()

VOID ScriptEngineUpdateTargetCoreDateTime ( PROCESSOR_DEBUGGING_STATE * DbgState)

Create and update the target core date and time.

Parameters
DbgStateThe processor debugging state
Returns
VOID
59{
60 LARGE_INTEGER SystemTime, LocalTime;
61 KeQuerySystemTime(&SystemTime);
62 ExSystemTimeToLocalTime(&SystemTime, &LocalTime);
63 RtlTimeToTimeFields(&LocalTime, &DbgState->DateTimeHolder.TimeFields);
64
65 sprintf_s(DbgState->DateTimeHolder.TimeBuffer,
66 RTL_NUMBER_OF(DbgState->DateTimeHolder.TimeBuffer),
67 "%02hd:%02hd:%02hd.%03hd",
68 DbgState->DateTimeHolder.TimeFields.Hour,
69 DbgState->DateTimeHolder.TimeFields.Minute,
70 DbgState->DateTimeHolder.TimeFields.Second,
71 DbgState->DateTimeHolder.TimeFields.Milliseconds);
72
73 sprintf_s(DbgState->DateTimeHolder.DateBuffer,
74 RTL_NUMBER_OF(DbgState->DateTimeHolder.DateBuffer),
75 "%04hd-%02hd-%02hd",
76 DbgState->DateTimeHolder.TimeFields.Year,
77 DbgState->DateTimeHolder.TimeFields.Month,
78 DbgState->DateTimeHolder.TimeFields.Day);
79}
TIME_FIELDS TimeFields
Definition State.h:152

◆ ScriptEngineWrapperGetAddressOfReservedBuffer()

UINT64 ScriptEngineWrapperGetAddressOfReservedBuffer ( PDEBUGGER_EVENT_ACTION Action)

Get the address of reserved buffer.

Parameters
ActionCorresponding action
Returns
UINT64 returns the requested buffer address from user
47{
49}
DEBUGGER_EVENT_REQUEST_BUFFER RequestedBuffer
Definition Debugger.h:92
UINT64 RequstBufferAddress
Definition RequestStructures.h:842

◆ ScriptEngineWrapperGetInstructionPointer()

UINT64 ScriptEngineWrapperGetInstructionPointer ( )

Get current ip from the debugger frame.

Returns
UINT64 returns the rip of the current debuggee state frame
22{
23 //
24 // Check if we are in vmx-root or not
25 //
27 {
28 return VmFuncGetRip();
29 }
30 else
31 {
32 //
33 // Otherwise $ip doesn't mean anything
34 //
35 return (UINT64)NULL;
36 }
37}
#define TRUE
Definition BasicTypes.h:55
BOOLEAN VmFuncVmxGetCurrentExecutionMode()
Get the current VMX operation state.
Definition Export.c:552
UINT64 VmFuncGetRip()
Read guest's RIP.
Definition Export.c:375
NULL()
Definition test-case-generator.py:530