Event Registration
How to programmatically activate an event using IOCTLs?
In order to send an IOCTL and enable an event programmatically, you should fill the following structure. This structure is used for tracing works in user mode and sending it to the kernel-mode. Keep in mind that this structure is not what we save for events in kernel-mode.
After sending this structure to the kernel, if it's valid, then the kernel creates a disabled event and is waiting for an action to be received then it activates the event.
Based on your request, you can select one of the following actions fromDEBUGGER_EVENT_TYPE_ENUM
enum. This enum will be updated in future versions, but if you want to simulate a special command, check the command's manual to see what's the command's type.
If you want to use the debugger features, you should connect the CommandsEventList
to the list of user-mode commands.
OptionalParamX is different in the case of each command. For example, in !epthook2, you should send the address of where you want to hook to the kernel as OptionalParam1. You have to check each command's manual to see what are its specific OptionalParam(s).
Tag is an ID that you can use later in action.
IsEnabled has a user-mode usage to trace whether the event is enabled or not.
CommandStringBuffer is the string of the command. You can ignore it.
If your event contains a condition buffer (ConditionBufferSize != 0
), you can use set the size if ConditionBufferSize
and append the buffer to the end of the above structure, and when you send the buffer to the kernel, you should send the sizeof(DEBUGGER_GENERAL_EVENT_DETAIL)+ ConditionBufferSize (if any)
.
Finally, you can send it to the kernel by using the following function.
If you want to send it directly using IOCTL, you can use the following IOCTL :
After sending the above event to the kernel, you should chain an action or multiple actions to the event.
You should fill the following structure to send a "Break", "Script", and "Custom Code" to the kernel. For example, you can append the custom code buffer after this structure and send them together to the kernel.
Also, EventTag is the unique ID that we sent previously in the event.
You can send the action to the kernel using the following function. Make sure to send the sizeof(DEBUGGER_GENERAL_ACTION)+ Size of Custom code (if any)
to the following function.
If you want to register the action to the event directly using DeviceIoControl
, you can use the following IOCTL.
Last updated