Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Runtime / InteropServices / RuntimeEnvironment.cs / 1305376 / RuntimeEnvironment.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================================== ** ** Class: RuntimeEnvironment ** ** ** Purpose: Runtime information ** ** =============================================================================*/ using System; using System.Text; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using System.Reflection; using Microsoft.Win32; using System.Runtime.Versioning; using StackCrawlMark = System.Threading.StackCrawlMark; namespace System.Runtime.InteropServices { [System.Runtime.InteropServices.ComVisible(true)] #if FEATURE_CORECLR static #endif public class RuntimeEnvironment { #if !FEATURE_CORECLR // This should have been a static class, but wasn't as of v3.5. Clearly, this is // broken. We'll keep this in V4 for binary compat, but marked obsolete as error // so migrated source code gets fixed. On Silverlight, this type exists but is // not public. [Obsolete("Do not create instances of the RuntimeEnvironment class. Call the static methods directly on this type instead", true)] public RuntimeEnvironment() { // Should not have been instantiable - here for binary compatibility in V4. } #endif [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern String GetModuleFileName(); [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern String GetDeveloperPath(); [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern String GetHostBindingFile(); #if !FEATURE_CORECLR [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.None)] [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] [SuppressUnmanagedCodeSecurity] internal static extern void _GetSystemVersion(StringHandleOnStack retVer); #endif //!FEATURE_CORECLR public static bool FromGlobalAccessCache(Assembly a) { return a.GlobalAssemblyCache; } [System.Security.SecuritySafeCritical] // public member [MethodImpl (MethodImplOptions.NoInlining)] public static String GetSystemVersion() { #if FEATURE_CORECLR return Assembly.GetExecutingAssembly().ImageRuntimeVersion; #else // FEATURE_CORECLR String ver = null; _GetSystemVersion(JitHelpers.GetStringHandleOnStack(ref ver)); return ver; #endif // FEATURE_CORECLR } [System.Security.SecuritySafeCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] public static String GetRuntimeDirectory() { String dir = GetRuntimeDirectoryImpl(); new FileIOPermission(FileIOPermissionAccess.PathDiscovery, dir).Demand(); return dir; } [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern String GetRuntimeDirectoryImpl(); // Returns the system ConfigurationFile public static String SystemConfigurationFile { [System.Security.SecuritySafeCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] get { StringBuilder sb = new StringBuilder(Path.MAX_PATH); sb.Append(GetRuntimeDirectory()); sb.Append(AppDomainSetup.RuntimeConfigurationFile); String path = sb.ToString(); // Do security check new FileIOPermission(FileIOPermissionAccess.PathDiscovery, path).Demand(); return path; } } #if FEATURE_COMINTEROP [System.Security.SecurityCritical] [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Process)] [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] [SuppressUnmanagedCodeSecurity] private static extern IntPtr GetRuntimeInterfaceImpl( [In, MarshalAs(UnmanagedType.LPStruct)] Guid clsid, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); // // This function does the equivalent of calling GetInterface(clsid, riid) on the // ICLRRuntimeInfo representing this runtime. See MetaHost.idl for a list of // CLSIDs and IIDs supported by this method. // // Returns unmanaged pointer to requested interface on success. Throws // COMException with failed HR if there is a QI failure. // [System.Security.SecurityCritical] // do not allow partial trust callers [ComVisible(false)] [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Process)] public static IntPtr GetRuntimeInterfaceAsIntPtr(Guid clsid, Guid riid) { return GetRuntimeInterfaceImpl(clsid, riid); } // // This function does the equivalent of calling GetInterface(clsid, riid) on the // ICLRRuntimeInfo representing this runtime. See MetaHost.idl for a list of // CLSIDs and IIDs supported by this method. // // Returns an RCW to requested interface on success. Throws // COMException with failed HR if there is a QI failure. // [System.Security.SecurityCritical] // do not allow partial trust callers [ComVisible(false)] [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Process)] public static object GetRuntimeInterfaceAsObject(Guid clsid, Guid riid) { IntPtr p = IntPtr.Zero; try { p = GetRuntimeInterfaceImpl(clsid, riid); return Marshal.GetObjectForIUnknown(p); } finally { if(p != IntPtr.Zero) { Marshal.Release(p); } } } #endif // FEATURE_COMINTEROP } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================================== ** ** Class: RuntimeEnvironment ** ** ** Purpose: Runtime information ** ** =============================================================================*/ using System; using System.Text; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using System.Reflection; using Microsoft.Win32; using System.Runtime.Versioning; using StackCrawlMark = System.Threading.StackCrawlMark; namespace System.Runtime.InteropServices { [System.Runtime.InteropServices.ComVisible(true)] #if FEATURE_CORECLR static #endif public class RuntimeEnvironment { #if !FEATURE_CORECLR // This should have been a static class, but wasn't as of v3.5. Clearly, this is // broken. We'll keep this in V4 for binary compat, but marked obsolete as error // so migrated source code gets fixed. On Silverlight, this type exists but is // not public. [Obsolete("Do not create instances of the RuntimeEnvironment class. Call the static methods directly on this type instead", true)] public RuntimeEnvironment() { // Should not have been instantiable - here for binary compatibility in V4. } #endif [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern String GetModuleFileName(); [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern String GetDeveloperPath(); [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern String GetHostBindingFile(); #if !FEATURE_CORECLR [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.None)] [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] [SuppressUnmanagedCodeSecurity] internal static extern void _GetSystemVersion(StringHandleOnStack retVer); #endif //!FEATURE_CORECLR public static bool FromGlobalAccessCache(Assembly a) { return a.GlobalAssemblyCache; } [System.Security.SecuritySafeCritical] // public member [MethodImpl (MethodImplOptions.NoInlining)] public static String GetSystemVersion() { #if FEATURE_CORECLR return Assembly.GetExecutingAssembly().ImageRuntimeVersion; #else // FEATURE_CORECLR String ver = null; _GetSystemVersion(JitHelpers.GetStringHandleOnStack(ref ver)); return ver; #endif // FEATURE_CORECLR } [System.Security.SecuritySafeCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] public static String GetRuntimeDirectory() { String dir = GetRuntimeDirectoryImpl(); new FileIOPermission(FileIOPermissionAccess.PathDiscovery, dir).Demand(); return dir; } [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern String GetRuntimeDirectoryImpl(); // Returns the system ConfigurationFile public static String SystemConfigurationFile { [System.Security.SecuritySafeCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] get { StringBuilder sb = new StringBuilder(Path.MAX_PATH); sb.Append(GetRuntimeDirectory()); sb.Append(AppDomainSetup.RuntimeConfigurationFile); String path = sb.ToString(); // Do security check new FileIOPermission(FileIOPermissionAccess.PathDiscovery, path).Demand(); return path; } } #if FEATURE_COMINTEROP [System.Security.SecurityCritical] [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Process)] [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] [SuppressUnmanagedCodeSecurity] private static extern IntPtr GetRuntimeInterfaceImpl( [In, MarshalAs(UnmanagedType.LPStruct)] Guid clsid, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); // // This function does the equivalent of calling GetInterface(clsid, riid) on the // ICLRRuntimeInfo representing this runtime. See MetaHost.idl for a list of // CLSIDs and IIDs supported by this method. // // Returns unmanaged pointer to requested interface on success. Throws // COMException with failed HR if there is a QI failure. // [System.Security.SecurityCritical] // do not allow partial trust callers [ComVisible(false)] [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Process)] public static IntPtr GetRuntimeInterfaceAsIntPtr(Guid clsid, Guid riid) { return GetRuntimeInterfaceImpl(clsid, riid); } // // This function does the equivalent of calling GetInterface(clsid, riid) on the // ICLRRuntimeInfo representing this runtime. See MetaHost.idl for a list of // CLSIDs and IIDs supported by this method. // // Returns an RCW to requested interface on success. Throws // COMException with failed HR if there is a QI failure. // [System.Security.SecurityCritical] // do not allow partial trust callers [ComVisible(false)] [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Process)] public static object GetRuntimeInterfaceAsObject(Guid clsid, Guid riid) { IntPtr p = IntPtr.Zero; try { p = GetRuntimeInterfaceImpl(clsid, riid); return Marshal.GetObjectForIUnknown(p); } finally { if(p != IntPtr.Zero) { Marshal.Release(p); } } } #endif // FEATURE_COMINTEROP } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TreeNodeEventArgs.cs
- CodeMemberField.cs
- InsufficientMemoryException.cs
- TemplateControlCodeDomTreeGenerator.cs
- Win32Exception.cs
- TypeDelegator.cs
- SqlConnectionPoolGroupProviderInfo.cs
- Int32.cs
- ThreadNeutralSemaphore.cs
- SecuritySessionClientSettings.cs
- RelOps.cs
- View.cs
- Image.cs
- TreeNodeStyleCollection.cs
- HttpServerUtilityWrapper.cs
- CodeDomSerializer.cs
- DiscoveryUtility.cs
- AsyncStreamReader.cs
- Int32AnimationUsingKeyFrames.cs
- ModelVisual3D.cs
- CompatibleComparer.cs
- ActivityExecutionFilter.cs
- XamlDesignerSerializationManager.cs
- SatelliteContractVersionAttribute.cs
- ModelUIElement3D.cs
- XmlUrlResolver.cs
- XmlQuerySequence.cs
- QilStrConcat.cs
- BuildResultCache.cs
- AppDomainEvidenceFactory.cs
- BaseCodeDomTreeGenerator.cs
- CalendarDayButton.cs
- HttpBrowserCapabilitiesWrapper.cs
- MimeTypeAttribute.cs
- ToolStripSplitStackLayout.cs
- XsltException.cs
- DataSpaceManager.cs
- FormViewModeEventArgs.cs
- StdValidatorsAndConverters.cs
- RedirectionProxy.cs
- InternalPermissions.cs
- OdbcEnvironment.cs
- DLinqAssociationProvider.cs
- MetadataException.cs
- CompiledQuery.cs
- PrimarySelectionAdorner.cs
- oledbmetadatacolumnnames.cs
- StandardOleMarshalObject.cs
- HelpExampleGenerator.cs
- HttpConfigurationSystem.cs
- XmlCharacterData.cs
- LogWriteRestartAreaAsyncResult.cs
- MarkupCompiler.cs
- MatchAllMessageFilter.cs
- TextWriterTraceListener.cs
- Bitmap.cs
- PointConverter.cs
- ConnectionPoint.cs
- ClientSession.cs
- SecurityRuntime.cs
- ViewStateException.cs
- DebugView.cs
- Int32Converter.cs
- XmlBinaryReader.cs
- MenuCommand.cs
- AsymmetricKeyExchangeFormatter.cs
- Qualifier.cs
- SplitterEvent.cs
- ServiceMetadataContractBehavior.cs
- PasswordPropertyTextAttribute.cs
- OverrideMode.cs
- ActivationServices.cs
- Composition.cs
- ContextDataSource.cs
- BuildProviderAppliesToAttribute.cs
- XmlMembersMapping.cs
- Point3DCollection.cs
- ApplicationManager.cs
- ImageSource.cs
- HttpPostedFileWrapper.cs
- ToolboxDataAttribute.cs
- CrossSiteScriptingValidation.cs
- X500Name.cs
- WebDisplayNameAttribute.cs
- LingerOption.cs
- NeedSkipTokenVisitor.cs
- SmtpFailedRecipientsException.cs
- PeerCollaboration.cs
- DocumentOrderQuery.cs
- WrappedKeySecurityToken.cs
- HtmlInputHidden.cs
- EventPropertyMap.cs
- XmlWrappingReader.cs
- PolicyException.cs
- UpdateProgress.cs
- WebPartConnectionsDisconnectVerb.cs
- ConfigurationElementProperty.cs
- EntryIndex.cs
- RuntimeHandles.cs
- PasswordRecovery.cs