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_IsDebuggerModulesLoaded
 this variable is used to indicate that modules are loaded so we make sure to later use a trace of loading in 'unload' command (used in Debugger VMM)
 
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 {
119 "\npausing...\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");
123 }
124 else
125 {
127 "\npausing...\nauto-unpause mode is disabled, you "
128 "should run 'g' when you want to continue, otherwise run "
129 "'settings "
130 "autounpause on'\n\n");
131 }
132
133 //
134 // Show the signature of HyperDbg
135 //
137
139 {
141 }
142 }
143 }
144 }
145
146 return TRUE;
147
148 //
149 // CTRL+CLOSE: confirm that the user wants to exit.
150 //
151 case CTRL_CLOSE_EVENT:
152 return TRUE;
153
154 case CTRL_LOGOFF_EVENT:
155 return FALSE;
156
157 case CTRL_SHUTDOWN_EVENT:
158 return FALSE;
159
160 default:
161
162 //
163 // Return TRUE if handled this message, further handler functions won't be
164 // called.
165 // Return FALSE to pass this message to further handlers until default
166 // handler calls ExitProcess().
167 //
168 return FALSE;
169 }
170}
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned int UINT32
Definition BasicTypes.h:48
BOOLEAN g_IsConnectedToRemoteDebuggee
Shows whether the current debugger is the host and connected to a remote debuggee (guest)
Definition globals.h:74
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
BOOLEAN g_BreakPrintingOutput
Shows whether the pause command or CTRL+C or CTRL+Break is executed or not.
Definition globals.h:499
BOOLEAN g_IsExecutingSymbolLoadingRoutines
Executing symbol reloading or downloading routines.
Definition globals.h:506
ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState
State of active debugging thread.
Definition globals.h:362
BOOLEAN g_AutoUnpause
Whether auto-unpause mode is enabled or not enabled.
Definition globals.h:577
BOOLEAN g_IsDebuggerModulesLoaded
this variable is used to indicate that modules are loaded so we make sure to later use a trace of loa...
Definition globals.h:356
BOOLEAN g_IgnorePauseRequests
Show whether the pause request (CTRL+C or CTRL+BREAK) should be ignored or not.
Definition globals.h:158
VOID HyperDbgShowSignature()
Show signature of HyperDbg.
Definition interpreter.cpp:566
VOID KdBreakControlCheckAndPauseDebugger()
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
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:228
BOOLEAN IsActive
Definition ud.h:49
UINT64 ProcessDebuggingToken
Definition ud.h:50
BOOLEAN UdPauseProcess(UINT64 ProcessDebuggingToken)
Pause the target process.
Definition ud.cpp:843

Variable Documentation

◆ g_ActiveProcessDebuggingState

ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState
extern

State of active debugging thread.

362{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_IsDebuggerModulesLoaded

BOOLEAN g_IsDebuggerModulesLoaded
extern

this variable is used to indicate that modules are loaded so we make sure to later use a trace of loading in 'unload' command (used in Debugger VMM)

◆ 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_IsSerialConnectedToRemoteDebuggee

BOOLEAN g_IsSerialConnectedToRemoteDebuggee
extern

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