Example #1
0
 internal PenContext(IPimcContext pimcContext, IntPtr hwnd, 
                         PenContexts contexts, bool supportInRange, bool isIntegrated,
                         int id, IntPtr commHandle, int tabletDeviceId) 
 { 
     _contexts = contexts;
     _pimcContext = new SecurityCriticalDataClass<IPimcContext>(pimcContext); 
     _id = id;
     _tabletDeviceId = tabletDeviceId;
     _commHandle = new SecurityCriticalData<IntPtr>(commHandle);
     _hwnd = new SecurityCriticalData<IntPtr>(hwnd); 
     _supportInRange = supportInRange;
     _isIntegrated = isIntegrated; 
 } 
Example #2
0
 internal PenContext(IPimcContext pimcContext, IntPtr hwnd,
                     PenContexts contexts, bool supportInRange, bool isIntegrated,
                     int id, IntPtr commHandle, int tabletDeviceId)
 {
     _contexts       = contexts;
     _pimcContext    = new SecurityCriticalDataClass <IPimcContext>(pimcContext);
     _id             = id;
     _tabletDeviceId = tabletDeviceId;
     _commHandle     = new SecurityCriticalData <IntPtr>(commHandle);
     _hwnd           = new SecurityCriticalData <IntPtr>(hwnd);
     _supportInRange = supportInRange;
     _isIntegrated   = isIntegrated;
     UpdateScreenMeasurementsPending = false;
 }
Example #3
0
        internal void Disable(bool shutdownWorkerThread)
        {
            // DDVSO:202023
            // There was a prior assumption here that this would always be called under Dispatcher.DisableProcessing.
            // This assumption has not been valid for some time, leading to re-entrancy.
            if (_penThreadPenContext != null)
            {
                if (_penThreadPenContext.RemovePenContext(this))
                {
                    // DDVSO:202023
                    // It is possible that calling ReleaseComObject throws.  We do not expect the
                    // COM object to be invalid here, but releasing can lead to a message pumped
                    // wait.  Re-entrancy can occur that will release the COM object prior to
                    // the wait resolving.  This results in an exception down the line when
                    // returning from the re-entrant call.
                    //
                    // To fix this, store a local, null out the member, and then release the local.
                    // Any re-entrant call will find the member variable already null and skip the
                    // release.
                    IPimcContext context = _pimcContext?.Value;
                    _pimcContext = null;

                    if (context != null)
                    {
                        Marshal.ReleaseComObject(context); // Make sure we release the COM Object so wisptis doesn't send messages to it anymore
                    }

                    // Check if we need to shut down our pen thread.
                    if (shutdownWorkerThread)
                    {
                        // DDVSO:202023
                        // A re-entrant call might find us with a null penThreadContext so we
                        // need to guard the call to Dispose against a null even though we already
                        // have a check above.
                        _penThreadPenContext?.Dispose();
                    }

                    _penThreadPenContext = null; // Can't free this ref until we can remove this context or else we won't see the stylus OutOfRange.
                }
            }
        }