internal static void GetEntryPoint (ActivationContext activationContext, out string fileName, out string parameters) { parameters = null; fileName = null; ICMS appManifest = activationContext.ApplicationComponentManifest; if (appManifest == null || appManifest.EntryPointSection == null) throw new ArgumentException(Environment.GetResourceString("Argument_NoMain")); IEnumUnknown refEnum = (IEnumUnknown) appManifest.EntryPointSection._NewEnum; uint count = 0; Object[] entries = new Object[1]; // Look for the first entry point. ClickOnce semantic validation ensures exactly one entry point is present. if (refEnum.Next(1, entries, ref count) == 0 && count == 1) { IEntryPointEntry iref= (IEntryPointEntry) entries[0]; EntryPointEntry reference = iref.AllData; if (reference.CommandLine_File != null && reference.CommandLine_File.Length > 0) { fileName = reference.CommandLine_File; } else { // Locate the dependent assembly that is being refered to. Well-formed manifests should have an identity. IAssemblyReferenceEntry refEntry = null; object assemblyObj = null; if (reference.Identity != null) { ((ISectionWithReferenceIdentityKey)appManifest.AssemblyReferenceSection).Lookup(reference.Identity, out assemblyObj); refEntry = (IAssemblyReferenceEntry) assemblyObj; fileName = refEntry.DependentAssembly.Codebase; } } parameters = reference.CommandLine_Parameters; } }
public static bool DetermineApplicationTrust(ActivationContext activationContext, TrustManagerContext context) { if (activationContext == null) { throw new ArgumentNullException("activationContext"); } ApplicationTrust trust = null; AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager; if (domainManager != null) { HostSecurityManager hostSecurityManager = domainManager.HostSecurityManager; if ((hostSecurityManager != null) && ((hostSecurityManager.Flags & HostSecurityManagerOptions.HostDetermineApplicationTrust) == HostSecurityManagerOptions.HostDetermineApplicationTrust)) { trust = hostSecurityManager.DetermineApplicationTrust(CmsUtils.MergeApplicationEvidence(null, activationContext.Identity, activationContext, null), null, context); if (trust == null) { return false; } return trust.IsApplicationTrustedToRun; } } trust = DetermineApplicationTrustInternal(activationContext, context); if (trust == null) { return false; } return trust.IsApplicationTrustedToRun; }
static StackObject *CreateInstance_21(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.String[] @activationCustomData = (System.String[]) typeof(System.String[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.ActivationContext @activationContext = (System.ActivationContext) typeof(System.ActivationContext).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = System.Activator.CreateInstance(@activationContext, @activationCustomData); object obj_result_of_this_method = result_of_this_method; if (obj_result_of_this_method is CrossBindingAdaptorType) { return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance)); } return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public static ManifestSignatureInformationCollection VerifySignature(ActivationContext application, ManifestKinds manifests, X509RevocationFlag revocationFlag, X509RevocationMode revocationMode) { if (application == null) { throw new ArgumentNullException("application"); } if ((revocationFlag < X509RevocationFlag.EndCertificateOnly) || (X509RevocationFlag.ExcludeRoot < revocationFlag)) { throw new ArgumentOutOfRangeException("revocationFlag"); } if ((revocationMode < X509RevocationMode.NoCheck) || (X509RevocationMode.Offline < revocationMode)) { throw new ArgumentOutOfRangeException("revocationMode"); } List<ManifestSignatureInformation> signatureInformation = new List<ManifestSignatureInformation>(); if ((manifests & ManifestKinds.Deployment) == ManifestKinds.Deployment) { ManifestSignedXml xml = new ManifestSignedXml(GetManifestXml(application, ManifestKinds.Deployment), ManifestKinds.Deployment); signatureInformation.Add(xml.VerifySignature(revocationFlag, revocationMode)); } if ((manifests & ManifestKinds.Application) == ManifestKinds.Application) { ManifestSignedXml xml2 = new ManifestSignedXml(GetManifestXml(application, ManifestKinds.Application), ManifestKinds.Application); signatureInformation.Add(xml2.VerifySignature(revocationFlag, revocationMode)); } return new ManifestSignatureInformationCollection(signatureInformation); }
private static unsafe XmlDocument GetManifestXml(ActivationContext application, ManifestKinds manifest) { IStream applicationComponentManifest = null; if (manifest == ManifestKinds.Application) { applicationComponentManifest = InternalActivationContextHelper.GetApplicationComponentManifest(application) as IStream; } else if (manifest == ManifestKinds.Deployment) { applicationComponentManifest = InternalActivationContextHelper.GetDeploymentComponentManifest(application) as IStream; } using (MemoryStream stream2 = new MemoryStream()) { byte[] pv = new byte[0x1000]; int count = 0; do { applicationComponentManifest.Read(pv, pv.Length, new IntPtr((void*) &count)); stream2.Write(pv, 0, count); } while (count == pv.Length); stream2.Position = 0L; XmlDocument document = new XmlDocument { PreserveWhitespace = true }; document.Load(stream2); return document; } }
public ApplicationSecurityInfo(ActivationContext activationContext) { if (activationContext == null) { throw new ArgumentNullException("activationContext"); } this.m_context = activationContext; }
internal static bool CompareIdentities(ActivationContext activationContext1, ActivationContext activationContext2) { if ((activationContext1 != null) && (activationContext2 != null)) { return IsolationInterop.AppIdAuthority.AreDefinitionsEqual(0, activationContext1.Identity.Identity, activationContext2.Identity.Identity); } return (activationContext1 == activationContext2); }
public static byte[] GetDeploymentManifestBytes(ActivationContext appInfo) { if (appInfo == null) { throw new ArgumentNullException("appInfo"); } return appInfo.GetDeploymentManifestBytes(); }
public static System.Security.Policy.ApplicationTrust RequestTrust(SubscriptionState subState, bool isShellVisible, bool isUpdate, ActivationContext actCtx) { TrustManagerContext tmc = new TrustManagerContext { IgnorePersistedDecision = false, NoPrompt = false, Persist = true }; return RequestTrust(subState, isShellVisible, isUpdate, actCtx, tmc); }
// Constructor. internal BindCompletedEventArgs (Exception error, bool cancelled, Object userState, ActivationContext activationContext, String friendlyName, bool isCached) : base(error, cancelled, userState) { this.activationContext = activationContext; this.friendlyName = friendlyName; this.isCached = isCached; }
public ActivationArguments(System.ActivationContext activationContext, string[] activationData) { if (activationContext == null) { throw new ArgumentNullException("activationContext"); } this.m_appFullName = activationContext.Identity.FullName; this.m_appManifestPaths = activationContext.ManifestPaths; this.m_activationData = activationData; this.m_useFusionActivationContext = true; }
private static async Task Proceed(Func<Task<object>> proceed, ActivationContext ctx) { if (!ctx.SkipAwait) { await proceed(); } else { proceed(); } }
public static System.Security.Policy.ApplicationTrust PersistTrustWithoutEvaluation(ActivationContext actCtx) { ApplicationSecurityInfo info = new ApplicationSecurityInfo(actCtx); System.Security.Policy.ApplicationTrust trust = new System.Security.Policy.ApplicationTrust(actCtx.Identity) { IsApplicationTrustedToRun = true, DefaultGrantSet = new PolicyStatement(info.DefaultRequestSet, PolicyStatementAttribute.Nothing), Persist = true, ApplicationIdentity = actCtx.Identity }; ApplicationSecurityManager.UserApplicationTrusts.Add(trust); return trust; }
private async Task<ActivationContext> DoAfter(MethodAdviceContext context, ActivationContext ctx) { if (context.IsAwaitable()) { ctx = await AfterProcesssingAsync(ctx); } else { ctx = AfterProcesssing(ctx); } return ctx; }
public virtual ObjectHandle CreateInstance(ActivationContext activationContext, string[] activationCustomData) { if (activationContext == null) { throw new ArgumentNullException("activationContext"); } if (CmsUtils.CompareIdentities(AppDomain.CurrentDomain.ActivationContext, activationContext)) { ManifestRunner runner = new ManifestRunner(AppDomain.CurrentDomain, activationContext); return new ObjectHandle(runner.ExecuteAsAssembly()); } AppDomainSetup adSetup = new AppDomainSetup(new ActivationArguments(activationContext, activationCustomData)); return CreateInstanceHelper(adSetup); }
internal static void CreateActivationContext(string fullName, string[] manifestPaths, bool useFusionActivationContext, out ApplicationIdentity applicationIdentity, out ActivationContext activationContext) { applicationIdentity = new ApplicationIdentity(fullName); activationContext = null; if (useFusionActivationContext) { if (manifestPaths != null) { activationContext = new ActivationContext(applicationIdentity, manifestPaths); } else { activationContext = new ActivationContext(applicationIdentity); } } }
public static System.Security.Policy.ApplicationTrust RequestTrust(SubscriptionState subState, bool isShellVisible, bool isUpdate, ActivationContext actCtx, TrustManagerContext tmc) { Logger.AddMethodCall("ApplicationTrust.RequestTrust(isShellVisible=" + isShellVisible.ToString() + ", isUpdate=" + isUpdate.ToString() + ", subState.IsInstalled=" + subState.IsInstalled.ToString() + ") called."); if (!subState.IsInstalled || (subState.IsShellVisible != isShellVisible)) { tmc.IgnorePersistedDecision = true; } if (isUpdate) { tmc.PreviousApplicationIdentity = subState.CurrentBind.ToApplicationIdentity(); } bool flag = false; try { Logger.AddInternalState("Calling ApplicationSecurityManager.DetermineApplicationTrust()."); Logger.AddInternalState("Trust Manager Context=" + Logger.Serialize(tmc)); flag = ApplicationSecurityManager.DetermineApplicationTrust(actCtx, tmc); } catch (TypeLoadException exception) { throw new InvalidDeploymentException(Resources.GetString("Ex_InvalidTrustInfo"), exception); } if (!flag) { throw new TrustNotGrantedException(Resources.GetString("Ex_NoTrust")); } Logger.AddInternalState("Trust granted."); System.Security.Policy.ApplicationTrust trust = null; for (int i = 0; i < 5; i++) { trust = ApplicationSecurityManager.UserApplicationTrusts[actCtx.Identity.FullName]; if (trust != null) { break; } Thread.Sleep(10); } if (trust == null) { throw new InvalidDeploymentException(Resources.GetString("Ex_InvalidMatchTrust")); } return trust; }
internal static string GetEntryPointFullPath (ActivationContext activationContext) { string file, parameters; GetEntryPoint(activationContext, out file, out parameters); if (!String.IsNullOrEmpty(file)) { string directoryName = activationContext.ApplicationDirectory; if (directoryName == null || directoryName.Length == 0) { // If we were passed a relative path, assume the app base is the current working directory StringBuilder sb = new StringBuilder(Path.MAX_PATH + 1); if (Win32Native.GetCurrentDirectory(sb.Capacity, sb) == 0) System.IO.__Error.WinIOError(); directoryName = sb.ToString(); } file = Path.Combine(directoryName, file); } return file; }
internal static string GetEntryPointFullPath (ActivationContext activationContext) { string file, parameters; GetEntryPoint(activationContext, out file, out parameters); if (!string.IsNullOrEmpty(file)) { string directoryName = activationContext.ApplicationDirectory; if (directoryName == null || directoryName.Length == 0) { // If we were passed a relative path, assume the app base is the current working directory directoryName = Directory.UnsafeGetCurrentDirectory(); } file = Path.Combine(directoryName, file); } return file; }
internal static IAssemblyReferenceEntry[] GetDependentAssemblies(ActivationContext activationContext) { IAssemblyReferenceEntry[] entries = null; ICMS appManifest = activationContext.ApplicationComponentManifest; if (appManifest == null) return null; ISection dependencySection = appManifest.AssemblyReferenceSection; uint count = (dependencySection != null) ? dependencySection.Count : 0; if (count > 0) { uint fetched = 0; entries = new IAssemblyReferenceEntry[count]; IEnumUnknown dependencyEnum = (IEnumUnknown)dependencySection._NewEnum; int hr = dependencyEnum.Next(count, entries, ref fetched); if (fetched != count || hr < 0) return null; // } return entries; }
internal static IAssemblyReferenceEntry[] GetDependentAssemblies(ActivationContext activationContext) { IAssemblyReferenceEntry[] rgelt = null; ICMS applicationComponentManifest = activationContext.ApplicationComponentManifest; if (applicationComponentManifest != null) { ISection assemblyReferenceSection = applicationComponentManifest.AssemblyReferenceSection; uint celt = (assemblyReferenceSection != null) ? assemblyReferenceSection.Count : 0; if (celt <= 0) { return rgelt; } uint celtFetched = 0; rgelt = new IAssemblyReferenceEntry[celt]; int num3 = ((IEnumUnknown) assemblyReferenceSection._NewEnum).Next(celt, rgelt, ref celtFetched); if ((celtFetched == celt) && (num3 >= 0)) { return rgelt; } } return null; }
internal ManifestRunner(AppDomain domain, ActivationContext activationContext) { string str; string str2; this.m_domain = domain; CmsUtils.GetEntryPoint(activationContext, out str, out str2); if (string.IsNullOrEmpty(str)) { throw new ArgumentException(Environment.GetResourceString("Argument_NoMain")); } if (string.IsNullOrEmpty(str2)) { this.m_args = new string[0]; } else { this.m_args = str2.Split(new char[] { ' ' }); } this.m_apt = ApartmentState.Unknown; string applicationDirectory = activationContext.ApplicationDirectory; this.m_path = Path.Combine(applicationDirectory, str); }
internal GetManifestCompletedEventArgs(BindCompletedEventArgs e, ActivationDescription activationDescription, string logFilePath, Logger.LogIdentity log) : base(e.Error, e.Cancelled, e.UserState) { this._applicationIdentity = (e.ActivationContext != null) ? e.ActivationContext.Identity : null; Logger.AddInternalState(log, "Creating GetManifestCompletedEventArgs."); string text = this._applicationIdentity.ToString(); DefinitionAppId id = new DefinitionAppId(text); this._subId = id.DeploymentIdentity.ToSubscriptionId(); this._logFilePath = logFilePath; this._isCached = e.IsCached; this._name = e.FriendlyName; this._actContext = e.ActivationContext; Logger.AddInternalState(log, "Application identity=" + text); Logger.AddInternalState(log, "Subscription identity=" + ((this._subId != null) ? this._subId.ToString() : "null")); Logger.AddInternalState(log, "IsCached=" + this._isCached.ToString()); if (this._isCached) { this._rawDeploymentManifest = e.ActivationContext.DeploymentManifestBytes; this._rawApplicationManifest = e.ActivationContext.ApplicationManifestBytes; } this._activationDescription = activationDescription; this._version = this._activationDescription.AppId.DeploymentIdentity.Version; this._support = this._activationDescription.DeployManifest.Description.SupportUri; }
[System.Security.SecurityCritical] // auto-generated private void SetupApplicationHelper (Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, ApplicationIdentity appIdentity, ActivationContext activationContext, string[] activationData) { Contract.Requires(providedSecurityInfo != null); HostSecurityManager securityManager = AppDomain.CurrentDomain.HostSecurityManager; ApplicationTrust appTrust = securityManager.DetermineApplicationTrust(providedSecurityInfo, creatorsSecurityInfo, new TrustManagerContext()); if (appTrust == null || !appTrust.IsApplicationTrustedToRun) throw new PolicyException(Environment.GetResourceString("Policy_NoExecutionPermission"), System.__HResults.CORSEC_E_NO_EXEC_PERM, null); // The application is trusted to run. Set up the AppDomain according to the manifests. if (activationContext != null) SetupDomainForApplication(activationContext, activationData); SetupDomainSecurityForApplication(appIdentity, appTrust); }
public static ManifestSignatureInformationCollection VerifySignature(ActivationContext application, System.Security.ManifestKinds manifests, System.Security.Cryptography.X509Certificates.X509RevocationFlag revocationFlag, System.Security.Cryptography.X509Certificates.X509RevocationMode revocationMode) { Contract.Ensures(Contract.Result<System.Security.Cryptography.ManifestSignatureInformationCollection>() != null); return default(ManifestSignatureInformationCollection); }
public static ManifestSignatureInformationCollection VerifySignature(ActivationContext application, System.Security.ManifestKinds manifests) { Contract.Ensures(Contract.Result<System.Security.Cryptography.ManifestSignatureInformationCollection>() != null); return default(ManifestSignatureInformationCollection); }
private static bool SearchPreviousTrustedVersion(ActivationContext activationContext, out ArrayList matchingTrusts) { // No match found by default matchingTrusts = null; ApplicationTrustCollection appTrusts = ApplicationSecurityManager.UserApplicationTrusts; foreach (ApplicationTrust appTrust in appTrusts) { IDefinitionAppId appTrustAppId = IsolationInterop.AppIdAuthority.TextToDefinition(0, appTrust.ApplicationIdentity.FullName); IDefinitionAppId actCtxAppId = IsolationInterop.AppIdAuthority.TextToDefinition(0, activationContext.Identity.FullName); if (IsolationInterop.AppIdAuthority.AreDefinitionsEqual((uint) IAPPIDAUTHORITY_ARE_DEFINITIONS_EQUAL_FLAGS.IAPPIDAUTHORITY_ARE_DEFINITIONS_EQUAL_FLAG_IGNORE_VERSION, appTrustAppId, actCtxAppId)) { // Found an older matching app (or same version app which should never occur in theory) if (matchingTrusts == null) { matchingTrusts = new ArrayList(); } matchingTrusts.Add(appTrust); } } // (matchingTrusts != null) <==> Found a prior version that was allowed to run. return (matchingTrusts != null); }
private static ApplicationTrust BlockingPrompt(ActivationContext activationContext, ParsedData parsedData, String deploymentUrl, ApplicationSecurityInfo info, ApplicationTrustExtraInfo appTrustExtraInfo, string zoneName, bool permissionElevationRequired) { TrustManagerPromptOptions options = CompletePromptOptions(permissionElevationRequired ? (TrustManagerPromptOptions.StopApp | TrustManagerPromptOptions.RequiresPermissions) : TrustManagerPromptOptions.StopApp, appTrustExtraInfo, zoneName, info); try { TrustManagerPromptUIThread errorDialog = new TrustManagerPromptUIThread(string.IsNullOrEmpty(parsedData.AppName) ? info.ApplicationId.Name : parsedData.AppName, DefaultBrowserExePath, parsedData.SupportUrl, GetHostFromDeploymentUrl(deploymentUrl), parsedData.AuthenticodedPublisher /*publisherName*/, parsedData.Certificate, options); errorDialog.ShowDialog(); } catch (Exception ex) { Debug.Fail("Error occurred while showing error dialog: " + ex.Message); } // Trust Manager should prompt, but is not allowed to. Return Don't Trust and Don't Persist. return CreateApplicationTrust(activationContext, info, appTrustExtraInfo, false /*trust*/, false /*persist*/); }
public ActivationArguments(System.ActivationContext activationData) : this(activationData, null) { }
/// <summary>Initializes a new instance of the <see cref="T:System.AppDomainSetup" /> class with the specified activation context to use for manifest-based activation of an application domain.</summary><param name="activationContext">The activation context to be used for an application domain.</param><exception cref="T:System.ArgumentNullException"><paramref name="activationContext" /> is null.</exception> public AppDomainSetup(ActivationContext activationContext) { throw new NotImplementedException(); }
public AppDomainSetup(ActivationContext activationContext) : this(new System.Runtime.Hosting.ActivationArguments(activationContext)) { }
public static ObjectHandle CreateInstance(ActivationContext activationContext) { throw new NotImplementedException(); }
public static ObjectHandle CreateInstance(ActivationContext activationContext, string [] activationCustomData) { throw new NotImplementedException(); }
public AppDomainSetup(ActivationContext activationContext) { _activationArguments = new ActivationArguments(activationContext); }
[System.Security.SecurityCritical] // auto-generated private void SetupDomainForApplication(ActivationContext activationContext, string[] activationData) { Contract.Requires(activationContext != null); if (IsDefaultAppDomain()) { // make the ActivationArguments available off the AppDomain object. AppDomainSetup adSetup = this.FusionStore; adSetup.ActivationArguments = new ActivationArguments(activationContext, activationData); // set the application base to point at where the application resides string entryPointPath = CmsUtils.GetEntryPointFullPath(activationContext); if (!String.IsNullOrEmpty(entryPointPath)) adSetup.SetupDefaults(entryPointPath); else adSetup.ApplicationBase = activationContext.ApplicationDirectory; // update fusion context SetupFusionStore(adSetup, null); } // perform app data directory migration. activationContext.PrepareForExecution(); activationContext.SetApplicationState(ActivationContext.ApplicationState.Starting); // set current app data directory. activationContext.SetApplicationState(ActivationContext.ApplicationState.Running); // make data directory path available. IPermission permission = null; string dataDirectory = activationContext.DataDirectory; if (dataDirectory != null && dataDirectory.Length > 0) permission = new FileIOPermission(FileIOPermissionAccess.PathDiscovery, dataDirectory); this.SetData("DataDirectory", dataDirectory, permission); _activationContext = activationContext; }
internal static ApplicationTrust DetermineApplicationTrustInternal(ActivationContext activationContext, TrustManagerContext context) { ApplicationTrust trust = null; ApplicationTrustCollection trusts = new ApplicationTrustCollection(true); if ((context == null) || !context.IgnorePersistedDecision) { trust = trusts[activationContext.Identity.FullName]; if (trust != null) { return trust; } } trust = ApplicationTrustManager.DetermineApplicationTrust(activationContext, context); if (trust == null) { trust = new ApplicationTrust(activationContext.Identity); } trust.ApplicationIdentity = activationContext.Identity; if (trust.Persist) { trusts.Add(trust); } return trust; }
public virtual ObjectHandle CreateInstance(ActivationContext activationContext) { return this.CreateInstance(activationContext, null); }
public static System.Runtime.Remoting.ObjectHandle CreateInstance(ActivationContext activationContext) { return(default(System.Runtime.Remoting.ObjectHandle)); }
public static object GetActivationContextData (ActivationContext appInfo) { throw new NotImplementedException (); }
public static ObjectHandle CreateInstance(ActivationContext activationContext, string[] activationCustomData) { throw new PlatformNotSupportedException("Activator.CreateInstance (ActivationContext) is not supported on this platform."); }
internal BindCompletedEventArgs(Exception error, bool cancelled, object userState, System.ActivationContext actCtx, string name, bool cached) : base(error, cancelled, userState) { this._actCtx = actCtx; this._name = name; this._cached = cached; }
public AppDomainSetup(ActivationContext activationContext) { Contract.Requires(activationContext.Identity != null); }