Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- ScriptingProfileServiceSection.cs
- ReadOnlyHierarchicalDataSource.cs
- RijndaelManagedTransform.cs
- ControlCollection.cs
- RegularExpressionValidator.cs
- WindowsBrush.cs
- CodeTypeParameterCollection.cs
- TransformValueSerializer.cs
- FontFamilyConverter.cs
- ListViewGroupItemCollection.cs
- TransportConfigurationTypeElementCollection.cs
- WebPartZone.cs
- UInt16Storage.cs
- QueryOperatorEnumerator.cs
- HScrollProperties.cs
- SchemaComplexType.cs
- TemplateField.cs
- WebPartsSection.cs
- BooleanAnimationUsingKeyFrames.cs
- BaseUriHelper.cs
- Translator.cs
- SystemPens.cs
- EntitySqlQueryBuilder.cs
- ConnectorRouter.cs
- NegationPusher.cs
- TextServicesDisplayAttribute.cs
- MailHeaderInfo.cs
- FixedPageStructure.cs
- HttpListenerException.cs
- PageFunction.cs
- AssociationTypeEmitter.cs
- SerialStream.cs
- ReadOnlyObservableCollection.cs
- InputLanguage.cs
- Metadata.cs
- ellipse.cs
- SecureStringHasher.cs
- ListBoxChrome.cs
- BooleanConverter.cs
- CloseSequence.cs
- PrimitiveDataContract.cs
- TextureBrush.cs
- XmlDeclaration.cs
- MarkupCompilePass2.cs
- SQLInt16Storage.cs
- SqlVersion.cs
- DBConnection.cs
- CheckBox.cs
- InstanceCreationEditor.cs
- Point3DCollection.cs
- BindingGroup.cs
- MeasureItemEvent.cs
- SchemaComplexType.cs
- ListChangedEventArgs.cs
- GridViewRowCollection.cs
- WindowsUpDown.cs
- RefreshPropertiesAttribute.cs
- EdmEntityTypeAttribute.cs
- ResolveNameEventArgs.cs
- DbConnectionPool.cs
- PersonalizationStateInfoCollection.cs
- Constraint.cs
- externdll.cs
- WebPartDescriptionCollection.cs
- DispatcherObject.cs
- TrackingProfileDeserializationException.cs
- HttpResponseWrapper.cs
- DispatcherFrame.cs
- CommandValueSerializer.cs
- Mouse.cs
- MemberAccessException.cs
- CatalogPartChrome.cs
- ValueHandle.cs
- RegisteredDisposeScript.cs
- AnimationStorage.cs
- PaperSource.cs
- TextReader.cs
- MachineKeyConverter.cs
- ObjectComplexPropertyMapping.cs
- DropDownList.cs
- DataGridViewIntLinkedList.cs
- DataGridViewCellPaintingEventArgs.cs
- TextSelectionProcessor.cs
- UnauthorizedAccessException.cs
- InfoCardConstants.cs
- ExceptionTrace.cs
- ClientSession.cs
- BindingNavigator.cs
- EntityConnection.cs
- WindowsButton.cs
- DecoderNLS.cs
- CodeDomExtensionMethods.cs
- NGCPageContentSerializerAsync.cs
- Button.cs
- Misc.cs
- GridLength.cs
- EntityDataSourceViewSchema.cs
- String.cs
- XmlMemberMapping.cs
- StylusDevice.cs