コード例 #1
0
ファイル: SoftKeyboard.cpp プロジェクト: kcrazy/winekit
STDMETHODIMP CSoftKeyboard::get_Translator(
                SoftKbdTranslator **ppTranslator)
/*++
Routine Description:
    Implement the get Translator propery for the interface
    ISoftKeyboard.

Synchronization: 
    None
 
Arguments:
    ppTranslator - caller allocated space to hold the property value.
    
Return Value:
    E_POINTER
        Invalid pointer for output parameter
    From called function
  
--*/
{
    HRESULT hr = S_OK;

    // Check if we have valid pointer to returned parameter
    IfFalseHrGo(NULL != ppTranslator, E_POINTER);
    *ppTranslator = NULL;

    ADDREF(m_piSoftKbdTranslator);
    *ppTranslator  = reinterpret_cast<SoftKbdTranslator *>(m_piSoftKbdTranslator);

    IfFailHrGo(hr);

Exit:
    return hr;

} // CSoftKeyboard::get_Translator
コード例 #2
0
ファイル: crypt.cpp プロジェクト: Sathyaish/Practice
    void SetSignatureKey(CryptKey *pKey)
    {
        CryptKey* pOldKey;

        if (pKey != NULL)
            ADDREF(pKey);

        pOldKey = m_pSignatureKey;
        m_pSignatureKey = pKey;

        if (pOldKey != NULL)
            RELEASE(pOldKey);
    }
コード例 #3
0
VOID
FxWorkItem::Enqueue(
    VOID
    )
{
    PFX_DRIVER_GLOBALS pFxDriverGlobals;
    KIRQL irql;
    BOOLEAN enqueue;

    pFxDriverGlobals = GetDriverGlobals();
    enqueue = FALSE;

    Lock(&irql);

    if (m_Enqueued) {
        DoTraceLevelMessage(
            pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGDEVICE,
            "Previously queued WDFWORKITEM 0x%p is already pending. "
            "Ignoring the request to queue again", GetHandle());
    }
    else if (m_RunningDown) {
        DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
                "WDFWORKITEM 0x%p is already deleted", GetHandle());
        FxVerifierDbgBreakPoint(pFxDriverGlobals);
    }
    else {
        m_WorkItemCompleted.Clear();

        m_Enqueued = TRUE;

        //
        // We are going to enqueue the work item. Reference this FxWorkItem 
        // object and Globals while they are outstanding.
        // These will be released when the workitem completes.
        //
        ADDREF(WorkItemThunk);
        pFxDriverGlobals->ADDREF(WorkItemThunk);

        enqueue = TRUE;
    }

    Unlock(irql);

    if (enqueue) {
        m_WorkItem. Enqueue(FxWorkItem::WorkItemThunk, this);
    }

    return;
}
コード例 #4
0
static WFC_IMAGE_PROVIDER*
WFC_ImageProvider_DoCreate(void* owner, /*WFC_CONTEXT* context,*/
                           OWFNativeStreamType stream,
                           WFC_IMAGE_PROVIDER_TYPE type)
{
    WFC_IMAGE_PROVIDER*         object;

    ENTER(WFC_ImageProvider_DoCreate);

    if (!stream)
    {
        return NULL;
    }
    object = CREATE(WFC_IMAGE_PROVIDER);

    if (!object)
    {
        return NULL;
    }

    owfNativeStreamAddReference(stream);
    object->streamHandle = stream;
    object->type            = type;
    object->contentUpdated  = WFC_FALSE;

    WFC_ImageProvider_LockForReading(object);
    if (object->lockedStream.image==NULL || object->lockedStream.image->data==NULL)
        {
        owfNativeStreamDestroy(stream);
        DESTROY(object);
        return NULL;
        }
    WFC_ImageProvider_Unlock(object);
    ADDREF(object->owner, owner);

    LEAVE(WFC_ImageProvider_DoCreate);
    return object;
}
コード例 #5
0
ファイル: crypt.cpp プロジェクト: Sathyaish/Practice
 void SetProvider(CryptProvider* pProvider)
 {
     _ASSERTE(m_pProvider == NULL);
     m_pProvider = pProvider;
     ADDREF(m_pProvider);
 }
