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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2022-05-04 16:38:21 -07:00
|
|
|
#include "pch.h"
|
2022-01-06 23:24:05 +03:30
|
|
|
|
2022-01-10 21:46:48 +03:30
|
|
|
//
|
|
|
|
|
// Global Variables
|
|
|
|
|
//
|
2023-08-06 23:50:17 +09:00
|
|
|
extern UINT32 g_ProcessIdOfLatestStartingProcess;
|
2022-01-16 03:16:15 +03:30
|
|
|
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-04-17 23:05:24 +04:30
|
|
|
|
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
|
2024-07-31 14:08:14 +09:00
|
|
|
* @param Command
|
2024-07-30 15:07:17 +09:00
|
|
|
*
|
2022-01-06 23:24:05 +03:30
|
|
|
* @return VOID
|
|
|
|
|
*/
|
|
|
|
|
VOID
|
2024-07-31 14:08:14 +09:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-06 23:50:17 +09:00
|
|
|
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
|
|
|
}
|