Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Input / InputProviderSite.cs / 1305600 / InputProviderSite.cs
using System; using System.Security; using System.Security.Permissions; using MS.Internal; using MS.Internal.PresentationCore; // SecurityHelper using MS.Win32; using System.Windows.Threading; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; namespace System.Windows.Input { ////// The object which input providers use to report input to the input /// manager. /// internal class InputProviderSite : IDisposable { ////// Critical: This code creates critical data in the form of InputManager and InputProvider /// [SecurityCritical] internal InputProviderSite(InputManager inputManager, IInputProvider inputProvider) { _inputManager = new SecurityCriticalDataClass(inputManager); _inputProvider = new SecurityCriticalDataClass (inputProvider); } /// /// Returns the input manager that this site is attached to. /// ////// Critical: We do not want to expose the Input manager in the SEE /// TreatAsSafe: This code has a demand in it /// public InputManager InputManager { [SecurityCritical,SecurityTreatAsSafe] get { SecurityHelper.DemandUnrestrictedUIPermission(); return CriticalInputManager; } } ////// Returns the input manager that this site is attached to. /// ////// Critical: We do not want to expose the Input manager in the SEE /// internal InputManager CriticalInputManager { [SecurityCritical] get { return _inputManager.Value; } } ////// Unregisters this input provider. /// ////// Critical: This code accesses critical data (InputManager and InputProvider). /// TreatAsSafe: The critical data is not exposed outside this call /// [SecurityCritical,SecurityTreatAsSafe] public void Dispose() { GC.SuppressFinalize(this); if (!_isDisposed) { _isDisposed = true; if (_inputManager != null && _inputProvider != null) { _inputManager.Value.UnregisterInputProvider(_inputProvider.Value); } _inputManager = null; _inputProvider = null; } } ////// Returns true if the CompositionTarget is disposed. /// public bool IsDisposed { get { return _isDisposed; } } ////// Reports input to the input manager. /// ////// Whether or not any event generated as a consequence of this /// event was handled. /// ////// Critical:This code is critical and can be used in event spoofing. It also accesses /// InputManager and calls into ProcessInput which is critical. /// // [SecurityCritical ] [UIPermissionAttribute(SecurityAction.LinkDemand,Unrestricted = true)] public bool ReportInput(InputReport inputReport) { if(IsDisposed) { throw new ObjectDisposedException(SR.Get(SRID.InputProviderSiteDisposed)); } bool handled = false; InputReportEventArgs input = new InputReportEventArgs(null, inputReport); input.RoutedEvent=InputManager.PreviewInputReportEvent; if(_inputManager != null) { handled = _inputManager.Value.ProcessInput(input); } return handled; } private bool _isDisposed; ////// Critical: This object should not be exposed in the SEE as it can be /// used for input spoofing /// private SecurityCriticalDataClass_inputManager; /// /// Critical: This object should not be exposed in the SEE as it can be /// used for input spoofing /// private SecurityCriticalDataClass_inputProvider; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Security; using System.Security.Permissions; using MS.Internal; using MS.Internal.PresentationCore; // SecurityHelper using MS.Win32; using System.Windows.Threading; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; namespace System.Windows.Input { /// /// The object which input providers use to report input to the input /// manager. /// internal class InputProviderSite : IDisposable { ////// Critical: This code creates critical data in the form of InputManager and InputProvider /// [SecurityCritical] internal InputProviderSite(InputManager inputManager, IInputProvider inputProvider) { _inputManager = new SecurityCriticalDataClass(inputManager); _inputProvider = new SecurityCriticalDataClass (inputProvider); } /// /// Returns the input manager that this site is attached to. /// ////// Critical: We do not want to expose the Input manager in the SEE /// TreatAsSafe: This code has a demand in it /// public InputManager InputManager { [SecurityCritical,SecurityTreatAsSafe] get { SecurityHelper.DemandUnrestrictedUIPermission(); return CriticalInputManager; } } ////// Returns the input manager that this site is attached to. /// ////// Critical: We do not want to expose the Input manager in the SEE /// internal InputManager CriticalInputManager { [SecurityCritical] get { return _inputManager.Value; } } ////// Unregisters this input provider. /// ////// Critical: This code accesses critical data (InputManager and InputProvider). /// TreatAsSafe: The critical data is not exposed outside this call /// [SecurityCritical,SecurityTreatAsSafe] public void Dispose() { GC.SuppressFinalize(this); if (!_isDisposed) { _isDisposed = true; if (_inputManager != null && _inputProvider != null) { _inputManager.Value.UnregisterInputProvider(_inputProvider.Value); } _inputManager = null; _inputProvider = null; } } ////// Returns true if the CompositionTarget is disposed. /// public bool IsDisposed { get { return _isDisposed; } } ////// Reports input to the input manager. /// ////// Whether or not any event generated as a consequence of this /// event was handled. /// ////// Critical:This code is critical and can be used in event spoofing. It also accesses /// InputManager and calls into ProcessInput which is critical. /// // [SecurityCritical ] [UIPermissionAttribute(SecurityAction.LinkDemand,Unrestricted = true)] public bool ReportInput(InputReport inputReport) { if(IsDisposed) { throw new ObjectDisposedException(SR.Get(SRID.InputProviderSiteDisposed)); } bool handled = false; InputReportEventArgs input = new InputReportEventArgs(null, inputReport); input.RoutedEvent=InputManager.PreviewInputReportEvent; if(_inputManager != null) { handled = _inputManager.Value.ProcessInput(input); } return handled; } private bool _isDisposed; ////// Critical: This object should not be exposed in the SEE as it can be /// used for input spoofing /// private SecurityCriticalDataClass_inputManager; /// /// Critical: This object should not be exposed in the SEE as it can be /// used for input spoofing /// private SecurityCriticalDataClass_inputProvider; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UserControlParser.cs
- LinkUtilities.cs
- CompilationSection.cs
- SubMenuStyle.cs
- CompilationLock.cs
- DataGridViewCellEventArgs.cs
- CngAlgorithm.cs
- WorkflowPrinting.cs
- CopyNodeSetAction.cs
- SyndicationDeserializer.cs
- PointCollectionConverter.cs
- ColorMatrix.cs
- CryptoApi.cs
- BrowserTree.cs
- InternalsVisibleToAttribute.cs
- PropertyChangedEventArgs.cs
- CacheOutputQuery.cs
- ValuePatternIdentifiers.cs
- BaseParaClient.cs
- Margins.cs
- SelectionChangedEventArgs.cs
- ExceptionUtil.cs
- DesignerFrame.cs
- XmlAtomErrorReader.cs
- JournalEntryStack.cs
- BitmapFrameDecode.cs
- httpserverutility.cs
- WsdlWriter.cs
- COSERVERINFO.cs
- ListViewUpdatedEventArgs.cs
- EncryptedData.cs
- WindowsMenu.cs
- X509IssuerSerialKeyIdentifierClause.cs
- TextElementCollectionHelper.cs
- ModuleElement.cs
- StreamGeometry.cs
- ArithmeticException.cs
- PropertyOrder.cs
- InputLangChangeRequestEvent.cs
- Pen.cs
- SamlAttribute.cs
- SequentialUshortCollection.cs
- StylusPlugin.cs
- EventLogPermissionHolder.cs
- TargetConverter.cs
- MessageQueueTransaction.cs
- PeerTransportCredentialType.cs
- TagMapCollection.cs
- WhitespaceRuleLookup.cs
- AtomMaterializerLog.cs
- SslStream.cs
- TextTreeRootNode.cs
- IdentityReference.cs
- MenuStrip.cs
- BindingListCollectionView.cs
- ConfigXmlCDataSection.cs
- ListViewInsertEventArgs.cs
- ZipIOExtraFieldZip64Element.cs
- MonthChangedEventArgs.cs
- MailWebEventProvider.cs
- ExtensibleClassFactory.cs
- StateItem.cs
- EncodingNLS.cs
- OuterGlowBitmapEffect.cs
- Types.cs
- SmtpFailedRecipientException.cs
- TileBrush.cs
- PrivateFontCollection.cs
- RegistryPermission.cs
- LinearGradientBrush.cs
- Exception.cs
- SpecialTypeDataContract.cs
- PartialCachingAttribute.cs
- WorkflowWebHostingModule.cs
- Single.cs
- PropertyEntry.cs
- TypeConverter.cs
- TimeSpanStorage.cs
- IProvider.cs
- CDSsyncETWBCLProvider.cs
- SiteMapNodeCollection.cs
- TTSEngineProxy.cs
- SQLDoubleStorage.cs
- JsonDeserializer.cs
- QueryReaderSettings.cs
- DependencyPropertyConverter.cs
- FlowchartStart.xaml.cs
- FontFamily.cs
- EntityContainerEntitySetDefiningQuery.cs
- Rotation3DAnimationUsingKeyFrames.cs
- ObjectConverter.cs
- ArrayHelper.cs
- RIPEMD160.cs
- XmlEncodedRawTextWriter.cs
- XPathNodeIterator.cs
- InputLanguageSource.cs
- MembershipValidatePasswordEventArgs.cs
- VarRefManager.cs
- Hex.cs
- UriWriter.cs