mirror of
https://github.com/HyperDbg/HyperDbg.git
synced 2026-07-10 01:29:59 +00:00
86 lines
1.7 KiB
C++
86 lines
1.7 KiB
C++
/**
|
|
* @file exit.cpp
|
|
* @author Sina Karvandi (sina@hyperdbg.org)
|
|
* @brief exit command
|
|
* @details
|
|
* @version 0.1
|
|
* @date 2020-05-27
|
|
*
|
|
* @copyright This project is released under the GNU Public License v3.
|
|
*
|
|
*/
|
|
#include "pch.h"
|
|
|
|
//
|
|
// Global Variables
|
|
//
|
|
extern HANDLE g_DeviceHandle;
|
|
extern BOOLEAN g_IsConnectedToHyperDbgLocally;
|
|
extern BOOLEAN g_IsSerialConnectedToRemoteDebuggee;
|
|
|
|
/**
|
|
* @brief help of the exit command
|
|
*
|
|
* @return VOID
|
|
*/
|
|
VOID
|
|
CommandExitHelp()
|
|
{
|
|
ShowMessages(
|
|
"exit : unloads and uninstalls the drivers and closes the debugger.\n\n");
|
|
|
|
ShowMessages("syntax : \texit\n");
|
|
}
|
|
|
|
/**
|
|
* @brief exit command handler
|
|
*
|
|
* @param CommandTokens
|
|
* @param Command
|
|
*
|
|
* @return VOID
|
|
*/
|
|
VOID
|
|
CommandExit(vector<CommandToken> CommandTokens, string Command)
|
|
{
|
|
if (CommandTokens.size() != 1)
|
|
{
|
|
ShowMessages("incorrect use of the '%s'\n\n",
|
|
GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
|
|
CommandExitHelp();
|
|
return;
|
|
}
|
|
|
|
if (g_IsConnectedToHyperDbgLocally)
|
|
{
|
|
//
|
|
// It is in VMI mode
|
|
//
|
|
|
|
//
|
|
// unload and exit if the vmm module is loaded
|
|
//
|
|
if (g_DeviceHandle)
|
|
{
|
|
//
|
|
// Unload the VMM module first because it is using the driver and then unload the KD module
|
|
//
|
|
HyperDbgUnloadVmm();
|
|
|
|
//
|
|
// Unload the KD module
|
|
//
|
|
HyperDbgUnloadKd();
|
|
}
|
|
}
|
|
else if (g_IsSerialConnectedToRemoteDebuggee)
|
|
{
|
|
//
|
|
// It is in debugger mode
|
|
//
|
|
|
|
KdCloseConnection();
|
|
}
|
|
|
|
exit(0);
|
|
}
|