HyperDbg Debugger
Loading...
Searching...
No Matches
break-control.cpp File Reference

break control is the handler for CTRL+C and CTRL+BREAK Signals More...

#include "pch.h"

Functions

BOOL BreakController (DWORD CtrlType)
 handle CTRL+C and CTRL+Break events

Variables

BOOLEAN g_BreakPrintingOutput
 Shows whether the pause command or CTRL+C or CTRL+Break is executed or not.
BOOLEAN g_IsKdModuleLoaded
 shows whether the kernel debugger (KD) module is loaded or not
BOOLEAN g_AutoUnpause
 Whether auto-unpause mode is enabled or not enabled.
BOOLEAN g_IsConnectedToRemoteDebuggee
 Shows whether the current debugger is the host and connected to a remote debuggee (guest).
BOOLEAN g_IsSerialConnectedToRemoteDebuggee
 Shows if the debugger was connected to remote debuggee over (A remote guest).
BOOLEAN g_IsExecutingSymbolLoadingRoutines
 Executing symbol reloading or downloading routines.
BOOLEAN g_IsInstrumentingInstructions
 Shows whether the user is running 't', 'p', or 'i' command.
BOOLEAN g_IgnorePauseRequests
 Show whether the pause request (CTRL+C or CTRL+BREAK) should be ignored or not.
ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState
 State of active debugging thread.

Detailed Description

break control is the handler for CTRL+C and CTRL+BREAK Signals

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.1
Date
2020-07-24

Function Documentation

◆ BreakController()

BOOL BreakController ( DWORD CtrlType)

handle CTRL+C and CTRL+Break events

