HyperDbg Debugger
Loading...
Searching...
No Matches
gu.cpp File Reference

gu command More...

#include "pch.h"

Functions

VOID CommandGuHelp ()
 help of the gu command
 
VOID CommandGu (vector< string > SplitCommand, string Command)
 handler of gu command
 

Variables

BOOLEAN g_IsSerialConnectedToRemoteDebuggee
 Shows if the debugger was connected to remote debuggee over (A remote guest)
 
BOOLEAN g_IsInstrumentingInstructions
 Shows whether the user is running 't', 'p', or 'i' command.
 
ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState
 State of active debugging thread.
 
BYTE g_CurrentRunningInstruction [MAXIMUM_INSTR_SIZE]
 Current executing instructions.
 
BOOLEAN g_IsRunningInstruction32Bit
 whether the Current executing instructions is 32-bit or 64 bit
 

Detailed Description

gu command

Author
xmaple555
Version
0.6
Date
2023-09-06

Function Documentation

◆ CommandGu()

VOID CommandGu ( vector< string > SplitCommand,
string Command )

handler of gu command

Parameters
SplitCommand
Command
Returns
VOID
52{
53 UINT32 StepCount;
55 BOOLEAN BreakOnNextInstruction = FALSE;
56
57 //
58 // Validate the commands
59 //
60 if (SplitCommand.size() != 1 && SplitCommand.size() != 2)
61 {
62 ShowMessages("incorrect use of the 'gu'\n\n");
64 return;
65 }
66
67 //
68 // Set type of request
69 //
71
72 //
73 // Check if the command has a counter parameter
74 //
75 if (SplitCommand.size() == 2)
76 {
77 if (!ConvertStringToUInt32(SplitCommand.at(1), &StepCount))
78 {
79 ShowMessages("please specify a correct hex value for [count]\n\n");
81 return;
82 }
83 }
84 else
85 {
87 }
88
89 //
90 // Check if the remote serial debuggee or user debugger are paused or not
91 //
93 {
94 //
95 // Check if the thread is paused or not
96 //
98 {
99 ShowMessages("the target process is running, use the "
100 "'pause' command or press CTRL+C to pause the process\n");
101 return;
102 }
103
104 //
105 // Indicate that we're instrumenting
106 //
108
109 for (size_t i = 0; i < StepCount; i++)
110 {
111 //
112 // For logging purpose
113 //
114 // ShowMessages("percentage : %f %% (%x)\n", 100.0 * (i /
115 // (float)StepCount), i);
116 //
117
118 //
119 // Check if the current instruction is 'ret' or not
120 //
124 g_IsRunningInstruction32Bit ? FALSE : TRUE // equals to !g_IsRunningInstruction32Bit
125 ))
126 {
127 BreakOnNextInstruction = TRUE;
128
129 //
130 // It's the last instruction, so we gonna show the instruction
131 //
133 }
134
136 {
137 //
138 // It's stepping over serial connection in kernel debugger
139 //
140 KdSendStepPacketToDebuggee(RequestFormat);
141 }
142 else
143 {
144 //
145 // It's stepping over user debugger
146 //
149 RequestFormat);
150 }
151
152 //
153 // Check if user pressed CTRL+C
154 //
156 {
157 break;
158 }
159
160 //
161 // Check if we see 'ret' in the previous instruction or not
162 //
163 if (BreakOnNextInstruction)
164 {
165 break;
166 }
167 }
168
169 //
170 // We're not instrumenting instructions anymore
171 //
173 }
174 else
175 {
176 ShowMessages("err, going up (gu) is not valid in the current context, you "
177 "should connect to a debuggee\n");
178 }
179}
UCHAR BOOLEAN
Definition BasicTypes.h:39
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned int UINT32
Definition BasicTypes.h:48
#define MAXIMUM_INSTR_SIZE
maximum instruction size in Intel
Definition Constants.h:468
@ DEBUGGER_REMOTE_STEPPING_REQUEST_STEP_OVER_FOR_GU
Definition RequestStructures.h:997
@ DEBUGGER_REMOTE_STEPPING_REQUEST_STEP_OVER_FOR_GU_LAST_INSTRUCTION
Definition RequestStructures.h:998
enum _DEBUGGER_REMOTE_STEPPING_REQUEST DEBUGGER_REMOTE_STEPPING_REQUEST
stepping and tracking types
#define DEBUGGER_REMOTE_TRACKING_DEFAULT_COUNT_OF_STEPPING
default number of instructions used in tracking and stepping
Definition RequestStructures.h:1023
BOOLEAN ConvertStringToUInt32(string TextToConvert, PUINT32 Result)
check and convert string to a 32 bit unsigned it and also check for special notations like 0x etc.
Definition common.cpp:347
BOOLEAN HyperDbgCheckWhetherTheCurrentInstructionIsRet(unsigned char *BufferToDisassemble, UINT64 BuffLength, BOOLEAN Isx86_64)
Check whether the current instruction is a 'ret' or not.
Definition disassembler.cpp:1096
BOOLEAN g_IsRunningInstruction32Bit
whether the Current executing instructions is 32-bit or 64 bit
Definition globals.h:210
BOOLEAN g_IsInstrumentingInstructions
Shows whether the user is running 't', 'p', or 'i' command.
Definition globals.h:561
BOOLEAN g_IsSerialConnectedToRemoteDebuggee
Shows if the debugger was connected to remote debuggee over (A remote guest)
Definition globals.h:231
ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState
State of active debugging thread.
Definition globals.h:362
VOID CommandGuHelp()
help of the gu command
Definition gu.cpp:29
BYTE g_CurrentRunningInstruction[MAXIMUM_INSTR_SIZE]
Current executing instructions.
Definition globals.h:204
BOOLEAN KdSendStepPacketToDebuggee(DEBUGGER_REMOTE_STEPPING_REQUEST StepRequestType)
Sends p (step out) and t (step in) packet to the debuggee.
Definition kd.cpp:1206
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
BOOLEAN IsActive
Definition ud.h:49
UINT32 ThreadId
Definition ud.h:52
UINT64 ProcessDebuggingToken
Definition ud.h:50
BOOLEAN IsPaused
Definition ud.h:53
VOID UdSendStepPacketToDebuggee(UINT64 ProcessDetailToken, UINT32 TargetThreadId, DEBUGGER_REMOTE_STEPPING_REQUEST StepType)
Send stepping instructions packet to user debugger.
Definition ud.cpp:1000

