HyperDbg/hyperdbg/libhyperdbg/code/debugger/commands/meta-commands/kill.cpp

80 lines
1.7 KiB
C++
Raw Permalink Normal View History

2022-01-06 23:24:05 +03:30
/**
* @file kill.cpp
2022-01-18 22:38:56 +03:30
* @author Sina Karvandi (sina@hyperdbg.org)
2022-01-06 23:24:05 +03:30
* @brief .kill command
* @details
* @version 0.1
* @date 2022-01-06
*
* @copyright This project is released under the GNU Public License v3.
*
*/
#include "pch.h"
2022-01-06 23:24:05 +03:30
2022-01-10 21:46:48 +03:30
//
// Global Variables
//
extern UINT32 g_ProcessIdOfLatestStartingProcess;
extern ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState;
2022-01-10 21:46:48 +03:30
2022-01-06 23:24:05 +03:30
/**
2023-07-13 16:05:42 +09:00
* @brief help of the .kill command
2022-01-06 23:24:05 +03:30
*
* @return VOID
*/
VOID
CommandKillHelp()
{
2022-04-10 22:24:56 +04:30
ShowMessages(".kill : terminates the current running process.\n\n");
2022-02-09 02:16:58 +03:30
ShowMessages("syntax : \t.kill \n");
2022-01-06 23:24:05 +03:30
}
/**
* @brief .kill command handler
*
2024-07-30 15:07:17 +09:00
* @param CommandTokens
* @param Command
2024-07-30 15:07:17 +09:00
*
2022-01-06 23:24:05 +03:30
* @return VOID
*/
VOID
CommandKill(vector<CommandToken> CommandTokens, string Command)
2022-01-06 23:24:05 +03:30
{
2024-07-30 15:07:17 +09:00
if (CommandTokens.size() != 1)
2022-01-10 21:46:48 +03:30
{
2024-07-30 15:07:17 +09:00
ShowMessages("incorrect use of the '%s'\n\n",
GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
2022-01-10 21:46:48 +03:30
CommandKillHelp();
return;
}
if (g_ActiveProcessDebuggingState.IsActive)
{
//
// Kill the current active process
//
if (!UdKillProcess(g_ActiveProcessDebuggingState.ProcessId))
{
ShowMessages("process does not exists, is it already terminated?\n");
}
}
else if (g_ProcessIdOfLatestStartingProcess != NULL)
{
if (!UdKillProcess(g_ProcessIdOfLatestStartingProcess))
{
ShowMessages("process does not exists, is it already terminated?\n");
}
//
// No longer the last process exists
//
g_ProcessIdOfLatestStartingProcess = NULL;
}
else
2022-01-10 21:46:48 +03:30
{
ShowMessages("nothing to terminate!\n");
return;
}
2022-01-06 23:24:05 +03:30
}