Exemplo n.º 1
0
extern "C" __declspec(dllexport) void CBRESUMEDEBUG(CBTYPE cbType, PLUG_CB_RESUMEDEBUG* info)
{
#if VERBOSE >= 2
	_plugin_logputs("[sync] debugging resumed!");
#endif

	ReleasePollTimer();
}
Exemplo n.º 2
0
void
CALLBACK
DebugExtensionNotify(ULONG Notify, ULONG64 Argument)
{
    UNREFERENCED_PARAMETER(Argument);
    HRESULT hRes=S_OK;
    BOOL bIgnoreEvent = false;

    switch(Notify){
        case DEBUG_NOTIFY_SESSION_ACTIVE:
            #if VERBOSE >= 2
            dprintf("[sync] DebugExtensionNotify: A debugging session is active. The session may not necessarily be suspended.\n");
            #endif
            break;

        case DEBUG_NOTIFY_SESSION_INACTIVE:
            #if VERBOSE >= 2
            dprintf("[sync] DebugExtensionNotify: No debugging session is active.\n");
            #endif
            break;

        case DEBUG_NOTIFY_SESSION_ACCESSIBLE:
            #if VERBOSE >= 2
            dprintf("[sync] DebugExtensionNotify: The debugging session has suspended and is now accessible.\n");
            #endif
            if(SUCCEEDED(TunnelIsUp()))
            {
                hRes = EventFilterCb(&bIgnoreEvent);
                if(SUCCEEDED(hRes) && bIgnoreEvent)
                    break;

                UpdateState();
                CreatePollTimer();
            }
            break;

        case DEBUG_NOTIFY_SESSION_INACCESSIBLE:
            #if VERBOSE >= 2
            dprintf("[sync] DebugExtensionNotify: The debugging session has started running and is now inaccessible.\n");
            #endif
            ReleasePollTimer();
            break;

        default:
            #if VERBOSE >= 2
            dprintf("[sync] DebugExtensionNotify: Unknown Notify reason (%x).\n", Notify);
            #endif
            break;
    }

    return;
}
Exemplo n.º 3
0
HRESULT syncoff()
{
	HRESULT hRes = S_OK;

	if (!g_Synchronized){
		return hRes;
	}

	ReleasePollTimer();
	hRes = TunnelClose();
	_plugin_logputs("[sync] sync is now disabled\n");

	return hRes;
}
Exemplo n.º 4
0
// Poll timer callback implementation: call PollCmd and set completion event
VOID
CALLBACK PollTimerCb(PVOID lpParameter, BOOL TimerOrWaitFired)
{
    HRESULT hRes;
    UNREFERENCED_PARAMETER(lpParameter);
    UNREFERENCED_PARAMETER(TimerOrWaitFired);

    hRes = PollCmd();

    // If an error occured in PollCmd() the timer callback is deleted.
    // (typically happens when client has closed the connection)
    if (FAILED(hRes))
        ReleasePollTimer();
}
Exemplo n.º 5
0
void
CALLBACK
DebugExtensionUninitialize(void)
{
    dprintf("[sync] DebugExtensionUninitialize\n");

    ReleasePollTimer();
    DeleteCriticalSection(&g_CritSectPollRelease);
    TunnelClose();

    if(g_ExtConfFile)
    {
        free(g_DefaultHost);
        free(g_DefaultPort);
    }

    EXIT_API();
    return;
}
Exemplo n.º 6
0
HRESULT
CALLBACK
syncoff(PDEBUG_CLIENT4 Client, PCSTR Args)
{
    HRESULT hRes=S_OK;
    UNREFERENCED_PARAMETER(Args);
    INIT_API();

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

    if(!g_Synchronized)
        return hRes;

    ReleasePollTimer();
    hRes=TunnelClose();
    dprintf("[sync] sync is now disabled\n");

    return hRes;
}
Exemplo n.º 7
0
HRESULT
CALLBACK
modcheck(PDEBUG_CLIENT4 Client, PCSTR Args)
{
    HRESULT hRes;
    DWORD cbBinary;
    int NbBytesRecvd = 0;
    LPSTR pszResString= NULL;
    CHAR *msg = NULL;
    CHAR *type;
    CHAR cmd[64] = {0};
    BOOL bUsePdb = TRUE;

    INIT_API();

    if(!g_Synchronized)
    {
        dprintf("[sync] please enable sync\n");
        return E_FAIL;
    }

    if (!(*g_NameBuffer))
    {
        dprintf("[sync] no module\n");
        return E_FAIL;
    }

    // check args
    // md5 is accepted only with local debuggee
    if (!Args || !*Args) {
        bUsePdb=TRUE;
    }
    else if(strcmp("md5", Args)==0)
    {
        bUsePdb=FALSE;

        if (!(IsLocalDebuggee()))
        {
            dprintf("[sync] can't use md5 check with non local debuggee\n");
            return E_FAIL;
        }
    }
    else
        dprintf("[sync] unknown argument, defaulting to pdb match\n");

    // The debugger does not know if an IDB client
    // is actually connected to the dispatcher.

    // First disable tunnel polling for commands (happy race...)
    ReleasePollTimer();

    // default behavior is to used !IToldYouSo  command.
    if (bUsePdb)
    {
        type = "pdb";
        _snprintf_s(cmd, 64, _TRUNCATE , "!itoldyouso  %x", g_Base);

        // g_CommandBuffer first four bytes should contains
        // return value for command exec
        hRes=LocalCmd(Client, cmd);
        if (FAILED(hRes) || FAILED(*g_CommandBuffer))
        {
            dprintf("[sync] failed to evaluate !ItoldYouSo  command\n");
            goto Exit;
        }

        cbBinary = (DWORD) strlen(g_CommandBuffer+4);
        if (cbBinary == 0)
        {
            dprintf("     ItoldYouSo return empty result\n");
            goto Exit;
        }

        dprintf("%s\n", g_CommandBuffer+4);

        hRes=ToBase64((const byte *)g_CommandBuffer+4, cbBinary, &pszResString);
        if (FAILED(hRes))
        {
            dprintf("[sync] modcheck ToBase64 failed\n");
            goto Exit;
        }
    }
    else
    {
        type="md5";
        hRes=modmd5(&pszResString);
        if (FAILED(hRes))
        {
            dprintf("[sync] modcheck modmd5 failed\n");
            goto Exit;
        }

        dprintf("       MD5: %s\n", pszResString);
    }

    hRes = TunnelSend("[sync]{\"type\":\"modcheck\",\"%s\":\"%s\"}\n", type, pszResString);
    if (FAILED(hRes))
    {
        dprintf("[sync] modcheck send failed\n");
        goto Exit;
    }

    // Let time for the IDB client to reply if it exists
    Sleep(150);

    // Poll tunnel
    hRes=TunnelPoll(&NbBytesRecvd, &msg);
    if (FAILED(hRes))
    {
        dprintf("[sync] modcheck poll failed\n");
        goto Exit;
    }
    else
    {
        if ((NbBytesRecvd>0) & (msg != NULL))
            dprintf("%s\n", msg);
        else
            dprintf("    -> no reply, make sure an idb is enabled first\n");
    }

Exit:
    // Re-enable tunnel polling
    CreatePollTimer();

    if (pszResString)
        free(pszResString);
    if (msg)
        free(msg);

    return hRes;
}