예제 #1
0
파일: Queue.cpp 프로젝트: kcrazy/winekit
CQueue::OnCreateFile(
    /*[in]*/ IWDFIoQueue*       pQueue,
    /*[in]*/ IWDFIoRequest*     pRequest,
    /*[in]*/ IWDFFile*          pFileObject
    )
{
    UNREFERENCED_PARAMETER(pQueue);
    TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_QUEUE, "%!FUNC! Entry");

    //  This critical section protects the section of code where we
    //  Create the serializer and results interfaces used in handling I/O messages.
    //  We only need to create them once, then we hang on to them for the lifetime of this
    //  queue object.
    CComCritSecLock<CComAutoCriticalSection> Lock(m_CriticalSection);
    HRESULT hr = S_OK;

    // Create the WPD serializer
    if ((hr == S_OK) &&
        (m_pWpdSerializer == NULL))
    {
        hr = CoCreateInstance(CLSID_WpdSerializer,
                              NULL,
                              CLSCTX_INPROC_SERVER,
                              IID_IWpdSerializer,
                              (VOID**)&m_pWpdSerializer);

        CHECK_HR(hr, "Failed to CoCreate CLSID_WpdSerializer");
    }

    // Create the client context map and associate it with the File Object
    // so we can obtain it on a per-client basis.
    if (hr == S_OK)
    {
        ContextMap* pClientContextMap = new ContextMap();

        if(pClientContextMap != NULL)
        {
            hr = pFileObject->AssignContext(this, (void*)pClientContextMap);
            CHECK_HR(hr, "Failed to set client context map");

            // Release the client context map if we cannot set it
            // properly
            if(FAILED(hr))
            {
                pClientContextMap->Release();
                pClientContextMap = NULL;
            }
        }
        else
        {
            hr = E_OUTOFMEMORY;
            CHECK_HR(hr, "Failed to create client context map");
        }
    }

    pRequest->Complete(hr);
    return;
}
예제 #2
0
파일: Queue.cpp 프로젝트: kcrazy/winekit
CQueue::OnCleanup(
    IWDFObject* pWdfObject
    )
{
    // Destroy the client context map
    HRESULT     hr                = S_OK;
    ContextMap* pClientContextMap = NULL;

    hr = pWdfObject->RetrieveContext((void**)&pClientContextMap);
    if((hr == S_OK) && (pClientContextMap != NULL))
    {
        pClientContextMap->Release();
        pClientContextMap = NULL;
    }
}
예제 #3
0
파일: Queue.cpp 프로젝트: kcrazy/winekit
CQueue::OnCleanup(
    IWDFObject* pWdfObject
    )
{
    TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FLAG_QUEUE, "%!FUNC! Entry");

    // Destroy the client context map
    HRESULT     hr                = S_OK;
    ContextMap* pClientContextMap = NULL;

    hr = pWdfObject->RetrieveContext((void**)&pClientContextMap);
    if((hr == S_OK) && (pClientContextMap != NULL))
    {
        pClientContextMap->Release();
        pClientContextMap = NULL;
    }
}