Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Shared / MS / Win32 / SafeSystemMetrics.cs / 1305600 / 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.Interop; 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(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(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(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(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(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(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(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.Interop; 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(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(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(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(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(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(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(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
- SqlDependencyUtils.cs
- MetadataAssemblyHelper.cs
- WebPartUtil.cs
- FaultPropagationQuery.cs
- WebServiceMethodData.cs
- SafeCancelMibChangeNotify.cs
- PermissionSet.cs
- CompilerInfo.cs
- StylesEditorDialog.cs
- WindowInteropHelper.cs
- TitleStyle.cs
- XmlNodeList.cs
- ToolStripRenderEventArgs.cs
- FieldAccessException.cs
- LinqToSqlWrapper.cs
- AtomParser.cs
- TimeoutValidationAttribute.cs
- DllNotFoundException.cs
- DateTimePicker.cs
- XPathException.cs
- Quaternion.cs
- HttpModulesSection.cs
- StatusCommandUI.cs
- DeclarativeCatalogPart.cs
- WFItemsToSpacerVisibility.cs
- ItemsPanelTemplate.cs
- StateItem.cs
- DecoratedNameAttribute.cs
- ClientTarget.cs
- UTF32Encoding.cs
- CqlParserHelpers.cs
- CounterSetInstance.cs
- SQLBytesStorage.cs
- printdlgexmarshaler.cs
- ContourSegment.cs
- DoubleAnimationUsingPath.cs
- ScriptResourceHandler.cs
- ControlParameter.cs
- TemplateXamlTreeBuilder.cs
- OracleDateTime.cs
- TableLayoutPanelResizeGlyph.cs
- GenericQueueSurrogate.cs
- BufferedGraphicsManager.cs
- WrapperSecurityCommunicationObject.cs
- CollectionViewGroup.cs
- HGlobalSafeHandle.cs
- XmlSchemaObject.cs
- transactioncontext.cs
- ClockController.cs
- UidPropertyAttribute.cs
- _NTAuthentication.cs
- SQLInt64Storage.cs
- Model3DGroup.cs
- SpeechRecognizer.cs
- TraceUtility.cs
- mongolianshape.cs
- DocumentSequenceHighlightLayer.cs
- DiscoveryDocumentSearchPattern.cs
- CreateUserWizardStep.cs
- Random.cs
- DateTimeOffset.cs
- HotSpotCollection.cs
- transactioncontext.cs
- HandlerBase.cs
- FtpCachePolicyElement.cs
- ArrayWithOffset.cs
- UserPreferenceChangedEventArgs.cs
- SchemaCollectionPreprocessor.cs
- DeclarativeCatalogPart.cs
- FormattedTextSymbols.cs
- ChangesetResponse.cs
- RadioButtonPopupAdapter.cs
- ObservableCollection.cs
- HostedHttpRequestAsyncResult.cs
- PeerValidationBehavior.cs
- formatter.cs
- MsmqProcessProtocolHandler.cs
- MethodImplAttribute.cs
- CharUnicodeInfo.cs
- TemplateParser.cs
- SiteIdentityPermission.cs
- SignatureHelper.cs
- SqlVisitor.cs
- _SafeNetHandles.cs
- WebPartChrome.cs
- XmlEncoding.cs
- DifferencingCollection.cs
- FormattedTextSymbols.cs
- HistoryEventArgs.cs
- WebPartRestoreVerb.cs
- WpfPayload.cs
- UseLicense.cs
- XmlSiteMapProvider.cs
- SynchronousChannelMergeEnumerator.cs
- MimeFormReflector.cs
- PersistChildrenAttribute.cs
- MessageDirection.cs
- DeclarativeExpressionConditionDeclaration.cs
- XmlNullResolver.cs
- VersionedStreamOwner.cs