HyperDbg Debugger
Loading...
Searching...
No Matches
preactivate.cpp File Reference

preactivate command More...

#include "pch.h"

Functions

VOID CommandPreactivateHelp ()
 help of the preactivate command
VOID CommandPreactivate (vector< CommandToken > CommandTokens, string Command)
 preactivate command handler

Variables

HANDLE g_DeviceHandle
 Holds the global handle of device which is used to send the request to the kernel by IOCTL, this handle is not used for IRP Pending of message tracing this handle is used in KD VMM.
BOOLEAN g_IsVmmModuleLoaded
 shows whether the VMM module is loaded or not

Detailed Description

preactivate command

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.7
Date
2023-10-25

Function Documentation

◆ CommandPreactivate()

VOID CommandPreactivate ( vector< CommandToken > CommandTokens,
string Command )

preactivate command handler

Parameters
CommandTokens
Command
Returns
VOID
50{
51 BOOL Status;
52 ULONG ReturnedLength;
53 DEBUGGER_PREACTIVATE_COMMAND PreactivateRequest = {};
54
55 if (CommandTokens.size() != 2)
56 {
57 ShowMessages("incorrect use of the '%s'\n\n",
58 GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
60 return;
61 }
62
63 //
64 // Set the type of preactivation
65 //
66 if (CompareLowerCaseStrings(CommandTokens.at(1), "mode") || CompareLowerCaseStrings(CommandTokens.at(1), "!mode"))
67 {
69 }
70 else
71 {
72 //
73 // Couldn't resolve or unknown parameter
74 //
75 ShowMessages("err, couldn't resolve error at '%s'\n",
76 GetCaseSensitiveStringFromCommandToken(CommandTokens.at(1)).c_str());
77 return;
78 }
79
81
82 //
83 // Send IOCTL
84 //
86 g_DeviceHandle, // Handle to device
87 IOCTL_PREACTIVATE_FUNCTIONALITY, // IO Control Code (IOCTL)
88 &PreactivateRequest, // Input Buffer to driver.
89 SIZEOF_DEBUGGER_PREACTIVATE_COMMAND, // Input buffer length
90 &PreactivateRequest, // Output Buffer from driver.
91 SIZEOF_DEBUGGER_PREACTIVATE_COMMAND, // Length of output
92 // buffer in bytes.
93 &ReturnedLength, // Bytes placed in buffer.
94 NULL // synchronous call
95 );
96
97 if (!Status)
98 {
99 ShowMessages("ioctl failed with code 0x%x\n", PlatformGetLastError());
100 return;
101 }
102
103 if (PreactivateRequest.KernelStatus == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
104 {
105 ShowMessages("the requested service is activated successfully!\n");
106 }
107 else
108 {
109 //
110 // An err occurred, no results
111 //
112 ShowErrorMessage(PreactivateRequest.KernelStatus);
113 }
114}
int BOOL
Definition BasicTypes.h:25
unsigned long ULONG
Definition BasicTypes.h:31
#define DEBUGGER_OPERATION_WAS_SUCCESSFUL
General value to indicate that the operation or request was successful.
Definition ErrorCodes.h:23
#define IOCTL_PREACTIVATE_FUNCTIONALITY
ioctl, to preactivate a functionality
Definition Ioctls.h:347
struct _DEBUGGER_PREACTIVATE_COMMAND DEBUGGER_PREACTIVATE_COMMAND
requests for the 'preactivate' command
@ DEBUGGER_PREACTIVATE_COMMAND_TYPE_MODE
Definition RequestStructures.h:217
#define SIZEOF_DEBUGGER_PREACTIVATE_COMMAND
Definition RequestStructures.h:221
std::string GetCaseSensitiveStringFromCommandToken(CommandToken TargetToken)
Get case sensitive string from command token.
Definition common.cpp:467
BOOLEAN CompareLowerCaseStrings(CommandToken TargetToken, const CHAR *StringToCompare)
Compare lower case strings.
Definition common.cpp:503
BOOLEAN ShowErrorMessage(UINT32 Error)
shows the error message
Definition debugger.cpp:40
#define AssertShowMessageReturnStmt(expr1, expr2, message1, message2, rc)
Definition common.h:59
#define ASSERT_MESSAGE_VMM_NOT_LOADED
Definition common.h:31
#define AssertReturn
Definition common.h:19
#define ASSERT_MESSAGE_DRIVER_NOT_LOADED
Definition common.h:27
HANDLE g_DeviceHandle
Holds the global handle of device which is used to send the request to the kernel by IOCTL,...
Definition globals.h:481
BOOLEAN g_IsVmmModuleLoaded
shows whether the VMM module is loaded or not
Definition globals.h:28
BOOL PlatformDeviceIoControl(HANDLE Device, DWORD IoControlCode, LPVOID InBuffer, DWORD InBufferSize, LPVOID OutBuffer, DWORD OutBufferSize, LPDWORD BytesReturned, LPVOID Overlapped)
DWORD PlatformGetLastError(VOID)
Platform independent wrapper for GetLastError.
Definition platform-lib-calls.c:350
VOID CommandPreactivateHelp()
help of the preactivate command
Definition preactivate.cpp:26
UINT32 KernelStatus
Definition RequestStructures.h:231
DEBUGGER_PREACTIVATE_COMMAND_TYPE Type
Definition RequestStructures.h:230

◆ CommandPreactivateHelp()

VOID CommandPreactivateHelp ( )

help of the preactivate command

Returns
VOID
27{
28 ShowMessages("preactivate : preactivates a special functionality.\n\n");
29
30 ShowMessages("syntax : \tpreactivate [Type (string)]\n");
31
32 ShowMessages("\n");
33 ShowMessages("\t\te.g : preactivate mode\n");
34
35 ShowMessages("\n");
36 ShowMessages("type of activations:\n");
37 ShowMessages("\tmode: used for preactivation of the '!mode' event\n");
38}

Variable Documentation

◆ g_DeviceHandle

HANDLE g_DeviceHandle
extern

Holds the global handle of device which is used to send the request to the kernel by IOCTL, this handle is not used for IRP Pending of message tracing this handle is used in KD VMM.

◆ g_IsVmmModuleLoaded

BOOLEAN g_IsVmmModuleLoaded
extern

shows whether the VMM module is loaded or not