Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- ObjectDataProvider.cs
- TransactionTable.cs
- ContainerActivationHelper.cs
- SoapConverter.cs
- KeyNotFoundException.cs
- DigestTraceRecordHelper.cs
- TrueReadOnlyCollection.cs
- ZoneButton.cs
- ObjectTag.cs
- TextBreakpoint.cs
- XomlCompilerParameters.cs
- WorkflowOwnershipException.cs
- TypeSystemProvider.cs
- ValidatedControlConverter.cs
- SettingsPropertyWrongTypeException.cs
- GenericTransactionFlowAttribute.cs
- HwndKeyboardInputProvider.cs
- ResizeGrip.cs
- FunctionQuery.cs
- ProxyFragment.cs
- CodeDelegateCreateExpression.cs
- SamlAttribute.cs
- mongolianshape.cs
- OverlappedAsyncResult.cs
- InputMethod.cs
- XappLauncher.cs
- TextLineResult.cs
- LogLogRecordHeader.cs
- CharKeyFrameCollection.cs
- HttpClientCertificate.cs
- ActivationService.cs
- EncryptedReference.cs
- TableLayoutRowStyleCollection.cs
- ACE.cs
- XmlnsPrefixAttribute.cs
- CacheAxisQuery.cs
- EnvelopedPkcs7.cs
- DiscoveryClientElement.cs
- SmiConnection.cs
- DataTemplate.cs
- TreeWalker.cs
- GlobalizationAssembly.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- TextEndOfSegment.cs
- URL.cs
- ContainerUIElement3D.cs
- DataTableMappingCollection.cs
- Imaging.cs
- Sql8ExpressionRewriter.cs
- BinaryReader.cs
- Quack.cs
- LoginUtil.cs
- SqlCachedBuffer.cs
- FileDialogCustomPlace.cs
- SingleTagSectionHandler.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- DefaultTextStoreTextComposition.cs
- SpeechSeg.cs
- SecurityTokenProvider.cs
- AppDomainManager.cs
- ReturnEventArgs.cs
- WorkflowElementDialogWindow.xaml.cs
- CapabilitiesSection.cs
- DrawListViewItemEventArgs.cs
- errorpatternmatcher.cs
- TraversalRequest.cs
- GridLengthConverter.cs
- XmlJsonReader.cs
- DataServiceQueryException.cs
- MultiView.cs
- JavaScriptObjectDeserializer.cs
- MetaColumn.cs
- _NegoState.cs
- HtmlTernaryTree.cs
- RoleService.cs
- OdbcTransaction.cs
- UnsafeNativeMethods.cs
- CultureSpecificStringDictionary.cs
- ColorContextHelper.cs
- HandlerFactoryCache.cs
- EntityType.cs
- FixedSOMFixedBlock.cs
- Int32KeyFrameCollection.cs
- ElementsClipboardData.cs
- TabletCollection.cs
- SingleConverter.cs
- FamilyMapCollection.cs
- ObjectDataSourceStatusEventArgs.cs
- hresults.cs
- ControllableStoryboardAction.cs
- XmlILIndex.cs
- XamlDesignerSerializationManager.cs
- HtmlMeta.cs
- RegistrationServices.cs
- UpdateCompiler.cs
- InterleavedZipPartStream.cs
- ChannelOptions.cs
- CodeCastExpression.cs
- MimeFormatter.cs
- SqlDataRecord.cs