Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- HttpWebRequestElement.cs
- CompositeDataBoundControl.cs
- CqlLexer.cs
- Stream.cs
- OpacityConverter.cs
- ProtocolViolationException.cs
- ProgressBarRenderer.cs
- SqlBulkCopy.cs
- ActivityExecutor.cs
- UnmanagedHandle.cs
- SiteMapNode.cs
- _ServiceNameStore.cs
- DecimalConverter.cs
- ImpersonateTokenRef.cs
- ClosableStream.cs
- FunctionOverloadResolver.cs
- MessageSmuggler.cs
- SoapElementAttribute.cs
- ResourceReferenceExpressionConverter.cs
- ProfileSection.cs
- EntitySet.cs
- Win32MouseDevice.cs
- CodeExporter.cs
- FileRecordSequenceCompletedAsyncResult.cs
- DateBoldEvent.cs
- RelatedImageListAttribute.cs
- TreeNodeEventArgs.cs
- MessageSecurityOverMsmq.cs
- UIElement.cs
- ConstraintEnumerator.cs
- EncryptedPackage.cs
- MetaDataInfo.cs
- FilterableAttribute.cs
- SafeProcessHandle.cs
- XmlSchemaFacet.cs
- SoapTypeAttribute.cs
- MultipartIdentifier.cs
- DbProviderFactories.cs
- Point4DConverter.cs
- CustomDictionarySources.cs
- DataMemberFieldEditor.cs
- MenuAdapter.cs
- HostingEnvironmentSection.cs
- UnknownWrapper.cs
- DynamicDiscoSearcher.cs
- ItemsControl.cs
- UiaCoreTypesApi.cs
- CodeSubDirectory.cs
- XmlQueryContext.cs
- ClientTargetCollection.cs
- Suspend.cs
- StrongNameUtility.cs
- AlphaSortedEnumConverter.cs
- Token.cs
- XmlSchemaSimpleTypeUnion.cs
- CodeCatchClause.cs
- RegionInfo.cs
- DBSchemaTable.cs
- EmptyEnumerator.cs
- PanelContainerDesigner.cs
- SmiContext.cs
- IgnorePropertiesAttribute.cs
- BuildResultCache.cs
- WinInet.cs
- SqlUtil.cs
- MULTI_QI.cs
- DesignTableCollection.cs
- JsonWriter.cs
- GestureRecognizer.cs
- DbConnectionStringCommon.cs
- WebPartConnectionsDisconnectVerb.cs
- CatalogPart.cs
- FlowLayout.cs
- LinkLabelLinkClickedEvent.cs
- StsCommunicationException.cs
- TryExpression.cs
- Main.cs
- LabelAutomationPeer.cs
- MeasurementDCInfo.cs
- SqlVersion.cs
- WebPartEditorOkVerb.cs
- ICspAsymmetricAlgorithm.cs
- ParameterElement.cs
- ViewManager.cs
- GeometryHitTestParameters.cs
- TreeViewBindingsEditorForm.cs
- WsdlBuildProvider.cs
- InvalidAsynchronousStateException.cs
- ApplicationSettingsBase.cs
- TableLayoutRowStyleCollection.cs
- StringPropertyBuilder.cs
- MasterPageBuildProvider.cs
- PropertyDescriptorComparer.cs
- URLIdentityPermission.cs
- CalendarAutoFormat.cs
- AppDomainAttributes.cs
- SharedRuntimeState.cs
- _ConnectOverlappedAsyncResult.cs
- _RequestCacheProtocol.cs
- KeyProperty.cs