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
- OdbcError.cs
- PingReply.cs
- SelectionRangeConverter.cs
- FixedSOMPageConstructor.cs
- HtmlDocument.cs
- MethodBuilderInstantiation.cs
- DecoderNLS.cs
- TdsRecordBufferSetter.cs
- MailDefinition.cs
- LedgerEntryCollection.cs
- StaticExtensionConverter.cs
- EventLogTraceListener.cs
- IISUnsafeMethods.cs
- EventLogConfiguration.cs
- SimpleHandlerBuildProvider.cs
- LinqDataSourceUpdateEventArgs.cs
- WebPartCollection.cs
- Image.cs
- SynchronizationHandlesCodeDomSerializer.cs
- AppDomain.cs
- ContentElement.cs
- LinearKeyFrames.cs
- HttpProcessUtility.cs
- InteropExecutor.cs
- HandlerBase.cs
- JoinSymbol.cs
- SortedDictionary.cs
- _LoggingObject.cs
- SourceLineInfo.cs
- DataObject.cs
- RelationshipConstraintValidator.cs
- ScrollChrome.cs
- _DigestClient.cs
- ListViewHitTestInfo.cs
- ContentPlaceHolder.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- SimpleFieldTemplateUserControl.cs
- WindowsStartMenu.cs
- WindowsUpDown.cs
- UriTemplateClientFormatter.cs
- DataSourceCache.cs
- TabPanel.cs
- XmlNodeReader.cs
- RequestCachePolicy.cs
- MailSettingsSection.cs
- HandlerBase.cs
- WindowsBrush.cs
- CodeBlockBuilder.cs
- GenericEnumConverter.cs
- XmlSchemaSimpleContent.cs
- ExpressionCopier.cs
- connectionpool.cs
- CapabilitiesUse.cs
- AsnEncodedData.cs
- TextTreeTextElementNode.cs
- PropertyHelper.cs
- CertificateManager.cs
- ProgressBar.cs
- StorageMappingFragment.cs
- BulletedList.cs
- ClipboardProcessor.cs
- XmlElement.cs
- DPTypeDescriptorContext.cs
- HandleRef.cs
- TextEffectResolver.cs
- MonitoringDescriptionAttribute.cs
- WebGetAttribute.cs
- AlignmentYValidation.cs
- PermissionAttributes.cs
- HttpConfigurationContext.cs
- SignedXml.cs
- FirewallWrapper.cs
- ElementNotAvailableException.cs
- ProxyAttribute.cs
- DBCSCodePageEncoding.cs
- DataListItemEventArgs.cs
- ParserContext.cs
- EdmError.cs
- TrailingSpaceComparer.cs
- SiteMapSection.cs
- MouseGesture.cs
- Padding.cs
- _ProxyRegBlob.cs
- SystemParameters.cs
- DataGridViewCell.cs
- Section.cs
- WsdlInspector.cs
- AbandonedMutexException.cs
- EventToken.cs
- URLEditor.cs
- FontFamily.cs
- SmiRequestExecutor.cs
- TrackingCondition.cs
- InputLanguageCollection.cs
- ServiceElementCollection.cs
- DiscoveryInnerClientAdhocCD1.cs
- ProviderConnectionPointCollection.cs
- CategoryAttribute.cs
- CalendarAutoFormatDialog.cs
- GeneralTransform3D.cs