◆ CommandGuHelp()

VOID CommandGuHelp ( )

help of the gu command

Returns
VOID
30{
32 "gu : executes a single instruction (step-out) and optionally displays the "
33 "resulting values of all registers and flags.\n\n");
34
35 ShowMessages("syntax : \tgu\n");
36 ShowMessages("syntax : \tgu [Count (hex)]\n");
37
38 ShowMessages("\n");
39 ShowMessages("\t\te.g : gu\n");
40 ShowMessages("\t\te.g : gu 10000\n");
41}

Variable Documentation

◆ g_ActiveProcessDebuggingState

ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState
extern

State of active debugging thread.

362{0};

◆ g_CurrentRunningInstruction

BYTE g_CurrentRunningInstruction[MAXIMUM_INSTR_SIZE]
extern

Current executing instructions.

204{0};

◆ g_IsInstrumentingInstructions

BOOLEAN g_IsInstrumentingInstructions
extern

Shows whether the user is running 't', 'p', or 'i' command.

◆ g_IsRunningInstruction32Bit

BOOLEAN g_IsRunningInstruction32Bit
extern

whether the Current executing instructions is 32-bit or 64 bit

◆ g_IsSerialConnectedToRemoteDebuggee

BOOLEAN g_IsSerialConnectedToRemoteDebuggee
extern

Shows if the debugger was connected to remote debuggee over (A remote guest)