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< CommandToken > CommandTokens, 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< CommandToken > CommandTokens,
string Command )

handler of gu command

Parameters
CommandTokens
Command
Returns
VOID
53{
54 UINT32 StepCount;
55 BOOLEAN LastInstruction = FALSE;
56 BOOLEAN BreakOnNextInstruction = FALSE;
57
58 //
59 // Validate the commands
60 //
61 if (CommandTokens.size() != 1 && CommandTokens.size() != 2)
62 {
63 ShowMessages("incorrect use of the '%s'\n\n",
64 GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
66 return;
67 }
68
69 //
70 // Check if the command has a counter parameter
71 //
72 if (CommandTokens.size() == 2)
73 {
74 if (!ConvertTokenToUInt32(CommandTokens.at(1), &StepCount))
75 {
76 ShowMessages("please specify a correct hex value for [count]\n\n");
78 return;
79 }
80 }
81 else
82 {
84 }
85
86 //
87 // Check if the remote serial debuggee or user debugger are paused or not
88 //
90 {
91 //
92 // Check if the thread is paused or not
93 //
95 {
96 ShowMessages("the target process is running, use the "
97 "'pause' command or press CTRL+C to pause the process\n");
98 return;
99 }
100
101 //
102 // Indicate that we're instrumenting
103 //
105
106 for (SIZE_T i = 0; i < StepCount; i++)
107 {
108 //
109 // For logging purpose
110 //
111 // ShowMessages("percentage : %f %% (%x)\n", 100.0 * (i /
112 // (float)StepCount), i);
113 //
114
115 //
116 // Check if the current instruction is 'ret' or not
117 //
121 g_IsRunningInstruction32Bit ? FALSE : TRUE // equals to !g_IsRunningInstruction32Bit
122 ))
123 {
124 BreakOnNextInstruction = TRUE;
125
126 //
127 // It's the last instruction, so we gonna show the instruction
128 //
129 LastInstruction = TRUE;
130 }
131
132 //
133 // Perform a GU step
134 //
135 SteppingStepOverForGu(LastInstruction);
136
137 //
138 // Check if user pressed CTRL+C
139 //
141 {
142 break;
143 }
144
145 //
146 // Check if we see 'ret' in the previous instruction or not
147 //
148 if (BreakOnNextInstruction)
149 {
150 break;
151 }
152 }
153
154 //
155 // We're not instrumenting instructions anymore
156 //
158 }
159 else
160 {
161 ShowMessages("err, going up (gu) is not valid in the current context, you "
162 "should connect to a debuggee\n");
163 }
164}
BOOLEAN g_IsSerialConnectedToRemoteDebuggee
Shows if the debugger was connected to remote debuggee over (A remote guest).
Definition globals.h:253
ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState
State of active debugging thread.
Definition globals.h:372
UCHAR BOOLEAN
Definition BasicTypes.h:35
#define TRUE
Definition BasicTypes.h:114
#define FALSE
Definition BasicTypes.h:113
unsigned int UINT32
Definition BasicTypes.h:54
#define MAXIMUM_INSTR_SIZE
maximum instruction size in Intel
Definition Constants.h:470
#define DEBUGGER_REMOTE_TRACKING_DEFAULT_COUNT_OF_STEPPING
default number of instructions used in tracking and stepping
Definition RequestStructures.h:1077
std::string GetCaseSensitiveStringFromCommandToken(CommandToken TargetToken)
Get case sensitive string from command token.
Definition common.cpp:467
BOOLEAN ConvertTokenToUInt32(CommandToken TargetToken, PUINT32 Result)
check and convert command token to a 32 bit unsigned integer
Definition common.cpp:546
BOOLEAN HyperDbgCheckWhetherTheCurrentInstructionIsRet(UCHAR *BufferToDisassemble, UINT64 BuffLength, BOOLEAN Isx86_64)
Check whether the current instruction is a 'ret' or not.
Definition disassembler.cpp:1095
BOOLEAN g_IsRunningInstruction32Bit
whether the Current executing instructions is 32-bit or 64 bit
Definition globals.h:232
BOOLEAN g_IsInstrumentingInstructions
Shows whether the user is running 't', 'p', or 'i' command.
Definition globals.h:571
VOID CommandGuHelp()
help of the gu command
Definition gu.cpp:29
BYTE g_CurrentRunningInstruction[MAXIMUM_INSTR_SIZE]
Current executing instructions.
Definition globals.h:226
BOOLEAN SteppingStepOverForGu(BOOLEAN LastInstruction)
Perform Step-over for GU.
Definition steppings.cpp:155

◆ CommandGuHelp()

VOID CommandGuHelp ( )

help of the gu command

Returns
VOID
30{
31 ShowMessages(
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.

372{0};

◆ g_CurrentRunningInstruction

BYTE g_CurrentRunningInstruction[MAXIMUM_INSTR_SIZE]
extern

Current executing instructions.

226{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).