Download Cs-71 Solved Assignment 1423

//------------------------------------------------------------------------------// <copyright file="Process.cs" company="Microsoft">// Copyright (c) Microsoft Corporation. All rights reserved.// </copyright> //------------------------------------------------------------------------------namespace System.Diagnostics { using System.Text; using System.Threading; using System.Runtime.InteropServices; using System.ComponentModel; using System.ComponentModel.Design; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using System.Diagnostics; using System; using System.Collections; using System.IO; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; using System.Collections.Specialized; using System.Globalization; using System.Security; using System.Security.Permissions; using System.Security.Principal; using System.Runtime.Versioning; ///<devdoc>///<para>/// Provides access to local and remote/// processes. Enables you to start and stop system processes.///</para>///</devdoc> [ MonitoringDescription(SR.ProcessDesc), DefaultEvent("Exited"), DefaultProperty("StartInfo"), Designer("System.Diagnostics.Design.ProcessDesigner, " + AssemblyRef.SystemDesign), // Disabling partial trust scenariosPermissionSet(SecurityAction.LinkDemand, Name="FullTrust"), PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust"), HostProtection(SharedState=true, Synchronization=true, ExternalProcessMgmt=true, SelfAffectingProcessMgmt=true) ] public classProcess : Component { //// FIELDS//boolhaveProcessId; intprocessId; boolhaveProcessHandle; SafeProcessHandlem_processHandle; boolisRemoteMachine; stringmachineName; ProcessInfoprocessInfo; Int32m_processAccess; #if !FEATURE_PAL ProcessThreadCollectionthreads; ProcessModuleCollectionmodules; #endif// !FEATURE_PAL boolhaveMainWindow; IntPtrmainWindowHandle; // no need to use SafeHandle for window stringmainWindowTitle; boolhaveWorkingSetLimits; IntPtrminWorkingSet; IntPtrmaxWorkingSet; boolhaveProcessorAffinity; IntPtrprocessorAffinity; boolhavePriorityClass; ProcessPriorityClasspriorityClass; ProcessStartInfostartInfo; boolwatchForExit; boolwatchingForExit; EventHandleronExited; boolexited; intexitCode; boolsignaled; DateTimeexitTime; boolhaveExitTime; boolresponding; boolhaveResponding; boolpriorityBoostEnabled; boolhavePriorityBoostEnabled; boolraisedOnExited; RegisteredWaitHandleregisteredWaitHandle; WaitHandlewaitHandle; ISynchronizeInvokesynchronizingObject; StreamReaderstandardOutput; StreamWriterstandardInput; StreamReaderstandardError; OperatingSystemoperatingSystem; booldisposed; static objects_CreateProcessLock = newobject(); // This enum defines the operation mode for redirected process stream.// We don't support switching between synchronous mode and asynchronous mode.private enumStreamReadMode { undefined, syncMode, asyncMode } StreamReadModeoutputStreamReadMode; StreamReadModeerrorStreamReadMode; // Support for asynchrously reading streams [Browsable(true), MonitoringDescription(SR.ProcessAssociated)] //[System.Runtime.InteropServices.ComVisible(false)] public eventDataReceivedEventHandlerOutputDataReceived; [Browsable(true), MonitoringDescription(SR.ProcessAssociated)] //[System.Runtime.InteropServices.ComVisible(false)] public eventDataReceivedEventHandlerErrorDataReceived; // Abstract the stream detailsinternalAsyncStreamReaderoutput; internalAsyncStreamReadererror; internal boolpendingOutputRead; internal boolpendingErrorRead; private staticSafeFileHandleInvalidPipeHandle = newSafeFileHandle(IntPtr.Zero, false); #if DEBUG internal static TraceSwitch processTracing = new TraceSwitch("processTracing", "Controls debug output from Process component"); #elseinternal staticTraceSwitchprocessTracing = null; #endif//// CONSTRUCTORS/////<devdoc>///<para>/// Initializes a new instance of the <seecref='System.Diagnostics.Process'/> class.///</para>///</devdoc>publicProcess() { this.machineName = "."; this.outputStreamReadMode = StreamReadMode.undefined; this.errorStreamReadMode = StreamReadMode.undefined; this.m_processAccess = NativeMethods.PROCESS_ALL_ACCESS; } [ResourceExposure(ResourceScope.Machine)] Process(stringmachineName, boolisRemoteMachine, intprocessId, ProcessInfoprocessInfo) : base() { Debug.Assert(SyntaxCheck.CheckMachineName(machineName), "The machine name should be valid!"); this.processInfo = processInfo; this.machineName = machineName; this.isRemoteMachine = isRemoteMachine; this.processId = processId; this.haveProcessId = true; this.outputStreamReadMode = StreamReadMode.undefined; this.errorStreamReadMode = StreamReadMode.undefined; this.m_processAccess = NativeMethods.PROCESS_ALL_ACCESS; } //// PROPERTIES/////<devdoc>/// Returns whether this process component is associated with a real process.///</devdoc>///<internalonly/> [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessAssociated)] boolAssociated { get { returnhaveProcessId || haveProcessHandle; } } #if !FEATURE_PAL ///<devdoc>///<para>/// Gets the base priority of/// the associated process.///</para>///</devdoc> [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessBasePriority)] public intBasePriority { get { EnsureState(State.HaveProcessInfo); returnprocessInfo.basePriority; } } #endif// FEATURE_PAL///<devdoc>///<para>/// Gets/// the/// value that was specified by the associated process when it was terminated.///</para>///</devdoc> [Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessExitCode)] public intExitCode { get { EnsureState(State.Exited); returnexitCode; } } ///<devdoc>///<para>/// Gets a/// value indicating whether the associated process has been terminated.///</para>///</devdoc> [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessTerminated)] public boolHasExited { get { if (!exited) { EnsureState(State.Associated); SafeProcessHandlehandle = null; try { handle = GetProcessHandle(NativeMethods.PROCESS_QUERY_INFORMATION | NativeMethods.SYNCHRONIZE, false); if (handle.IsInvalid) { exited = true; } else { intexitCode; // Although this is the wrong way to check whether the process has exited,// it was historically the way we checked for it, and a lot of code then took a dependency on// the fact that this would always be set before the pipes were closed, so they would read// the exit code out after calling ReadToEnd() or standard output or standard error. In order// to allow 259 to function as a valid exit code and to break as few people as possible that// took the ReadToEnd dependency, we check for an exit code before doing the more correct// check to see if we have been signalled.if (NativeMethods.GetExitCodeProcess(handle, outexitCode) && exitCode != NativeMethods.STILL_ACTIVE) { this.exited = true; this.exitCode = exitCode; } else { // The best check for exit is that the kernel process object handle is invalid, // or that it is valid and signaled. Checking if the exit code != STILL_ACTIVE // does not guarantee the process is closed,// since some process could return an actual STILL_ACTIVE exit code (259).if (!signaled) // if we just came from WaitForExit, don't repeat { ProcessWaitHandlewh = null; try { wh = newProcessWaitHandle(handle); this.signaled = wh.WaitOne(0, false); } finally { if (wh != null) wh.Close(); } } if (signaled) { if (!NativeMethods.GetExitCodeProcess(handle, outexitCode)) thrownewWin32Exception(); this.exited = true; this.exitCode = exitCode; } } } } finally { ReleaseProcessHandle(handle); } if (exited) { RaiseOnExited(); } } returnexited; } } privateProcessThreadTimesGetProcessTimes() { ProcessThreadTimesprocessTimes = newProcessThreadTimes(); SafeProcessHandlehandle = null; try { intaccess = NativeMethods.PROCESS_QUERY_INFORMATION; if (EnvironmentHelpers.IsWindowsVistaOrAbove()) access = NativeMethods.PROCESS_QUERY_LIMITED_INFORMATION; handle = GetProcessHandle(access, false); if( handle.IsInvalid) { // On OS older than XP, we will not be able to get the handle for a process// after it terminates. // On Windows XP and newer OS, the information about a process will stay longer. thrownewInvalidOperationException(SR.GetString(SR.ProcessHasExited, processId.ToString(CultureInfo.CurrentCulture))); } if (!NativeMethods.GetProcessTimes(handle, outprocessTimes.create, outprocessTimes.exit, outprocessTimes.kernel, outprocessTimes.user)) { thrownewWin32Exception(); } } finally { ReleaseProcessHandle(handle); } returnprocessTimes; } #if !FEATURE_PAL ///<devdoc>///<para>/// Gets the time that the associated process exited.///</para>///</devdoc> [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessExitTime)] publicDateTimeExitTime { get { if (!haveExitTime) { EnsureState(State.IsNt | State.Exited); exitTime = GetProcessTimes().ExitTime; haveExitTime = true; } returnexitTime; } } #endif// !FEATURE_PAL///<devdoc>///<para>/// Returns the native handle for the associated process. The handle is only available/// if this component started the process.///</para>///</devdoc> [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessHandle)] publicIntPtrHandle { [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] get { EnsureState(State.Associated); returnOpenProcessHandle(this.m_processAccess).DangerousGetHandle(); } } [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] publicSafeProcessHandleSafeHandle { get { EnsureState(State.Associated); returnOpenProcessHandle(this.m_processAccess); } } #if !FEATURE_PAL ///<devdoc>///<para>/// Gets the number of handles that are associated/// with the process.///</para>///</devdoc> [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessHandleCount)] public intHandleCount { get { EnsureState(State.HaveProcessInfo); returnprocessInfo.handleCount; } } #endif// !FEATURE_PAL///<devdoc>///<para>/// Gets/// the unique identifier for the associated process.///</para>///</devdoc> [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessId)] public intId { get { EnsureState(State.HaveId); returnprocessId; } } ///<devdoc>///<para>/// Gets/// the name of the computer on which the associated process is running.///</para>///</devdoc> [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessMachineName)] public stringMachineName { get { EnsureState(State.Associated); returnmachineName; } } #if !FEATURE_PAL ///<devdoc>///<para>/// Returns the window handle of the main window of the associated process.///</para>///</devdoc> [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessMainWindowHandle)] publicIntPtrMainWindowHandle { [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] get { if (!haveMainWindow) { EnsureState(State.IsLocal | State.HaveId); mainWindowHandle = ProcessManager.GetMainWindowHandle(processId); if (mainWindowHandle != (IntPtr)0) { haveMainWindow = true; } else { // We do the following only for the side-effect that it will throw when if the process no longer exists on the system. In Whidbey// we always did this check but have now changed it to just require a ProcessId. In the case where someone has called Refresh() // and the process has exited this call will throw an exception where as the above code would return 0 as the handle.EnsureState(State.HaveProcessInfo); } } returnmainWindowHandle; } } ///<devdoc>///<para>/// Returns the caption of the <seecref='System.Diagnostics.Process.MainWindowHandle'/> of/// the process. If the handle is zero (0), then an empty string is returned.///</para>///</devdoc> [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessMainWindowTitle)] public stringMainWindowTitle { [ResourceExposure(ResourceScope.None)] [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] get { if (mainWindowTitle == null) { IntPtrhandle = MainWindowHandle; if (handle == (IntPtr)0) { mainWindowTitle = String.Empty; } else { intlength = NativeMethods.GetWindowTextLength(newHandleRef(this, handle)) * 2; StringBuilderbuilder = newStringBuilder(length); NativeMethods.GetWindowText(newHandleRef(this, handle), builder, builder.Capacity); mainWindowTitle = builder.ToString(); } } returnmainWindowTitle; } } ///<devdoc>///<para>/// Gets/// the main module for the associated process.///</para>///</devdoc> [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessMainModule)] publicProcessModuleMainModule { [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] get { // We only return null if we couldn't find a main module.// This could be because// 1. The process hasn't finished loading the main module (most likely)// 2. There are no modules loaded (possible for certain OS processes)// 3. Possibly other?if (OperatingSystem.Platform == PlatformID.Win32NT) { EnsureState(State.HaveId | State.IsLocal); // on NT the first module is the main module ModuleInfomodule = NtProcessManager.GetFirstModuleInfo(processId); returnnewProcessModule(module); } else { ProcessModuleCollectionmoduleCollection = Modules; // on 9x we have to do a little more workEnsureState(State.HaveProcessInfo); foreach (ProcessModulepminmoduleCollection) { if (pm.moduleInfo.Id == processInfo.mainModuleId) { returnpm; } } return null; } } } ///<devdoc>///<para>/// Gets or sets the maximum allowable working set for the associated/// process.///</para>///</devdoc> [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessMaxWorkingSet)] publicIntPtrMaxWorkingSet { get { EnsureWorkingSetLimits(); returnmaxWorkingSet; } [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Process)] set { SetWorkingSetLimits(null, value); } } ///<devdoc>///<para>/// Gets or sets the minimum allowable working set for the associated/// process.///</para>///</devdoc> [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessMinWorkingSet)] publicIntPtrMinWorkingSet { get { EnsureWorkingSetLimits(); returnminWorkingSet; } [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Process)] set { SetWorkingSetLimits(value, null); } } ///<devdoc>///<para>/// Gets/// the modules that have been loaded by the associated process.///</para>///</devdoc> [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessModules)] publicProcessModuleCollectionModules { [ResourceExposure(ResourceScope.None)] [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] get { if (modules == null) { EnsureState(State.HaveId | State.IsLocal); ModuleInfo[] moduleInfos = ProcessManager.GetModuleInfos(processId); ProcessModule[] newModulesArray = newProcessModule[moduleInfos.Length]; for (inti = 0; i < moduleInfos.Length; i++) { newModulesArray[i] = newProcessModule(moduleInfos[i]); } ProcessModuleCollectionnewModules = newProcessModuleCollection(newModulesArray); modules = newModules; } returnmodules; } } ///<devdoc>/// Returns the amount of memory that the system has allocated on behalf of the/// associated process that can not be written to the virtual memory paging file.///</devdoc> [Obsolete("This property has been deprecated. Please use System.Diagnostics.Process.NonpagedSystemMemorySize64 instead. http://go.microsoft.com/fwlink/?linkid=14202")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessNonpagedSystemMemorySize)] public intNonpagedSystemMemorySize { get { EnsureState(State.HaveNtProcessInfo); return unchecked((int)processInfo.poolNonpagedBytes); } } [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessNonpagedSystemMemorySize)] [System.Runtime.InteropServices.ComVisible(false)] public longNonpagedSystemMemorySize64 { get { EnsureState(State.HaveNtProcessInfo); returnprocessInfo.poolNonpagedBytes; } } ///<devdoc>/// Returns the amount of memory that the associated process has allocated/// that can be written to the virtual memory paging file.///</devdoc> [Obsolete("This property has been deprecated. Please use System.Diagnostics.Process.PagedMemorySize64 instead. http://go.microsoft.com/fwlink/?linkid=14202")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessPagedMemorySize)] public intPagedMemorySize { get { EnsureState(State.HaveNtProcessInfo); return unchecked((int)processInfo.pageFileBytes); } } [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessPagedMemorySize)] [System.Runtime.InteropServices.ComVisible(false)] public longPagedMemorySize64 { get { EnsureState(State.HaveNtProcessInfo); returnprocessInfo.pageFileBytes; } } ///<devdoc>/// Returns the amount of memory that the system has allocated on behalf of the/// associated process that can be written to the virtual memory paging file.///</devdoc> [Obsolete("This property has been deprecated. Please use System.Diagnostics.Process.PagedSystemMemorySize64 instead. http://go.microsoft.com/fwlink/?linkid=14202")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessPagedSystemMemorySize)] public intPagedSystemMemorySize { get { EnsureState(State.HaveNtProcessInfo); return unchecked((int)processInfo.poolPagedBytes); } } [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessPagedSystemMemorySize)] [System.Runtime.InteropServices.ComVisible(false)] public longPagedSystemMemorySize64 { get { EnsureState(State.HaveNtProcessInfo); returnprocessInfo.poolPagedBytes; } } ///<devdoc>///<para>/// Returns the maximum amount of memory that the associated process has/// allocated that could be written to the virtual memory paging file.///</para>///</devdoc> [Obsolete("This property has been deprecated. Please use System.Diagnostics.Process.PeakPagedMemorySize64 instead. http://go.microsoft.com/fwlink/?linkid=14202")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessPeakPagedMemorySize)] public intPeakPagedMemorySize { get { EnsureState(State.HaveNtProcessInfo); return unchecked((int)processInfo.pageFileBytesPeak); } } [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessPeakPagedMemorySize)] [System.Runtime.InteropServices.ComVisible(false)] public longPeakPagedMemorySize64 { get { EnsureState(State.HaveNtProcessInfo); returnprocessInfo.pageFileBytesPeak; } } ///<devdoc>///<para>/// Returns the maximum amount of physical memory that the associated/// process required at once.///</para>///</devdoc> [Obsolete("This property has been deprecated. Please use System.Diagnostics.Process.PeakWorkingSet64 instead. http://go.microsoft.com/fwlink/?linkid=14202")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessPeakWorkingSet)] public intPeakWorkingSet { get { EnsureState(State.HaveNtProcessInfo); return unchecked((int)processInfo.workingSetPeak); } } [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessPeakWorkingSet)] [System.Runtime.InteropServices.ComVisible(false)] public longPeakWorkingSet64 { get { EnsureState(State.HaveNtProcessInfo); returnprocessInfo.workingSetPeak; } } ///<devdoc>/// Returns the maximum amount of virtual memory that the associated/// process has requested.///</devdoc> [Obsolete("This property has been deprecated. Please use System.Diagnostics.Process.PeakVirtualMemorySize64 instead. http://go.microsoft.com/fwlink/?linkid=14202")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessPeakVirtualMemorySize)] public intPeakVirtualMemorySize { get { EnsureState(State.HaveNtProcessInfo); return unchecked((int)processInfo.virtualBytesPeak); } } [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessPeakVirtualMemorySize)] [System.Runtime.InteropServices.ComVisible(false)] public longPeakVirtualMemorySize64 { get { EnsureState(State.HaveNtProcessInfo); returnprocessInfo.virtualBytesPeak; } } privateOperatingSystemOperatingSystem { get { if (operatingSystem == null) { operatingSystem = Environment.OSVersion; } returnoperatingSystem; } } ///<devdoc>///<para>/// Gets or sets a value indicating whether the associated process priority/// should be temporarily boosted by the operating system when the main window/// has focus.///</para>///</devdoc> [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessPriorityBoostEnabled)] public boolPriorityBoostEnabled { get { EnsureState(State.IsNt); if (!havePriorityBoostEnabled) { SafeProcessHandlehandle = null; try { handle = GetProcessHandle(NativeMethods.PROCESS_QUERY_INFORMATION); booldisabled = false; if (!NativeMethods.GetProcessPriorityBoost(handle, outdisabled)) { thrownewWin32Exception(); } priorityBoostEnabled = !disabled; havePriorityBoostEnabled = true; } finally { ReleaseProcessHandle(handle); } } returnpriorityBoostEnabled; } set { EnsureState(State.IsNt); SafeProcessHandlehandle = null; try { handle = GetProcessHandle(NativeMethods.PROCESS_SET_INFORMATION); if (!NativeMethods.SetProcessPriorityBoost(handle, !value)) thrownewWin32Exception(); priorityBoostEnabled = value; havePriorityBoostEnabled = true; } finally { ReleaseProcessHandle(handle); } } } ///<devdoc>///<para>/// Gets or sets the overall priority category for the/// associated process.///</para>///</devdoc> [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessPriorityClass)] publicProcessPriorityClassPriorityClass { get { if (!havePriorityClass) { SafeProcessHandlehandle = null; try { handle = GetProcessHandle(NativeMethods.PROCESS_QUERY_INFORMATION); intvalue = NativeMethods.GetPriorityClass(handle); if (value == 0) { thrownewWin32Exception(); } priorityClass = (ProcessPriorityClass)value; havePriorityClass = true; } finally { ReleaseProcessHandle(handle); } } returnpriorityClass; } [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] set { if (!Enum.IsDefined(typeof(ProcessPriorityClass), value)) { thrownewInvalidEnumArgumentException("value", (int)value, typeof(ProcessPriorityClass)); } // BelowNormal and AboveNormal are only available on Win2k and greater.if (((value
// ==++==// // Copyright (c) Microsoft Corporation. All rights reserved.// // ==--==/*============================================================================= ** ** Class: AppDomainSetup ** ** <OWNER>blanders</OWNER> ** ** Purpose: Defines the settings that the loader uses to find assemblies in an ** AppDomain ** ** Date: Dec 22, 2000 ** =============================================================================*/namespace System { using System; #if FEATURE_CLICKONCE #if !FEATURE_PAL using System.Deployment.Internal.Isolation; using System.Deployment.Internal.Isolation.Manifest; using System.Runtime.Hosting; #endif#endifusing System.Runtime.CompilerServices; using System.Runtime; using System.Text; using System.Threading; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Reflection; using System.Security; using System.Security.Permissions; using System.Security.Policy; using System.Globalization; usingPath = System.IO.Path; using System.Runtime.Versioning; using System.Diagnostics.Contracts; using System.Collections; using System.Collections.Generic; [Serializable] [ClassInterface(ClassInterfaceType.None)] [System.Runtime.InteropServices.ComVisible(true)] public sealed classAppDomainSetup : IAppDomainSetup { [Serializable] internal enumLoaderInformation { // If you add a new value, add the corresponding property// to AppDomain.GetData() and SetData()'s switch statements.ApplicationBaseValue = LOADER_APPLICATION_BASE, ConfigurationFileValue = LOADER_CONFIGURATION_BASE, DynamicBaseValue = LOADER_DYNAMIC_BASE, DevPathValue = LOADER_DEVPATH, ApplicationNameValue = LOADER_APPLICATION_NAME, PrivateBinPathValue = LOADER_PRIVATE_PATH, PrivateBinPathProbeValue = LOADER_PRIVATE_BIN_PATH_PROBE, ShadowCopyDirectoriesValue = LOADER_SHADOW_COPY_DIRECTORIES, ShadowCopyFilesValue = LOADER_SHADOW_COPY_FILES, CachePathValue = LOADER_CACHE_PATH, LicenseFileValue = LOADER_LICENSE_FILE, DisallowPublisherPolicyValue = LOADER_DISALLOW_PUBLISHER_POLICY, DisallowCodeDownloadValue = LOADER_DISALLOW_CODE_DOWNLOAD, DisallowBindingRedirectsValue = LOADER_DISALLOW_BINDING_REDIRECTS, DisallowAppBaseProbingValue = LOADER_DISALLOW_APPBASE_PROBING, ConfigurationBytesValue = LOADER_CONFIGURATION_BYTES, LoaderMaximum = LOADER_MAXIMUM, } // This class has an unmanaged representation so be aware you will need to make edits in vm\object.h if you change the order// of these fields or add new ones.private string[] _Entries; privateLoaderOptimization_LoaderOptimization; #pragmawarningdisable 169 privateString_AppBase; // for compat with v1.1#pragmawarningrestore 169 [OptionalField(VersionAdded = 2)] privateAppDomainInitializer_AppDomainInitializer; [OptionalField(VersionAdded = 2)] private string[] _AppDomainInitializerArguments; #if FEATURE_CLICKONCE [OptionalField(VersionAdded = 2)] privateActivationArguments_ActivationArguments; #endif#if FEATURE_CORECLR // On the CoreCLR, this contains just the name of the permission set that we install in the new appdomain. // Not the ToXml().ToString() of an ApplicationTrust object. #endif [OptionalField(VersionAdded = 2)] private string_ApplicationTrust; [OptionalField(VersionAdded = 2)] private byte[] _ConfigurationBytes; #if FEATURE_COMINTEROP [OptionalField(VersionAdded = 3)] private bool_DisableInterfaceCache = false; #endif// FEATURE_COMINTEROP [OptionalField(VersionAdded = 4)] private string_AppDomainManagerAssembly; [OptionalField(VersionAdded = 4)] private string_AppDomainManagerType; #if FEATURE_APTCA [OptionalField(VersionAdded = 4)] private string[] _AptcaVisibleAssemblies; #endif// A collection of strings used to indicate which breaking changes shouldn't be applied// to an AppDomain. We only use the keys, the values are ignored. [OptionalField(VersionAdded = 4)] privateDictionary<string, object> _CompatFlags; [OptionalField(VersionAdded = 5)] // This was added in .NET FX v4.5privateString_TargetFrameworkName; #if !FEATURE_CORECLR [NonSerialized] internalAppDomainSortingSetupInfo_AppDomainSortingSetupInfo; #endif [OptionalField(VersionAdded = 5)] // This was added in .NET FX v4.5private bool_CheckedForTargetFrameworkName; #if FEATURE_RANDOMIZED_STRING_HASHING [OptionalField(VersionAdded = 5)] // This was added in .NET FX v4.5private bool_UseRandomizedStringHashing; #endif [SecuritySafeCritical] internalAppDomainSetup(AppDomainSetupcopy, boolcopyDomainBoundData) { string[] mine = Value; if(copy != null) { string[] other = copy.Value; intmineSize = _Entries.Length; intotherSize = other.Length; intsize = (otherSize < mineSize) ? otherSize : mineSize; for (inti = 0; i < size; i++) mine[i] = other[i]; if (size < mineSize) { // This case can happen when the copy is a deserialized version of// an AppDomainSetup object serialized by Everett.for (inti = size; i < mineSize; i++) mine[i] = null; } _LoaderOptimization = copy._LoaderOptimization; _AppDomainInitializerArguments = copy.AppDomainInitializerArguments; #if FEATURE_CLICKONCE _ActivationArguments = copy.ActivationArguments; #endif_ApplicationTrust = copy._ApplicationTrust; if (copyDomainBoundData) _AppDomainInitializer = copy.AppDomainInitializer; else_AppDomainInitializer = null; _ConfigurationBytes = copy.GetConfigurationBytes(); #if FEATURE_COMINTEROP _DisableInterfaceCache = copy._DisableInterfaceCache; #endif// FEATURE_COMINTEROP_AppDomainManagerAssembly = copy.AppDomainManagerAssembly; _AppDomainManagerType = copy.AppDomainManagerType; #if FEATURE_APTCA _AptcaVisibleAssemblies = copy.PartialTrustVisibleAssemblies; #endifif (copy._CompatFlags != null) { SetCompatibilitySwitches(copy._CompatFlags.Keys); } #if !FEATURE_CORECLR if(copy._AppDomainSortingSetupInfo != null) { _AppDomainSortingSetupInfo = newAppDomainSortingSetupInfo(copy._AppDomainSortingSetupInfo); } #endif_TargetFrameworkName = copy._TargetFrameworkName; #if FEATURE_RANDOMIZED_STRING_HASHING _UseRandomizedStringHashing = copy._UseRandomizedStringHashing; #endif } else_LoaderOptimization = LoaderOptimization.NotSpecified; } publicAppDomainSetup() { _LoaderOptimization = LoaderOptimization.NotSpecified; } #if FEATURE_CLICKONCE // Creates an AppDomainSetup object from an application identity. [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] publicAppDomainSetup (ActivationContextactivationContext) : this (newActivationArguments(activationContext)) {} [System.Security.SecuritySafeCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] publicAppDomainSetup (ActivationArgumentsactivationArguments) { if (activationArguments == null) thrownewArgumentNullException("activationArguments"); Contract.EndContractBlock(); _LoaderOptimization = LoaderOptimization.NotSpecified; ActivationArguments = activationArguments; Contract.Assert(activationArguments.ActivationContext != null, "Cannot set base directory without activation context"); stringentryPointPath = CmsUtils.GetEntryPointFullPath(activationArguments); if (!String.IsNullOrEmpty(entryPointPath)) SetupDefaults(entryPointPath); elseApplicationBase = activationArguments.ActivationContext.ApplicationDirectory; } #endif// !FEATURE_CLICKONCE#if FEATURE_CORECLR [System.Security.SecurityCritical] // auto-generated #endif [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] internal voidSetupDefaults(stringimageLocation, boolimageLocationAlreadyNormalized = false) { char[] sep = {'\\', '/'}; inti = imageLocation.LastIndexOfAny(sep); if (i == -1) { ApplicationName = imageLocation; } else { ApplicationName = imageLocation.Substring(i+1); stringappBase = imageLocation.Substring(0, i+1); if (imageLocationAlreadyNormalized) Value[(int) LoaderInformation.ApplicationBaseValue] = appBase; elseApplicationBase = appBase; } ConfigurationFile = ApplicationName + AppDomainSetup.ConfigurationExtension; } internal string[] Value { get { if( _Entries == null) _Entries = newString[LOADER_MAXIMUM]; return_Entries; } } internalStringGetUnsecureApplicationBase() { returnValue[(int) LoaderInformation.ApplicationBaseValue]; } public stringAppDomainManagerAssembly { get { return_AppDomainManagerAssembly; } set { _AppDomainManagerAssembly = value; } } public stringAppDomainManagerType { get { return_AppDomainManagerType; } set { _AppDomainManagerType = value; } } #if FEATURE_APTCA public string[] PartialTrustVisibleAssemblies { get { return_AptcaVisibleAssemblies; } set { if (value != null) { _AptcaVisibleAssemblies = (string[])value.Clone(); Array.Sort<string>(_AptcaVisibleAssemblies, StringComparer.OrdinalIgnoreCase); } else { _AptcaVisibleAssemblies = null; } } } #endifpublicStringApplicationBase { #if FEATURE_CORECLR [System.Security.SecurityCritical] // auto-generated #else [System.Security.SecuritySafeCritical] #endif [Pure] [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] get { returnVerifyDir(GetUnsecureApplicationBase(), false); } #if FEATURE_CORECLR [System.Security.SecurityCritical] // auto-generated #endif [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] set { Value[(int) LoaderInformation.ApplicationBaseValue] = NormalizePath(value, false); } } [System.Security.SecuritySafeCritical] private stringNormalizePath(stringpath, booluseAppBase) { if(path == null) return null; // If we add very long file name support ("\\?\") to the Path class then this is unnecesary,// but we do not plan on doing this for now.// Long path checks can be quirked, and as loading default quirks too early in the setup of an AppDomain is risky// we'll avoid checking path lengths- we'll still fail at MAX_PATH later if we're !useAppBase when we call Path's// NormalizePath.if (!useAppBase) path = System.Security.Util.URLString.PreProcessForExtendedPathRemoval( checkPathLength: false, url: path, isFileUrl: false); intlen = path.Length; if (len == 0) return null; boolUNCpath = false; if ((len > 7) && (String.Compare( path, 0, "file:", 0, 5, StringComparison.OrdinalIgnoreCase) == 0)) { inttrim; if (path[6] == '\\') { if ((path[7] == '\\') || (path[7] == '/')) { // Don't allow "file:\\\\", because we can't tell the difference// with it for "file:\\" + "\\server" and "file:\\\" + "\localpath"if ( (len > 8) && ((path[8] == '\\') || (path[8] == '/')) ) thrownewArgumentException(Environment.GetResourceString("Argument_InvalidPathChars")); // file:\\\ means local pathelsetrim = 8; } // file:\\ means remote serverelse { trim = 5; UNCpath = true; } } // local pathelse if (path[7] == '/') trim = 8; // remoteelse { // file://\\remoteif ( (len > 8) && (path[7] == '\\') && (path[8] == '\\') ) trim = 7; else { // file://remotetrim = 5; // Create valid UNC path by changing// all occurences of '/' to '\\' in path System.Text.StringBuilderwinPathBuilder = new System.Text.StringBuilder(len); for (inti = 0; i < len; i++) { charc = path[i]; if (c == '/') winPathBuilder.Append('\\'); elsewinPathBuilder.Append(c); } path = winPathBuilder.ToString(); } UNCpath = true; } path = path.Substring(trim); len -= trim; } boollocalPath; // UNCif (UNCpath || ( (len > 1) && ( (path[0] == '/') || (path[0] == '\\') ) && ( (path[1] == '/') || (path[1] == '\\') ) )) localPath = false; else { intcolon = path.IndexOf(':') + 1; // protocol other than file:if ((colon != 0) && (len > colon+1) && ( (path[colon] == '/') || (path[colon] == '\\') ) && ( (path[colon+1] == '/') || (path[colon+1] == '\\') )) localPath = false; elselocalPath = true; } if (localPath) { if (useAppBase && ((len == 1) || (path[1] != ':'))) { StringappBase = Value[(int)LoaderInformation.ApplicationBaseValue]; if ((appBase == null) || (appBase.Length == 0)) thrownewMemberAccessException(Environment.GetResourceString("AppDomain_AppBaseNotSet")); StringBuilderresult = StringBuilderCache.Acquire(); boolslash = false; if ((path[0] == '/') || (path[0] == '\\')) { // Emulate Path.GetPathRoot without hitting code paths that check quirksstringpathRoot = AppDomain.NormalizePath(appBase, fullCheck: false); pathRoot = pathRoot.Substring(0, System.IO.PathInternal.GetRootLength(pathRoot)); if (pathRoot.Length == 0) { // URLintindex = appBase.IndexOf(":/", StringComparison.Ordinal); if (index == -1) index = appBase.IndexOf(":\\", StringComparison.Ordinal); // Get past last slashes of "url:http://"inturlLen = appBase.Length; for (index += 1; (index < urlLen) && ((appBase[index] == '/') || (appBase[index] == '\\')); index++) ; // Now find the next slash to get domain namefor (; (index < urlLen) && (appBase[index] != '/') && (appBase[index] != '\\'); index++) ; pathRoot = appBase.Substring(0, index); } result.Append(pathRoot); slash = true; } elseresult.Append(appBase); // Make sure there's a slash separator (and only one)intaLen = result.Length - 1; if ((result[aLen] != '/') && (result[aLen] != '\\')) { if (!slash) { if (appBase.IndexOf(":/", StringComparison.Ordinal) == -1) result.Append('\\'); elseresult.Append('/'); } } else if (slash) result.Remove(aLen, 1); result.Append(path); path = StringBuilderCache.GetStringAndRelease(result); } else { path = AppDomain.NormalizePath(path, fullCheck: true); } } returnpath; } private boolIsFilePath(Stringpath) { return (path[1] == ':') || ( (path[0] == '\\') && (path[1] == '\\') ); } internal staticStringApplicationBaseKey { get { return ACTAG_APP_BASE_URL; } } publicStringConfigurationFile { [System.Security.SecuritySafeCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] get { returnVerifyDir(Value[(int) LoaderInformation.ConfigurationFileValue], true); } [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] set { Value[(int) LoaderInformation.ConfigurationFileValue] = value; } } // Used by the ResourceManager internally. This must not do any // security checks to avoid infinite loops.internalStringConfigurationFileInternal { [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] get { returnNormalizePath(Value[(int) LoaderInformation.ConfigurationFileValue], true); } } internal staticStringConfigurationFileKey { get { return ACTAG_APP_CONFIG_FILE; } } public byte[] GetConfigurationBytes() { if (_ConfigurationBytes == null) return null; return (byte[]) _ConfigurationBytes.Clone(); } public voidSetConfigurationBytes(byte[] value) { _ConfigurationBytes = value; } private staticStringConfigurationBytesKey { get { return ACTAG_APP_CONFIG_BLOB; } } // only needed by AppDomain.Setup(). Not really needed by users. internalDictionary<string, object> GetCompatibilityFlags() { return_CompatFlags; } public voidSetCompatibilitySwitches(IEnumerable<String> switches) { #if !FEATURE_CORECLR if(_AppDomainSortingSetupInfo != null) { _AppDomainSortingSetupInfo._useV2LegacySorting = false; _AppDomainSortingSetupInfo._useV4LegacySorting = false; } #endif#if FEATURE_RANDOMIZED_STRING_HASHING _UseRandomizedStringHashing = false; #endifif (switches != null) { _CompatFlags = newDictionary<string, object>(); foreach (Stringstrinswitches) { #if !FEATURE_CORECLR if(StringComparer.OrdinalIgnoreCase.Equals("NetFx40_Legacy20SortingBehavior", str)) { if(_AppDomainSortingSetupInfo == null) { _AppDomainSortingSetupInfo = newAppDomainSortingSetupInfo(); } _AppDomainSortingSetupInfo._useV2LegacySorting = true; } if(StringComparer.OrdinalIgnoreCase.Equals("NetFx45_Legacy40SortingBehavior", str)) { if(_AppDomainSortingSetupInfo == null) { _AppDomainSortingSetupInfo = newAppDomainSortingSetupInfo(); } _AppDomainSortingSetupInfo._useV4LegacySorting = true; } #endif#if FEATURE_RANDOMIZED_STRING_HASHING if(StringComparer.OrdinalIgnoreCase.Equals("UseRandomizedStringHashAlgorithm", str)) { _UseRandomizedStringHashing = true; } #endif_CompatFlags.Add(str, null); } } else { _CompatFlags = null; } } // A target Framework moniker, in a format parsible by the FrameworkName class.publicStringTargetFrameworkName { get { return_TargetFrameworkName; } set { _TargetFrameworkName = value; } } internal boolCheckedForTargetFrameworkName { get { return_CheckedForTargetFrameworkName; } set { _CheckedForTargetFrameworkName = value; } } #if !FEATURE_CORECLR [SecurityCritical] public voidSetNativeFunction(stringfunctionName, intfunctionVersion, IntPtrfunctionPointer) { if(functionName == null) { thrownewArgumentNullException("functionName"); } if(functionPointer == IntPtr.Zero) { thrownewArgumentNullException("functionPointer"); } if(String.IsNullOrWhiteSpace(functionName)) { thrownewArgumentException(Environment.GetResourceString("Argument_NPMSInvalidName"), "functionName"); } Contract.EndContractBlock(); if(functionVersion < 1) { thrownewArgumentException(Environment.GetResourceString("ArgumentException_MinSortingVersion", 1, functionName)); } if(_AppDomainSortingSetupInfo == null) { _AppDomainSortingSetupInfo = newAppDomainSortingSetupInfo(); } if(String.Equals(functionName, "IsNLSDefinedString", StringComparison.OrdinalIgnoreCase)) { _AppDomainSortingSetupInfo._pfnIsNLSDefinedString = functionPointer; } if (String.Equals(functionName, "CompareStringEx", StringComparison.OrdinalIgnoreCase)) { _AppDomainSortingSetupInfo._pfnCompareStringEx = functionPointer; } if (String.Equals(functionName, "LCMapStringEx", StringComparison.OrdinalIgnoreCase)) { _AppDomainSortingSetupInfo._pfnLCMapStringEx = functionPointer; } if (String.Equals(functionName, "FindNLSStringEx", StringComparison.OrdinalIgnoreCase)) { _AppDomainSortingSetupInfo._pfnFindNLSStringEx = functionPointer; } if (String.Equals(functionName, "CompareStringOrdinal", StringComparison.OrdinalIgnoreCase)) { _AppDomainSortingSetupInfo._pfnCompareStringOrdinal = functionPointer; } if (String.Equals(functionName, "GetNLSVersionEx", StringComparison.OrdinalIgnoreCase)) { _AppDomainSortingSetupInfo._pfnGetNLSVersionEx = functionPointer; } if (String.Equals(functionName, "FindStringOrdinal", StringComparison.OrdinalIgnoreCase)) { _AppDomainSortingSetupInfo._pfnFindStringOrdinal = functionPointer; } } #endifpublicStringDynamicBase { [System.Security.SecuritySafeCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] get { returnVerifyDir(Value[(int) LoaderInformation.DynamicBaseValue], true); } [System.Security.SecuritySafeCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] set { if (value == null) Value[(int) LoaderInformation.DynamicBaseValue] = null; else { if(ApplicationName == null) thrownewMemberAccessException(Environment.GetResourceString("AppDomain_RequireApplicationName")); StringBuilders = newStringBuilder( NormalizePath(value, false) ); s.Append('\\'); stringh = ParseNumbers.IntToString(ApplicationName.GetLegacyNonRandomizedHashCode(), 16, 8, '0', ParseNumbers.PrintAsI4); s.Append(h); Value[(int) LoaderInformation.DynamicBaseValue] = s.ToString(); } } } internal staticStringDynamicBaseKey { get { return ACTAG_APP_DYNAMIC_BASE; } } public boolDisallowPublisherPolicy { get { return (Value[(int) LoaderInformation.DisallowPublisherPolicyValue] != null); } set { if (value) Value[(int) LoaderInformation.DisallowPublisherPolicyValue]="true"; elseValue[(int) LoaderInformation.DisallowPublisherPolicyValue]=null; } } public boolDisallowBindingRedirects { get { return (Value[(int) LoaderInformation.DisallowBindingRedirectsValue] != null); } set { if (value) Value[(int) LoaderInformation.DisallowBindingRedirectsValue] = "true"; elseValue[(int) LoaderInformation.DisallowBindingRedirectsValue] = null; } } public boolDisallowCodeDownload { get { return (Value[(int) LoaderInformation.DisallowCodeDownloadValue] != null); } set { if (value) Value[(int) LoaderInformation.DisallowCodeDownloadValue] = "true"; elseValue[(int) LoaderInformation.DisallowCodeDownloadValue] = null; } } public boolDisallowApplicationBaseProbing { get { return (Value[(int) LoaderInformation.DisallowAppBaseProbingValue] != null); } set { if (value) Value[(int) LoaderInformation.DisallowAppBaseProbingValue] = "true"; elseValue[(int) LoaderInformation.DisallowAppBaseProbingValue] = null; } } [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] privateStringVerifyDir(Stringdir, boolnormalize) { if (dir != null) { if (dir.Length == 0) { dir = null; } else { if (normalize) dir = NormalizePath(dir, true); // The only way AppDomainSetup is exposed in coreclr is through the AppDomainManager // and the AppDomainManager is a SecurityCritical type. Also, all callers of callstacks // leading from VerifyDir are SecurityCritical. So we can remove the Demand because // we have validated that all callers are SecurityCritical#if !FEATURE_CORECLR if (IsFilePath(dir)) { // If we've already normalized we don't need to do it again, and can avoid hitting// quirks in FileIOPermission.newFileIOPermission( access: FileIOPermissionAccess.PathDiscovery, pathList: newstring[] { dir }, checkForDuplicates: false, needFullPath: false).Demand(); } #endif// !FEATURE_CORECLR } } returndir; } [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] private voidVerifyDirList(Stringdirs) { if (dirs != null) { String[] dirArray = dirs.Split(';'); intlen = dirArray.Length; for (inti = 0; i < len; i++) VerifyDir(dirArray[i], true); } } internalStringDeveloperPath { [System.Security.SecurityCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] get { Stringdirs = Value[(int) LoaderInformation.DevPathValue]; VerifyDirList(dirs); returndirs; } [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] set { if(value == null) Value[(int) LoaderInformation.DevPathValue] = null; else { String[] directories = value.Split(';'); intsize = directories.Length; StringBuildernewPath = StringBuilderCache.Acquire(); boolfDelimiter = false; for(inti = 0; i < size; i++) { if(directories[i].Length != 0) { if(fDelimiter) newPath.Append(";"); elsefDelimiter = true; newPath.Append(Path.GetFullPathInternal(directories[i])); } } StringnewString = StringBuilderCache.GetStringAndRelease(newPath); if (newString.Length == 0) Value[(int) LoaderInformation.DevPathValue] = null; elseValue[(int) LoaderInformation.DevPathValue] = newString; } } } internal staticStringDisallowPublisherPolicyKey { get { return ACTAG_DISALLOW_APPLYPUBLISHERPOLICY; } } internal staticStringDisallowCodeDownloadKey { get { return ACTAG_CODE_DOWNLOAD_DISABLED; } } internal staticStringDisallowBindingRedirectsKey { get { return ACTAG_DISALLOW_APP_BINDING_REDIRECTS; } } internal staticStringDeveloperPathKey { get { return ACTAG_DEV_PATH; } } internal staticStringDisallowAppBaseProbingKey { get { return ACTAG_DISALLOW_APP_BASE_PROBING; } } publicStringApplicationName { get { returnValue[(int) LoaderInformation.ApplicationNameValue]; } set { Value[(int) LoaderInformation.ApplicationNameValue] = value; } } internal staticStringApplicationNameKey { get { return ACTAG_APP_NAME; } } [XmlIgnoreMember] publicAppDomainInitializerAppDomainInitializer { get { return_AppDomainInitializer; } set { _AppDomainInitializer = value; } } public string[] AppDomainInitializerArguments { get { return_AppDomainInitializerArguments; } set { _AppDomainInitializerArguments = value; } } #if FEATURE_CLICKONCE [XmlIgnoreMember] publicActivationArgumentsActivationArguments { [Pure] get { return_ActivationArguments; } set { _ActivationArguments = value; } } #endif// !FEATURE_CLICKONCEinternalApplicationTrustInternalGetApplicationTrust() { if (_ApplicationTrust == null) return null; #if FEATURE_CORECLR ApplicationTrust grantSet = new ApplicationTrust(NamedPermissionSet.GetBuiltInSet(_ApplicationTrust)); #elseSecurityElementsecurityElement = SecurityElement.FromString(_ApplicationTrust); ApplicationTrustgrantSet = newApplicationTrust(); grantSet.FromXml(securityElement); #endifreturngrantSet; } #if FEATURE_CORECLR internal void InternalSetApplicationTrust(String permissionSetName) { _ApplicationTrust = permissionSetName; } #elseinternal voidInternalSetApplicationTrust(ApplicationTrustvalue) { if (value != null) { _ApplicationTrust = value.ToXml().ToString(); } else { _ApplicationTrust = null; } } #endif#if FEATURE_CLICKONCE [XmlIgnoreMember] publicApplicationTrustApplicationTrust { get { returnInternalGetApplicationTrust(); } set { InternalSetApplicationTrust(value); } } #else// FEATURE_CLICKONCE [XmlIgnoreMember] internal ApplicationTrust ApplicationTrust { get { return InternalGetApplicationTrust(); } #if !FEATURE_CORECLR set { InternalSetApplicationTrust(value); } #endif } #endif// FEATURE_CLICKONCEpublicStringPrivateBinPath { [System.Security.SecuritySafeCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] get { Stringdirs = Value[(int) LoaderInformation.PrivateBinPathValue]; VerifyDirList(dirs); returndirs; } [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] set { Value[(int) LoaderInformation.PrivateBinPathValue] = value; } } internal staticStringPrivateBinPathKey { get { return ACTAG_APP_PRIVATE_BINPATH; } } publicStringPrivateBinPathProbe { get { returnValue[(int) LoaderInformation.PrivateBinPathProbeValue]; } set { Value[(int) LoaderInformation.PrivateBinPathProbeValue] = value; } } internal staticStringPrivateBinPathProbeKey { get { return ACTAG_BINPATH_PROBE_ONLY; } } publicStringShadowCopyDirectories { [System.Security.SecuritySafeCritical] // auto-generated [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] get { Stringdirs = Value[(int) LoaderInformation.ShadowCopyDirectoriesValue]; VerifyDirList(dirs); returndirs

0 comments

Leave a Reply

Your email address will not be published. Required fields are marked *