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

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

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.
*
*/
#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");
ShowMessages("syntax : \tbe [BreakpointId (hex)]\n");
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
* @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
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
{
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
}