Ejemplo n.º 1
0
HRESULT
Identity(PSTR *Buffer)
{
    HRESULT hRes;
    ULONG IdentitySize=0;

    hRes = g_ExtClient->GetIdentity(NULL, NULL, &IdentitySize);
    if (FAILED(hRes))
    {
        dprintf("[sync] GetIdentity failed\n");
        return hRes;
    }

    *Buffer = (PSTR) malloc(IdentitySize+1);
    if (Buffer==NULL)
    {
        dprintf("[sync] Identity failed to allocate buffer: %d\n", GetLastError());
        return E_FAIL;
    }

    hRes = g_ExtClient->GetIdentity(*Buffer, IdentitySize, &IdentitySize);
    if (FAILED(hRes))
    {
        dprintf("[sync] GetIdentity failed\n");
        return hRes;
    }

    return hRes;
}
Ejemplo n.º 2
0
// Queries for all debugger interfaces.
extern "C" HRESULT
ExtQuery(PDEBUG_CLIENT4 Client)
{
    HRESULT Status;

    if ((Status = Client->QueryInterface(__uuidof(IDebugControl),
                                 (void **)&g_ExtControl)) != S_OK)
    {
        goto Fail;
    }
    if ((Status = Client->QueryInterface(__uuidof(IDebugSymbols3),
                                (void **)&g_ExtSymbols)) != S_OK)
    {
		goto Fail;
    }
	if ((Status = Client->QueryInterface(__uuidof(IDebugSystemObjects2),
								(void **)&g_ExtSystem)) != S_OK)
	{
		goto Fail;
	}

	if ((Status = Client->QueryInterface(__uuidof(IDebugDataSpaces),
					(void **)&g_ExtData)) != S_OK){
		goto Fail;
	}

    g_ExtClient = Client;

    return S_OK;

 Fail:
	dprintf("F**k...");
    ExtRelease();
    return Status;
}
Ejemplo n.º 3
0
// Queries for all debugger interfaces.
extern "C" HRESULT
ExtQuery(PDEBUG_CLIENT4 Client)
{
    HRESULT Status;

    if ((Status = Client->QueryInterface(__uuidof(IDebugControl),
                                         (void **)&g_ExtControl)) != S_OK)
    {
        goto Fail;
    }
    if ((Status = Client->QueryInterface(__uuidof(IDebugSymbols2),
                                         (void **)&g_ExtSymbols)) != S_OK)
    {
        goto Fail;
    }
    if ((Status = Client->QueryInterface(__uuidof(IDebugAdvanced),
                                         (void **)&g_ExtAdanced)) != S_OK)
    {
        goto Fail;
    }
    if ((Status = Client->QueryInterface(__uuidof(IDebugRegisters),
                                         (void **)&g_ExtRegister)) != S_OK)
    {
        goto Fail;
    }

    g_ExtClient = Client;

    return S_OK;

Fail:
    ExtRelease();
    return Status;
}
Ejemplo n.º 4
0
// Queries for all debugger interfaces.
extern "C" HRESULT
ExtQuery(PDEBUG_CLIENT4 Client)
{
    HRESULT hRes=S_OK;

    if(g_ExtClient!=NULL)
        return S_OK;

    if (FAILED(hRes = Client->QueryInterface(__uuidof(IDebugControl), (void **)&g_ExtControl)))
        goto Fail;

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

    if (FAILED(hRes = Client->QueryInterface(__uuidof(IDebugSymbols), (void **)&g_ExtSymbols)))
        goto Fail;

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

    if (FAILED(hRes = Client->QueryInterface(__uuidof(IDebugSymbols2), (void **)&g_ExtSymbols2)))
        goto Fail;

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

    if (FAILED(hRes = Client->QueryInterface(__uuidof(IDebugSymbols3), (void **)&g_ExtSymbols3)))
        goto Fail;

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

    if (FAILED(hRes = Client->QueryInterface(__uuidof(IDebugRegisters), (void **)&g_ExtRegisters)))
        goto Fail;

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

    g_ExtClient = Client;
    return S_OK;

 Fail:
    ExtRelease();
    return hRes;
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
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;
}
Ejemplo n.º 7
0
static bool enter_command(PDEBUG_CLIENT4 Client)
{
    gDebugClient4 = Client;
    if (!gDebugSymbols3
            && Client->QueryInterface(__uuidof(IDebugSymbols3), (void **)&gDebugSymbols3) != S_OK)
        return false;

    if (!gDebugControl
            && Client->QueryInterface(__uuidof(IDebugControl), (void **)&gDebugControl) != S_OK)
        return false;

    if (!gDebugSystemObjects
            && Client->QueryInterface(__uuidof(IDebugSystemObjects), (void **)&gDebugSystemObjects) != S_OK)
        return false;

    if (!gDebugAdvanced2
            && Client->QueryInterface(__uuidof(IDebugAdvanced2), (void **)&gDebugAdvanced2) != S_OK)
        return false;

    if (!gDebugDataSpaces4
            && Client->QueryInterface(__uuidof(IDebugDataSpaces4), (void **)&gDebugDataSpaces4) != S_OK)
        return false;

    if (!gDebugRegisters2
            && Client->QueryInterface(__uuidof(IDebugRegisters2), (void **)&gDebugRegisters2) != S_OK)
        return false;

    // Get the current scope
    if (gDebugSymbols3->GetScope(&intr, &stack_frame, &context, sizeof(context)) != S_OK)
        return false;

    g_debug_context.tid = engine_tid;
    g_debug_context.frame_level = stack_frame.FrameNumber;
    g_debug_context.sp = stack_frame.StackOffset;

    if (!update_memory_segments_and_heaps())
        return false;

    return true;
}