Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / Input / InputProviderSite.cs / 1 / 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() { 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() { 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
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DocumentXPathNavigator.cs
- __ConsoleStream.cs
- FixedSOMFixedBlock.cs
- ArraySortHelper.cs
- SchemaImporter.cs
- PageCache.cs
- Rotation3DAnimationBase.cs
- BufferedWebEventProvider.cs
- BaseParaClient.cs
- XsltException.cs
- HotSpotCollection.cs
- ConfigErrorGlyph.cs
- MatrixTransform.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- WorkflowValidationFailedException.cs
- VisualStyleInformation.cs
- NegationPusher.cs
- AspProxy.cs
- _SpnDictionary.cs
- HtmlTableRowCollection.cs
- ComEventsMethod.cs
- PanelContainerDesigner.cs
- MetadataArtifactLoaderResource.cs
- SystemGatewayIPAddressInformation.cs
- MatrixKeyFrameCollection.cs
- ListControlBuilder.cs
- HttpContext.cs
- SocketAddress.cs
- WindowsGraphicsWrapper.cs
- CompiledQueryCacheEntry.cs
- LogicalExpr.cs
- RecognitionResult.cs
- RenderTargetBitmap.cs
- DataGridViewMethods.cs
- PrivilegedConfigurationManager.cs
- DropTarget.cs
- ChangeProcessor.cs
- WorkItem.cs
- QuotedStringWriteStateInfo.cs
- ClientEventManager.cs
- MimePart.cs
- SoapFaultCodes.cs
- InternalBase.cs
- RuleRef.cs
- TransformGroup.cs
- XmlILIndex.cs
- MetadataCacheItem.cs
- PreviewKeyDownEventArgs.cs
- odbcmetadatacolumnnames.cs
- FixedSOMTable.cs
- FormViewUpdatedEventArgs.cs
- AnalyzedTree.cs
- Ipv6Element.cs
- HttpCapabilitiesBase.cs
- CheckBoxStandardAdapter.cs
- MessageContractExporter.cs
- StoreItemCollection.cs
- XmlParserContext.cs
- ProviderException.cs
- DateTimeFormatInfoScanner.cs
- RecognitionResult.cs
- ContentFilePart.cs
- SuppressIldasmAttribute.cs
- NativeMethods.cs
- XamlDesignerSerializationManager.cs
- IODescriptionAttribute.cs
- PrinterUnitConvert.cs
- GridViewDeleteEventArgs.cs
- ThumbAutomationPeer.cs
- DetailsViewRowCollection.cs
- WebProxyScriptElement.cs
- MetadataHelper.cs
- ListView.cs
- FastEncoder.cs
- CodeDOMUtility.cs
- SHA1CryptoServiceProvider.cs
- EntityContainerEmitter.cs
- safesecurityhelperavalon.cs
- ConsoleKeyInfo.cs
- DataGridRowHeader.cs
- CacheDependency.cs
- wgx_commands.cs
- ObjectDataSourceStatusEventArgs.cs
- XhtmlBasicPhoneCallAdapter.cs
- FormattedText.cs
- StringReader.cs
- RegisteredScript.cs
- wmiprovider.cs
- WebMessageFormatHelper.cs
- CodeRegionDirective.cs
- TdsParserStaticMethods.cs
- ObjectStateFormatter.cs
- formatstringdialog.cs
- UnknownBitmapEncoder.cs
- Margins.cs
- BinaryFormatter.cs
- BitmapInitialize.cs
- GridProviderWrapper.cs
- InvalidStoreProtectionKeyException.cs
- NTAccount.cs