diff --git a/hyperdbg/hprdbgctrl/code/app/hprdbgctrl.cpp b/hyperdbg/hprdbgctrl/code/app/hprdbgctrl.cpp index 15a3b3f8..bca9fac1 100644 --- a/hyperdbg/hprdbgctrl/code/app/hprdbgctrl.cpp +++ b/hyperdbg/hprdbgctrl/code/app/hprdbgctrl.cpp @@ -202,7 +202,7 @@ ReadIrpBasedBuffer() // // Error occured for second time, and we show the error message // - //ShowMessages("ioctl failed with code 0x%x\n", GetLastError()); + // ShowMessages("ioctl failed with code 0x%x\n", GetLastError()); // // if we reach here, the packet is probably failed, it might @@ -495,14 +495,14 @@ HyperdbgInstallVmmDriver() return 1; } - if (!ManageDriver(DRIVER_NAME, g_DriverLocation, DRIVER_FUNC_INSTALL)) + if (!ManageDriver(VMM_DRIVER_NAME, g_DriverLocation, DRIVER_FUNC_INSTALL)) { ShowMessages("unable to install driver\n"); // // Error - remove driver // - ManageDriver(DRIVER_NAME, g_DriverLocation, DRIVER_FUNC_REMOVE); + ManageDriver(VMM_DRIVER_NAME, g_DriverLocation, DRIVER_FUNC_REMOVE); return 1; } @@ -516,14 +516,14 @@ HyperdbgInstallVmmDriver() * @return int return zero if it was successful or non-zero if there * was error */ -HPRDBGCTRL_API int -HyperdbgStopDriver() +int +HyperdbgStopDriver(LPCTSTR DriverName) { // // Unload the driver if loaded // if (g_DriverLocation[0] != (TCHAR)0 && - ManageDriver(DRIVER_NAME, g_DriverLocation, DRIVER_FUNC_STOP)) + ManageDriver(DriverName, g_DriverLocation, DRIVER_FUNC_STOP)) { return 0; } @@ -534,19 +534,31 @@ HyperdbgStopDriver() } /** - * @brief Remove the driver + * @brief Stop VMM driver * * @return int return zero if it was successful or non-zero if there * was error */ HPRDBGCTRL_API int -HyperdbgUninstallDriver() +HyperdbgStopVmmDriver() +{ + return HyperdbgStopDriver(VMM_DRIVER_NAME); +} + +/** + * @brief Remove the driver + * + * @return int return zero if it was successful or non-zero if there + * was error + */ +int +HyperdbgUninstallDriver(LPCTSTR DriverName) { // // Unload the driver if loaded. Ignore any errors // if (g_DriverLocation[0] != (TCHAR)0 && - ManageDriver(DRIVER_NAME, g_DriverLocation, DRIVER_FUNC_REMOVE)) + ManageDriver(DriverName, g_DriverLocation, DRIVER_FUNC_REMOVE)) { return 0; } @@ -556,6 +568,18 @@ HyperdbgUninstallDriver() } } +/** + * @brief Remove the VMM driver + * + * @return int return zero if it was successful or non-zero if there + * was error + */ +HPRDBGCTRL_API int +HyperdbgUninstallVmmDriver() +{ + return HyperdbgUninstallDriver(VMM_DRIVER_NAME); +} + /** * @brief Load the driver * @@ -661,13 +685,13 @@ HyperdbgLoadVmm() } /** - * @brief Unload driver + * @brief Unload VMM driver * * @return int return zero if it was successful or non-zero if there * was error */ HPRDBGCTRL_API int -HyperdbgUnload() +HyperdbgUnloadVmm() { BOOL Status; diff --git a/hyperdbg/hprdbgctrl/code/debugger/commands/debugging-commands/exit.cpp b/hyperdbg/hprdbgctrl/code/debugger/commands/debugging-commands/exit.cpp index 64f5b958..b435f819 100644 --- a/hyperdbg/hprdbgctrl/code/debugger/commands/debugging-commands/exit.cpp +++ b/hyperdbg/hprdbgctrl/code/debugger/commands/debugging-commands/exit.cpp @@ -52,7 +52,7 @@ CommandExit(vector SplittedCommand, string Command) // if (g_DeviceHandle) { - HyperdbgUnload(); + HyperdbgUnloadVmm(); } exit(0); diff --git a/hyperdbg/hprdbgctrl/code/debugger/commands/debugging-commands/unload.cpp b/hyperdbg/hprdbgctrl/code/debugger/commands/debugging-commands/unload.cpp index f9b4bb81..71eaf7d4 100644 --- a/hyperdbg/hprdbgctrl/code/debugger/commands/debugging-commands/unload.cpp +++ b/hyperdbg/hprdbgctrl/code/debugger/commands/debugging-commands/unload.cpp @@ -80,7 +80,7 @@ CommandUnload(vector SplittedCommand, string Command) if (g_IsDebuggerModulesLoaded) { - HyperdbgUnload(); + HyperdbgUnloadVmm(); } else { @@ -95,7 +95,7 @@ CommandUnload(vector SplittedCommand, string Command) // // Stop the driver // - if (HyperdbgStopDriver()) + if (HyperdbgStopVmmDriver()) { ShowMessages("err, failed to stop driver\n"); return; @@ -104,7 +104,7 @@ CommandUnload(vector SplittedCommand, string Command) // // Uninstall the driver // - if (HyperdbgUninstallDriver()) + if (HyperdbgUninstallVmmDriver()) { ShowMessages("err, failed to uninstall the driver\n"); return; diff --git a/hyperdbg/hprdbgctrl/code/debugger/driver-loader/install.cpp b/hyperdbg/hprdbgctrl/code/debugger/driver-loader/install.cpp index 6aad54e0..0d30a90b 100644 --- a/hyperdbg/hprdbgctrl/code/debugger/driver-loader/install.cpp +++ b/hyperdbg/hprdbgctrl/code/debugger/driver-loader/install.cpp @@ -478,7 +478,7 @@ SetupDriverName(_Inout_updates_bytes_all_(BufferLength) PCHAR DriverLocation, // Setup path name to driver file. // if (FAILED( - StringCbCat(DriverLocation, BufferLength, "\\" DRIVER_NAME ".sys"))) + StringCbCat(DriverLocation, BufferLength, "\\" VMM_DRIVER_NAME ".sys"))) { return FALSE; } @@ -489,7 +489,7 @@ SetupDriverName(_Inout_updates_bytes_all_(BufferLength) PCHAR DriverLocation, if ((FileHandle = CreateFile(DriverLocation, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { - ShowMessages("%s.sys is not loaded.\n", DRIVER_NAME); + ShowMessages("%s.sys is not loaded.\n", VMM_DRIVER_NAME); // // Indicate failure. diff --git a/hyperdbg/hprdbgctrl/code/debugger/kernel-level/kd.cpp b/hyperdbg/hprdbgctrl/code/debugger/kernel-level/kd.cpp index cd70770b..08a6e89c 100644 --- a/hyperdbg/hprdbgctrl/code/debugger/kernel-level/kd.cpp +++ b/hyperdbg/hprdbgctrl/code/debugger/kernel-level/kd.cpp @@ -2354,7 +2354,7 @@ KdCloseConnection() { if (g_IsConnectedToHyperDbgLocally && g_IsDebuggerModulesLoaded) { - HyperdbgUnload(); + HyperdbgUnloadVmm(); } } else if (g_IsSerialConnectedToRemoteDebuggee) diff --git a/hyperdbg/hprdbgctrl/header/import-exports.h b/hyperdbg/hprdbgctrl/header/import-exports.h index e707c034..8f9b528c 100644 --- a/hyperdbg/hprdbgctrl/header/import-exports.h +++ b/hyperdbg/hprdbgctrl/header/import-exports.h @@ -19,14 +19,22 @@ // Exports // extern "C" { + extern bool inline AsmVmxSupportDetection(); -__declspec(dllexport) int HyperdbgInterpreter(char * Command); +// +// VMM Module +// __declspec(dllexport) int HyperdbgLoadVmm(); -__declspec(dllexport) int HyperdbgUnload(); +__declspec(dllexport) int HyperdbgUnloadVmm(); __declspec(dllexport) int HyperdbgInstallVmmDriver(); -__declspec(dllexport) int HyperdbgUninstallDriver(); -__declspec(dllexport) int HyperdbgStopDriver(); +__declspec(dllexport) int HyperdbgUninstallVmmDriver(); +__declspec(dllexport) int HyperdbgStopVmmDriver(); + +// +// General exports +// +__declspec(dllexport) int HyperdbgInterpreter(char * Command); __declspec(dllexport) void HyperdbgShowSignature(); __declspec(dllexport) void HyperdbgSetTextMessageCallback(Callback handler); __declspec(dllexport) void HyperDbgScriptReadFileAndExecuteCommand(std::vector & PathAndArgs); diff --git a/hyperdbg/hyperdbg.sln b/hyperdbg/hyperdbg.sln index 95ad112d..87d678c1 100644 --- a/hyperdbg/hyperdbg.sln +++ b/hyperdbg/hyperdbg.sln @@ -56,6 +56,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Headers", "Headers", "{D67D ProjectSection(SolutionItems) = preProject include\SDK\Headers\BasicTypes.h = include\SDK\Headers\BasicTypes.h include\SDK\Headers\Constants.h = include\SDK\Headers\Constants.h + include\SDK\Headers\Connection.h = include\SDK\Headers\Connection.h include\SDK\Headers\Datatypes.h = include\SDK\Headers\Datatypes.h include\SDK\Headers\ErrorCodes.h = include\SDK\Headers\ErrorCodes.h include\SDK\Headers\Events.h = include\SDK\Headers\Events.h diff --git a/hyperdbg/include/Definition.h b/hyperdbg/include/Definition.h index f46074df..34af5206 100644 --- a/hyperdbg/include/Definition.h +++ b/hyperdbg/include/Definition.h @@ -41,10 +41,10 @@ typedef RFLAGS * PRFLAGS; ////////////////////////////////////////////////// /** - * @brief name of HyperDbg driver + * @brief name of HyperDbg's VMM driver * */ -#define DRIVER_NAME "hprdbghv" +#define VMM_DRIVER_NAME "hprdbghv" ////////////////////////////////////////////////// // Test Cases // diff --git a/hyperdbg/include/SDK/Headers/Connection.h b/hyperdbg/include/SDK/Headers/Connection.h new file mode 100644 index 00000000..77c07b28 --- /dev/null +++ b/hyperdbg/include/SDK/Headers/Connection.h @@ -0,0 +1,174 @@ +/** + * @file Connection.h + * @author Sina Karvandi (sina@hyperdbg.org) + * @brief HyperDbg's SDK Headers For Native Structures, Enums and Constants + * @details These datatypes are used in all devices like HDL (FPGAs) + * @version 0.2 + * @date 2022-07-14 + * + * @copyright This project is released under the GNU Public License v3. + * + */ +#pragma once + +/** + * @brief enum for reasons why debuggee is paused + * + */ +typedef enum _DEBUGGEE_PAUSING_REASON +{ + + // + // For both kernel & user debugger + // + DEBUGGEE_PAUSING_REASON_NOT_PAUSED = 0, + DEBUGGEE_PAUSING_REASON_PAUSE_WITHOUT_DISASM, + DEBUGGEE_PAUSING_REASON_REQUEST_FROM_DEBUGGER, + DEBUGGEE_PAUSING_REASON_DEBUGGEE_STEPPED, + DEBUGGEE_PAUSING_REASON_DEBUGGEE_SOFTWARE_BREAKPOINT_HIT, + DEBUGGEE_PAUSING_REASON_DEBUGGEE_HARDWARE_DEBUG_REGISTER_HIT, + DEBUGGEE_PAUSING_REASON_DEBUGGEE_CORE_SWITCHED, + DEBUGGEE_PAUSING_REASON_DEBUGGEE_PROCESS_SWITCHED, + DEBUGGEE_PAUSING_REASON_DEBUGGEE_THREAD_SWITCHED, + DEBUGGEE_PAUSING_REASON_DEBUGGEE_COMMAND_EXECUTION_FINISHED, + DEBUGGEE_PAUSING_REASON_DEBUGGEE_EVENT_TRIGGERED, + DEBUGGEE_PAUSING_REASON_DEBUGGEE_ENTRY_POINT_REACHED, + + // + // Only for user-debugger + // + DEBUGGEE_PAUSING_REASON_DEBUGGEE_GENERAL_DEBUG_BREAK, + DEBUGGEE_PAUSING_REASON_DEBUGGEE_GENERAL_THREAD_INTERCEPTED, + + // + // Only used for hardware debugging + // + DEBUGGEE_PAUSING_REASON_HARDWARE_BASED_DEBUGGEE_GENERAL_BREAK, + +} DEBUGGEE_PAUSING_REASON; + +/** + * @brief enum for requested action for HyperDbg packet + * + */ +typedef enum _DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION +{ + + // + // Debugger to debuggee (user-mode execution) + // + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_USER_MODE_PAUSE = 1, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_USER_MODE_DO_NOT_READ_ANY_PACKET, + + // + // Debugger to debuggee (vmx-root mode execution) + // + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_STEP, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CONTINUE, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CLOSE_AND_UNLOAD_DEBUGGEE, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CHANGE_CORE, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_FLUSH_BUFFERS, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CALLSTACK, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_TEST_QUERY, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CHANGE_PROCESS, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CHANGE_THREAD, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_RUN_SCRIPT, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_USER_INPUT_BUFFER, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_SEARCH_QUERY, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_REGISTER_EVENT, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_ADD_ACTION_TO_EVENT, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_QUERY_AND_MODIFY_EVENT, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_READ_REGISTERS, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_READ_MEMORY, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_EDIT_MEMORY, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_BP, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_LIST_OR_MODIFY_BREAKPOINTS, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_SYMBOL_RELOAD, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_QUERY_PA2VA_AND_VA2PA, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_SYMBOL_QUERY_PTE, + + // + // Debuggee to debugger + // + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_NO_ACTION = 0, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_STARTED, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_LOGGING_MECHANISM, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_PAUSED_AND_CURRENT_INSTRUCTION, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CHANGING_CORE, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CHANGING_PROCESS, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CHANGING_THREAD, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_RUNNING_SCRIPT, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_FORMATS, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_FLUSH, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CALLSTACK, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_TEST_QUERY, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_REGISTERING_EVENT, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_ADDING_ACTION_TO_EVENT, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_QUERY_AND_MODIFY_EVENT, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_READING_REGISTERS, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_READING_MEMORY, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_EDITING_MEMORY, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_BP, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_LIST_OR_MODIFY_BREAKPOINTS, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_UPDATE_SYMBOL_INFO, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RELOAD_SYMBOL_FINISHED, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RELOAD_SEARCH_QUERY, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_PTE, + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_VA2PA_AND_PA2VA, + + // + // hardware debuggee to debugger + // + + // + // hardware debugger to debuggee + // + +} DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION; + +/** + * @brief enum for diffrent packet types in HyperDbg packets + * + */ +typedef enum _DEBUGGER_REMOTE_PACKET_TYPE +{ + + // + // Debugger to debuggee (vmx-root) + // + DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGER_TO_DEBUGGEE_EXECUTE_ON_VMX_ROOT = 1, + + // + // Debugger to debuggee (user-mode) + // + DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGER_TO_DEBUGGEE_EXECUTE_ON_USER_MODE, + + // + // Debuggee to debugger (user-mode and kernel-mode, vmx-root mode) + // + DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGEE_TO_DEBUGGER, + + // + // Debugger to debuggee (hardware) + // + DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGER_TO_DEBUGGEE_HARDWARE_LEVEL = 1, + + // + // Debuggee to debugger (hardware) + // + DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGEE_TO_DEBUGGER_HARDWARE_LEVEL, + +} DEBUGGER_REMOTE_PACKET_TYPE; + +/** + * @brief The structure of remote packets in HyperDbg + * + */ +typedef struct _DEBUGGER_REMOTE_PACKET +{ + BYTE Checksum; + UINT64 Indicator; /* Shows the type of the packet */ + DEBUGGER_REMOTE_PACKET_TYPE TypeOfThePacket; + DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION RequestedActionOfThePacket; + +} DEBUGGER_REMOTE_PACKET, *PDEBUGGER_REMOTE_PACKET; diff --git a/hyperdbg/include/SDK/Headers/Datatypes.h b/hyperdbg/include/SDK/Headers/Datatypes.h index bda1598a..f8dde970 100644 --- a/hyperdbg/include/SDK/Headers/Datatypes.h +++ b/hyperdbg/include/SDK/Headers/Datatypes.h @@ -62,111 +62,6 @@ typedef struct _DEBUGGEE_EVENT_AND_ACTION_HEADER_FOR_REMOTE_PACKET // Pausing // ////////////////////////////////////////////////// -/** - * @brief enum for reasons why debuggee is paused - * - */ -typedef enum _DEBUGGEE_PAUSING_REASON -{ - - // - // For both kernel & user debugger - // - DEBUGGEE_PAUSING_REASON_NOT_PAUSED = 0, - DEBUGGEE_PAUSING_REASON_PAUSE_WITHOUT_DISASM, - DEBUGGEE_PAUSING_REASON_REQUEST_FROM_DEBUGGER, - DEBUGGEE_PAUSING_REASON_DEBUGGEE_STEPPED, - DEBUGGEE_PAUSING_REASON_DEBUGGEE_SOFTWARE_BREAKPOINT_HIT, - DEBUGGEE_PAUSING_REASON_DEBUGGEE_HARDWARE_DEBUG_REGISTER_HIT, - DEBUGGEE_PAUSING_REASON_DEBUGGEE_CORE_SWITCHED, - DEBUGGEE_PAUSING_REASON_DEBUGGEE_PROCESS_SWITCHED, - DEBUGGEE_PAUSING_REASON_DEBUGGEE_THREAD_SWITCHED, - DEBUGGEE_PAUSING_REASON_DEBUGGEE_COMMAND_EXECUTION_FINISHED, - DEBUGGEE_PAUSING_REASON_DEBUGGEE_EVENT_TRIGGERED, - DEBUGGEE_PAUSING_REASON_DEBUGGEE_ENTRY_POINT_REACHED, - - // - // Only for user-debugger - // - DEBUGGEE_PAUSING_REASON_DEBUGGEE_GENERAL_DEBUG_BREAK, - DEBUGGEE_PAUSING_REASON_DEBUGGEE_GENERAL_THREAD_INTERCEPTED, - -} DEBUGGEE_PAUSING_REASON; - -/** - * @brief enum for requested action for HyperDbg packet - * - */ -typedef enum _DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION -{ - - // - // Debugger to debuggee (user-mode execution) - // - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_USER_MODE_PAUSE = 1, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_USER_MODE_DO_NOT_READ_ANY_PACKET, - - // - // Debugger to debuggee (vmx-root mode execution) - // - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_STEP, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CONTINUE, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CLOSE_AND_UNLOAD_DEBUGGEE, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CHANGE_CORE, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_FLUSH_BUFFERS, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CALLSTACK, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_TEST_QUERY, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CHANGE_PROCESS, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CHANGE_THREAD, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_RUN_SCRIPT, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_USER_INPUT_BUFFER, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_SEARCH_QUERY, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_REGISTER_EVENT, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_ADD_ACTION_TO_EVENT, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_QUERY_AND_MODIFY_EVENT, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_READ_REGISTERS, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_READ_MEMORY, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_EDIT_MEMORY, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_BP, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_LIST_OR_MODIFY_BREAKPOINTS, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_SYMBOL_RELOAD, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_QUERY_PA2VA_AND_VA2PA, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_SYMBOL_QUERY_PTE, - - // - // Debuggee to debugger - // - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_NO_ACTION = 0, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_STARTED, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_LOGGING_MECHANISM, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_PAUSED_AND_CURRENT_INSTRUCTION, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CHANGING_CORE, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CHANGING_PROCESS, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CHANGING_THREAD, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_RUNNING_SCRIPT, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_FORMATS, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_FLUSH, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CALLSTACK, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_TEST_QUERY, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_REGISTERING_EVENT, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_ADDING_ACTION_TO_EVENT, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_QUERY_AND_MODIFY_EVENT, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_READING_REGISTERS, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_READING_MEMORY, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_EDITING_MEMORY, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_BP, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_LIST_OR_MODIFY_BREAKPOINTS, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_UPDATE_SYMBOL_INFO, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RELOAD_SYMBOL_FINISHED, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RELOAD_SEARCH_QUERY, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_PTE, - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_VA2PA_AND_PA2VA, - -} DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION; - -/* ============================================================================================== - */ - #define SIZEOF_DEBUGGER_PAUSE_PACKET_RECEIVED \ sizeof(DEBUGGER_PAUSE_PACKET_RECEIVED) @@ -234,43 +129,6 @@ static_assert(sizeof(DEBUGGEE_UD_PAUSED_PACKET) < PacketChunkSize, // Debugger // ////////////////////////////////////////////////// -/** - * @brief enum for diffrent packet types in HyperDbg packets - * - */ -typedef enum _DEBUGGER_REMOTE_PACKET_TYPE -{ - - // - // Debugger to debuggee (vmx-root) - // - DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGER_TO_DEBUGGEE_EXECUTE_ON_VMX_ROOT = 1, - - // - // Debugger to debuggee (user-mode) - // - DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGER_TO_DEBUGGEE_EXECUTE_ON_USER_MODE, - - // - // Debuggee to debugger - // - DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGEE_TO_DEBUGGER - -} DEBUGGER_REMOTE_PACKET_TYPE; - -/** - * @brief The structure of remote packets in HyperDbg - * - */ -typedef struct _DEBUGGER_REMOTE_PACKET -{ - BYTE Checksum; - UINT64 Indicator; /* Shows the type of the packet */ - DEBUGGER_REMOTE_PACKET_TYPE TypeOfThePacket; - DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION RequestedActionOfThePacket; - -} DEBUGGER_REMOTE_PACKET, *PDEBUGGER_REMOTE_PACKET; - /** * @brief The structure of message packet in HyperDbg * diff --git a/hyperdbg/include/SDK/HyperDbgSdk.h b/hyperdbg/include/SDK/HyperDbgSdk.h index 7fe5550e..6e63d646 100644 --- a/hyperdbg/include/SDK/HyperDbgSdk.h +++ b/hyperdbg/include/SDK/HyperDbgSdk.h @@ -2,8 +2,9 @@ #include "SDK/Headers/Constants.h" #include "SDK/Headers/BasicTypes.h" -#include "SDK/Headers/Datatypes.h" #include "SDK/Headers/ErrorCodes.h" +#include "SDK/Headers/Connection.h" +#include "SDK/Headers/Datatypes.h" #include "SDK/Headers/Ioctls.h" #include "SDK/Headers/Events.h" #include "SDK/Headers/RequestStructures.h" diff --git a/hyperdbg/include/SDK/HyperDbgUserExports.h b/hyperdbg/include/SDK/HyperDbgUserExports.h index baeda19b..188b3ed1 100644 --- a/hyperdbg/include/SDK/HyperDbgUserExports.h +++ b/hyperdbg/include/SDK/HyperDbgUserExports.h @@ -5,11 +5,19 @@ // Imports // extern "C" { + +// +// VMM Module +// __declspec(dllimport) int HyperdbgLoadVmm(); -__declspec(dllimport) int HyperdbgUnload(); +__declspec(dllimport) int HyperdbgUnloadVmm(); __declspec(dllimport) int HyperdbgInstallVmmDriver(); -__declspec(dllimport) int HyperdbgUninstallDriver(); -__declspec(dllimport) int HyperdbgStopDriver(); +__declspec(dllimport) int HyperdbgUninstallVmmDriver(); +__declspec(dllimport) int HyperdbgStopVmmDriver(); + +// +// General imports +// __declspec(dllimport) int HyperdbgInterpreter(char * Command); __declspec(dllimport) void HyperdbgShowSignature(); __declspec(dllimport) void HyperdbgSetTextMessageCallback(Callback handler);