2021-03-11 01:17:23 +03:30
|
|
|
/**
|
|
|
|
|
* @file be.cpp
|
2022-01-18 22:38:56 +03:30
|
|
|
* @author Sina Karvandi (sina@hyperdbg.org)
|
2021-03-11 01:17:23 +03:30
|
|
|
* @brief be command
|
|
|
|
|
* @details
|
|
|
|
|
* @version 0.1
|
|
|
|
|
* @date 2021-03-11
|
|
|
|
|
*
|
|
|
|
|
* @copyright This project is released under the GNU Public License v3.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2022-05-04 16:38:21 -07:00
|
|
|
#include "pch.h"
|
2021-03-11 01:17:23 +03:30
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Global Variables
|
|
|
|
|
//
|
|
|
|
|
extern BOOLEAN g_IsSerialConnectedToRemoteDebuggee;
|
|
|
|
|
|
|
|
|
|
/**
|
2023-07-13 16:05:42 +09:00
|
|
|
* @brief help of the be command
|
2021-03-11 01:17:23 +03:30
|
|
|
*
|
|
|
|
|
* @return VOID
|
|
|
|
|
*/
|
2021-03-22 18:19:39 +04:30
|
|
|
VOID
|
|
|
|
|
CommandBeHelp()
|
|
|
|
|
{
|
|
|
|
|
ShowMessages("be : enables a breakpoint using breakpoint id.\n\n");
|
2022-04-17 23:05:24 +04:30
|
|
|
|
2022-02-08 16:06:26 +03:30
|
|
|
ShowMessages("syntax : \tbe [BreakpointId (hex)]\n");
|
2022-04-17 23:05:24 +04:30
|
|
|
|
|
|
|
|
ShowMessages("\n");
|
2021-03-22 18:19:39 +04:30
|
|
|
ShowMessages("\t\te.g : be 0\n");
|
|
|
|
|
ShowMessages("\t\te.g : be 2\n");
|
2021-03-11 01:17:23 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief handler of be 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-03-11 01:17:23 +03:30
|
|
|
* @return VOID
|
|
|
|
|
*/
|
2021-03-22 18:19:39 +04:30
|
|
|
VOID
|
2024-07-31 14:08:14 +09:00
|
|
|
CommandBe(vector<CommandToken> CommandTokens, string Command)
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
|
|
|
|
UINT64 BreakpointId;
|
|
|
|
|
DEBUGGEE_BP_LIST_OR_MODIFY_PACKET Request = {0};
|
2021-03-11 01:17:23 +03:30
|
|
|
|
|
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
// Validate the commands
|
2021-03-11 01:17:23 +03:30
|
|
|
//
|
2024-07-29 18:06:54 +09:00
|
|
|
if (CommandTokens.size() != 2)
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
2024-07-31 18:21:23 +09:00
|
|
|
ShowMessages("incorrect use of the '%s'\n\n",
|
|
|
|
|
GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
|
2021-03-22 18:19:39 +04:30
|
|
|
CommandBeHelp();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-03-11 01:17:23 +03:30
|
|
|
|
2021-03-13 00:40:16 +03:30
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
// Get the breakpoint id
|
2021-03-13 00:40:16 +03:30
|
|
|
//
|
2024-07-29 18:06:54 +09:00
|
|
|
if (!ConvertTokenToUInt64(CommandTokens.at(1), &BreakpointId))
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
|
|
|
|
ShowMessages("please specify a correct hex value for breakpoint id\n\n");
|
|
|
|
|
CommandBeHelp();
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-03-13 00:40:16 +03:30
|
|
|
|
2021-03-11 01:17:23 +03:30
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
// Check if the remote serial debuggee is paused or not (connected or not)
|
2021-03-11 01:17:23 +03:30
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
if (g_IsSerialConnectedToRemoteDebuggee)
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
// Perform enabling breakpoint
|
|
|
|
|
//
|
|
|
|
|
Request.Request = DEBUGGEE_BREAKPOINT_MODIFICATION_REQUEST_ENABLE;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Set breakpoint id
|
|
|
|
|
//
|
|
|
|
|
Request.BreakpointId = BreakpointId;
|
2021-03-11 01:17:23 +03:30
|
|
|
|
2021-03-22 18:19:39 +04:30
|
|
|
//
|
|
|
|
|
// Send the request
|
|
|
|
|
//
|
|
|
|
|
KdSendListOrModifyPacketToDebuggee(&Request);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ShowMessages("err, enabling breakpoints is only valid if you connected to "
|
|
|
|
|
"a debuggee in debugger-mode\n");
|
|
|
|
|
}
|
2021-03-11 01:17:23 +03:30
|
|
|
}
|