Getting AIM buddies list.

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by KaE, 10 Apr 2010.

  1. KaE

    KaE New Member

    Joined:
    27 Sep 2009
    Messages:
    44
    Likes Received:
    1
    Reputations:
    5
    Приветствую,

    Пишу софтину, пытающуюся сграббить всех клиентов, которые находятся в режиме онлайн в главном окне мессенджера AIM.
    Суть следующая:
    BSTR GetInternetExplorerText(HWND hWnd);
    ....

    fprintf(stderr, "Getting __oxFrame.class__ handle...");
    HWND oxFrame = FindWindow("__oxFrame.class__", NULL);
    if(oxFrame == NULL) {
    fprintf(stderr, "[FAIL] exiting.\n");
    return 0;
    }
    fprintf(stderr, "[OK]\n");
    HWND oxFrame1 = FindWindowEx(oxFrame, 0, "__oxFrame.class__", NULL);

    oxFrame1 = FindWindowEx(oxFrame, oxFrame1, "__oxFrame.class__", NULL);
    oxFrame1 = FindWindowEx(oxFrame, oxFrame1, "__oxFrame.class__", NULL);
    HWND ie = FindWindowEx(oxFrame1, 0, "_AIMBROWSER_", NULL);
    ie = FindWindowEx(ie, 0, "_AIMBROWSER_TH", NULL);
    ie = FindWindowEx(ie, 0, "Shell Embedding", NULL);
    ie = FindWindowEx(ie, 0, "Shell DocObject View", NULL);
    ie = FindWindowEx(ie, 0, "Internet Explorer_Server", NULL);

    и чуть пониже:
    BSTR GetInternetExplorerText(HWND hWnd) // by Napalm
    {
    BSTR bsResult = (BSTR)NULL;
    if(!hWnd) {
    printf("!!!!!!!!!!!!!!!!!!!!!!");
    return bsResult;
    }
    IHTMLDocument *pHTMLDoc = NULL;
    IDispatch *pDispatch = NULL;
    IHTMLWindow2 *pHTMLWin = NULL;
    IHTMLDocument2 *pHTMLDoc2 = NULL;
    IHTMLElement *pHTMLBody = NULL;
    UINT uMsg = RegisterWindowMessage("WM_HTML_GETOBJECT");
    LRESULT lResult = 0;
    SendMessageTimeout(hWnd, uMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&lResult);
    if(!lResult) {
    fprintf(stderr, "!!!!!!\n");
    return bsResult;
    }
    if(FAILED(ObjectFromLresult(lResult, IHTMLDocument2, 0, (void **)&pHTMLDoc)))
    {fprintf(stderr, "111!!!!!!\n");goto label_cleanup;}
    if(FAILED(pHTMLDoc->get_Script(&pDispatch)))
    {fprintf(stderr, "222!!!!!!\n");goto label_cleanup;}
    if(FAILED(pDispatch->QueryInterface(IID_IHTMLWindow2, (void **)&pHTMLWin)))
    {fprintf(stderr, "333!!!!!!\n");goto label_cleanup;}
    if(FAILED(pHTMLWin->get_document(&pHTMLDoc2)))
    {fprintf(stderr, "444!!!!!!\n");goto label_cleanup;}
    if(FAILED(pHTMLDoc2->get_body(&pHTMLBody)))
    {fprintf(stderr, "555!!!!!!\n");goto label_cleanup;}
    pHTMLBody->get_outerHTML(&bsResult);
    label_cleanup:
    if(pHTMLBody)
    pHTMLBody->Release();
    if(pHTMLDoc2)
    pHTMLDoc2->Release();
    if(pHTMLWin)
    pHTMLWin->Release();
    if(pDispatch)
    pDispatch->Release();
    if(pHTMLDoc)
    pHTMLDoc->Release();
    return bsResult;
    }

    //---Возникает проблема:
    ObjectFromLresult(lResult, IHTMLDocument2, 0, (void **)&pHTMLDoc) // Эта функция падает в данном контексте

    Remarks: Не особо силен в программировании под Win.
     
    #1 KaE, 10 Apr 2010
    Last edited: 10 Apr 2010