change the SDK api to C types

This commit is contained in:
unknown 2022-11-16 14:25:37 +09:00
parent daffe69a3d
commit 1b9ba13d5d
5 changed files with 52 additions and 34 deletions

View file

@ -146,7 +146,7 @@ HyperDbgScriptReadFileAndExecuteCommand(std::vector<std::string> & PathAndArgs)
//
// Check for multiline commands
//
if (HyperDbgCheckMultilineCommand(Line, Reset))
if (HyperDbgCheckMultilineCommand((char *)Line.c_str(), Reset))
{
//
// if the reset is true, we should make the saving buffer empty
@ -219,6 +219,42 @@ HyperDbgScriptReadFileAndExecuteCommand(std::vector<std::string> & PathAndArgs)
}
}
/**
* @brief Parsing the command line options for scripts
*
* @return int
*/
int
HyperDbgScriptReadFileAndExecuteCommandline(int argc, char * argv[])
{
vector<string> Args;
//
// Convert it to the array
//
for (size_t i = 2; i < argc; i++)
{
std::string TempStr(argv[i]);
Args.push_back(TempStr);
}
//
// Check if the target path and args for script is not empty
//
if (!Args.empty())
{
HyperDbgScriptReadFileAndExecuteCommand(Args);
printf("\n");
}
else
{
printf("err, invalid command line options passed to the HyperDbg!\n");
return FALSE;
}
return TRUE;
}
/**
* @brief .script command handler
*

View file

@ -369,9 +369,10 @@ HyperDbgShowSignature()
* return false
*/
bool
HyperDbgCheckMultilineCommand(std::string & CurrentCommand, bool Reset)
HyperDbgCheckMultilineCommand(char * CurrentCommand, bool Reset)
{
UINT32 CurrentCommandLen = 0;
UINT32 CurrentCommandLen = 0;
std::string CurrentCommandStr(CurrentCommand);
if (Reset)
{
@ -380,11 +381,11 @@ HyperDbgCheckMultilineCommand(std::string & CurrentCommand, bool Reset)
g_InterpreterCountOfOpenCurlyBrackets = 0;
}
CurrentCommandLen = CurrentCommand.length();
CurrentCommandLen = CurrentCommandStr.length();
for (size_t i = 0; i < CurrentCommandLen; i++)
{
switch (CurrentCommand.at(i))
switch (CurrentCommandStr.at(i))
{
case '"':

View file

@ -37,7 +37,7 @@ __declspec(dllexport) int HyperDbgStopVmmDriver();
__declspec(dllexport) int HyperDbgInterpreter(char * Command);
__declspec(dllexport) void HyperDbgShowSignature();
__declspec(dllexport) void HyperdbgSetTextMessageCallback(Callback handler);
__declspec(dllexport) void HyperDbgScriptReadFileAndExecuteCommand(std::vector<std::string> & PathAndArgs);
__declspec(dllexport) int HyperDbgScriptReadFileAndExecuteCommandline(int argc, char * argv[]);
__declspec(dllexport) bool HyperDbgContinuePreviousCommand();
__declspec(dllexport) bool HyperDbgCheckMultilineCommand(std::string & CurrentCommand, bool Reset);
__declspec(dllexport) bool HyperDbgCheckMultilineCommand(char * CurrentCommand, bool Reset);
}

View file

@ -32,10 +32,9 @@ using namespace std;
int
main(int argc, char * argv[])
{
bool ExitFromDebugger = false;
string PreviousCommand;
bool Reset = false;
vector<string> Args;
bool ExitFromDebugger = false;
string PreviousCommand;
bool Reset = false;
printf("HyperDbg Debugger [version: %s, build: %s]\n", CompleteVersion, BuildVersion);
printf("Please visit https://docs.hyperdbg.org for more information...\n");
@ -49,27 +48,9 @@ main(int argc, char * argv[])
if (!strcmp(argv[1], "--script"))
{
//
// Handle the script
//
//
for (size_t i = 2; i < argc; i++)
{
std::string TempStr(argv[i]);
Args.push_back(TempStr);
}
//
// Check if the target path and args for script is not empty
//
if (!Args.empty())
{
HyperDbgScriptReadFileAndExecuteCommand(Args);
printf("\n");
}
else
{
printf("err, invalid command line options passed to the HyperDbg!\n");
return 1;
}
HyperDbgScriptReadFileAndExecuteCommandline(argc, argv);
}
else
{
@ -110,7 +91,7 @@ main(int argc, char * argv[])
//
// Check for multi-line commands
//
if (HyperDbgCheckMultilineCommand(TempCommand, Reset) == true)
if (HyperDbgCheckMultilineCommand((char *)TempCommand.c_str(), Reset) == true)
{
//
// It's a multi-line command

View file

@ -23,9 +23,9 @@ __declspec(dllimport) int HyperDbgStopVmmDriver();
__declspec(dllimport) int HyperDbgInterpreter(char * Command);
__declspec(dllimport) void HyperDbgShowSignature();
__declspec(dllimport) void HyperDbgSetTextMessageCallback(Callback handler);
__declspec(dllimport) void HyperDbgScriptReadFileAndExecuteCommand(std::vector<std::string> & PathAndArgs);
__declspec(dllimport) int HyperDbgScriptReadFileAndExecuteCommandline(int argc, char * argv[]);
__declspec(dllimport) bool HyperDbgContinuePreviousCommand();
__declspec(dllimport) bool HyperDbgCheckMultilineCommand(std::string & CurrentCommand, bool Reset);
__declspec(dllimport) bool HyperDbgCheckMultilineCommand(char * CurrentCommand, bool Reset);
#ifdef __cplusplus
}