Parameters
CtrlType
Returns
BOOL
35{
36 switch (CtrlType)
37 {
38 //
39 // Handle the CTRL + C & CTRL + Break signal
40 //
41 case CTRL_BREAK_EVENT:
42 case CTRL_C_EVENT:
43
44 //
45 // check if we should ignore the break requests or not
46 //
48 {
49 return TRUE;
50 }
51
52 //
53 // Check for aborting symbol loading routines
54 //
56 {
57 //
58 // Avoid to calling it again
59 //
61
62 //
63 // Abort the execution
64 //
66 }
67
68 //
69 // Check if the debuggee is running because of pausing or not
70 //
72 {
74 {
76 }
77 else
78 {
80 }
81 }
83 {
84 //
85 // vmm module is not loaded here
86 //
87 }
88 else
89 {
91 {
93 }
94 else
95 {
96 //
97 // Sleep because the other thread that shows must be stopped
98 //
100
101 //
102 // Check if its a remote debuggee then we should send the 'pause' command
103 //
105 {
106 RemoteConnectionSendCommand("pause", (UINT32)strlen("pause") + 1);
107 }
108
109 Sleep(300);
110
111 //
112 // It is because we didn't query the target debuggee auto-unpause variable
113 //
115 {
116 if (g_AutoUnpause)
117 {
118 ShowMessages(
119 "\npausing...%s\nauto-unpause mode is enabled, "
120 "debugger will automatically continue when you run a new "
121 "event command, if you want to change this behaviour then "
122 "run run 'settings autounpause off'\n\n",
124 }
125 else
126 {
127 ShowMessages(
128 "\npausing...%s\nauto-unpause mode is disabled, you "
129 "should run 'g' when you want to continue, otherwise run "
130 "'settings autounpause on'\n\n",
132 }
133
134 //
135 // Show the signature of HyperDbg
136 //
138
139 //
140 // Not pause the process if CTRL+C is pressed (Commented)
141 //
142 // if (g_ActiveProcessDebuggingState.IsActive)
143 // {
144 // UdPauseProcess(g_ActiveProcessDebuggingState.ProcessDebuggingToken);
145 // }
146 }
147 }
148 }
149
150 return TRUE;
151
152 //
153 // CTRL+CLOSE: confirm that the user wants to exit.
154 //
155 case CTRL_CLOSE_EVENT:
156 return TRUE;
157
158 case CTRL_LOGOFF_EVENT:
159 return FALSE;
160
161 case CTRL_SHUTDOWN_EVENT:
162 return FALSE;
163
164 default:
165
166 //
167 // Return TRUE if handled this message, further handler functions won't be
168 // called.
169 // Return FALSE to pass this message to further handlers until default
170 // handler calls ExitProcess().
171 //
172 return FALSE;
173 }
174}
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
BOOLEAN g_IsExecutingSymbolLoadingRoutines
Executing symbol reloading or downloading routines.
Definition globals.h:516
BOOLEAN g_IgnorePauseRequests
Show whether the pause request (CTRL+C or CTRL+BREAK) should be ignored or not.
Definition globals.h:180
#define TRUE
Definition BasicTypes.h:114
#define FALSE
Definition BasicTypes.h:113
unsigned int UINT32
Definition BasicTypes.h:54
BOOLEAN g_IsConnectedToRemoteDebuggee
Shows whether the current debugger is the host and connected to a remote debuggee (guest).
Definition globals.h:96
BOOLEAN g_IsInstrumentingInstructions
Shows whether the user is running 't', 'p', or 'i' command.
Definition globals.h:571
VOID HyperDbgShowSignature()
Show signature of HyperDbg.
Definition interpreter.cpp:1086
VOID KdBreakControlCheckAndPauseDebugger(BOOLEAN SignalRunningFlag)
check if the debuggee needs to be paused
Definition kd.cpp:2040
#define PAUSE_MESSAGE_IN_USER_DEBUGGER
Definition common.h:25
BOOLEAN g_IsKdModuleLoaded
shows whether the kernel debugger (KD) module is loaded or not
Definition globals.h:22
BOOLEAN g_BreakPrintingOutput
Shows whether the pause command or CTRL+C or CTRL+Break is executed or not.
Definition globals.h:509
INT RemoteConnectionSendCommand(const CHAR *sendbuf, INT len)
send the command as a client (debugger, host) to the server (debuggee, guest)
Definition remote-connection.cpp:445
VOID ScriptEngineSymbolAbortLoadingWrapper()
SymbolAbortLoading wrapper.
Definition script-engine-wrapper.cpp:229
BOOLEAN g_AutoUnpause
Whether auto-unpause mode is enabled or not enabled.
Definition globals.h:587

Variable Documentation

◆ g_ActiveProcessDebuggingState

ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState
extern

State of active debugging thread.

372{0};

◆ g_AutoUnpause

BOOLEAN g_AutoUnpause
extern

Whether auto-unpause mode is enabled or not enabled.

it is enabled by default

◆ g_BreakPrintingOutput

BOOLEAN g_BreakPrintingOutput
extern

Shows whether the pause command or CTRL+C or CTRL+Break is executed or not.

◆ g_IgnorePauseRequests

BOOLEAN g_IgnorePauseRequests
extern

Show whether the pause request (CTRL+C or CTRL+BREAK) should be ignored or not.

◆ g_IsConnectedToRemoteDebuggee

BOOLEAN g_IsConnectedToRemoteDebuggee
extern

Shows whether the current debugger is the host and connected to a remote debuggee (guest).

◆ g_IsExecutingSymbolLoadingRoutines

BOOLEAN g_IsExecutingSymbolLoadingRoutines
extern

Executing symbol reloading or downloading routines.

◆ g_IsInstrumentingInstructions

BOOLEAN g_IsInstrumentingInstructions
extern

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

◆ g_IsKdModuleLoaded

BOOLEAN g_IsKdModuleLoaded
extern

shows whether the kernel debugger (KD) module is loaded or not

◆ g_IsSerialConnectedToRemoteDebuggee

BOOLEAN g_IsSerialConnectedToRemoteDebuggee
extern

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