.switch (show the list and switch between active debugging processes)
Description of the '.switch' command in HyperDbg.
Command
.switch
Syntax
.switch
.switch [pid ProcessId (hex)]
.switch [tid ThreadId (hex)]
Description
Shows a list of active debugging processes and threads or switches between different active debugging threads and processes. This command displays the list of intercepted threads that you can switch to these processes or threads. It won't show all of the threads of the target process.
If you don't specify any parameters to this command, it shows the list of threads and processes.
This command won't use any Windows API for intercepting and pausing threads, and everything is done at the hypervisor level.
Parameters
[pid ProcessId (hex)]
The target Process Id to switch.
[tid ThreadId (hex)]
The target Thread Id to switch.
Examples
The following command shows the list of active debugging threads/processes.
We'll use the following command to switch to thread id 0x2020
.
As you can see, the arrow in the list of active debugging threads is changed.
It is also possible to switch by using process id.
Again, the active debugging process (thread) is changed.
IOCTL
This function works by calling DeviceIoControl with IOCTL = IOCTL_DEBUGGER_ATTACH_DETACH_USER_MODE_PROCESS
. You have to send it in the following structure.
First, you should set the Action to DEBUGGER_ATTACH_DETACH_USER_MODE_PROCESS_ACTION_QUERY_COUNT_OF_ACTIVE_DEBUGGING_THREADS
in the above structure, when the IOCTL returns from the kernel, CountOfActiveDebuggingThreadsAndProcesses is filled with appropriate data from the process.
After getting the results from the kernel and if the Result is equal to DEBUGGER_OPERATION_WAS_SUCCESSFULL
you should pass a new IOCTL to the kernel again.
The new IOCTL is equal to IOCTL_GET_DETAIL_OF_ACTIVE_THREADS_AND_PROCESSES
. There is no need for the input buffer, but for the output buffer, you should allocate a memory with the size of the following structure multiplied by the count of threads/processes returned from the previous IOCTL.
The Action can be from the following enum:
Remarks
This command is logically designed to be used in VMI Mode. You can use the '.process' and the '.thread' commands in Debugger Mode.
Requirements
None
Related
.restart (restart the process)
Last updated