diff --git a/hyperdbg/hprdbgctrl/code/debugger/script-engine-wrapper/script-engine-wrapper.cpp b/hyperdbg/hprdbgctrl/code/debugger/script-engine-wrapper/script-engine-wrapper.cpp index 7d251728..f90a6acb 100644 --- a/hyperdbg/hprdbgctrl/code/debugger/script-engine-wrapper/script-engine-wrapper.cpp +++ b/hyperdbg/hprdbgctrl/code/debugger/script-engine-wrapper/script-engine-wrapper.cpp @@ -340,7 +340,7 @@ ScriptEngineEvalWrapper(PGUEST_REGS GuestRegs, ShowMessages("%s\n", CodeBuffer->Message); } - //RemoveSymbolBuffer(CodeBuffer); + RemoveSymbolBuffer(CodeBuffer); return; } @@ -425,7 +425,7 @@ ScriptEngineWrapperTestParser(string Expr) GuestRegs.r15 = (ULONG64)test; ScriptEngineEvalWrapper(&GuestRegs, Expr); - //free(TestStruct); + free(TestStruct); } /** diff --git a/hyperdbg/include/Definition.h b/hyperdbg/include/Definition.h index de241bc8..c794087a 100644 --- a/hyperdbg/include/Definition.h +++ b/hyperdbg/include/Definition.h @@ -412,7 +412,7 @@ const unsigned char BuildVersion[] = /** * @brief Test cases file name */ -#define SCRIPT_ENGINE_TEST_CASES_DIRECTORY "D:\\IPM\\HyperDbg\\Git\\se-test-files" +#define SCRIPT_ENGINE_TEST_CASES_DIRECTORY "D:\\IPM\\HyperDbg\\Git\\se-test-files\\tmp" /** * @brief Maximum test cases to communicate between debugger and debuggee process diff --git a/hyperdbg/script-engine/script-engine.c b/hyperdbg/script-engine/script-engine.c index b747c867..c05b5c93 100644 --- a/hyperdbg/script-engine/script-engine.c +++ b/hyperdbg/script-engine/script-engine.c @@ -2039,23 +2039,9 @@ SemanticRuleToInt(char * str) char * HandleError(PSCRIPT_ENGINE_ERROR_TYPE Error, char * str) { - // - // allocate rquired memory for message - // - int MessageSize = (InputIdx - CurrentLineIdx) * 2 + 30 + 100; - char * Message = (char *)malloc(MessageSize); // - // add line number - // - strcpy(Message, "Line "); - char * Line = (char *)malloc(16); - sprintf(Line, "%d:\n", CurrentLine); - strcat(Message, Line); - free(Line); - - // - // add the line which error happened at + // calculate position of current line // unsigned int LineEnd; for (int i = InputIdx;; i++) @@ -2066,10 +2052,35 @@ HandleError(PSCRIPT_ENGINE_ERROR_TYPE Error, char * str) break; } } + + // + // allocate required memory for message, 16 for line, 100 for error information, + // (CurrentTokenIdx - CurrentLineIdx) for space and, + // (LineEnd - CurrentLineIdx) for input string + // + int MessageSize = 16 + 100 + (CurrentTokenIdx - CurrentLineIdx) + (LineEnd - CurrentLineIdx); + char * Message = (char *)malloc(MessageSize); + // + // add line number + // + strcpy(Message, "Line "); + char Line[16] = {0}; + sprintf(Line, "%d:\n", CurrentLine); + strcat(Message, Line); + + + + // + // add the line which error happened at + // + + strncat(Message, (str + CurrentLineIdx), LineEnd - CurrentLineIdx); strcat(Message, "\n"); + + // // add pointer //