コード例 #6
0
_Must_inspect_result_
NTSTATUS
FxWorkItem::Initialize(
    __in PWDF_OBJECT_ATTRIBUTES Attributes,
    __in PWDF_WORKITEM_CONFIG Config,
    __in FxObject* ParentObject,
    __out WDFWORKITEM* WorkItem
    )
{
    PFX_DRIVER_GLOBALS pFxDriverGlobals;
    IFxHasCallbacks* pCallbacks;
    NTSTATUS status;

    pFxDriverGlobals = GetDriverGlobals();

#if (FX_CORE_MODE == FX_CORE_USER_MODE)
    status = m_WorkItemCompleted.Initialize(NotificationEvent, TRUE);
    if(!NT_SUCCESS(status)) {
        DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
                            "Could not initialize m_WorkItemCompleted event "
                            "%!STATUS!", status);
        return status;
    }
#endif

    ASSERT(Config->EvtWorkItemFunc != NULL);

    // Set users callback function
    m_Callback = Config->EvtWorkItemFunc;

    //
    // As long as we are associated, the parent object holds a reference
    // count on the WDFWORKITEM.
    //
    // This reference must be taken early before we return any failure,
    // since Dispose() expects this extra reference, and Dispose() will
    // be called even if we return a failure status right now.
    //
    ADDREF(this);

    //
    // WorkItems can be parented by, and optionally serialize with an FxDevice or an FxQueue
    //
    m_DeviceBase = FxDeviceBase::_SearchForDevice(ParentObject, &pCallbacks);

    if (m_DeviceBase == NULL) {
        return STATUS_INVALID_DEVICE_REQUEST;
    }

    //
    // Determine if it's an FxDevice, or FxIoQueue and get the
    // CallbackSpinLock pointer for it.
    //
    status = _GetEffectiveLock(
        ParentObject,
        pCallbacks,
        Config->AutomaticSerialization,
        TRUE,
        &m_CallbackLock,
        &m_CallbackLockObject
        );

    if (!NT_SUCCESS(status)) {
        if (status == STATUS_WDF_INCOMPATIBLE_EXECUTION_LEVEL) {






            DoTraceLevelMessage(
                pFxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
                "ParentObject %p cannot automatically synchronize callbacks "
                "with a WorkItem since it is not configured for passive level "
                "callback constraints.  Use a WDFDPC instead or set "
                "AutomaticSerialization to FALSE."
                "%!STATUS!", Attributes->ParentObject, status);
        }

        return status;
    }

    //
    // Allocate the PIO_WORKITEM we will re-use
    //
#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
    m_WorkItem.Allocate(m_Device->GetDeviceObject());
#elif (FX_CORE_MODE == FX_CORE_USER_MODE)
    m_WorkItem.Allocate(
        m_Device->GetDeviceObject(),
        (PVOID)&m_Device->GetDriver()->GetDriverObject()->ThreadPoolEnv);
