HyperDbg/hyperdbg/libhyperdbg/code/debugger/commands/debugging-commands/pause.cpp

86 lines
1.8 KiB
C++
Raw Permalink Normal View History

2020-07-25 03:32:04 -07:00
/**
* @file pause.cpp
2022-01-18 22:38:56 +03:30
* @author Sina Karvandi (sina@hyperdbg.org)
2020-07-25 03:32:04 -07:00
* @brief pause command
* @details
* @version 0.1
* @date 2020-07-25
*
* @copyright This project is released under the GNU Public License v3.
*
*/
#include "pch.h"
2020-07-25 03:32:04 -07:00
//
// Global Variables
//
2022-01-17 14:54:41 +03:30
extern BOOLEAN g_BreakPrintingOutput;
extern BOOLEAN g_IsConnectedToRemoteDebuggee;
extern ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState;
2020-07-25 03:32:04 -07:00
2020-08-28 04:03:12 -07:00
/**
2023-07-13 16:05:42 +09:00
* @brief help of the pause command
2021-02-10 15:19:01 -08:00
*
* @return VOID
2020-08-28 04:03:12 -07:00
*/
2021-03-22 18:19:39 +04:30
VOID
CommandPauseHelp()
{
ShowMessages("pause : pauses the kernel events.\n\n");
ShowMessages("syntax : \tpause \n");
2020-07-25 03:32:04 -07:00
}
2020-08-28 04:03:12 -07:00
/**
2023-01-18 20:23:40 +09:00
* @brief request to pause
2021-02-10 15:19:01 -08:00
*
* @return VOID
2020-08-28 04:03:12 -07:00
*/
2021-03-22 18:19:39 +04:30
VOID
2021-04-28 02:16:33 +04:30
CommandPauseRequest()
2021-03-22 18:19:39 +04:30
{
//
// Set the g_BreakPrintingOutput to TRUE
//
g_BreakPrintingOutput = TRUE;
2022-01-17 14:54:41 +03:30
ShowMessages("pausing...\n");
2020-07-25 03:32:04 -07:00
2021-04-22 03:17:46 +04:30
//
// If it's a remote debugger then we send the remote debuggee a 'g'
//
if (g_IsConnectedToRemoteDebuggee)
{
2024-03-14 14:02:18 +09:00
RemoteConnectionSendCommand("pause", (UINT32)strlen("pause") + 1);
2021-04-22 03:17:46 +04:30
}
2022-01-17 14:54:41 +03:30
else if (g_ActiveProcessDebuggingState.IsActive && UdPauseProcess(g_ActiveProcessDebuggingState.ProcessDebuggingToken))
{
ShowMessages("please keep interacting with the process until all the threads are intercepted "
"and halted; you can run the 'g' command to continue the debuggee\n");
2022-01-17 14:54:41 +03:30
}
2020-07-25 03:32:04 -07:00
}
2021-04-28 02:16:33 +04:30
/**
* @brief pause command handler
*
2024-07-30 13:17:50 +09:00
* @param CommandTokens
* @param Command
2024-07-30 13:17:50 +09:00
*
2021-04-28 02:16:33 +04:30
* @return VOID
*/
VOID
CommandPause(vector<CommandToken> CommandTokens, string Command)
2021-04-28 02:16:33 +04:30
{
2024-07-30 13:17:50 +09:00
if (CommandTokens.size() != 1)
2021-04-28 02:16:33 +04:30
{
ShowMessages("incorrect use of the '%s'\n\n",
GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
2021-04-28 02:16:33 +04:30
CommandPauseHelp();
return;
}
2024-07-30 13:17:50 +09:00
//
// request to pause
//
2021-04-28 02:16:33 +04:30
CommandPauseRequest();
}