Пример #1
0
extern "C" HRESULT
ExtQuery(PDEBUG_CLIENT client)
{
    g_ExtClient = client;
#else
extern "C" HRESULT
ExtQuery(ILLDBServices* services)
{
    g_ExtServices = services;
    DebugClient* client = new DebugClient(services);
    g_DebugClient = client;
#endif
    HRESULT Status;
    SOS_ExtQueryFailGo(g_ExtControl, IDebugControl2);
    SOS_ExtQueryFailGo(g_ExtData, IDebugDataSpaces);
    SOS_ExtQueryFailGo(g_ExtRegisters, IDebugRegisters);
    SOS_ExtQueryFailGo(g_ExtSymbols, IDebugSymbols);
    SOS_ExtQueryFailGo(g_ExtSystem, IDebugSystemObjects);
#ifndef FEATURE_PAL
    SOS_ExtQueryFailGo(g_ExtData2, IDebugDataSpaces2);
    SOS_ExtQueryFailGo(g_ExtSymbols2, IDebugSymbols2);
    SOS_ExtQueryFailGo(g_ExtAdvanced3, IDebugAdvanced3);
#endif // FEATURE_PAL
    return S_OK;

 Fail:
    if (Status == E_OUTOFMEMORY)
        ReportOOM();
    
    ExtRelease();
    return Status;
}
Пример #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;
}
Пример #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;
}
Пример #4
0
// Queries for all debugger interfaces.
HRESULT
ExtQuery(PDEBUG_CLIENT Client)
{
    HRESULT Status;
    
    if ((Status = Client->QueryInterface(__uuidof(IDebugClient2),
                                         (void **)&g_ExtClient)) != S_OK ||
        (Status = Client->QueryInterface(__uuidof(IDebugControl2),
                                         (void **)&g_ExtControl)) != S_OK ||
        (Status = Client->QueryInterface(__uuidof(IDebugDataSpaces2),
                                         (void **)&g_ExtData)) != S_OK ||
        (Status = Client->QueryInterface(__uuidof(IDebugRegisters),
                                         (void **)&g_ExtRegisters)) != S_OK ||
        (Status = Client->QueryInterface(__uuidof(IDebugSymbols3),
                                         (void **)&g_ExtSymbols)) != S_OK ||
        (Status = Client->QueryInterface(__uuidof(IDebugSystemObjects2),
                                         (void **)&g_ExtSystem)) != S_OK)
    {
        ExtRelease();
        return Status;
    }

	//Status =Client->SetOutputCallbacks( &g_MyDebugOutputCallbacks );
	//_ASSERT(0==Status);

    return S_OK;
}
Пример #5
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;
}
Пример #6
0
// Queries for all debugger interfaces.
HRESULT
ExtQuery(PDEBUG_CLIENT Client)
{
    HRESULT Status;
    
    if ((Status = Client->QueryInterface(__uuidof(IDebugClient2),
                                         (void **)&g_ExtClient)) != S_OK ||
        (Status = Client->QueryInterface(__uuidof(IDebugControl2),
                                         (void **)&g_ExtControl)) != S_OK ||
        (Status = Client->QueryInterface(__uuidof(IDebugDataSpaces2),
                                         (void **)&g_ExtData)) != S_OK ||
        (Status = Client->QueryInterface(__uuidof(IDebugRegisters),
                                         (void **)&g_ExtRegisters)) != S_OK ||
        (Status = Client->QueryInterface(__uuidof(IDebugSymbols2),
                                         (void **)&g_ExtSymbols)) != S_OK ||
        (Status = Client->QueryInterface(__uuidof(IDebugSystemObjects2),
                                         (void **)&g_ExtSystem)) != S_OK)
    {
        ExtRelease();
        return Status;
    }

    return S_OK;
}
Пример #7
0
HRESULT
CALLBACK
DebugExtensionInitialize(PULONG Version, PULONG Flags)
{
    IDebugClient *DebugClient;
    PDEBUG_CONTROL DebugControl;
    HRESULT Hr;

    *Version = DEBUG_EXTENSION_VERSION(1, 0);
    *Flags = 0;

    if (g_Initialized)
    {
        return S_OK;
    }
    g_Initialized = true;

    if ((Hr = DebugCreate(__uuidof(IDebugClient),
                          (void **)&DebugClient)) != S_OK)
    {
        return Hr;
    }
    if ((Hr = DebugClient->QueryInterface(__uuidof(IDebugControl),
                                              (void **)&DebugControl)) != S_OK)
    {
        return Hr;
    }

    ExtensionApis.nSize = sizeof (ExtensionApis);
    if ((Hr = DebugControl->GetWindbgExtensionApis64(&ExtensionApis)) != S_OK)
    {
        return Hr;
    }
    
    // Fixes the "Unable to read dynamic function table entries" error messages by disabling the WinDbg security
    // feature that prevents the loading of unknown out of proc tack walkers.
    DebugControl->Execute(DEBUG_OUTCTL_IGNORE, ".settings set EngineInitialization.VerifyFunctionTableCallbacks=false", 
        DEBUG_EXECUTE_NOT_LOGGED | DEBUG_EXECUTE_NO_REPEAT);

    ExtQuery(DebugClient);
    if (IsMiniDumpFileNODAC())
    {
        ExtOut (
            "----------------------------------------------------------------------------\n"
            "The user dump currently examined is a minidump. Consequently, only a subset\n"
            "of sos.dll functionality will be available. If needed, attaching to the live\n"
            "process or debugging a full dump will allow access to sos.dll's full feature\n"
            "set.\n"
            "To create a full user dump use the command: .dump /ma <filename>\n"
            "----------------------------------------------------------------------------\n");
    }
    ExtRelease();
    
    OnUnloadTask::Register(CleanupEventCallbacks);
    g_pCallbacksClient = DebugClient;
    EventCallbacks* pCallbacksObj = new EventCallbacks(DebugClient);
    IDebugEventCallbacks* pCallbacks = NULL;
    pCallbacksObj->QueryInterface(__uuidof(IDebugEventCallbacks), (void**)&pCallbacks);
    pCallbacksObj->Release();

    if(FAILED(Hr = g_pCallbacksClient->SetEventCallbacks(pCallbacks)))
    {
        ExtOut ("SOS: Failed to register callback events\n");
        pCallbacks->Release();
        return Hr;
    }
    pCallbacks->Release();

#ifndef _ARM_
    // Make sure we do not tear down the debugger when a security function fails
    // Since we link statically against CRT this will only affect the SOS module.
    _set_invalid_parameter_handler(_SOS_invalid_parameter);
#endif
    
    DebugControl->Release();
    return S_OK;
}