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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2022-05-04 16:38:21 -07:00
|
|
|
#include "pch.h"
|
2020-07-25 03:32:04 -07:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Global Variables
|
|
|
|
|
//
|
2022-01-16 03:16:15 +03:30
|
|
|
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");
|
2022-04-17 23:05:24 +04:30
|
|
|
|
2022-02-08 16:06:26 +03:30
|
|
|
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
|
|
|
{
|
2020-12-22 15:16:46 -08:00
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
// Check if the remote serial debuggee is paused or not
|
2020-12-22 15:16:46 -08:00
|
|
|
//
|
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'
|
2022-01-13 01:12:04 +03:30
|
|
|
// 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
|
|
|
}
|
2022-01-16 03:16:15 +03:30
|
|
|
else if (g_ActiveProcessDebuggingState.IsActive)
|
2022-01-13 01:12:04 +03:30
|
|
|
{
|
2022-01-28 21:19:20 +03:30
|
|
|
if (g_ActiveProcessDebuggingState.IsPaused)
|
|
|
|
|
{
|
2025-06-23 20:35:32 +02:00
|
|
|
UdContinueProcess(g_ActiveProcessDebuggingState.ProcessDebuggingToken);
|
2022-01-28 21:19:20 +03:30
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Target process is running
|
|
|
|
|
//
|
|
|
|
|
g_ActiveProcessDebuggingState.IsPaused = FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2025-06-24 18:12:02 +02:00
|
|
|
ShowMessages("the target process is already running\n");
|
2022-01-28 21:19:20 +03:30
|
|
|
}
|
2022-01-13 01:12:04 +03:30
|
|
|
}
|
2020-12-22 15:16:46 -08:00
|
|
|
}
|
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
|
2024-07-31 14:08:14 +09:00
|
|
|
* @param Command
|
2024-07-29 18:06:54 +09:00
|
|
|
*
|
2021-04-28 02:16:33 +04:30
|
|
|
* @return VOID
|
|
|
|
|
*/
|
|
|
|
|
VOID
|
2024-07-31 14:08:14 +09:00
|
|
|
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();
|
|
|
|
|
}
|