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
- DataAdapter.cs
- EnumerableRowCollection.cs
- RotateTransform3D.cs
- StylusPointProperty.cs
- IndexerNameAttribute.cs
- Journaling.cs
- ValidationResult.cs
- RangeValidator.cs
- WebPartConnectionsConfigureVerb.cs
- TreeWalkHelper.cs
- ComponentEditorPage.cs
- FormClosingEvent.cs
- Exceptions.cs
- WebExceptionStatus.cs
- ProfileBuildProvider.cs
- Model3D.cs
- XmlReflectionMember.cs
- SessionEndingEventArgs.cs
- ApplicationActivator.cs
- Empty.cs
- BroadcastEventHelper.cs
- LinkUtilities.cs
- DataSourceXmlElementAttribute.cs
- PerformanceCounterScope.cs
- ChunkedMemoryStream.cs
- CanExecuteRoutedEventArgs.cs
- LocationReference.cs
- DataObjectCopyingEventArgs.cs
- DrawingBrush.cs
- SiteMapDataSource.cs
- ExtendedPropertyCollection.cs
- DoubleAnimationBase.cs
- FilterException.cs
- IndentedTextWriter.cs
- DateTimeSerializationSection.cs
- SupportingTokenSecurityTokenResolver.cs
- SrgsSubset.cs
- Encoding.cs
- NullableFloatMinMaxAggregationOperator.cs
- Zone.cs
- OpenTypeLayout.cs
- _FtpDataStream.cs
- AppDomainShutdownMonitor.cs
- AppDomainFactory.cs
- MethodRental.cs
- DefaultMemberAttribute.cs
- TextRangeProviderWrapper.cs
- TextDecorations.cs
- IdentitySection.cs
- RuntimeCompatibilityAttribute.cs
- ReplyChannel.cs
- HwndSource.cs
- GlyphCache.cs
- HttpAsyncResult.cs
- CodeDomSerializationProvider.cs
- FormsAuthenticationModule.cs
- LazyTextWriterCreator.cs
- PeerContact.cs
- FileRecordSequenceCompletedAsyncResult.cs
- Model3D.cs
- HtmlMeta.cs
- BoolExpression.cs
- ShutDownListener.cs
- DataGridViewRowPostPaintEventArgs.cs
- DesignerTransactionCloseEvent.cs
- DataControlFieldHeaderCell.cs
- QueryConverter.cs
- NumericUpDownAcceleration.cs
- DataGridLength.cs
- SqlConnectionString.cs
- Size.cs
- DesignSurfaceManager.cs
- FieldAccessException.cs
- IndexExpression.cs
- XmlNamespaceMapping.cs
- SqlBulkCopyColumnMapping.cs
- BooleanProjectedSlot.cs
- DataColumnMappingCollection.cs
- odbcmetadatafactory.cs
- WindowClosedEventArgs.cs
- FrameworkContentElement.cs
- ColumnResult.cs
- HelpEvent.cs
- DataSourceIDConverter.cs
- XmlIlTypeHelper.cs
- SlipBehavior.cs
- CryptoKeySecurity.cs
- ObjectQueryExecutionPlan.cs
- Deserializer.cs
- SmiConnection.cs
- ExecutionEngineException.cs
- IgnoreFileBuildProvider.cs
- ContainerVisual.cs
- SqlDataSourceConnectionPanel.cs
- DataGridViewMethods.cs
- EventSinkHelperWriter.cs
- Size.cs
- DataGridViewRow.cs
- NavigationEventArgs.cs
- Stopwatch.cs