Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / System / Windows / Input / Win32MouseDevice.cs / 1 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- _SslState.cs
- WorkerRequest.cs
- AutomationProperty.cs
- WebControlAdapter.cs
- SafeNativeMethodsMilCoreApi.cs
- RecordsAffectedEventArgs.cs
- XmlObjectSerializerReadContextComplexJson.cs
- TextFormatterContext.cs
- PaintValueEventArgs.cs
- DropTarget.cs
- ReadingWritingEntityEventArgs.cs
- SimpleHandlerBuildProvider.cs
- ValidateNames.cs
- ListControlDataBindingHandler.cs
- MessageDescription.cs
- BindingContext.cs
- TheQuery.cs
- TagMapInfo.cs
- LogEntryHeaderDeserializer.cs
- QilReference.cs
- PageCatalogPartDesigner.cs
- SecureStringHasher.cs
- ComPlusInstanceContextInitializer.cs
- BrowserInteropHelper.cs
- SafeNativeMethods.cs
- DataSourceSelectArguments.cs
- HttpConfigurationContext.cs
- EpmCustomContentWriterNodeData.cs
- TransformPattern.cs
- CursorConverter.cs
- RequestCachePolicy.cs
- MasterPage.cs
- AsymmetricKeyExchangeDeformatter.cs
- SupportsEventValidationAttribute.cs
- CounterCreationData.cs
- EntitySetRetriever.cs
- ReadOnlyHierarchicalDataSource.cs
- FieldBuilder.cs
- TextPointer.cs
- PackagingUtilities.cs
- WizardPanel.cs
- MobileUITypeEditor.cs
- RSAOAEPKeyExchangeDeformatter.cs
- CorrelationManager.cs
- ToolStripDropTargetManager.cs
- CatalogPartChrome.cs
- WriteFileContext.cs
- RegexFCD.cs
- ProfileServiceManager.cs
- CapabilitiesRule.cs
- DependentTransaction.cs
- StandardBindingElementCollection.cs
- recordstate.cs
- TransformerTypeCollection.cs
- TextTabProperties.cs
- SessionState.cs
- CompiledAction.cs
- GetLedgerRequest.cs
- SqlProviderUtilities.cs
- TileBrush.cs
- InstanceNotReadyException.cs
- _NtlmClient.cs
- Oid.cs
- DetailsViewPagerRow.cs
- SqlLiftWhereClauses.cs
- TextServicesProperty.cs
- TextElementAutomationPeer.cs
- CodeArrayCreateExpression.cs
- Image.cs
- HttpSessionStateWrapper.cs
- ToolStripItemImageRenderEventArgs.cs
- SchemaNotation.cs
- DrawingAttributesDefaultValueFactory.cs
- BaseDataBoundControl.cs
- InstanceCompleteException.cs
- ToolStripContainer.cs
- ProbeRequestResponseAsyncResult.cs
- SchemaCollectionCompiler.cs
- TemplateKey.cs
- SystemWebExtensionsSectionGroup.cs
- MembershipValidatePasswordEventArgs.cs
- ResourceProviderFactory.cs
- TypeLibConverter.cs
- XmlSchemaSet.cs
- DrawingContext.cs
- DecimalConverter.cs
- rsa.cs
- GroupStyle.cs
- IISUnsafeMethods.cs
- XmlSchemaSet.cs
- DbConnectionPoolOptions.cs
- StateRuntime.cs
- DirectionalLight.cs
- Effect.cs
- APCustomTypeDescriptor.cs
- CheckBox.cs
- Preprocessor.cs
- UnsafeNativeMethods.cs
- Label.cs
- SkewTransform.cs