HyperDbg/hyperdbg/hyperdbg-cli/hyperdbg-cli.cpp

92 lines
1.8 KiB
C++
Raw Normal View History

2020-04-11 08:27:51 -07:00
/**
* @file hyperdbg-cli.cpp
* @author Sina Karvandi (sina@rayanfam.com)
2020-04-11 10:28:37 -07:00
* @brief Main HyperDbg Cli source coede
2020-04-11 08:27:51 -07:00
* @details
* @version 0.1
* @date 2020-04-11
2020-04-11 10:28:37 -07:00
*
2020-04-11 08:27:51 -07:00
* @copyright This project is released under the GNU Public License v3.
2020-04-11 10:28:37 -07:00
*
2020-04-11 08:27:51 -07:00
*/
2020-03-24 06:35:02 -07:00
#include <Windows.h>
2020-04-11 20:43:08 -07:00
#include <string>
2020-03-24 06:35:02 -07:00
#include <conio.h>
2020-04-11 10:28:37 -07:00
#include <iostream>
#include "Definition.h"
#include "Configuration.h"
2020-04-12 03:09:26 -07:00
#include "details.h"
2020-03-24 06:35:02 -07:00
2020-03-26 11:02:50 -07:00
#pragma comment(lib, "HPRDBGCTRL.lib")
2020-03-24 06:35:02 -07:00
2020-04-11 20:43:08 -07:00
using namespace std;
2020-04-11 10:28:37 -07:00
//
// Header file of HPRDBGCTRL
// Imports
//
extern "C"
{
__declspec (dllimport) int __cdecl HyperdbgLoad();
__declspec (dllimport) int __cdecl HyperdbgUnload();
__declspec (dllimport) int __cdecl HyperdbgInstallDriver();
__declspec (dllimport) int __cdecl HyperdbgUninstallDriver();
2020-04-12 03:09:26 -07:00
__declspec (dllimport) int __cdecl HyperdbgInterpreter(const char* Command);
2020-04-11 10:28:37 -07:00
__declspec (dllimport) void __stdcall HyperdbgSetTextMessageCallback(Callback handler);
2020-04-01 09:34:24 -07:00
}
2020-03-24 06:35:02 -07:00
2020-04-11 20:43:08 -07:00
2020-04-11 10:28:37 -07:00
/**
* @brief CLI main function
*
* @return int
*/
int main()
{
//
// Put to ease the test, it will be removed
//
2020-04-28 06:41:33 -07:00
/*if (HyperdbgInstallDriver()) {
2020-04-27 10:44:15 -07:00
return 1;
}
if (HyperdbgLoad()) {
return 1;
2020-04-28 06:41:33 -07:00
}*/
2020-04-27 10:44:15 -07:00
// ---------------------------------------------------------
2020-04-12 03:09:26 -07:00
bool ExitFromDebugger = false;
printf("HyperDbg Debugger [core version: v%s]\n",Version);
printf("Please visit https://docs.hyperdbg.com for more information...\n");
printf("HyperDbg is released under the GNU Public License v3 (GPLv3).\n\n");
while (!ExitFromDebugger)
{
2020-04-12 08:50:58 -07:00
printf("HyperDbg >");
2020-04-12 03:09:26 -07:00
string command;
getline(cin, command);
int CommandExecutionResult = HyperdbgInterpreter(command.c_str());
printf("\n");
2020-04-12 03:09:26 -07:00
//
//if the debugger encounters an exit state then the return will be 1
//
if (CommandExecutionResult == 1)
{
//
// Exit from the debugger
//
ExitFromDebugger = true;
}
2020-04-12 03:09:26 -07:00
}
2020-04-11 10:28:37 -07:00
return 0;
2020-03-24 06:35:02 -07:00
}
2020-04-11 10:28:37 -07:00