sending results of format to the user debugger

This commit is contained in:
sina 2025-09-01 18:27:01 +02:00
parent fe4f2be270
commit 0d940ee543
No known key found for this signature in database
8 changed files with 58 additions and 4 deletions

View file

@ -836,7 +836,7 @@ KdNotifyDebuggeeForUserInput(DEBUGGEE_USER_INPUT_PACKET * Descriptor, UINT32 Len
}
/**
* @brief Notify user-mode to unload the debuggee and close the connections
* @brief Send the result of formats command to the kernel debugger
* @param Value
*
* @return VOID

View file

@ -185,6 +185,19 @@ UdApplyHardwareDebugRegister(PVOID TargetAddress)
(UINT64)TargetAddress);
}
/**
* @brief Send the result of formats command to the user debugger
* @param Value
*
* @return VOID
*/
VOID
UdSendFormatsFunctionResult(UINT64 Value)
{
g_UserDebuggerFormatsResultPacket.Result = DEBUGGER_OPERATION_WAS_SUCCESSFUL;
g_UserDebuggerFormatsResultPacket.Value = Value;
}
/**
* @brief routines to broadcast setting hardware debug registers on all cores
* @param TargetAddress
@ -423,9 +436,25 @@ UdRunScript(PROCESSOR_DEBUGGING_STATE * DbgState)
&g_EventTriggerDetail))
{
//
// Set status
// Check if we need to format the output or not
//
ScriptPacket->Result = DEBUGGER_OPERATION_WAS_SUCCESSFUL;
if (ScriptPacket->IsFormat)
{
//
// For the format, we need to get the result from the script engine
// through global variables, we store the result of format into
// optional parameters
//
ScriptPacket->Result = g_UserDebuggerFormatsResultPacket.Result;
ScriptPacket->FormatValue = g_UserDebuggerFormatsResultPacket.Value;
}
else
{
//
// Set status
//
ScriptPacket->Result = DEBUGGER_OPERATION_WAS_SUCCESSFUL;
}
}
else
{

View file

@ -76,3 +76,6 @@ UdCheckForCommand(PROCESSOR_DEBUGGING_STATE * DbgState,
BOOLEAN
UdHandleDebugEventsWhenUserDebuggerIsAttached(PROCESSOR_DEBUGGING_STATE * DbgState,
BOOLEAN TrapSetByDebugger);
VOID
UdSendFormatsFunctionResult(UINT64 Value);

View file

@ -84,6 +84,12 @@ DEBUGGEE_REQUEST_TO_IGNORE_BREAKS_UNTIL_AN_EVENT g_IgnoreBreaksToDebugger;
*/
HARDWARE_DEBUG_REGISTER_DETAILS g_HardwareDebugRegisterDetailsForStepOver;
/**
* @brief Holds the result of user debugger formats command
*
*/
DEBUGGEE_FORMATS_PACKET g_UserDebuggerFormatsResultPacket;
/**
* @brief Process switch to EPROCESS or Process ID
*

View file

@ -1403,6 +1403,7 @@ typedef struct _DEBUGGEE_SCRIPT_PACKET
UINT32 ScriptBufferSize;
UINT32 ScriptBufferPointer;
BOOLEAN IsFormat;
UINT64 FormatValue;
UINT32 Result;
//

View file

@ -43,7 +43,7 @@ ScriptEngineEvalSingleExpression(string Expr, PBOOLEAN HasError)
//
// Send data to the target user debugger or kernel debugger
//
if (!ScriptEngineExecuteSingleExpression((CHAR *)Expr.c_str(), TRUE, FALSE))
if (!ScriptEngineExecuteSingleExpression((CHAR *)Expr.c_str(), TRUE, TRUE))
{
*HasError = TRUE;
return NULL;

View file

@ -17,6 +17,8 @@
extern UINT32 g_ProcessIdOfLatestStartingProcess;
extern ACTIVE_DEBUGGING_PROCESS g_ActiveProcessDebuggingState;
extern BOOLEAN g_IsUserDebuggerInitialized;
extern UINT64 g_ResultOfEvaluatedExpression;
extern UINT32 g_ErrorStateOfResultOfEvaluatedExpression;
extern CommandType g_CommandsList;
extern DEBUGGER_SYNCRONIZATION_EVENTS_STATE
g_UserSyncronizationObjectsHandleTable[DEBUGGER_MAXIMUM_SYNCRONIZATION_USER_DEBUGGER_OBJECTS];
@ -1218,6 +1220,15 @@ UdSendScriptBufferToProcess(UINT64 ProcessDetailToken,
NULL,
NULL);
//
// Check if it's a format expression and if there was an error or not
//
if (IsFormat && Result)
{
g_ErrorStateOfResultOfEvaluatedExpression = DEBUGGER_OPERATION_WAS_SUCCESSFUL;
g_ResultOfEvaluatedExpression = ScriptPacket->FormatValue;
}
free(ScriptPacket);
return Result;

View file

@ -1225,6 +1225,10 @@ ScriptEngineFunctionFormats(UINT64 Tag, BOOLEAN ImmediateMessagePassing, UINT64
{
KdSendFormatsFunctionResult(Value);
}
else if (g_UserDebuggerState)
{
UdSendFormatsFunctionResult(Value);
}
else
{
//