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
- EventListener.cs
- PrimitiveSchema.cs
- FigureHelper.cs
- DispatcherExceptionFilterEventArgs.cs
- SqlDataSourceTableQuery.cs
- ReturnEventArgs.cs
- TaiwanCalendar.cs
- PartitionResolver.cs
- InstanceStore.cs
- XPathNode.cs
- DebugInfo.cs
- AutomationAttributeInfo.cs
- DrawingBrush.cs
- Property.cs
- ClientBase.cs
- PageRequestManager.cs
- ApplicationGesture.cs
- GenericTextProperties.cs
- DataSourceConverter.cs
- SoapCommonClasses.cs
- OleDbCommandBuilder.cs
- XMLSyntaxException.cs
- UpdateEventArgs.cs
- MetaDataInfo.cs
- SoapClientMessage.cs
- RoleManagerModule.cs
- TraceContextRecord.cs
- MarginCollapsingState.cs
- SafeNativeMethods.cs
- WebPartRestoreVerb.cs
- MexHttpBindingElement.cs
- ImageClickEventArgs.cs
- DotNetATv1WindowsLogEntryDeserializer.cs
- AutomationPropertyChangedEventArgs.cs
- PeerName.cs
- ScrollableControl.cs
- Geometry.cs
- ManualResetEvent.cs
- SafeNativeMethods.cs
- HttpListenerException.cs
- XmlDictionary.cs
- WeakEventTable.cs
- FileRecordSequenceCompletedAsyncResult.cs
- RowsCopiedEventArgs.cs
- TypeLibConverter.cs
- ToggleButtonAutomationPeer.cs
- ClusterSafeNativeMethods.cs
- BinaryFormatter.cs
- EventHandlerList.cs
- AnnotationMap.cs
- DeclaredTypeValidator.cs
- Typography.cs
- WebPartCloseVerb.cs
- FormatConvertedBitmap.cs
- FrameworkRichTextComposition.cs
- HMACRIPEMD160.cs
- KerberosSecurityTokenProvider.cs
- Assert.cs
- CompilerState.cs
- DataGridTable.cs
- DeclarativeCatalogPart.cs
- ExtendedPropertyDescriptor.cs
- TreeNodeMouseHoverEvent.cs
- BufferCache.cs
- DbConnectionPoolGroupProviderInfo.cs
- ControlTemplate.cs
- UidPropertyAttribute.cs
- Evidence.cs
- PrefixHandle.cs
- PeerNameRecordCollection.cs
- PixelShader.cs
- StrokeDescriptor.cs
- MgmtResManager.cs
- TextContainerHelper.cs
- ParallelTimeline.cs
- RegexWriter.cs
- EventArgs.cs
- PermissionListSet.cs
- StaticTextPointer.cs
- SystemNetworkInterface.cs
- MultiAsyncResult.cs
- NameSpaceEvent.cs
- processwaithandle.cs
- Manipulation.cs
- HttpRuntime.cs
- IndicCharClassifier.cs
- SemanticBasicElement.cs
- FreezableOperations.cs
- CapabilitiesUse.cs
- DecoratedNameAttribute.cs
- DropSource.cs
- RayHitTestParameters.cs
- SQLInt16.cs
- SkinBuilder.cs
- RangeBase.cs
- ReadOnlyHierarchicalDataSource.cs
- SelectionRange.cs
- GifBitmapEncoder.cs
- CreateUserWizard.cs
- AgileSafeNativeMemoryHandle.cs