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
- DataGridTable.cs
- Color.cs
- AppSettingsExpressionBuilder.cs
- CorrelationTokenInvalidatedHandler.cs
- DES.cs
- ToolboxComponentsCreatingEventArgs.cs
- MailSettingsSection.cs
- UnorderedHashRepartitionStream.cs
- SeekStoryboard.cs
- DependencyProperty.cs
- MDIClient.cs
- IsolatedStorageFilePermission.cs
- OverflowException.cs
- WebPartsPersonalization.cs
- XmlSerializerNamespaces.cs
- Ref.cs
- XslAst.cs
- WebPartTransformerCollection.cs
- GeneralTransform3DCollection.cs
- IODescriptionAttribute.cs
- HotSpotCollection.cs
- ConstraintCollection.cs
- EditCommandColumn.cs
- RegionData.cs
- ByteStack.cs
- HelloMessageApril2005.cs
- Vector3DAnimationUsingKeyFrames.cs
- ThemeConfigurationDialog.cs
- PackageProperties.cs
- ImmutableCollection.cs
- activationcontext.cs
- KeyFrames.cs
- SolidBrush.cs
- DesignColumn.cs
- HScrollBar.cs
- Process.cs
- DataBindingCollection.cs
- AuthenticationService.cs
- AliasGenerator.cs
- OleDbError.cs
- IndexedEnumerable.cs
- XmlSchemaSimpleContentExtension.cs
- Sentence.cs
- IriParsingElement.cs
- StreamReader.cs
- ComponentCache.cs
- ParameterReplacerVisitor.cs
- TextTrailingWordEllipsis.cs
- Parallel.cs
- PropertyPathConverter.cs
- UxThemeWrapper.cs
- ContainerParagraph.cs
- KeyBinding.cs
- TransformedBitmap.cs
- ValidateNames.cs
- SimpleColumnProvider.cs
- TagPrefixInfo.cs
- DesignerTransaction.cs
- RowParagraph.cs
- RelatedCurrencyManager.cs
- Utility.cs
- BinaryObjectInfo.cs
- DatePickerAutomationPeer.cs
- TextTreeRootNode.cs
- UpdateCommandGenerator.cs
- UInt16Converter.cs
- PathParser.cs
- ScriptReference.cs
- AppModelKnownContentFactory.cs
- FontEmbeddingManager.cs
- PublisherIdentityPermission.cs
- RoutedUICommand.cs
- HitTestDrawingContextWalker.cs
- InputLanguageSource.cs
- GatewayDefinition.cs
- UIntPtr.cs
- TreeViewEvent.cs
- SaveFileDialog.cs
- EnumerableCollectionView.cs
- IncrementalHitTester.cs
- CLSCompliantAttribute.cs
- DetailsViewInsertEventArgs.cs
- SelectionEditor.cs
- WebPartDescription.cs
- OdbcConnection.cs
- GlyphManager.cs
- XmlQueryContext.cs
- AnonymousIdentificationSection.cs
- SchemaNames.cs
- MailAddressParser.cs
- SqlNodeAnnotations.cs
- TemplateControlCodeDomTreeGenerator.cs
- LogWriteRestartAreaAsyncResult.cs
- IFlowDocumentViewer.cs
- CellParaClient.cs
- COM2AboutBoxPropertyDescriptor.cs
- CollectionsUtil.cs
- CompilerWrapper.cs
- _LocalDataStore.cs
- XsdBuildProvider.cs