none
在具有hook功能的dll中, hook到复制函数copyitems后在自己的函数里运行dll导出类的构造函数出现explore.exe自动重启的问题, RRS feed

  • Question

  • 具体问题是:windows下,将hook功能封装为dll,hook copyitems后在自己的函数copyitems_new里运行文档检测函数, 此文档检测函数来自另一个dll的导出类里。当调用此导出类的构造函数时候出现explore.exe自动重启,但是explore.exe自动重启后,hook功能还在,有复制动作后,程序仍会卡在同样位置。

    具体代码如下:

              

    static HRESULT __stdcall CopyItems_new(IFileOperation* pThis,
                                           IUnknown* punkItems,
                                           IShellItem* psiDestinationFolder)
    {

        LPWSTR lpDst = NULL;
        psiDestinationFolder->GetDisplayName(SIGDN_FILESYSPATH, &lpDst);
        HRESULT hr = S_FALSE;
        PFileOPItem pfoi = GetOPItem();
        do
        {

            char chDstFileName[256] = {0};
            WideCharToMultiByte(CP_ACP, 0, lpDst, wcslen(lpDst) + 1, chDstFileName, 256, NULL, NULL);
            WriteLog("CopyItems_new->lpDst:%s", chDstFileName);

    //WriteLog("\n");
            if(1/*目的路径为指定路径*/)
    {

    pfoi->srcCount = GetFilesFromDataObject(punkItems, &(pfoi->srcList));//此函数定义见下方。
    }

            SetOPType(MOVE_FILE);



            //wcscpy(pfoi->dstFolder, lpDst );
    strcpy(pfoi->dstFolder, UnicodeToANSI( lpDst ));
            hr = CopyItems_old(pThis, punkItems, psiDestinationFolder);
        }
        while (FALSE);
        if(!SUCCEEDED(hr))
        {
            FreeOPItem();
        }
        CoTaskMemFree(lpDst);
        return hr;
    }

            

    // 获取一次文件操作中所有文件名
    static UINT __stdcall GetFilesFromDataObject(IUnknown *iUnknown, WPATH **ppPath)
    {
        UINT uFileCount = 0;
        IDataObject *iDataObject = NULL;
        HRESULT hr = iUnknown->QueryInterface(IID_IDataObject, (void **)&iDataObject);
        do
        {
            if(!SUCCEEDED(hr))
            {
                break;
            }
            FORMATETC fmt = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
            STGMEDIUM stg = { TYMED_HGLOBAL };
            if(!SUCCEEDED(iDataObject->GetData(&fmt, &stg)))
            {
                break;
            }
            HDROP hDrop = (HDROP)GlobalLock(stg.hGlobal);
            if(hDrop == NULL)
            {
                break;
            }
            uFileCount = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
            if(uFileCount <= 0)
            {
                break;
            }
            *ppPath = new WPATH[uFileCount];
            if(*ppPath != NULL)
            {
    //wchar_t path[MAX_PATH] = {0};

                for(UINT uIndex = 0; uIndex < uFileCount; uIndex++)
                {
    int size=DragQueryFile(hDrop, uIndex, NULL, 0);
                    DragQueryFile(hDrop, uIndex, (*ppPath)[uIndex], size+1);
                    WriteLog("size = [%d]", size);
    WriteLog("(*ppPath)[%d] =%s",  uIndex, (*ppPath)[uIndex] );
    ScanOptions scan_options;
            scan_options.key = true;
            scan_options.regex = true;
            scan_options.uncompress_time = 2;
            ScanResults scan_results;
    //问题出在下面这个构造函数:

    Cfileanalysis fa_inst(&scan_options, transfer_result, &scan_results);

    //之后会发生explore.exe重启的问题,

    int check = fa_inst.fileanalysis( (*ppPath)[uIndex] );

    if(1)
    {
    WriteLog("check_ok"  );
    }
    else
    {
    WriteLog("check_bad"  );
    }
                }
            }
            else
            {
                uFileCount = 0;
            }
            GlobalUnlock(stg.hGlobal);
            ReleaseStgMedium(&stg);
        }
        while (FALSE);
        return uFileCount;
    }

    Tuesday, September 3, 2013 1:19 PM

Answers

  • Hi,

    1) Please ask your questions in this forum in English.

    2) your question is not about Training and Certification, please ask your question in the correct forum.


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

    MCSE:Server Infrastructure, MCSE:Desktop Infrastructure, MCSA Server 2012, Citrix CCIA & CCEE, Cisco CCNA, VMware VCP 3/4/5 Twitter: @dnyvandam http://www.dannyvandam.net


    Tuesday, September 3, 2013 3:05 PM
    Moderator

All replies

  • Hi,

    1) Please ask your questions in this forum in English.

    2) your question is not about Training and Certification, please ask your question in the correct forum.


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

    MCSE:Server Infrastructure, MCSE:Desktop Infrastructure, MCSA Server 2012, Citrix CCIA & CCEE, Cisco CCNA, VMware VCP 3/4/5 Twitter: @dnyvandam http://www.dannyvandam.net


    Tuesday, September 3, 2013 3:05 PM
    Moderator
  • Thank you ! I have asked the same quesion in English.

    Wednesday, September 4, 2013 2:23 AM