k, kd, kq (display stack backtrace)
Description of 'k, kd, kq' commands in HyperDbg.
Command
k : show stack backtrace (only calls)
kd : show stack backtrace (calls along with parameters in stack) in 32-bit format
kq : show stack backtrace (calls along with parameters in stack) in 64-bit format
Syntax
k
kd
kq
k [base StackAddress (hex)] [l Length (hex)]
kd [base StackAddress (hex)] [l Length (hex)]
kq [base StackAddress (hex)] [l Length (hex)]
Description
Displays stack backtrace and optionally show the parameter in the stack.
Parameters
[base StackAddress (hex)] (optional)
If you want to specify any address other than the current rsp
or esp
register, you should set the base address by using this parameter.
[l Length (hex)] (optional)
The length (byte) in hex format.
Examples
The following command shows the callstack of the current thread.
The following command shows the callstack of the current thread along with stack parameters.
The following command shows the calls along with parameters (the base address is @rbx-10
).
The following command shows the callstack of the current thread in a 32-bit environment.
The following command shows the callstack of the current thread along with parameters in a 32-bit environment.
IOCTL
This commands works over serial by sending the serial packets to the remote computer.
First of all, you should fill the following structure, set the Is32Bit
to your target execution context, set the Size
and count of frames FrameCount
, the base address (setting NULL
as based address indicates that debuggee needs the current rsp
register as the base address).
After allocating the below structure, you should also allocate as many frames structure (DEBUGGER_SINGLE_CALLSTACK_FRAME
) that you want to read from the stack (FrameCount * sizeof(DEBUGGER_SINGLE_CALLSTACK_FRAME)
).
The following structure shows the different fields of the frame structure.
The DisplayMethod
can be selected from the below enum:
The next step is sending the above structure to the debuggee when debuggee is paused and waiting for new command on vmx-root mode.
You should send the above structure with DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CALLSTACK
as RequestedAction
and DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGER_TO_DEBUGGEE_EXECUTE_ON_VMX_ROOT
as PacketType
.
In return, the debuggee sends the above structure with the following type.
In the returned structure, the KernelStatus
and frames structures are filled by the kernel.
If the KernelStatus
is DEBUGEER_OPERATION_WAS_SUCCESSFULL
, then the operation was successful. Otherwise, the returned result is an error.
The following function is responsible for sending interpreting frames in the debugger.
Remarks
If you don't specify the length, the default length for HyperDbg is
0x100
Bytes for 32-bit contexts and0x200
for 64-bit contexts.HyperDbg automatically switches between 32-bit and 64-bit environments based on the debuggee's execution context.
Please note that you should specify a space between 'l' and the length in HyperDbg. For example, 'l100' is invalid, but 'l 100' is valid. (It's opposed to windbg).
This command is guaranteed to keep debuggee in a halt state (in Debugger Mode); thus, nothing will change during its execution.
Requirements
None
Related
Last updated