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
- ProxyWebPartConnectionCollection.cs
- ExpressionParser.cs
- GlobalProxySelection.cs
- DetailsViewModeEventArgs.cs
- Win32MouseDevice.cs
- FragmentNavigationEventArgs.cs
- DataGridViewCellValidatingEventArgs.cs
- KeyValuePair.cs
- SqlRewriteScalarSubqueries.cs
- SecurityUniqueId.cs
- FixedSOMGroup.cs
- ErrorTableItemStyle.cs
- IndexedString.cs
- FormatException.cs
- StateDesigner.TransitionInfo.cs
- XdrBuilder.cs
- EventManager.cs
- EntityContainerEntitySet.cs
- RuleEngine.cs
- OneWayChannelFactory.cs
- ConditionalAttribute.cs
- ResourceCodeDomSerializer.cs
- SettingsAttributeDictionary.cs
- FlowchartDesigner.xaml.cs
- EditorZoneDesigner.cs
- TypeInitializationException.cs
- ObjectDataSourceDesigner.cs
- TreeViewHitTestInfo.cs
- ProcessModelSection.cs
- DefaultSerializationProviderAttribute.cs
- EncodingNLS.cs
- ReturnValue.cs
- EventLogWatcher.cs
- RouteValueDictionary.cs
- ListControl.cs
- RemotingSurrogateSelector.cs
- CurrencyManager.cs
- UserNamePasswordValidator.cs
- XmlSchemaInclude.cs
- DataException.cs
- WindowsMenu.cs
- ProxyManager.cs
- SchemaNotation.cs
- WebPart.cs
- Nullable.cs
- WriteTimeStream.cs
- _NetworkingPerfCounters.cs
- DataGridViewCellStyle.cs
- StateMachineExecutionState.cs
- HttpListenerResponse.cs
- TogglePatternIdentifiers.cs
- ComNativeDescriptor.cs
- FixedPage.cs
- Barrier.cs
- ClassImporter.cs
- XMLDiffLoader.cs
- FixUp.cs
- FixedSOMTextRun.cs
- CompensableActivity.cs
- MethodSignatureGenerator.cs
- PairComparer.cs
- OletxVolatileEnlistment.cs
- FieldTemplateUserControl.cs
- DiscoveryMessageSequence.cs
- ObjectSpanRewriter.cs
- XmlSiteMapProvider.cs
- WeakReadOnlyCollection.cs
- BamlTreeUpdater.cs
- DataServices.cs
- DocumentPage.cs
- ContractCodeDomInfo.cs
- GroupBox.cs
- ServiceOperationParameter.cs
- SqlAliaser.cs
- BCryptHashAlgorithm.cs
- CommandHelpers.cs
- ProviderCommandInfoUtils.cs
- ScriptResourceMapping.cs
- Positioning.cs
- HandlerBase.cs
- PrimaryKeyTypeConverter.cs
- CustomError.cs
- XAMLParseException.cs
- Menu.cs
- IdentityManager.cs
- VisualTreeUtils.cs
- BigInt.cs
- DataDocumentXPathNavigator.cs
- SystemIPGlobalProperties.cs
- TrackingMemoryStream.cs
- SqlDelegatedTransaction.cs
- InvalidCastException.cs
- InputChannel.cs
- ProtocolException.cs
- HttpContextBase.cs
- BuildProvidersCompiler.cs
- CallTemplateAction.cs
- EntityDescriptor.cs
- ICspAsymmetricAlgorithm.cs
- TypeBrowserDialog.cs