HRESULT
CSimdeviceQueue::Initialize(
    _In_ IWDFDevice *FxDevice
    )
{
    IWDFIoQueue *fxQueue;
    HRESULT hr;

    //
    // Initialize the critical section before we continue
    //

    if (!InitializeCriticalSectionAndSpinCount(&m_Crit,0x80000400)) {
        hr = HRESULT_FROM_WIN32(GetLastError());
        goto Exit;
    }
    m_InitCritSec = TRUE;

    //
    // Create the framework queue
    //

    {
        IUnknown *unknown = QueryIUnknown();
        hr = FxDevice->CreateIoQueue(unknown,
                                     TRUE,
                                     WdfIoQueueDispatchSequential,
                                     TRUE,
                                     FALSE,
                                     &fxQueue);
        unknown->Release();
    }

    if (FAILED(hr)) {
        goto Exit;
    }

    m_FxQueue = fxQueue;

    fxQueue->Release();

Exit:
    return hr;
}
Example #2
0
HRESULT
CMyQueue::Initialize(
    __in WDF_IO_QUEUE_DISPATCH_TYPE DispatchType,
    __in bool Default,
    __in bool PowerManaged
    )
{
    IWDFIoQueue *fxQueue = NULL;
    HRESULT hr = S_OK;

    //
    // Create the I/O Queue object.
    //

    if (SUCCEEDED(hr))
    {
        IUnknown *callback = QueryIUnknown();

        hr = m_Device->GetFxDevice()->CreateIoQueue(
                                        callback,
                                        Default,
                                        DispatchType,
                                        PowerManaged,
                                        FALSE,
                                        &fxQueue
                                        );
        callback->Release();
    }

    if (SUCCEEDED(hr))
    {
        m_FxQueue = fxQueue;

        //
        // Release the creation reference on the queue.  This object will be 
        // destroyed before the queue so we don't need to have a reference out 
        // on it.
        //

        fxQueue->Release();
    }

    return hr;
}
HRESULT
STDMETHODCALLTYPE
CUnknown::QueryInterface (
                          __in REFIID InterfaceId,
                          __deref_out PVOID *Object)
/*++
 
  Routine Description:

    This method provides the basic support for query interface on CUnknown.
    If the interface requested is IUnknown it references the object and 
    returns an interface pointer.  Otherwise it returns an error.

  Arguments:

    InterfaceId - the IID being requested

    Object - a location to store the interface pointer to return.

  Return Value:

    S_OK or E_NOINTERFACE

--*/
{

    HRESULT hr = S_OK;

    if (IsEqualIID(InterfaceId, __uuidof(IUnknown)))
    {
        *Object = QueryIUnknown();
    }
    else
    {
        *Object = NULL;
        hr = E_NOINTERFACE;
    }

    return hr;

}
HRESULT
CVDevParallelQueue::Initialize()
{
    HRESULT hr;


    {
        IUnknown *callback = QueryIUnknown();

        hr = m_FxDevice->CreateIoQueue (
            callback,
            true,                       // This is the default queue object
            WdfIoQueueDispatchParallel,
            true,                       // Let the Framework handle PowMgmt.
            true,
            &m_FxQueue);

        callback->Release();
    }

    if (FAILED (hr))
    {
        return hr;
    }
    else
    {
        m_FxQueue->Release();
    }
    
    if (!InitializeCriticalSectionAndSpinCount(&m_Crit,0x80000400))
    {
        hr = HRESULT_FROM_WIN32(GetLastError());
    }

    return hr;
}
Example #5
0
HRESULT
CMyQueue::Initialize(
    _In_ IWDFDevice *FxDevice
    )
{
    IWDFIoQueue *fxQueue;
    IUnknown *unknown = NULL;
    HRESULT hr;

    //
    // Initialize ring buffer
    //

    hr = m_RingBuffer.Initialize(DATA_BUFFER_SIZE);

    if (FAILED(hr))
    {
        goto Exit;
    }

    unknown = QueryIUnknown();

    //
    // Create the default queue
    //

    {
        hr = FxDevice->CreateIoQueue(unknown,
                                     TRUE,
                                     WdfIoQueueDispatchParallel,
                                     TRUE,
                                     FALSE,
                                     &fxQueue);
    }

    if (FAILED(hr))
    {
        goto Exit;
    }

    m_FxQueue = fxQueue;

    fxQueue->Release();

    //
    // Create a manual queue to hold pending read requests. By keeping
    // them in the queue, framework takes care of cancelling them if the app
    // exits
    //

    {
        hr = FxDevice->CreateIoQueue(NULL,
                                     FALSE,
                                     WdfIoQueueDispatchManual,
                                     TRUE,
                                     FALSE,
                                     &fxQueue);
    }

    if (FAILED(hr))
    {
        goto Exit;
    }

    m_FxReadQueue = fxQueue;

    fxQueue->Release();

Exit:
    SAFE_RELEASE(unknown);
    return hr;
}