2020-10-08 05:32:57 -07:00
|
|
|
/**
|
|
|
|
|
* @file print.cpp
|
2022-01-18 22:38:56 +03:30
|
|
|
* @author Sina Karvandi (sina@hyperdbg.org)
|
|
|
|
|
* @author M.H. Gholamrezaei (mh@hyperdbg.org)
|
2020-10-08 05:32:57 -07:00
|
|
|
* @brief print command
|
|
|
|
|
* @details
|
|
|
|
|
* @version 0.1
|
|
|
|
|
* @date 2020-10-08
|
|
|
|
|
*
|
|
|
|
|
* @copyright This project is released under the GNU Public License v3.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2022-05-04 16:38:21 -07:00
|
|
|
#include "pch.h"
|
2020-10-21 11:12:41 +03:30
|
|
|
|
2020-10-22 09:02:28 -07:00
|
|
|
using namespace std;
|
2020-10-08 08:16:23 -07:00
|
|
|
|
2020-10-08 05:32:57 -07:00
|
|
|
/**
|
2023-07-13 16:05:42 +09:00
|
|
|
* @brief help of the print command
|
2020-10-08 05:32:57 -07:00
|
|
|
*
|
|
|
|
|
* @return VOID
|
|
|
|
|
*/
|
2021-03-22 18:19:39 +04:30
|
|
|
VOID
|
|
|
|
|
CommandPrintHelp()
|
|
|
|
|
{
|
2022-04-10 22:24:56 +04:30
|
|
|
ShowMessages("print : evaluates expressions.\n\n");
|
2022-04-17 23:05:24 +04:30
|
|
|
|
2022-02-08 16:06:26 +03:30
|
|
|
ShowMessages("syntax : \tprint [Expression (string)]\n");
|
2022-04-17 23:05:24 +04:30
|
|
|
|
|
|
|
|
ShowMessages("\n");
|
2021-03-22 18:19:39 +04:30
|
|
|
ShowMessages("\t\te.g : print dq(poi(@rcx))\n");
|
2020-10-08 05:32:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief handler of print command
|
|
|
|
|
*
|
2024-07-31 18:21:23 +09:00
|
|
|
* @param CommandTokens
|
2021-02-10 15:19:01 -08:00
|
|
|
* @param Command
|
2024-07-31 18:21:23 +09:00
|
|
|
*
|
2020-10-08 05:32:57 -07:00
|
|
|
* @return VOID
|
|
|
|
|
*/
|
2021-03-22 18:19:39 +04:30
|
|
|
VOID
|
2024-07-31 18:21:23 +09:00
|
|
|
CommandPrint(vector<CommandToken> CommandTokens, string Command)
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
2024-07-31 18:21:23 +09:00
|
|
|
if (CommandTokens.size() == 1)
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
2024-07-31 18:21:23 +09:00
|
|
|
ShowMessages("incorrect use of the '%s'\n\n",
|
|
|
|
|
GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
|
2021-03-22 18:19:39 +04:30
|
|
|
CommandPrintHelp();
|
|
|
|
|
return;
|
2021-02-04 06:40:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
// Trim the command
|
2021-02-04 06:40:09 -08:00
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
Trim(Command);
|
2021-02-04 06:40:09 -08:00
|
|
|
|
|
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
// Remove print from it
|
2021-02-04 06:40:09 -08:00
|
|
|
//
|
2024-07-31 18:21:23 +09:00
|
|
|
Command.erase(0, GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).size());
|
2021-02-04 06:40:09 -08:00
|
|
|
|
|
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
// Trim it again
|
2021-02-04 06:40:09 -08:00
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
Trim(Command);
|
2021-02-04 06:40:09 -08:00
|
|
|
|
2021-02-04 13:36:57 -08:00
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
// Prepend and append 'print(' and ')'
|
2021-02-04 13:36:57 -08:00
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
Command.insert(0, "print(");
|
|
|
|
|
Command.append(");");
|
2021-02-04 13:36:57 -08:00
|
|
|
|
2025-09-01 14:38:59 +02:00
|
|
|
//
|
|
|
|
|
// Execute the expression
|
|
|
|
|
//
|
|
|
|
|
ScriptEngineExecuteSingleExpression((CHAR *)Command.c_str(), TRUE, FALSE);
|
2020-10-08 05:32:57 -07:00
|
|
|
}
|