Exemplo n.º 1
0
HRESULT
CALLBACK
cmd(PDEBUG_CLIENT4 Client, PCSTR Args)
{
    HRESULT hRes=S_OK;
    ULONG Flags;
    PDEBUG_OUTPUT_CALLBACKS Callbacks;
    INIT_API();

    #if VERBOSE >= 2
    dprintf("[sync] !cmd command called\n");
    #endif

    if (!Args || !*Args) {
        dprintf("[sync] !cmd <command to execute and dump>\n");
        return E_FAIL;
    }

    if (FAILED(hRes=g_ExtClient->GetOutputCallbacks(&Callbacks)))
    {
        dprintf("[sync] GetOutputCallbacks failed\n");
        goto exit;
    }

    if (FAILED(hRes=g_ExtClient->SetOutputCallbacks(&g_OutputCb)))
    {
        dprintf("[sync] SetOutputCallbacks failed\n");
        goto exit;
    }

    // msdn: Execute method executes the specified debugger commands.
    Flags = DEBUG_EXECUTE_ECHO;

    if (g_OutputCbLocal)
        Flags = DEBUG_EXECUTE_NOT_LOGGED;

    hRes=g_ExtControl->Execute(DEBUG_OUTCTL_ALL_CLIENTS, Args, Flags);

    g_ExtClient->FlushCallbacks();
    g_ExtClient->SetOutputCallbacks(Callbacks);

    #if VERBOSE >= 2
    dprintf("[sync] OutputCallbacks removed\n");
    #endif

exit:
    return hRes;
}
Exemplo n.º 2
0
HRESULT CALLBACK testext(PDEBUG_CLIENT4 Client, PCSTR args)
{
    PDEBUG_OUTPUT_CALLBACKS prev;
    PDEBUG_CONTROL Control;
    char cmd[256];

    sprintf(cmd, "!E:\\talk\\demo\\Debug\\dbgexts.plusplus %s", args);

    Client->GetOutputCallbacks(&prev);
    Client->SetOutputCallbacks(&g_OutputCb);
    Client->QueryInterface(__uuidof(IDebugControl), (void **)&Control);
    Control->Execute(DEBUG_OUTCTL_ALL_CLIENTS |
                     DEBUG_OUTCTL_OVERRIDE_MASK |
                     DEBUG_OUTCTL_NOT_LOGGED,
                     cmd, // Command to be executed
                     DEBUG_EXECUTE_DEFAULT );
    Control->Release();
    Client->SetOutputCallbacks(prev);

    return S_OK;
}