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

98 lines
2 KiB
C++
Raw Permalink Normal View History

2021-03-11 01:17:23 +03:30
/**
* @file bc.cpp
2022-01-18 22:38:56 +03:30
* @author Sina Karvandi (sina@hyperdbg.org)
2021-03-11 01:17:23 +03:30
* @brief bc command
* @details
* @version 0.1
* @date 2021-03-11
*
* @copyright This project is released under the GNU Public License v3.
*
*/
#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 bc command
2021-03-11 01:17:23 +03:30
*
* @return VOID
*/
2021-03-22 18:19:39 +04:30
VOID
CommandBcHelp()
{
ShowMessages("bc : clears a breakpoint using breakpoint id.\n\n");
ShowMessages("syntax : \tbc [BreakpointId (hex)]\n");
ShowMessages("\n");
2021-03-22 18:19:39 +04:30
ShowMessages("\t\te.g : bc 0\n");
ShowMessages("\t\te.g : bc 2\n");
2021-03-11 01:17:23 +03:30
}
/**
* @brief handler of bc command
*
2024-07-29 18:06:54 +09:00
* @param CommandTokens
* @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
CommandBc(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
{
ShowMessages("incorrect use of the '%s'\n\n",
GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
2021-03-22 18:19:39 +04:30
CommandBcHelp();
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");
CommandBcHelp();
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 clearing breakpoint
//
Request.Request = DEBUGGEE_BREAKPOINT_MODIFICATION_REQUEST_CLEAR;
//
// 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, clearing breakpoints is only valid if you connected to "
"a debuggee in debugger-mode\n");
}
2021-03-11 01:17:23 +03:30
}