mirror of
https://github.com/HyperDbg/HyperDbg.git
synced 2026-07-09 17:19:26 +00:00
54 lines
1.2 KiB
C
54 lines
1.2 KiB
C
/**
|
|
* @file ScriptEngine.c
|
|
* @author M.H. Gholamrezaei (mh@hyperdbg.org)
|
|
* @brief Script engine parser and wrapper functions
|
|
* @details
|
|
* @version 0.1
|
|
* @date 2020-10-22
|
|
*
|
|
* @copyright This project is released under the GNU Public License v3.
|
|
*
|
|
*/
|
|
#include "pch.h"
|
|
|
|
/**
|
|
* @brief Get current ip from the debugger frame
|
|
*
|
|
* @return UINT64 returns the rip of the current debuggee state frame
|
|
*/
|
|
UINT64
|
|
ScriptEngineWrapperGetInstructionPointer()
|
|
{
|
|
UINT64 GuestRip = NULL;
|
|
ULONG CurrentProcessorIndex;
|
|
|
|
CurrentProcessorIndex = KeGetCurrentProcessorNumber();
|
|
|
|
//
|
|
// Check if we are in vmx-root or not
|
|
//
|
|
if (VmxGetCurrentExecutionMode() == TRUE)
|
|
{
|
|
__vmx_vmread(VMCS_GUEST_RIP, &GuestRip);
|
|
return GuestRip;
|
|
}
|
|
else
|
|
{
|
|
//
|
|
// Otherwise $ip doesn't mean anything
|
|
//
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief Get the address of reserved buffer
|
|
*
|
|
* @param Action Corresponding action
|
|
* @return UINT64 returns the requested buffer address from user
|
|
*/
|
|
UINT64
|
|
ScriptEngineWrapperGetAddressOfReservedBuffer(PDEBUGGER_EVENT_ACTION Action)
|
|
{
|
|
return Action->RequestedBuffer.RequstBufferAddress;
|
|
}
|