2020-05-27 09:59:17 -07:00
|
|
|
/**
|
|
|
|
|
* @file monitor.cpp
|
2022-01-18 22:38:56 +03:30
|
|
|
* @author Sina Karvandi (sina@hyperdbg.org)
|
2020-05-27 09:59:17 -07:00
|
|
|
* @brief !monitor command
|
|
|
|
|
* @details
|
|
|
|
|
* @version 0.1
|
|
|
|
|
* @date 2020-05-27
|
|
|
|
|
*
|
|
|
|
|
* @copyright This project is released under the GNU Public License v3.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2022-05-04 16:38:21 -07:00
|
|
|
#include "pch.h"
|
2020-05-27 09:59:17 -07:00
|
|
|
|
2020-08-28 04:03:12 -07:00
|
|
|
/**
|
2023-07-13 16:05:42 +09:00
|
|
|
* @brief help of the !monitor command
|
2020-10-22 06:27:28 -07:00
|
|
|
*
|
|
|
|
|
* @return VOID
|
2020-08-28 04:03:12 -07:00
|
|
|
*/
|
2021-03-22 18:19:39 +04:30
|
|
|
VOID
|
|
|
|
|
CommandMonitorHelp()
|
|
|
|
|
{
|
2022-04-10 22:24:56 +04:30
|
|
|
ShowMessages("!monitor : monitors address range for read and writes.\n\n");
|
2022-04-17 23:05:24 +04:30
|
|
|
|
2024-06-06 19:41:22 +09:00
|
|
|
ShowMessages("syntax : \t!monitor [MemoryType (vapa)] [Attribute (string)] [FromAddress (hex)] "
|
2022-02-11 02:53:28 +03:30
|
|
|
"[ToAddress (hex)] [pid ProcessId (hex)] [core CoreId (hex)] "
|
2023-07-31 15:05:14 +09:00
|
|
|
"[imm IsImmediate (yesno)] [sc EnableShortCircuiting (onoff)] [stage CallingStage (prepostall)] "
|
2024-07-19 17:03:43 +09:00
|
|
|
"[buffer PreAllocatedBuffer (hex)] [script { Script (string) }] [asm condition { Condition (assembly/hex) }] "
|
|
|
|
|
"[asm code { Code (assembly/hex) }] [output {OutputName (string)}]\n");
|
2021-03-22 18:19:39 +04:30
|
|
|
|
2024-06-06 19:41:22 +09:00
|
|
|
ShowMessages("syntax : \t!monitor [MemoryType (vapa)] [Attribute (string)] [FromAddress (hex)] "
|
2024-01-31 15:46:45 +09:00
|
|
|
"[l Length (hex)] [pid ProcessId (hex)] [core CoreId (hex)] "
|
|
|
|
|
"[imm IsImmediate (yesno)] [sc EnableShortCircuiting (onoff)] [stage CallingStage (prepostall)] "
|
2024-07-19 17:03:43 +09:00
|
|
|
"[buffer PreAllocatedBuffer (hex)] [script { Script (string) }] [asm condition { Condition (assembly/hex) }] "
|
|
|
|
|
"[asm code { Code (assembly/hex) }] [output {OutputName (string)}]\n");
|
2024-01-31 15:46:45 +09:00
|
|
|
|
2022-04-17 23:05:24 +04:30
|
|
|
ShowMessages("\n");
|
2021-03-22 18:19:39 +04:30
|
|
|
ShowMessages("\t\te.g : !monitor rw fffff801deadb000 fffff801deadbfff\n");
|
2024-01-31 15:46:45 +09:00
|
|
|
ShowMessages("\t\te.g : !monitor rw fffff801deadb000 l 1000\n");
|
2024-06-06 19:41:22 +09:00
|
|
|
ShowMessages("\t\te.g : !monitor pa rw c01000 l 1000\n");
|
2023-07-07 01:21:07 +09:00
|
|
|
ShowMessages("\t\te.g : !monitor rwx fffff801deadb000 fffff801deadbfff\n");
|
2024-01-31 15:46:45 +09:00
|
|
|
ShowMessages("\t\te.g : !monitor rwx fffff801deadb000 l 230d0\n");
|
2021-09-24 03:24:38 +03:30
|
|
|
ShowMessages("\t\te.g : !monitor rw nt!Kd_DEFAULT_Mask Kd_DEFAULT_Mask+5\n");
|
2022-02-11 02:53:28 +03:30
|
|
|
ShowMessages("\t\te.g : !monitor r fffff801deadb000 fffff801deadbfff pid 400\n");
|
|
|
|
|
ShowMessages("\t\te.g : !monitor w fffff801deadb000 fffff801deadbfff core 2 pid 400\n");
|
2024-06-06 19:41:22 +09:00
|
|
|
ShowMessages("\t\te.g : !monitor w c01000 c01000+2500 core 2 pid 400\n");
|
2023-07-07 01:21:07 +09:00
|
|
|
ShowMessages("\t\te.g : !monitor x fffff801deadb000 fffff801deadbfff core 2 pid 400\n");
|
2024-01-31 15:46:45 +09:00
|
|
|
ShowMessages("\t\te.g : !monitor x fffff801deadb000 l 500 core 2 pid 400\n");
|
2023-07-07 01:21:07 +09:00
|
|
|
ShowMessages("\t\te.g : !monitor wx fffff801deadb000 fffff801deadbfff core 2 pid 400\n");
|
2024-07-20 22:05:39 +09:00
|
|
|
ShowMessages("\t\te.g : !monitor rw fffff801deadb000 l 1000 script { printf(\"read/write occurred at the virtual address: %%llx\\n\", $context); }\n");
|
|
|
|
|
ShowMessages("\t\te.g : !monitor rw fffff801deadb000 l 1000 asm code { nop; nop; nop }\n");
|
2020-05-27 09:59:17 -07:00
|
|
|
}
|
|
|
|
|
|
2020-08-28 04:03:12 -07:00
|
|
|
/**
|
|
|
|
|
* @brief !monitor command handler
|
2020-10-22 06:27:28 -07:00
|
|
|
*
|
2024-07-30 18:44:15 +09:00
|
|
|
* @param CommandTokens
|
2024-07-31 14:08:14 +09:00
|
|
|
* @param Command
|
2024-07-30 18:44:15 +09:00
|
|
|
*
|
2020-10-22 06:27:28 -07:00
|
|
|
* @return VOID
|
2020-08-28 04:03:12 -07:00
|
|
|
*/
|
2021-03-22 18:19:39 +04:30
|
|
|
VOID
|
2024-07-31 14:08:14 +09:00
|
|
|
CommandMonitor(vector<CommandToken> CommandTokens, string Command)
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
2021-08-21 20:48:17 +04:30
|
|
|
PDEBUGGER_GENERAL_EVENT_DETAIL Event = NULL;
|
|
|
|
|
PDEBUGGER_GENERAL_ACTION ActionBreakToDebugger = NULL;
|
|
|
|
|
PDEBUGGER_GENERAL_ACTION ActionCustomCode = NULL;
|
|
|
|
|
PDEBUGGER_GENERAL_ACTION ActionScript = NULL;
|
|
|
|
|
UINT32 EventLength;
|
|
|
|
|
UINT32 ActionBreakToDebuggerLength = 0;
|
|
|
|
|
UINT32 ActionCustomCodeLength = 0;
|
|
|
|
|
UINT32 ActionScriptLength = 0;
|
2024-01-31 15:46:45 +09:00
|
|
|
UINT32 HookLength = 0;
|
2024-06-06 19:41:22 +09:00
|
|
|
UINT64 OptionalParam1 = 0; // Set the 'from' target address
|
|
|
|
|
UINT64 OptionalParam2 = 0; // Set the 'to' target address
|
|
|
|
|
BOOLEAN SetFrom = FALSE;
|
|
|
|
|
BOOLEAN SetTo = FALSE;
|
|
|
|
|
BOOLEAN IsNextLength = FALSE;
|
|
|
|
|
BOOLEAN LengthAlreadySet = FALSE;
|
|
|
|
|
BOOLEAN SetAttributes = FALSE;
|
|
|
|
|
BOOLEAN HookMemoryTypeSet = FALSE;
|
|
|
|
|
DEBUGGER_HOOK_MEMORY_TYPE HookMemoryType = DEBUGGER_MEMORY_HOOK_VIRTUAL_ADDRESS; // by default virtual address
|
2021-08-21 20:48:17 +04:30
|
|
|
DEBUGGER_EVENT_PARSING_ERROR_CAUSE EventParsingErrorCause;
|
2021-03-22 18:19:39 +04:30
|
|
|
|
2024-07-30 18:44:15 +09:00
|
|
|
if (CommandTokens.size() < 4)
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
2024-07-30 18:44:15 +09:00
|
|
|
ShowMessages("incorrect use of the '%s'\n\n",
|
|
|
|
|
GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
|
|
|
|
|
|
2021-03-22 18:19:39 +04:30
|
|
|
CommandMonitorHelp();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-08-28 04:03:12 -07:00
|
|
|
|
2021-03-22 18:19:39 +04:30
|
|
|
//
|
|
|
|
|
// Interpret and fill the general event and action fields
|
|
|
|
|
//
|
|
|
|
|
// We use HIDDEN_HOOK_READ_AND_WRITE here but it might be changed to
|
2023-07-07 01:21:07 +09:00
|
|
|
// HIDDEN_HOOK_READ or HIDDEN_HOOK_WRITE or other events it is because
|
|
|
|
|
// we are not sure what kind event the user need
|
2021-03-22 18:19:39 +04:30
|
|
|
//
|
|
|
|
|
if (!InterpretGeneralEventAndActionsFields(
|
2024-07-30 18:44:15 +09:00
|
|
|
&CommandTokens,
|
2023-07-07 01:21:07 +09:00
|
|
|
HIDDEN_HOOK_READ_AND_WRITE_AND_EXECUTE,
|
2021-03-22 18:19:39 +04:30
|
|
|
&Event,
|
|
|
|
|
&EventLength,
|
|
|
|
|
&ActionBreakToDebugger,
|
|
|
|
|
&ActionBreakToDebuggerLength,
|
|
|
|
|
&ActionCustomCode,
|
|
|
|
|
&ActionCustomCodeLength,
|
|
|
|
|
&ActionScript,
|
2021-08-21 20:48:17 +04:30
|
|
|
&ActionScriptLength,
|
|
|
|
|
&EventParsingErrorCause))
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-08-28 04:03:12 -07:00
|
|
|
|
2021-03-22 18:19:39 +04:30
|
|
|
//
|
|
|
|
|
// Interpret command specific details (if any)
|
|
|
|
|
//
|
2024-07-30 18:44:15 +09:00
|
|
|
for (auto Section : CommandTokens)
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
2024-07-30 18:44:15 +09:00
|
|
|
if (CompareLowerCaseStrings(Section, "!monitor"))
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
|
|
|
|
continue;
|
2020-05-27 09:59:17 -07:00
|
|
|
}
|
2024-01-31 15:46:45 +09:00
|
|
|
else if (IsNextLength)
|
|
|
|
|
{
|
2024-07-30 18:44:15 +09:00
|
|
|
if (!ConvertTokenToUInt32(Section, &HookLength))
|
2024-01-31 15:46:45 +09:00
|
|
|
{
|
|
|
|
|
ShowMessages("err, you should enter a valid length\n\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IsNextLength = FALSE;
|
|
|
|
|
LengthAlreadySet = TRUE;
|
|
|
|
|
SetTo = TRUE; // No longer need a second address
|
|
|
|
|
}
|
2024-07-30 18:44:15 +09:00
|
|
|
else if (CompareLowerCaseStrings(Section, "r") && !SetAttributes)
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
|
|
|
|
Event->EventType = HIDDEN_HOOK_READ;
|
2023-09-18 19:47:13 +09:00
|
|
|
SetAttributes = TRUE;
|
2020-05-27 09:59:17 -07:00
|
|
|
}
|
2024-07-30 18:44:15 +09:00
|
|
|
else if (CompareLowerCaseStrings(Section, "w") && !SetAttributes)
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
|
|
|
|
Event->EventType = HIDDEN_HOOK_WRITE;
|
2023-09-18 19:47:13 +09:00
|
|
|
SetAttributes = TRUE;
|
2021-03-22 18:19:39 +04:30
|
|
|
}
|
2024-07-30 18:44:15 +09:00
|
|
|
else if (CompareLowerCaseStrings(Section, "x") && !SetAttributes)
|
2023-07-07 01:21:07 +09:00
|
|
|
{
|
|
|
|
|
Event->EventType = HIDDEN_HOOK_EXECUTE;
|
2023-09-18 19:47:13 +09:00
|
|
|
SetAttributes = TRUE;
|
2023-07-07 01:21:07 +09:00
|
|
|
}
|
2024-07-30 18:44:15 +09:00
|
|
|
else if ((CompareLowerCaseStrings(Section, "rw") || CompareLowerCaseStrings(Section, "wr")) && !SetAttributes)
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
|
|
|
|
Event->EventType = HIDDEN_HOOK_READ_AND_WRITE;
|
2023-09-18 19:47:13 +09:00
|
|
|
SetAttributes = TRUE;
|
2021-03-22 18:19:39 +04:30
|
|
|
}
|
2024-07-30 18:44:15 +09:00
|
|
|
else if ((CompareLowerCaseStrings(Section, "rx") || CompareLowerCaseStrings(Section, "xr")) &&
|
2023-09-18 19:47:13 +09:00
|
|
|
!SetAttributes)
|
2023-07-07 01:21:07 +09:00
|
|
|
{
|
|
|
|
|
Event->EventType = HIDDEN_HOOK_READ_AND_EXECUTE;
|
2023-09-18 19:47:13 +09:00
|
|
|
SetAttributes = TRUE;
|
2023-07-07 01:21:07 +09:00
|
|
|
}
|
2024-07-30 18:44:15 +09:00
|
|
|
else if ((CompareLowerCaseStrings(Section, "wx") || CompareLowerCaseStrings(Section, "xw")) &&
|
2023-09-18 19:47:13 +09:00
|
|
|
!SetAttributes)
|
2023-07-07 01:21:07 +09:00
|
|
|
{
|
|
|
|
|
Event->EventType = HIDDEN_HOOK_WRITE_AND_EXECUTE;
|
2023-09-18 19:47:13 +09:00
|
|
|
SetAttributes = TRUE;
|
2023-07-07 01:21:07 +09:00
|
|
|
}
|
2024-07-30 18:44:15 +09:00
|
|
|
else if ((CompareLowerCaseStrings(Section, "rwx") ||
|
|
|
|
|
CompareLowerCaseStrings(Section, "rxw") ||
|
|
|
|
|
CompareLowerCaseStrings(Section, "wrx") ||
|
|
|
|
|
CompareLowerCaseStrings(Section, "wxr") ||
|
|
|
|
|
CompareLowerCaseStrings(Section, "xrw") ||
|
|
|
|
|
CompareLowerCaseStrings(Section, "xwr")) &&
|
2023-09-18 19:47:13 +09:00
|
|
|
!SetAttributes)
|
2023-07-07 01:21:07 +09:00
|
|
|
{
|
|
|
|
|
Event->EventType = HIDDEN_HOOK_READ_AND_WRITE_AND_EXECUTE;
|
2023-09-18 19:47:13 +09:00
|
|
|
SetAttributes = TRUE;
|
2023-07-07 01:21:07 +09:00
|
|
|
}
|
2024-07-30 18:44:15 +09:00
|
|
|
else if (CompareLowerCaseStrings(Section, "l") && !SetTo && !LengthAlreadySet)
|
2024-01-31 15:46:45 +09:00
|
|
|
{
|
|
|
|
|
IsNextLength = TRUE;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2024-07-30 18:44:15 +09:00
|
|
|
else if (CompareLowerCaseStrings(Section, "va") && !HookMemoryTypeSet)
|
2024-06-06 19:41:22 +09:00
|
|
|
{
|
|
|
|
|
HookMemoryType = DEBUGGER_MEMORY_HOOK_VIRTUAL_ADDRESS;
|
|
|
|
|
HookMemoryTypeSet = TRUE;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2024-07-30 18:44:15 +09:00
|
|
|
else if (CompareLowerCaseStrings(Section, "pa") && !HookMemoryTypeSet)
|
2024-06-06 19:41:22 +09:00
|
|
|
{
|
|
|
|
|
HookMemoryType = DEBUGGER_MEMORY_HOOK_PHYSICAL_ADDRESS;
|
|
|
|
|
HookMemoryTypeSet = TRUE;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2021-03-22 18:19:39 +04:30
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
// It's probably address
|
|
|
|
|
//
|
|
|
|
|
if (!SetFrom)
|
|
|
|
|
{
|
2021-09-24 00:40:21 +03:30
|
|
|
if (!SymbolConvertNameOrExprToAddress(
|
2024-07-30 18:44:15 +09:00
|
|
|
GetCaseSensitiveStringFromCommandToken(Section),
|
2021-06-02 18:23:54 +04:30
|
|
|
&OptionalParam1))
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
|
|
|
|
//
|
2024-03-17 01:01:22 +09:00
|
|
|
// couldn't resolve or unknown parameter
|
2021-03-22 18:19:39 +04:30
|
|
|
//
|
2021-06-03 16:43:00 +04:30
|
|
|
ShowMessages("err, couldn't resolve error at '%s'\n\n",
|
2024-07-30 18:44:15 +09:00
|
|
|
GetCaseSensitiveStringFromCommandToken(Section).c_str());
|
2021-03-22 18:19:39 +04:30
|
|
|
CommandMonitorHelp();
|
2022-05-09 01:34:07 +04:30
|
|
|
|
|
|
|
|
FreeEventsAndActionsMemory(Event, ActionBreakToDebugger, ActionCustomCode, ActionScript);
|
2021-03-22 18:19:39 +04:30
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SetFrom = TRUE;
|
|
|
|
|
}
|
2024-01-31 15:46:45 +09:00
|
|
|
else if (!SetTo && !LengthAlreadySet)
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
2021-09-24 00:40:21 +03:30
|
|
|
if (!SymbolConvertNameOrExprToAddress(
|
2024-07-30 18:44:15 +09:00
|
|
|
GetCaseSensitiveStringFromCommandToken(Section),
|
2021-06-02 18:23:54 +04:30
|
|
|
&OptionalParam2))
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
|
|
|
|
//
|
2024-03-17 01:01:22 +09:00
|
|
|
// Couldn't resolve or unknown parameter
|
2021-03-22 18:19:39 +04:30
|
|
|
//
|
2021-06-03 16:43:00 +04:30
|
|
|
ShowMessages("err, couldn't resolve error at '%s'\n\n",
|
2024-07-30 18:44:15 +09:00
|
|
|
GetCaseSensitiveStringFromCommandToken(Section).c_str());
|
2021-06-03 16:43:00 +04:30
|
|
|
|
2021-03-22 18:19:39 +04:30
|
|
|
CommandMonitorHelp();
|
2022-05-09 01:34:07 +04:30
|
|
|
|
|
|
|
|
FreeEventsAndActionsMemory(Event, ActionBreakToDebugger, ActionCustomCode, ActionScript);
|
2021-03-22 18:19:39 +04:30
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SetTo = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//
|
2024-03-17 19:00:14 +09:00
|
|
|
// Unknown parameter
|
2021-03-22 18:19:39 +04:30
|
|
|
//
|
2024-07-30 18:44:15 +09:00
|
|
|
ShowMessages("unknown parameter '%s'\n\n",
|
|
|
|
|
GetCaseSensitiveStringFromCommandToken(Section).c_str());
|
2021-03-22 18:19:39 +04:30
|
|
|
CommandMonitorHelp();
|
2022-05-09 01:34:07 +04:30
|
|
|
|
|
|
|
|
FreeEventsAndActionsMemory(Event, ActionBreakToDebugger, ActionCustomCode, ActionScript);
|
2021-03-22 18:19:39 +04:30
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-12 23:57:32 +03:30
|
|
|
|
2024-01-31 15:46:45 +09:00
|
|
|
//
|
|
|
|
|
// Check if all parameters are received
|
|
|
|
|
//
|
|
|
|
|
if (!SetFrom || !SetTo)
|
|
|
|
|
{
|
|
|
|
|
ShowMessages("please choose the 'from' or 'to' values or specify the length\n");
|
|
|
|
|
FreeEventsAndActionsMemory(Event, ActionBreakToDebugger, ActionCustomCode, ActionScript);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Check if user specified the 'l' rather than providing two addresses
|
|
|
|
|
//
|
|
|
|
|
if (LengthAlreadySet)
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
// Because when the user specifies length, the last byte should be ignored
|
|
|
|
|
//
|
|
|
|
|
OptionalParam2 = OptionalParam1 + HookLength - 1;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-12 23:57:32 +03:30
|
|
|
//
|
|
|
|
|
// Check for invalid order of address
|
|
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
if (OptionalParam1 > OptionalParam2)
|
|
|
|
|
{
|
2020-05-27 09:59:17 -07:00
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
// 'from' is greater than 'to'
|
2020-05-27 09:59:17 -07:00
|
|
|
//
|
2021-04-11 22:21:22 +04:30
|
|
|
ShowMessages("please choose the 'from' value first, then choose the 'to' "
|
2021-04-18 23:22:28 +04:30
|
|
|
"value\n");
|
2022-05-09 01:34:07 +04:30
|
|
|
|
|
|
|
|
FreeEventsAndActionsMemory(Event, ActionBreakToDebugger, ActionCustomCode, ActionScript);
|
2020-05-27 09:59:17 -07:00
|
|
|
return;
|
|
|
|
|
}
|
2020-08-28 04:03:12 -07:00
|
|
|
|
2021-11-12 23:57:32 +03:30
|
|
|
//
|
2023-09-18 19:47:13 +09:00
|
|
|
// Check if user set the attributes of !monitor or not
|
2021-11-12 23:57:32 +03:30
|
|
|
//
|
2023-09-18 19:47:13 +09:00
|
|
|
if (!SetAttributes)
|
2021-11-12 23:57:32 +03:30
|
|
|
{
|
2023-09-18 19:47:13 +09:00
|
|
|
ShowMessages("please specify the attribute(s) that you want to monitor (r, w, x, rw, rx, wx, rwx)\n");
|
2022-05-09 01:34:07 +04:30
|
|
|
|
|
|
|
|
FreeEventsAndActionsMemory(Event, ActionBreakToDebugger, ActionCustomCode, ActionScript);
|
2021-11-12 23:57:32 +03:30
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 09:59:17 -07:00
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
// Set the optional parameters
|
2020-05-27 09:59:17 -07:00
|
|
|
//
|
2023-10-14 21:28:08 +09:00
|
|
|
Event->Options.OptionalParam1 = OptionalParam1;
|
|
|
|
|
Event->Options.OptionalParam2 = OptionalParam2;
|
2024-06-06 19:41:22 +09:00
|
|
|
Event->Options.OptionalParam3 = HookMemoryType;
|
2020-08-28 04:03:12 -07:00
|
|
|
|
|
|
|
|
//
|
2022-05-08 22:13:44 +04:30
|
|
|
// Send the ioctl to the kernel for event registration
|
2020-08-28 04:03:12 -07:00
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
if (!SendEventToKernel(Event, EventLength))
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
// There was an error, probably the handle was not initialized
|
|
|
|
|
// we have to free the Action before exit, it is because, we
|
|
|
|
|
// already freed the Event and string buffers
|
|
|
|
|
//
|
2022-05-08 22:13:44 +04:30
|
|
|
|
2022-05-09 01:34:07 +04:30
|
|
|
FreeEventsAndActionsMemory(Event, ActionBreakToDebugger, ActionCustomCode, ActionScript);
|
2021-03-22 18:19:39 +04:30
|
|
|
return;
|
2020-10-22 06:27:28 -07:00
|
|
|
}
|
2020-05-27 12:09:57 -07:00
|
|
|
|
2020-08-28 04:03:12 -07:00
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
// Add the event to the kernel
|
2020-08-28 04:03:12 -07:00
|
|
|
//
|
2022-05-09 01:34:07 +04:30
|
|
|
if (!RegisterActionToEvent(Event,
|
|
|
|
|
ActionBreakToDebugger,
|
2022-03-13 01:33:21 +03:30
|
|
|
ActionBreakToDebuggerLength,
|
|
|
|
|
ActionCustomCode,
|
|
|
|
|
ActionCustomCodeLength,
|
|
|
|
|
ActionScript,
|
|
|
|
|
ActionScriptLength))
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
// There was an error
|
|
|
|
|
//
|
2022-05-09 01:34:07 +04:30
|
|
|
|
|
|
|
|
FreeEventsAndActionsMemory(Event, ActionBreakToDebugger, ActionCustomCode, ActionScript);
|
2021-03-22 18:19:39 +04:30
|
|
|
return;
|
|
|
|
|
}
|
2020-05-27 09:59:17 -07:00
|
|
|
}
|