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
- LicenseException.cs
- SortExpressionBuilder.cs
- HashFinalRequest.cs
- Metafile.cs
- DelegatedStream.cs
- ChannelSinkStacks.cs
- PtsHelper.cs
- BCryptHashAlgorithm.cs
- WSDualHttpSecurity.cs
- MSG.cs
- KeyValueSerializer.cs
- ThicknessAnimation.cs
- BrushValueSerializer.cs
- remotingproxy.cs
- UriExt.cs
- PageAsyncTaskManager.cs
- XmlIlVisitor.cs
- ListItemParagraph.cs
- FormDocumentDesigner.cs
- StylusButton.cs
- OdbcParameter.cs
- ParameterReplacerVisitor.cs
- HMACMD5.cs
- Internal.cs
- SoapAttributeOverrides.cs
- ProfilePropertySettings.cs
- InvalidateEvent.cs
- SparseMemoryStream.cs
- ButtonAutomationPeer.cs
- MSAAEventDispatcher.cs
- X509Chain.cs
- Int32Converter.cs
- AttributeProviderAttribute.cs
- XmlSchemaSimpleContent.cs
- XmlHierarchyData.cs
- XPathItem.cs
- ImageListStreamer.cs
- TcpProcessProtocolHandler.cs
- CharacterShapingProperties.cs
- ListItem.cs
- ThemeConfigurationDialog.cs
- BufferedWebEventProvider.cs
- SqlConnection.cs
- SinglePhaseEnlistment.cs
- ElementProxy.cs
- QueryAsyncResult.cs
- HttpResponse.cs
- SelectionProviderWrapper.cs
- CultureMapper.cs
- UndoManager.cs
- ExpressionBuilder.cs
- JsonQNameDataContract.cs
- KeyboardEventArgs.cs
- OrderedDictionaryStateHelper.cs
- CommandExpr.cs
- Highlights.cs
- WebPartVerbCollection.cs
- DataTableTypeConverter.cs
- SingleObjectCollection.cs
- OdbcFactory.cs
- OdbcFactory.cs
- OLEDB_Enum.cs
- Logging.cs
- FixUpCollection.cs
- X509SecurityToken.cs
- CategoryNameCollection.cs
- Mutex.cs
- LeafCellTreeNode.cs
- SuppressIldasmAttribute.cs
- SQLCharsStorage.cs
- Stack.cs
- CodeGotoStatement.cs
- PackageStore.cs
- PageScaling.cs
- SaveFileDialogDesigner.cs
- TextSpanModifier.cs
- Wizard.cs
- TakeQueryOptionExpression.cs
- tibetanshape.cs
- ItemCheckedEvent.cs
- TextParaClient.cs
- UnsafeNativeMethods.cs
- DataGridItemEventArgs.cs
- EmbeddedMailObject.cs
- UnsafeNativeMethods.cs
- RegexInterpreter.cs
- ToolStripItemBehavior.cs
- ToolStrip.cs
- XsltArgumentList.cs
- StickyNoteContentControl.cs
- CounterNameConverter.cs
- MD5CryptoServiceProvider.cs
- PageContentAsyncResult.cs
- COM2IVsPerPropertyBrowsingHandler.cs
- Literal.cs
- RelationshipEndCollection.cs
- HttpApplication.cs
- TrackBarRenderer.cs
- AsynchronousChannel.cs
- exports.cs