2023-03-23 18:42:33 +09:00
|
|
|
/**
|
|
|
|
|
* @file rev-ctrl.cpp
|
|
|
|
|
* @author Sina Karvandi (sina@hyperdbg.org)
|
|
|
|
|
* @brief Controller of the reversing machine's module
|
|
|
|
|
* @details
|
|
|
|
|
*
|
|
|
|
|
* @version 0.2
|
|
|
|
|
* @date 2023-03-23
|
|
|
|
|
*
|
|
|
|
|
* @copyright This project is released under the GNU Public License v3.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#include "pch.h"
|
|
|
|
|
|
2026-06-08 23:45:43 +02:00
|
|
|
//
|
|
|
|
|
// Global Variables
|
|
|
|
|
//
|
|
|
|
|
extern BOOLEAN g_IsVmmModuleLoaded;
|
|
|
|
|
|
2023-03-23 18:42:33 +09:00
|
|
|
/**
|
|
|
|
|
* @brief Request service from the reversing machine
|
|
|
|
|
*
|
|
|
|
|
* @param RevRequest
|
|
|
|
|
*
|
|
|
|
|
* @return BOOLEAN
|
|
|
|
|
*/
|
|
|
|
|
BOOLEAN
|
|
|
|
|
RevRequestService(REVERSING_MACHINE_RECONSTRUCT_MEMORY_REQUEST * RevRequest)
|
|
|
|
|
{
|
|
|
|
|
BOOLEAN Status;
|
|
|
|
|
ULONG ReturnedLength;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Check if debugger is loaded or not
|
|
|
|
|
//
|
2026-06-08 23:45:43 +02:00
|
|
|
AssertShowMessageReturnStmt(g_IsVmmModuleLoaded, g_DeviceHandle, ASSERT_MESSAGE_VMM_NOT_LOADED, ASSERT_MESSAGE_DRIVER_NOT_LOADED, AssertReturnFalse);
|
2023-03-23 18:42:33 +09:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Send the request to the kernel
|
|
|
|
|
//
|
2026-07-18 17:09:52 +02:00
|
|
|
Status = PlatformDeviceIoControl(
|
2023-03-23 18:42:33 +09:00
|
|
|
g_DeviceHandle, // Handle to device
|
|
|
|
|
IOCTL_REQUEST_REV_MACHINE_SERVICE, // IO Control
|
|
|
|
|
// code
|
|
|
|
|
RevRequest, // Input Buffer to driver.
|
|
|
|
|
SIZEOF_REVERSING_MACHINE_RECONSTRUCT_MEMORY_REQUEST, // Input buffer length
|
|
|
|
|
RevRequest, // Output Buffer from driver.
|
|
|
|
|
SIZEOF_REVERSING_MACHINE_RECONSTRUCT_MEMORY_REQUEST, // Length of output
|
|
|
|
|
// buffer in bytes.
|
|
|
|
|
&ReturnedLength, // Bytes placed in buffer.
|
|
|
|
|
NULL // synchronous call
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!Status)
|
|
|
|
|
{
|
2026-07-18 17:09:52 +02:00
|
|
|
ShowMessages("ioctl failed with code 0x%x\n", PlatformGetLastError());
|
2023-03-23 18:42:33 +09:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Check if the service request was successful or not
|
|
|
|
|
//
|
|
|
|
|
if (RevRequest->KernelStatus == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
|
|
|
|
|
{
|
2023-03-27 14:18:46 +09:00
|
|
|
ShowMessages("the reversing machine service request was successful!\n");
|
2023-03-23 18:42:33 +09:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ShowErrorMessage(RevRequest->KernelStatus);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|