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 / Win32KeyboardDevice.cs / 1 / Win32KeyboardDevice.cs
using System.Collections; using System.Windows; using System.Security; using System.Security.Permissions; using MS.Internal; using MS.Internal.PresentationCore; // SecurityHelper using System.Windows.Media; using MS.Win32; // VK translation. using System; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; namespace System.Windows.Input { ////// The Win32KeyboardDevice class implements the platform specific /// KeyboardDevice features for the Win32 platform /// internal sealed class Win32KeyboardDevice : KeyboardDevice { ////// /// /// /// ////// Critical: This code creates critical data(_tsfManager,_textcompositionManager) and stores critical data (inputManager) /// TreatAsSafe: Although it creates critical data there are demand on the critical data and the constructor is safe /// [SecurityCritical,SecurityTreatAsSafe] internal Win32KeyboardDevice(InputManager inputManager) : base(inputManager) { } ////// Gets the current state of the specified key from the device from the underlying system /// /// /// Key to get the state of /// ////// The state of the specified key /// ////// Critical: Makes calls to UnsafeNativeMethods (GetKeyState) /// TreatAsSafe: Only returns the current state of a specified key /// [SecurityCritical, SecurityTreatAsSafe] protected override KeyStates GetKeyStatesFromSystem(Key key) { KeyStates keyStates = KeyStates.None; // Security Mitigation: do not give out input state if the device is not active. if(IsActive) { int virtualKeyCode = KeyInterop.VirtualKeyFromKey(key); int nativeKeyState; nativeKeyState = UnsafeNativeMethods.GetKeyState(virtualKeyCode); if( (nativeKeyState & 0x00008000) == 0x00008000 ) keyStates |= KeyStates.Down; if( (nativeKeyState & 0x00000001) == 0x00000001 ) keyStates |= KeyStates.Toggled; } return keyStates; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System.Collections; using System.Windows; using System.Security; using System.Security.Permissions; using MS.Internal; using MS.Internal.PresentationCore; // SecurityHelper using System.Windows.Media; using MS.Win32; // VK translation. using System; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; namespace System.Windows.Input { ////// The Win32KeyboardDevice class implements the platform specific /// KeyboardDevice features for the Win32 platform /// internal sealed class Win32KeyboardDevice : KeyboardDevice { ////// /// /// /// ////// Critical: This code creates critical data(_tsfManager,_textcompositionManager) and stores critical data (inputManager) /// TreatAsSafe: Although it creates critical data there are demand on the critical data and the constructor is safe /// [SecurityCritical,SecurityTreatAsSafe] internal Win32KeyboardDevice(InputManager inputManager) : base(inputManager) { } ////// Gets the current state of the specified key from the device from the underlying system /// /// /// Key to get the state of /// ////// The state of the specified key /// ////// Critical: Makes calls to UnsafeNativeMethods (GetKeyState) /// TreatAsSafe: Only returns the current state of a specified key /// [SecurityCritical, SecurityTreatAsSafe] protected override KeyStates GetKeyStatesFromSystem(Key key) { KeyStates keyStates = KeyStates.None; // Security Mitigation: do not give out input state if the device is not active. if(IsActive) { int virtualKeyCode = KeyInterop.VirtualKeyFromKey(key); int nativeKeyState; nativeKeyState = UnsafeNativeMethods.GetKeyState(virtualKeyCode); if( (nativeKeyState & 0x00008000) == 0x00008000 ) keyStates |= KeyStates.Down; if( (nativeKeyState & 0x00000001) == 0x00000001 ) keyStates |= KeyStates.Toggled; } return keyStates; } } } // 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
- Oid.cs
- RectIndependentAnimationStorage.cs
- OdbcEnvironmentHandle.cs
- WorkflowServiceHost.cs
- RetrieveVirtualItemEventArgs.cs
- SettingsBase.cs
- PostBackTrigger.cs
- NamespaceExpr.cs
- WaitHandle.cs
- DropTarget.cs
- JoinTreeNode.cs
- UTF32Encoding.cs
- AsmxEndpointPickerExtension.cs
- TextTreeObjectNode.cs
- Attributes.cs
- AspCompat.cs
- AnnotationResource.cs
- SizeIndependentAnimationStorage.cs
- validation.cs
- CallId.cs
- IsolationInterop.cs
- AbsoluteQuery.cs
- ConfigXmlText.cs
- XpsFixedDocumentReaderWriter.cs
- StyleXamlParser.cs
- ObjectDataSourceSelectingEventArgs.cs
- WebPartPersonalization.cs
- DbException.cs
- ToolZone.cs
- HostingPreferredMapPath.cs
- InsufficientExecutionStackException.cs
- ListViewGroup.cs
- ComPlusSynchronizationContext.cs
- AutoGeneratedFieldProperties.cs
- ObjectDataSourceView.cs
- MenuItem.cs
- PropertyGridCommands.cs
- Baml6Assembly.cs
- RegexTree.cs
- DefaultHttpHandler.cs
- ConversionHelper.cs
- BasicViewGenerator.cs
- ResourceSet.cs
- SessionStateContainer.cs
- SByte.cs
- TextSimpleMarkerProperties.cs
- RecoverInstanceLocksCommand.cs
- ServiceProviders.cs
- TextTreeExtractElementUndoUnit.cs
- ProfileBuildProvider.cs
- TrustManagerPromptUI.cs
- OdbcConnectionString.cs
- SerialErrors.cs
- PathFigureCollection.cs
- TypedReference.cs
- IISUnsafeMethods.cs
- ComponentDispatcherThread.cs
- WindowsScrollBarBits.cs
- RegexRunnerFactory.cs
- PostBackOptions.cs
- AncillaryOps.cs
- SelectorAutomationPeer.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- ButtonFlatAdapter.cs
- MarshalByRefObject.cs
- ConnectionStringsExpressionEditor.cs
- XamlVector3DCollectionSerializer.cs
- Function.cs
- GradientSpreadMethodValidation.cs
- tabpagecollectioneditor.cs
- InternalControlCollection.cs
- BindableTemplateBuilder.cs
- EntityContainerAssociationSetEnd.cs
- AutomationEvent.cs
- MenuRendererClassic.cs
- InputScopeConverter.cs
- DeviceSpecific.cs
- LinkedResource.cs
- RtfNavigator.cs
- HttpDebugHandler.cs
- FontConverter.cs
- TraceContextRecord.cs
- XmlSerializerFormatAttribute.cs
- ClusterSafeNativeMethods.cs
- DropSourceBehavior.cs
- HtmlInputPassword.cs
- TextEncodedRawTextWriter.cs
- Quaternion.cs
- ErrorHandler.cs
- NetworkInterface.cs
- PreviewKeyDownEventArgs.cs
- MetaForeignKeyColumn.cs
- PointCollectionValueSerializer.cs
- Pair.cs
- DataGridBoolColumn.cs
- DataAccessor.cs
- Validator.cs
- XmlStringTable.cs
- Vector3D.cs
- XmlSerializerFactory.cs