#endif
    if (m_WorkItem.GetWorkItem() == NULL) {
        status =  STATUS_INSUFFICIENT_RESOURCES;
        DoTraceLevelMessage(
            pFxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
            "Could not allocate IoWorkItem, %!STATUS!", status);
        return status;
    }

    //
    // We automatically synchronize with and reference count
    // the lifetime of the framework object to prevent any WORKITEM races
    // that can access the object while it is going away.
    //

    //
    // The caller supplied object is the object the caller wants the
    // WorkItem to be associated with, and the framework must ensure this
    // object remains live until the WorkItem object is destroyed. Otherwise,
    // it could access either object context memory, or an object API
    // on a freed object.
    //
    // Due to the locking model of the framework, the lock may actually
    // be owned by a higher level object as well. This is the lockObject
    // returned. As long as we are a child of this object, the lockObject
    // does not need to be dereferenced since it will notify us of Cleanup
    // before it goes away.
    //

    //
    // Associate the FxWorkItem with the object. When this object Cleans up, it
    // will notify our Cleanup function as well.
    //

    //
    // Add a reference to the parent object we are associated with.
    // We will be notified of Cleanup to release this reference.
    //
    ParentObject->ADDREF(this);

    // Save the ptr to the object the WorkItem is associated with
    m_Object = ParentObject;

    //
    // Attributes->ParentObject is the same as ParentObject. Since we already
    // converted it to an object, use that.
    //
    status = Commit(Attributes, (WDFOBJECT*)WorkItem, ParentObject);

    if (!NT_SUCCESS(status)) {
        return status;
    }

    return status;
}
コード例 #7
0
_Must_inspect_result_
NTSTATUS
FxDpc::Initialize(
    __in PWDF_OBJECT_ATTRIBUTES Attributes,
    __in PWDF_DPC_CONFIG Config,
    __in FxObject* ParentObject,
    __out WDFDPC* Dpc
    )
{
    PFX_DRIVER_GLOBALS pFxDriverGlobals;
    IFxHasCallbacks* pCallbacks;
    NTSTATUS status;
    KDPC* pDpc;

    pFxDriverGlobals = GetDriverGlobals();
    pDpc = NULL;
    pCallbacks = NULL;

    pDpc = &m_Dpc;

    //
    // Set user's callback function
    //
    m_Callback = Config->EvtDpcFunc;

    //
    // Initialize the DPC to point to our thunk
    //
    KeInitializeDpc(
        pDpc,         // Dpc
        FxDpcThunk,   // DeferredRoutine
        this          // DeferredContext
        );

    //
    // As long as we are associated, the parent object holds a reference
    // count on the DPC.
    //
    // We keep an extra reference count since on Dispose, we wait until
    // all outstanding DPC's complete before allowing finalization.
    //
    // This reference must be taken early before we return any failure,
    // since Dispose() expects this extra reference, and Dispose() will
    // be called even if we return a failure status right now.
    //
    ADDREF(this);

    //
    // DPC's can be parented by, and optionally serialize with an FxDevice or
    // an FxQueue.
    //
    m_DeviceBase = FxDeviceBase::_SearchForDevice(ParentObject, &pCallbacks);

    if (m_DeviceBase == NULL) {
        return STATUS_INVALID_DEVICE_REQUEST;
    }

    //
    // Configure Serialization for the DPC and callbacks on the supplied object
    //
    status = _GetEffectiveLock(
        ParentObject,
        pCallbacks,
        Config->AutomaticSerialization,
        FALSE,
        &m_CallbackLock,
        &m_CallbackLockObject
        );

    if (!NT_SUCCESS(status)) {
        if (status == STATUS_WDF_INCOMPATIBLE_EXECUTION_LEVEL) {






            DoTraceLevelMessage(
                pFxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDEVICE,
                "ParentObject %p can not automatically synchronize callbacks "
                "with a DPC since it is configured for passive level callback "
                "constraints. Set AutomaticSerialization to FALSE. %!STATUS!",
                Attributes->ParentObject, status);
        }

        return status;
    }

    //
    // We automatically synchronize with and reference count
    // the lifetime of the framework object to prevent any DPC races
    // that can access the object while it is going away.
    //

    //
    // The caller supplied object is the object the caller wants the
    // DPC to be associated with, and the framework must ensure this
    // object remains live until the DPC object is destroyed. Otherwise,
    // it could access either object context memory, or an object API
    // on a freed object.
    //
    // Due to the locking model of the framework, the lock may actually
    // be owned by a higher level object as well. This is the lockObject
    // returned. As long was we are a child of this object, the lockObject
    // does not need to be dereferenced since it will notify us of Cleanup
    // before it goes away.
    //

    //
    // Associate the FxDpc with the object. When this object gets deleted or
    // disposed, it will notify our Dispose function as well.
    //

    //
    // Add a reference to the parent object we are associated with.
    // We will be notified of Cleanup to release this reference.
    //
    ParentObject->ADDREF(this);

    // Save the ptr to the object the DPC is associated with
    m_Object = ParentObject;

    //
    // Attributes->ParentObject is the same as ParentObject.  Since we already
    // converted it to an object, use that.
    //
    status = Commit(Attributes, (WDFOBJECT*)Dpc, ParentObject);

    if (!NT_SUCCESS(status)) {
        return status;
    }

    return status;
}