run script for the .formats command in the user debugger

This commit is contained in:
sina 2025-09-01 15:00:21 +02:00
parent cda5029081
commit fe4f2be270
No known key found for this signature in database
2 changed files with 8 additions and 46 deletions

View file

@ -17,7 +17,7 @@ New release of the HyperDbg Debugger.
- Added support to modify registers or a specific register for the user debugger ([link](https://docs.hyperdbg.org/commands/debugging-commands/r))
- Added support to evaluate (run) scripts on the target thread in the user debugger ([link](https://docs.hyperdbg.org/commands/debugging-commands/eval))
- Added indication of a thread running or paused state to the HyperDbg signature in the user debugger ([link](https://docs.hyperdbg.org/using-hyperdbg/prerequisites/signatures))
- Added support to the 'print' command for the user debugger ([link](https://docs.hyperdbg.org/commands/debugging-commands/print))
- Added support to the '.formats' command for the user debugger ([link](https://docs.hyperdbg.org/commands/meta-commands/.formats))
### Changed
- Non-volatile XMM registers are no longer saved/restored on VM-exit handler ([link](https://learn.microsoft.com/en-us/cpp/build/x64-software-conventions?view=msvc-170))

View file

@ -30,10 +30,6 @@ extern ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState;
UINT64
ScriptEngineEvalSingleExpression(string Expr, PBOOLEAN HasError)
{
PVOID CodeBuffer;
UINT64 BufferAddress;
UINT32 BufferLength;
UINT32 Pointer;
UINT64 Result = NULL;
//
@ -42,45 +38,16 @@ ScriptEngineEvalSingleExpression(string Expr, PBOOLEAN HasError)
Expr.insert(0, "formats(");
Expr.append(");");
//
// Run script engine handler
//
CodeBuffer = ScriptEngineParseWrapper((char *)Expr.c_str(), FALSE);
if (CodeBuffer == NULL)
if (g_IsSerialConnectedToRemoteDebuggee || g_ActiveProcessDebuggingState.IsActive)
{
//
// return to show that this item contains an script
// Send data to the target user debugger or kernel debugger
//
*HasError = TRUE;
return NULL;
}
//
// Print symbols (test)
//
// PrintSymbolBufferWrapper(CodeBuffer);
//
// Set the buffer and length
//
BufferAddress = ScriptEngineWrapperGetHead(CodeBuffer);
BufferLength = ScriptEngineWrapperGetSize(CodeBuffer);
Pointer = ScriptEngineWrapperGetPointer(CodeBuffer);
//
// Check if it's connected over remote debuggee (in the Debugger Mode)
//
if (g_IsSerialConnectedToRemoteDebuggee)
{
//
// Send over serial
//
//
// Send it to the remote debuggee
//
KdSendScriptPacketToDebuggee(BufferAddress, BufferLength, Pointer, TRUE);
if (!ScriptEngineExecuteSingleExpression((CHAR *)Expr.c_str(), TRUE, FALSE))
{
*HasError = TRUE;
return NULL;
}
//
// Check whether there was an error in evaluation or not
@ -117,11 +84,6 @@ ScriptEngineEvalSingleExpression(string Expr, PBOOLEAN HasError)
Result = ScriptEngineEvalUInt64StyleExpressionWrapper(Expr, HasError);
}
//
// Remove the buffer of script engine interpreted code
//
ScriptEngineWrapperRemoveSymbolBuffer(CodeBuffer);
return Result;
}