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
- BaseAddressElement.cs
- DataMemberFieldEditor.cs
- ToolStripStatusLabel.cs
- DataContractJsonSerializerOperationBehavior.cs
- XmlNodeList.cs
- XmlSchemaImporter.cs
- FieldInfo.cs
- RecipientInfo.cs
- XPathNodeList.cs
- MenuScrollingVisibilityConverter.cs
- HostedImpersonationContext.cs
- DescendantBaseQuery.cs
- ZipIOExtraFieldElement.cs
- IsolatedStorageException.cs
- MergeLocalizationDirectives.cs
- HttpRequest.cs
- XmlSchemaSimpleTypeList.cs
- SmiContext.cs
- QilBinary.cs
- ArcSegment.cs
- DeflateEmulationStream.cs
- DummyDataSource.cs
- ConfigXmlDocument.cs
- RecognitionEventArgs.cs
- TemplateControlCodeDomTreeGenerator.cs
- QueryAccessibilityHelpEvent.cs
- FileIOPermission.cs
- ObjectCache.cs
- FileEnumerator.cs
- TypeDependencyAttribute.cs
- WebServiceHandler.cs
- HtmlDocument.cs
- WebBrowserContainer.cs
- WorkflowRuntimeElement.cs
- OpenFileDialog.cs
- WebDescriptionAttribute.cs
- BoundField.cs
- ISO2022Encoding.cs
- DiagnosticStrings.cs
- NetNamedPipeBinding.cs
- ProjectionCamera.cs
- RawUIStateInputReport.cs
- FocusWithinProperty.cs
- ExpressionEditorAttribute.cs
- CompareValidator.cs
- ActivityStateRecord.cs
- SqlDataSourceQueryEditor.cs
- RemotingException.cs
- ToolStripSeparator.cs
- RulePatternOps.cs
- GatewayDefinition.cs
- HtmlGenericControl.cs
- OutOfProcStateClientManager.cs
- UidPropertyAttribute.cs
- TextTreeInsertUndoUnit.cs
- SplineKeyFrames.cs
- HtmlInputText.cs
- EncodingDataItem.cs
- TcpChannelListener.cs
- AlternationConverter.cs
- PauseStoryboard.cs
- AppDomainInstanceProvider.cs
- BitHelper.cs
- LinqDataSourceInsertEventArgs.cs
- TimeZone.cs
- QueryResponse.cs
- OracleLob.cs
- ProtectedConfigurationProviderCollection.cs
- DataSet.cs
- DataColumnCollection.cs
- Column.cs
- parserscommon.cs
- Lock.cs
- cookie.cs
- PreparingEnlistment.cs
- PathTooLongException.cs
- AutomationPeer.cs
- KeyFrames.cs
- CollectionBase.cs
- OdbcReferenceCollection.cs
- LinqToSqlWrapper.cs
- SubpageParaClient.cs
- TextEditorSpelling.cs
- BigInt.cs
- DescriptionAttribute.cs
- QueryContinueDragEvent.cs
- SmtpLoginAuthenticationModule.cs
- CodeBlockBuilder.cs
- HandlerFactoryCache.cs
- JapaneseCalendar.cs
- DispatcherSynchronizationContext.cs
- PartialClassGenerationTaskInternal.cs
- FieldInfo.cs
- StructuralCache.cs
- EncryptedPackage.cs
- EventManager.cs
- OdbcCommand.cs
- RelationshipSet.cs
- RoutedEventValueSerializer.cs
- ListViewTableCell.cs