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
- ClientSettingsStore.cs
- _DigestClient.cs
- SharedStream.cs
- COM2IVsPerPropertyBrowsingHandler.cs
- ResourceProviderFactory.cs
- URLAttribute.cs
- ReflectionUtil.cs
- DrawListViewSubItemEventArgs.cs
- AccessDataSourceView.cs
- WebPartsSection.cs
- SynchronousReceiveElement.cs
- EditorZone.cs
- control.ime.cs
- TextTreeRootTextBlock.cs
- ParsedAttributeCollection.cs
- DataTablePropertyDescriptor.cs
- InvalidOleVariantTypeException.cs
- CodeMethodMap.cs
- CorrelationToken.cs
- RightsManagementPermission.cs
- LinkedResource.cs
- Icon.cs
- HttpBrowserCapabilitiesWrapper.cs
- Accessible.cs
- TypeInformation.cs
- SessionState.cs
- ISAPIApplicationHost.cs
- DocumentViewerHelper.cs
- MenuStrip.cs
- UdpRetransmissionSettings.cs
- StreamUpdate.cs
- coordinator.cs
- PersonalizationProviderCollection.cs
- DataObject.cs
- WaitHandleCannotBeOpenedException.cs
- ContextDataSource.cs
- DataGridParentRows.cs
- PolygonHotSpot.cs
- BaseProcessor.cs
- Part.cs
- PackageRelationship.cs
- PrintSchema.cs
- LambdaCompiler.Unary.cs
- MetadataProperty.cs
- HTMLTagNameToTypeMapper.cs
- SyndicationDeserializer.cs
- CodeIndexerExpression.cs
- RTLAwareMessageBox.cs
- XmlAttribute.cs
- ExpressionHelper.cs
- ZipIOExtraFieldZip64Element.cs
- XmlSchemaExporter.cs
- XamlDesignerSerializationManager.cs
- AttributeQuery.cs
- CaseInsensitiveComparer.cs
- DateTimeStorage.cs
- EntityDescriptor.cs
- DetailsView.cs
- Set.cs
- GridViewDeleteEventArgs.cs
- Timer.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- WebPartCloseVerb.cs
- UndoEngine.cs
- WinEventHandler.cs
- EventToken.cs
- InputBuffer.cs
- WebPartAddingEventArgs.cs
- Bits.cs
- JoinGraph.cs
- HttpListenerRequest.cs
- RootAction.cs
- XmlSerializerSection.cs
- BaseTreeIterator.cs
- SBCSCodePageEncoding.cs
- ProcessThreadCollection.cs
- Win32SafeHandles.cs
- ExpressionVisitorHelpers.cs
- WindowsScrollBar.cs
- unitconverter.cs
- JsonFormatWriterGenerator.cs
- CustomAttribute.cs
- GcSettings.cs
- DefaultTypeArgumentAttribute.cs
- ContainerAction.cs
- ReflectionUtil.cs
- CodeExpressionCollection.cs
- ResourceProviderFactory.cs
- DynamicPropertyReader.cs
- SystemSounds.cs
- FileLogRecordStream.cs
- ToolStripMenuItem.cs
- Quaternion.cs
- QilIterator.cs
- DetailsViewModeEventArgs.cs
- DocobjHost.cs
- MimeTypeMapper.cs
- Size3DConverter.cs
- XsdDateTime.cs
- TimersDescriptionAttribute.cs