Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Input / Win32MouseDevice.cs / 1305600 / Win32MouseDevice.cs
using System.Diagnostics; using System.Collections; using System.Windows; using System.Windows.Media; using System.Windows.Interop; using System.Windows.Threading; using System.Security; using System.Security.Permissions; using MS.Internal; using MS.Internal.PresentationCore; // SecurityHelper using MS.Win32; // *NativeMethods using System.Runtime.InteropServices; using System; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; namespace System.Windows.Input { ////// The Win32MouseDevice class implements the platform specific /// MouseDevice features for the Win32 platform /// internal sealed class Win32MouseDevice : MouseDevice { ////// /// /// /// ////// Critical - This is code that elevates AND creates the mouse device which /// happens to hold the callback to filter mouse messages /// TreatAsSafe: This constructor handles critical data but does not expose it /// It stores instance but there are demands on the instances. /// [SecurityCritical,SecurityTreatAsSafe] internal Win32MouseDevice(InputManager inputManager) : base(inputManager) { } ////// Gets the current state of the specified button from the device from the underlying system /// /// /// The mouse button to get the state of /// ////// The state of the specified mouse button /// ////// Critical: Makes calls to UnsafeNativeMethods (GetKeyState) /// TreatAsSafe: Only returns the current state of the specified button /// [SecurityCritical,SecurityTreatAsSafe] internal override MouseButtonState GetButtonStateFromSystem(MouseButton mouseButton) { MouseButtonState mouseButtonState = MouseButtonState.Released; // Security Mitigation: do not give out input state if the device is not active. if(IsActive) { int virtualKeyCode = 0; switch( mouseButton ) { case MouseButton.Left: virtualKeyCode = NativeMethods.VK_LBUTTON; break; case MouseButton.Right: virtualKeyCode = NativeMethods.VK_RBUTTON; break; case MouseButton.Middle: virtualKeyCode = NativeMethods.VK_MBUTTON; break; case MouseButton.XButton1: virtualKeyCode = NativeMethods.VK_XBUTTON1; break; case MouseButton.XButton2: virtualKeyCode = NativeMethods.VK_XBUTTON2; break; } mouseButtonState = ( UnsafeNativeMethods.GetKeyState(virtualKeyCode) & 0x8000 ) != 0 ? MouseButtonState.Pressed : MouseButtonState.Released; } return mouseButtonState; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System.Diagnostics; using System.Collections; using System.Windows; using System.Windows.Media; using System.Windows.Interop; using System.Windows.Threading; using System.Security; using System.Security.Permissions; using MS.Internal; using MS.Internal.PresentationCore; // SecurityHelper using MS.Win32; // *NativeMethods using System.Runtime.InteropServices; using System; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; namespace System.Windows.Input { ////// The Win32MouseDevice class implements the platform specific /// MouseDevice features for the Win32 platform /// internal sealed class Win32MouseDevice : MouseDevice { ////// /// /// /// ////// Critical - This is code that elevates AND creates the mouse device which /// happens to hold the callback to filter mouse messages /// TreatAsSafe: This constructor handles critical data but does not expose it /// It stores instance but there are demands on the instances. /// [SecurityCritical,SecurityTreatAsSafe] internal Win32MouseDevice(InputManager inputManager) : base(inputManager) { } ////// Gets the current state of the specified button from the device from the underlying system /// /// /// The mouse button to get the state of /// ////// The state of the specified mouse button /// ////// Critical: Makes calls to UnsafeNativeMethods (GetKeyState) /// TreatAsSafe: Only returns the current state of the specified button /// [SecurityCritical,SecurityTreatAsSafe] internal override MouseButtonState GetButtonStateFromSystem(MouseButton mouseButton) { MouseButtonState mouseButtonState = MouseButtonState.Released; // Security Mitigation: do not give out input state if the device is not active. if(IsActive) { int virtualKeyCode = 0; switch( mouseButton ) { case MouseButton.Left: virtualKeyCode = NativeMethods.VK_LBUTTON; break; case MouseButton.Right: virtualKeyCode = NativeMethods.VK_RBUTTON; break; case MouseButton.Middle: virtualKeyCode = NativeMethods.VK_MBUTTON; break; case MouseButton.XButton1: virtualKeyCode = NativeMethods.VK_XBUTTON1; break; case MouseButton.XButton2: virtualKeyCode = NativeMethods.VK_XBUTTON2; break; } mouseButtonState = ( UnsafeNativeMethods.GetKeyState(virtualKeyCode) & 0x8000 ) != 0 ? MouseButtonState.Pressed : MouseButtonState.Released; } return mouseButtonState; } } } // 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
- TdsEnums.cs
- DataSourceGroupCollection.cs
- ContentElement.cs
- DefaultValueConverter.cs
- ObjectKeyFrameCollection.cs
- safesecurityhelperavalon.cs
- UidManager.cs
- WebUtil.cs
- VersionConverter.cs
- Tag.cs
- AsymmetricAlgorithm.cs
- InputScope.cs
- SendMessageContent.cs
- ComponentResourceKeyConverter.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- InputBindingCollection.cs
- UriSectionReader.cs
- NodeLabelEditEvent.cs
- Html32TextWriter.cs
- TextServicesContext.cs
- Marshal.cs
- ChangesetResponse.cs
- WindowsGraphicsCacheManager.cs
- ArgumentOutOfRangeException.cs
- ProxyWebPartManager.cs
- SerializationFieldInfo.cs
- PathFigureCollectionConverter.cs
- QuestionEventArgs.cs
- SynchronizationValidator.cs
- documentation.cs
- ProfilePropertyNameValidator.cs
- ManualResetEvent.cs
- PointLight.cs
- ResourceAttributes.cs
- CapabilitiesSection.cs
- TextEditorSelection.cs
- FormsAuthenticationConfiguration.cs
- DataGridItemEventArgs.cs
- TraceUtils.cs
- FtpWebRequest.cs
- PropertyCondition.cs
- Compress.cs
- ObjectRef.cs
- BaseTemplateBuildProvider.cs
- Route.cs
- FileFormatException.cs
- Property.cs
- XmlSchemaAnyAttribute.cs
- ValueTypeFixupInfo.cs
- ControlBindingsCollection.cs
- XPathAncestorQuery.cs
- DataGridViewRowEventArgs.cs
- DoubleAnimation.cs
- Boolean.cs
- StructuredTypeEmitter.cs
- UserMapPath.cs
- PageHandlerFactory.cs
- ConcurrentStack.cs
- WindowsRebar.cs
- SQLInt32.cs
- HtmlShim.cs
- HintTextConverter.cs
- ConcurrentStack.cs
- JsonReader.cs
- ControlPaint.cs
- Parallel.cs
- Debug.cs
- DataGridViewBindingCompleteEventArgs.cs
- SpeechRecognitionEngine.cs
- FieldAccessException.cs
- DataGridColumn.cs
- QilGenerator.cs
- SelectionItemProviderWrapper.cs
- X509SubjectKeyIdentifierClause.cs
- WebConfigurationManager.cs
- FixUp.cs
- DocumentPageViewAutomationPeer.cs
- ETagAttribute.cs
- WindowsFormsSectionHandler.cs
- ObjectCloneHelper.cs
- PLINQETWProvider.cs
- DataControlLinkButton.cs
- ContentControl.cs
- ValidationPropertyAttribute.cs
- UIElementHelper.cs
- XsltException.cs
- CharacterBuffer.cs
- TextSchema.cs
- SchemaImporterExtensionElement.cs
- RowToFieldTransformer.cs
- TextServicesDisplayAttributePropertyRanges.cs
- ConstructorExpr.cs
- elementinformation.cs
- PatternMatcher.cs
- HostProtectionPermission.cs
- AuthorizationRuleCollection.cs
- LoadedEvent.cs
- ItemDragEvent.cs
- RuntimeArgumentHandle.cs
- COM2Enum.cs