示例#1
0
VOID
KdpCmdBlockedList(
    PCHAR Parameter
    )
{
    extern PPROCESS KepBlockedList;
    extern PPROCESS KepTimerList;
    PPROCESS current;

    UNREFERENCED_PARAMETER(Parameter);

    KdpPrint("Blocked processes:\n");
    current = KepBlockedList;
    while (current) {
        CHAR dump[320];
        ObDumpObject(current, dump, sizeof(dump));
        KdpPrint("0x%x %s\n", current, dump);
        current = current->NextPCB;
    }

    KdpPrint("Timer processes:\n");
    current = KepTimerList;
    while (current) {
        CHAR dump[320];
        ObDumpObject(current, dump, sizeof(dump));
        KdpPrint("0x%x %s\n", current, dump);
        current = current->NextPCB;
    }
}
示例#2
0
VOID
KdpCmdObjects(
    PCHAR Parameter
    )
{
    // HACKHACK :)
    extern POBJECT_TYPE ObTypeObjectListHead;

    POBJECT_TYPE currentType = ObTypeObjectListHead;

    UNREFERENCED_PARAMETER(Parameter);

    while (currentType) {
        PVOID currentObject = ObGetFirstObjectOfType(currentType);

        KdpPrint("OBJECT_TYPE 0x%x Name: 0x%x\n", currentType, currentType->Name);

        while (currentObject) {
            CHAR dump[320];
            ObDumpObject(currentObject, dump, sizeof(dump));
    
            KdpPrint("0x%x %s\n", currentObject, dump);
            currentObject = ObGetNextObjectOfType(currentObject);
        }

        currentType = currentType->NextTypeObject;

        if (currentType) KdpPrintChar('\n');
    }
}
示例#3
0
VOID
KdpCmdTicks(
    PCHAR Parameter
    )
{
    UNREFERENCED_PARAMETER(Parameter);
    
    KdpPrint("%d milliseconds\n", KeGetTickCount());
}
示例#4
0
VOID
KdpCmdHelp(
    PCHAR Parameter
    )
{
    ULONG i;

    UNREFERENCED_PARAMETER(Parameter);

    for (i = 0; i < COUNTOF(KdpCommands); i++) {

        KdpPrint("%s - %s\n", KdpCommands[i].Name, KdpCommands[i].HelpText);
    }
}
示例#5
0
VOID
KdpExecuteCommand(
    PCHAR command
    )
{
    PCHAR parameter = KdpSplitParameter(command);
    ULONG i;

    for (i = 0; i < COUNTOF(KdpCommands); i++) {

        if (RtlCompareStrings(KdpCommands[i].Name, command) == 0) {

            KdpCommands[i].Execute(parameter);
            return;
        }
    }

    KdpPrint("%s: command not recognized\n", command);
}
示例#6
0
BOOLEAN
NTAPI
KdpTrap(IN PKTRAP_FRAME TrapFrame,
        IN PKEXCEPTION_FRAME ExceptionFrame,
        IN PEXCEPTION_RECORD ExceptionRecord,
        IN PCONTEXT ContextRecord,
        IN KPROCESSOR_MODE PreviousMode,
        IN BOOLEAN SecondChanceException)
{
    BOOLEAN Unload = FALSE;
    ULONG_PTR ProgramCounter;
    BOOLEAN Handled;
    NTSTATUS ReturnStatus;
    USHORT ReturnLength;

    /*
     * Check if we got a STATUS_BREAKPOINT with a SubID for Print, Prompt or
     * Load/Unload symbols. Make sure it isn't a software breakpoints as those
     * are handled by KdpReport.
     */
    if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
            (ExceptionRecord->ExceptionInformation[0] != BREAKPOINT_BREAK))
    {
        /* Save Program Counter */
        ProgramCounter = KeGetContextPc(ContextRecord);

        /* Check what kind of operation was requested from us */
        switch (ExceptionRecord->ExceptionInformation[0])
        {
        /* DbgPrint */
        case BREAKPOINT_PRINT:

            /* Call the worker routine */
            ReturnStatus = KdpPrint((ULONG)KdpGetParameterThree(ContextRecord),
                                    (ULONG)KdpGetParameterFour(ContextRecord),
                                    (LPSTR)ExceptionRecord->
                                    ExceptionInformation[1],
                                    (USHORT)ExceptionRecord->
                                    ExceptionInformation[2],
                                    PreviousMode,
                                    TrapFrame,
                                    ExceptionFrame,
                                    &Handled);

            /* Update the return value for the caller */
            KeSetContextReturnRegister(ContextRecord, ReturnStatus);
            break;

        /* DbgPrompt */
        case BREAKPOINT_PROMPT:

            /* Call the worker routine */
            ReturnLength = KdpPrompt((LPSTR)ExceptionRecord->
                                     ExceptionInformation[1],
                                     (USHORT)ExceptionRecord->
                                     ExceptionInformation[2],
                                     (LPSTR)KdpGetParameterThree(ContextRecord),
                                     (USHORT)KdpGetParameterFour(ContextRecord),
                                     PreviousMode,
                                     TrapFrame,
                                     ExceptionFrame);
            Handled = TRUE;

            /* Update the return value for the caller */
            KeSetContextReturnRegister(ContextRecord, ReturnLength);
            break;

        /* DbgUnLoadImageSymbols */
        case BREAKPOINT_UNLOAD_SYMBOLS:

            /* Drop into the load case below, with the unload parameter */
            Unload = TRUE;

        /* DbgLoadImageSymbols */
        case BREAKPOINT_LOAD_SYMBOLS:

            /* Call the worker routine */
            KdpSymbol((PSTRING)ExceptionRecord->
                      ExceptionInformation[1],
                      (PKD_SYMBOLS_INFO)ExceptionRecord->
                      ExceptionInformation[2],
                      Unload,
                      PreviousMode,
                      ContextRecord,
                      TrapFrame,
                      ExceptionFrame);
            Handled = TRUE;
            break;

        /* DbgCommandString */
        case BREAKPOINT_COMMAND_STRING:

            /* Call the worker routine */
            KdpCommandString((PSTRING)ExceptionRecord->
                             ExceptionInformation[1],
                             (PSTRING)ExceptionRecord->
                             ExceptionInformation[2],
                             PreviousMode,
                             ContextRecord,
                             TrapFrame,
                             ExceptionFrame);
            Handled = TRUE;
            break;

        /* Anything else, do nothing */
        default:

            /* Invalid debug service! Don't handle this! */
            Handled = FALSE;
            break;
        }

        /*
         * If the PC was not updated, we'll increment it ourselves so execution
         * continues past the breakpoint.
         */
        if (ProgramCounter == KeGetContextPc(ContextRecord))
        {
            /* Update it */
            KeSetContextPc(ContextRecord,
                           ProgramCounter + KD_BREAKPOINT_SIZE);
        }
    }
    else
    {
        /* Call the worker routine */
        Handled = KdpReport(TrapFrame,
                            ExceptionFrame,
                            ExceptionRecord,
                            ContextRecord,
                            PreviousMode,
                            SecondChanceException);
    }

    /* Return TRUE or FALSE to caller */
    return Handled;
}