Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Shared / MS / Win32 / SafeSystemMetrics.cs / 1 / SafeSystemMetrics.cs
//------------------------------------------------------------------------------
// Microsoft Avalon
// Copyright (c) Microsoft Corporation, 2004
//
// File: SafeSystemMetrics.cs
// This class is copied from the system metrics class in frameworks. The
// reason it exists is to consolidate all system metric calls through one layer
// so that maintenance from a security stand point gets easier. We will add
// mertrics on a need basis. The caching code is removed since the original calls
// that were moved here do not rely on caching. If there is a percieved perf. problem
// we can work on enabling this.
//-----------------------------------------------------------------------------
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Windows.Media;
using Microsoft.Win32;
using System.Security;
using System.Security.Permissions;
using MS.Win32;
using MS.Internal;
using MS.Internal.PresentationCore;
namespace MS.Win32
{
///
/// Contains properties that are queries into the system's various settings.
///
[FriendAccessAllowed] // Built into Core, also used by Framework.
internal sealed class SafeSystemMetrics
{
private SafeSystemMetrics()
{
}
#if !PRESENTATION_CORE
///
/// Maps to SM_CXVIRTUALSCREEN
///
///
/// TreatAsSafe --There exists a demand
/// Security Critical -- Calling UnsafeNativeMethods
///
internal static int VirtualScreenWidth
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
SecurityHelper.DemandUnmanagedCode();
return UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CXVIRTUALSCREEN);
}
}
///
/// Maps to SM_CYVIRTUALSCREEN
///
///
/// TreatAsSafe --There exists a demand
/// Security Critical -- Calling UnsafeNativeMethods
///
internal static int VirtualScreenHeight
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
SecurityHelper.DemandUnmanagedCode();
return UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CYVIRTUALSCREEN);
}
}
#endif //end !PRESENTATIONCORE
///
/// Maps to SM_CXDOUBLECLK
///
///
/// TreatAsSafe --This data is safe to expose
/// Security Critical -- Calling UnsafeNativeMethods
///
internal static int DoubleClickDeltaX
{
[SecurityCritical, SecurityTreatAsSafe]
get
{
return UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CXDOUBLECLK);
}
}
///
/// Maps to SM_CYDOUBLECLK
///
///
/// TreatAsSafe --This data is safe to expose
/// Security Critical -- Calling UnsafeNativeMethods
///
internal static int DoubleClickDeltaY
{
[SecurityCritical, SecurityTreatAsSafe]
get
{
return UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CYDOUBLECLK);
}
}
///
/// Maps to SM_CXDRAG
///
///
/// TreatAsSafe --This data is safe to expose
/// Security Critical -- Calling UnsafeNativeMethods
///
internal static int DragDeltaX
{
[SecurityCritical, SecurityTreatAsSafe]
get
{
return UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CXDRAG);
}
}
///
/// Maps to SM_CYDRAG
///
///
/// TreatAsSafe --This data is safe to expose
/// Security Critical -- Calling UnsafeNativeMethods
///
internal static int DragDeltaY
{
[SecurityCritical, SecurityTreatAsSafe]
get
{
return UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CYDRAG);
}
}
///
/// Is an IMM enabled ? Maps to SM_IMMENABLED
///
///
///Critical - calls a method that performs an elevation.
/// TreatAsSafe - data is considered safe to expose.
///
internal static bool IsImmEnabled
{
[SecurityCritical, SecurityTreatAsSafe]
get
{
return (UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_IMMENABLED) != 0);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
// Microsoft Avalon
// Copyright (c) Microsoft Corporation, 2004
//
// File: SafeSystemMetrics.cs
// This class is copied from the system metrics class in frameworks. The
// reason it exists is to consolidate all system metric calls through one layer
// so that maintenance from a security stand point gets easier. We will add
// mertrics on a need basis. The caching code is removed since the original calls
// that were moved here do not rely on caching. If there is a percieved perf. problem
// we can work on enabling this.
//-----------------------------------------------------------------------------
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Windows.Media;
using Microsoft.Win32;
using System.Security;
using System.Security.Permissions;
using MS.Win32;
using MS.Internal;
using MS.Internal.PresentationCore;
namespace MS.Win32
{
///
/// Contains properties that are queries into the system's various settings.
///
[FriendAccessAllowed] // Built into Core, also used by Framework.
internal sealed class SafeSystemMetrics
{
private SafeSystemMetrics()
{
}
#if !PRESENTATION_CORE
///
/// Maps to SM_CXVIRTUALSCREEN
///
///
/// TreatAsSafe --There exists a demand
/// Security Critical -- Calling UnsafeNativeMethods
///
internal static int VirtualScreenWidth
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
SecurityHelper.DemandUnmanagedCode();
return UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CXVIRTUALSCREEN);
}
}
///
/// Maps to SM_CYVIRTUALSCREEN
///
///
/// TreatAsSafe --There exists a demand
/// Security Critical -- Calling UnsafeNativeMethods
///
internal static int VirtualScreenHeight
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
SecurityHelper.DemandUnmanagedCode();
return UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CYVIRTUALSCREEN);
}
}
#endif //end !PRESENTATIONCORE
///
/// Maps to SM_CXDOUBLECLK
///
///
/// TreatAsSafe --This data is safe to expose
/// Security Critical -- Calling UnsafeNativeMethods
///
internal static int DoubleClickDeltaX
{
[SecurityCritical, SecurityTreatAsSafe]
get
{
return UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CXDOUBLECLK);
}
}
///
/// Maps to SM_CYDOUBLECLK
///
///
/// TreatAsSafe --This data is safe to expose
/// Security Critical -- Calling UnsafeNativeMethods
///
internal static int DoubleClickDeltaY
{
[SecurityCritical, SecurityTreatAsSafe]
get
{
return UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CYDOUBLECLK);
}
}
///
/// Maps to SM_CXDRAG
///
///
/// TreatAsSafe --This data is safe to expose
/// Security Critical -- Calling UnsafeNativeMethods
///
internal static int DragDeltaX
{
[SecurityCritical, SecurityTreatAsSafe]
get
{
return UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CXDRAG);
}
}
///
/// Maps to SM_CYDRAG
///
///
/// TreatAsSafe --This data is safe to expose
/// Security Critical -- Calling UnsafeNativeMethods
///
internal static int DragDeltaY
{
[SecurityCritical, SecurityTreatAsSafe]
get
{
return UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_CYDRAG);
}
}
///
/// Is an IMM enabled ? Maps to SM_IMMENABLED
///
///
///Critical - calls a method that performs an elevation.
/// TreatAsSafe - data is considered safe to expose.
///
internal static bool IsImmEnabled
{
[SecurityCritical, SecurityTreatAsSafe]
get
{
return (UnsafeNativeMethods.GetSystemMetrics(NativeMethods.SM_IMMENABLED) != 0);
}
}
}
}
// 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
- AuthorizationSection.cs
- OneOfScalarConst.cs
- XmlEncodedRawTextWriter.cs
- SqlComparer.cs
- MetadataException.cs
- ToolStripItemBehavior.cs
- ItemsPanelTemplate.cs
- FileUtil.cs
- SiteMapDataSource.cs
- CodeObject.cs
- Quad.cs
- StateBag.cs
- TrackingStringDictionary.cs
- Size3D.cs
- BufferedConnection.cs
- SemanticResultValue.cs
- SystemBrushes.cs
- EndpointAddressAugust2004.cs
- Thread.cs
- WindowsToolbar.cs
- PanelDesigner.cs
- XmlText.cs
- CodeCompiler.cs
- ViewManager.cs
- WindowsEditBox.cs
- OrderedParallelQuery.cs
- ToolStripItemTextRenderEventArgs.cs
- ObjectContext.cs
- SiteMap.cs
- SmiEventSink.cs
- ColumnMapProcessor.cs
- UnsafeNativeMethodsMilCoreApi.cs
- TreeNodeStyle.cs
- ThemeableAttribute.cs
- Deflater.cs
- RectangleF.cs
- DLinqAssociationProvider.cs
- KeyFrames.cs
- DomNameTable.cs
- MetadataSerializer.cs
- UnicodeEncoding.cs
- XmlParserContext.cs
- Vector3D.cs
- NavigationPropertyEmitter.cs
- RadioButtonDesigner.cs
- NTAccount.cs
- Point.cs
- EastAsianLunisolarCalendar.cs
- ManagedIStream.cs
- connectionpool.cs
- DataGridColumnCollection.cs
- URI.cs
- CompiledAction.cs
- OledbConnectionStringbuilder.cs
- SiteMapNodeItem.cs
- ActivationServices.cs
- XmlSchemaComplexType.cs
- RegionData.cs
- XmlSchemaImport.cs
- StartUpEventArgs.cs
- SHA256Managed.cs
- SqlException.cs
- IsolatedStorage.cs
- HyperLinkStyle.cs
- GridErrorDlg.cs
- RuleInfoComparer.cs
- AffineTransform3D.cs
- ScrollItemPattern.cs
- BreakRecordTable.cs
- WindowsPrincipal.cs
- KeyPressEvent.cs
- OdbcConnectionString.cs
- OracleConnectionFactory.cs
- UnsafeNativeMethods.cs
- ControllableStoryboardAction.cs
- ListBoxItemAutomationPeer.cs
- OutputCacheModule.cs
- Main.cs
- StringCollection.cs
- ContainerAction.cs
- XmlNavigatorStack.cs
- EntityModelSchemaGenerator.cs
- AccessibleObject.cs
- Error.cs
- ResourceDescriptionAttribute.cs
- XmlSchemaInclude.cs
- WpfGeneratedKnownProperties.cs
- ReachSerializableProperties.cs
- CloseSequenceResponse.cs
- XmlNodeComparer.cs
- XDRSchema.cs
- MessageBox.cs
- initElementDictionary.cs
- UpdateException.cs
- SecurityKeyType.cs
- StagingAreaInputItem.cs
- CriticalFileToken.cs
- SimpleWorkerRequest.cs
- TextDecorationCollection.cs
- ListViewGroupConverter.cs