r (read or modify registers)
Description of the 'r' command in HyperDbg.
Command
r
Syntax
r
r [Register (string)] [= Expr (string)]
Description
Reads or modifies registers when the debuggee is paused.
Parameters
[Register (string)] (optional)
The register that needs to be read or modified.
[= Expr (string)] (optional)
The value or the expression that needs to be evaluated and modify the target register.
If you don't specify any parameters to the 'r' command, it shows all general-purpose + segment registers.
The first parameter to this command is a register (not an expression). If you want to evaluate and see the result of registers as an expression (e.g., rax+rbx+rcx
) then you can use the '.formats' command.
Examples
If you want to see all general purpose and segment registers.
If you want to see one special register (e.g., rax
).
If you want to see one special register (e.g., cs
).
If you want to change a register to a constant hex value.
If you want to change a register to a new value which is the result of an expression.
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 RegisterId
to your special register number, which is an ID from REGS_ENUM
enum.
If you want to view all the registers, then you should set RegisterID
to DEBUGGEE_SHOW_ALL_REGISTERS
.
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_READ_REGISTERS
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
is 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 read register buffers in the debugger.
If you specified DEBUGGEE_SHOW_ALL_REGISTERS
then the debuggee sends the registers with two buffers that are appended. The first buffer is GUEST_REGS
and the second buffer is GUEST_EXTRA_REGISTERS
.
The first buffer contains general-purpose registers, and the second buffer contains other registers, including segment registers.
Note that modifying registers are performed through script-engine as we might need the evaluation of expressions to get the register's value.
Remarks
This command is guaranteed to keep debuggee in a halt state (in Debugger Mode); thus, nothing will change during its execution.
Requirements
None
Related
None
Last updated