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

106 lines
2.4 KiB
C++
Raw Permalink Normal View History

2020-07-25 03:32:04 -07:00
/**
* @file g.cpp
2022-01-18 22:38:56 +03:30
* @author Sina Karvandi (sina@hyperdbg.org)
2020-07-25 03:32:04 -07:00
* @brief g 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
//
extern BOOLEAN g_BreakPrintingOutput;
extern BOOLEAN g_IsConnectedToRemoteDebuggee;
extern BOOLEAN g_IsSerialConnectedToRemoteDebuggee;
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 g command
2020-08-28 06:07:44 -07:00
*
* @return VOID
2020-08-28 04:03:12 -07:00
*/
2021-03-22 18:19:39 +04:30
VOID
CommandGHelp()
{
2022-04-10 22:24:56 +04:30
ShowMessages("g : continues debuggee or continues processing kernel messages.\n\n");
ShowMessages("syntax : \tg \n");
2020-07-25 03:32:04 -07:00
}
2020-08-28 04:03:12 -07:00
/**
2021-04-28 02:16:33 +04:30
* @brief Request to unpause
2020-08-28 06:07:44 -07: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
CommandGRequest()
2021-03-22 18:19:39 +04:30
{
//
2021-03-22 18:19:39 +04:30
// Check if the remote serial debuggee is paused or not
//
2021-03-22 18:19:39 +04:30
if (g_IsSerialConnectedToRemoteDebuggee)
{
KdBreakControlCheckAndContinueDebugger();
}
else
{
//
// Set the g_BreakPrintingOutput to FALSE
//
g_BreakPrintingOutput = FALSE;
2020-08-28 06:07:44 -07:00
2021-03-22 18:19:39 +04:30
//
// If it's a remote debugger then we send the remote debuggee a 'g'
// and if we're connect to user debugger then we send the packet
// with current debugging thread token
2021-03-22 18:19:39 +04:30
//
if (g_IsConnectedToRemoteDebuggee)
{
2024-03-14 14:02:18 +09:00
RemoteConnectionSendCommand("g", (UINT32)strlen("g") + 1);
2021-03-22 18:19:39 +04:30
}
else if (g_ActiveProcessDebuggingState.IsActive)
{
if (g_ActiveProcessDebuggingState.IsPaused)
{
UdContinueProcess(g_ActiveProcessDebuggingState.ProcessDebuggingToken);
//
// Target process is running
//
g_ActiveProcessDebuggingState.IsPaused = FALSE;
}
else
{
ShowMessages("the target process is already running\n");
}
}
}
2020-07-25 03:32:04 -07:00
}
2021-04-28 02:16:33 +04:30
/**
* @brief handler of g command
*
2024-07-29 18:06:54 +09:00
* @param CommandTokens
* @param Command
2024-07-29 18:06:54 +09:00
*
2021-04-28 02:16:33 +04:30
* @return VOID
*/
VOID
CommandG(vector<CommandToken> CommandTokens, string Command)
2021-04-28 02:16:33 +04:30
{
2024-07-29 18:06:54 +09:00
if (CommandTokens.size() != 1)
2021-04-28 02:16:33 +04:30
{
2024-07-30 15:07:17 +09:00
ShowMessages("incorrect use of the '%s'\n\n",
GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
2021-04-28 02:16:33 +04:30
CommandGHelp();
return;
}
CommandGRequest();
}