Exemplo n.º 1
0
 private static void AddShellExtensions(DefinitionIdentity subId, Uri deploymentProviderUri, AssemblyManifest appManifest)
 {
     foreach (FileAssociation fileAssociation in appManifest.FileAssociations)
     {
         ShellExposure.AddFileAssociation(fileAssociation, subId, deploymentProviderUri);
     }
 }
 public void RollbackSubscription(SubscriptionState subState)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         this.CheckInstalledAndShellVisible(subState);
         if (subState.RollbackDeployment == null)
         {
             throw new DeploymentException(ExceptionTypes.SubscriptionState, Resources.GetString("Ex_SubNoRollbackDeployment"));
         }
         if (subState.CurrentApplicationManifest != null)
         {
             string productName = null;
             if ((subState.CurrentDeploymentManifest != null) && (subState.CurrentDeploymentManifest.Description != null))
             {
                 productName = subState.CurrentDeploymentManifest.Description.Product;
             }
             if (productName == null)
             {
                 productName = subState.SubscriptionId.Name;
             }
             ShellExposure.RemoveShellExtensions(subState.SubscriptionId, subState.CurrentApplicationManifest, productName);
         }
         this._compStore.RollbackSubscription(subState);
         this.UpdateSubscriptionExposure(subState);
         OnDeploymentRemoved(subState);
     }
 }
 public void UninstallCustomUXSubscription(SubscriptionState subState)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         CheckInstalled(subState);
         if (subState.appType != AppType.CustomUX)
         {
             throw new InvalidOperationException(Resources.GetString("Ex_CannotCallUninstallCustomUXApplication"));
         }
         if (subState.CurrentApplicationManifest != null)
         {
             string productName = null;
             if ((subState.CurrentDeploymentManifest != null) && (subState.CurrentDeploymentManifest.Description != null))
             {
                 productName = subState.CurrentDeploymentManifest.Description.Product;
             }
             if (productName == null)
             {
                 productName = subState.SubscriptionId.Name;
             }
             ShellExposure.RemoveShellExtensions(subState.SubscriptionId, subState.CurrentApplicationManifest, productName);
         }
         this._compStore.RemoveSubscription(subState);
         OnDeploymentRemoved(subState);
     }
 }
Exemplo n.º 4
0
 public static void RemoveShellExtensions(DefinitionIdentity subId, AssemblyManifest appManifest, string productName)
 {
     foreach (FileAssociation fileAssociation in appManifest.FileAssociations)
     {
         ShellExposure.RemoveFileAssociation(fileAssociation, subId, productName);
     }
     NativeMethods.SHChangeNotify(134217728, 0U, IntPtr.Zero, IntPtr.Zero);
 }
Exemplo n.º 5
0
        private static void AddFileAssociation(FileAssociation fileAssociation, DefinitionIdentity subId, Uri deploymentProviderUri)
        {
            if (!ShellExposure.CanAddFileAssociation(fileAssociation))
            {
                return;
            }
            string subkey = Guid.NewGuid().ToString("B");
            string str    = subId.ToString();

            using (RegistryKey subKey1 = Registry.CurrentUser.CreateSubKey("Software\\Classes"))
            {
                using (RegistryKey subKey2 = subKey1.CreateSubKey(fileAssociation.Extension))
                {
                    subKey2.SetValue((string)null, (object)fileAssociation.ProgID);
                    subKey2.SetValue("AppId", (object)str);
                    subKey2.SetValue("Guid", (object)subkey);
                    subKey2.SetValue("DeploymentProviderUrl", (object)deploymentProviderUri.AbsoluteUri);
                }
                using (RegistryKey subKey2 = subKey1.CreateSubKey(fileAssociation.ProgID))
                {
                    subKey2.SetValue((string)null, (object)fileAssociation.Description);
                    subKey2.SetValue("AppId", (object)str);
                    subKey2.SetValue("Guid", (object)subkey);
                    subKey2.SetValue("DeploymentProviderUrl", (object)deploymentProviderUri.AbsoluteUri);
                    using (RegistryKey subKey3 = subKey2.CreateSubKey("shell"))
                    {
                        subKey3.SetValue((string)null, (object)"open");
                        using (RegistryKey subKey4 = subKey3.CreateSubKey("open\\command"))
                        {
                            subKey4.SetValue((string)null, (object)("rundll32.exe dfshim.dll, ShOpenVerbExtension " + subkey + " %1"));
                            Logger.AddInternalState("File association created. Extension=" + fileAssociation.Extension + " value=rundll32.exe dfshim.dll, ShOpenVerbExtension " + subkey + " %1");
                        }
                        using (RegistryKey subKey4 = subKey2.CreateSubKey("shellex\\IconHandler"))
                        {
                            subKey4.SetValue((string)null, (object)subkey);
                            Logger.AddInternalState("File association icon handler created. Extension=" + fileAssociation.Extension + " value=" + subkey);
                        }
                    }
                }
                using (RegistryKey subKey2 = subKey1.CreateSubKey("CLSID"))
                {
                    using (RegistryKey subKey3 = subKey2.CreateSubKey(subkey))
                    {
                        subKey3.SetValue((string)null, (object)("Shell Icon Handler For " + fileAssociation.Description));
                        subKey3.SetValue("AppId", (object)str);
                        subKey3.SetValue("DeploymentProviderUrl", (object)deploymentProviderUri.AbsoluteUri);
                        subKey3.SetValue("IconFile", (object)fileAssociation.DefaultIcon);
                        using (RegistryKey subKey4 = subKey3.CreateSubKey("InProcServer32"))
                        {
                            subKey4.SetValue((string)null, (object)"dfshim.dll");
                            subKey4.SetValue("ThreadingModel", (object)"Apartment");
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
 public static void UpdateSubscriptionShellExposure(SubscriptionState subState)
 {
     using (subState.SubscriptionStore.AcquireStoreWriterLock())
     {
         ShellExposure.ShellExposureInformation exposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(subState.SubscriptionId);
         ShellExposure.UpdateShortcuts(subState, ref exposureInformation);
         ShellExposure.UpdateShellExtensions(subState, ref exposureInformation);
         ShellExposure.UpdateArpEntry(subState, exposureInformation);
     }
 }
Exemplo n.º 7
0
 internal static void RemovePins(SubscriptionState subState)
 {
     Logger.AddInternalState("Attempting to remove shell pins.");
     ShellExposure.ShellExposureInformation exposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(subState.SubscriptionId);
     if (exposureInformation == null)
     {
         Logger.AddInternalState("shellExposureInformation is null.");
     }
     else
     {
         if (!System.IO.File.Exists(exposureInformation.ApplicationShortcutPath))
         {
             return;
         }
         ShellExposure.UnpinShortcut(exposureInformation.ApplicationShortcutPath);
     }
 }
Exemplo n.º 8
0
 private static void RemoveFileAssociation(FileAssociation fileAssociation, DefinitionIdentity subId, string productName)
 {
     using (RegistryKey classesKey = Registry.CurrentUser.OpenSubKey("Software\\Classes", true))
     {
         if (classesKey == null)
         {
             return;
         }
         Logger.AddMethodCall("RemoveFileAssociation(" + fileAssociation.ToString() + ") called.");
         ShellExposure.RemoveFileAssociationExtentionInfo(fileAssociation, subId, classesKey, productName);
         string clsIdString = ShellExposure.RemoveFileAssociationProgIDInfo(fileAssociation, subId, classesKey, productName);
         if (clsIdString == null)
         {
             return;
         }
         ShellExposure.RemoveFileAssociationCLSIDInfo(fileAssociation, subId, classesKey, clsIdString, productName);
     }
 }
Exemplo n.º 9
0
            public static ShellExposure.ShellExposureInformation CreateShellExposureInformation(DefinitionIdentity subscriptionIdentity)
            {
                ShellExposure.ShellExposureInformation exposureInformation = (ShellExposure.ShellExposureInformation)null;
                string path2_1 = (string)null;
                string str1    = (string)null;
                string path2_2 = (string)null;
                string str2    = (string)null;
                string str3    = "";

                using (RegistryKey registryKey1 = ShellExposure.UninstallRoot.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"))
                {
                    if (registryKey1 != null)
                    {
                        using (RegistryKey registryKey2 = registryKey1.OpenSubKey(ShellExposure.GenerateArpKeyName(subscriptionIdentity)))
                        {
                            if (registryKey2 != null)
                            {
                                path2_1 = registryKey2.GetValue("ShortcutFolderName") as string;
                                str1    = registryKey2.GetValue("ShortcutFileName") as string;
                                path2_2 = registryKey2.GetValue("ShortcutSuiteName") == null ? "" : registryKey2.GetValue("ShortcutSuiteName") as string;
                                str2    = registryKey2.GetValue("SupportShortcutFileName") as string;
                                str3    = registryKey2.GetValue("ShortcutAppId") == null ? "" : registryKey2.GetValue("ShortcutAppId") as string;
                            }
                        }
                    }
                }
                if (path2_1 != null && str1 != null && str2 != null)
                {
                    exposureInformation = new ShellExposure.ShellExposureInformation();
                    exposureInformation._applicationRootFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), path2_1);
                    exposureInformation._applicationFolderPath     = !string.IsNullOrEmpty(path2_2) ? Path.Combine(exposureInformation._applicationRootFolderPath, path2_2) : exposureInformation._applicationRootFolderPath;
                    exposureInformation._applicationShortcutPath   = Path.Combine(exposureInformation._applicationFolderPath, str1 + ".appref-ms");
                    exposureInformation._supportShortcutPath       = Path.Combine(exposureInformation._applicationFolderPath, str2 + ".url");
                    exposureInformation._desktopShortcutPath       = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), str1 + ".appref-ms");
                    exposureInformation._appVendor          = path2_1;
                    exposureInformation._appProduct         = str1;
                    exposureInformation._appSupportShortcut = str2;
                    exposureInformation._shortcutAppId      = str3;
                    exposureInformation._appSuiteName       = path2_2;
                }
                return(exposureInformation);
            }
Exemplo n.º 10
0
 public static void RemoveSubscriptionShellExposure(SubscriptionState subState)
 {
     using (subState.SubscriptionStore.AcquireStoreWriterLock())
     {
         DefinitionIdentity subscriptionId = subState.SubscriptionId;
         bool flag = false;
         ShellExposure.ShellExposureInformation exposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(subscriptionId);
         if (exposureInformation == null)
         {
             flag = true;
         }
         else
         {
             for (int index = 1; index <= 2; ++index)
             {
                 try
                 {
                     ShellExposure.RemoveShortcuts(exposureInformation);
                     break;
                 }
                 catch (DeploymentException ex)
                 {
                     Logger.AddInternalState("Remove shortcut entries Failed: " + exposureInformation.ApplicationShortcutPath + "," + exposureInformation.SupportShortcutPath + "," + exposureInformation.DesktopShortcutPath + "," + exposureInformation.ApplicationFolderPath + "," + exposureInformation.ApplicationRootFolderPath);
                     if (index < 2)
                     {
                         Thread.Sleep(1000);
                     }
                     else if (!(ex.InnerException is UnauthorizedAccessException))
                     {
                         throw;
                     }
                 }
             }
         }
         ShellExposure.RemoveArpEntry(subscriptionId);
         if (flag)
         {
             throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_ShortcutRemovalFailureDueToInvalidPublisherProduct"));
         }
     }
 }
Exemplo n.º 11
0
        public static void UpdateShellExtensions(SubscriptionState subState, ref ShellExposure.ShellExposureInformation shellExposureInformation)
        {
            string productName = (string)null;

            if (shellExposureInformation != null)
            {
                productName = shellExposureInformation.AppProduct;
            }
            if (productName == null)
            {
                productName = subState.SubscriptionId.Name;
            }
            if (subState.PreviousBind != null)
            {
                Logger.AddInternalState("Removing file associations if existed for the previous version.");
                ShellExposure.RemoveShellExtensions(subState.SubscriptionId, subState.PreviousApplicationManifest, productName);
            }
            Logger.AddInternalState("Registering file associations if there is any in the manifest for the new version. ");
            ShellExposure.AddShellExtensions(subState.SubscriptionId, subState.DeploymentProviderUri, subState.CurrentApplicationManifest);
            NativeMethods.SHChangeNotify(134217728, 0U, IntPtr.Zero, IntPtr.Zero);
        }
Exemplo n.º 12
0
 private static void RemoveArpEntry(DefinitionIdentity subId)
 {
     using (RegistryKey registryKey = ShellExposure.UninstallRoot.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", true))
     {
         string subkey = (string)null;
         try
         {
             if (registryKey == null)
             {
                 return;
             }
             subkey = ShellExposure.GenerateArpKeyName(subId);
             registryKey.DeleteSubKeyTree(subkey);
         }
         catch (ArgumentException ex)
         {
             throw new DeploymentException(ExceptionTypes.InvalidARPEntry, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_ArpEntryRemovalFailure"), new object[1]
             {
                 (object)subkey
             }), (Exception)ex);
         }
     }
 }
 public void UninstallSubscription(SubscriptionState subState)
 {
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         this.CheckInstalledAndShellVisible(subState);
         if (subState.CurrentApplicationManifest != null)
         {
             string productName = null;
             if ((subState.CurrentDeploymentManifest != null) && (subState.CurrentDeploymentManifest.Description != null))
             {
                 productName = subState.CurrentDeploymentManifest.Description.Product;
             }
             if (productName == null)
             {
                 productName = subState.SubscriptionId.Name;
             }
             ShellExposure.RemoveShellExtensions(subState.SubscriptionId, subState.CurrentApplicationManifest, productName);
             ShellExposure.RemovePins(subState);
         }
         this._compStore.RemoveSubscription(subState);
         RemoveSubscriptionExposure(subState);
         OnDeploymentRemoved(subState);
     }
 }
 private static void RemoveSubscriptionExposure(SubscriptionState subState)
 {
     ShellExposure.RemoveSubscriptionShellExposure(subState);
 }
 public void CommitApplication(ref SubscriptionState subState, CommitApplicationParams commitParams)
 {
     Logger.AddMethodCall("CommitApplication called.");
     using (this.AcquireSubscriptionWriterLock(subState))
     {
         if (commitParams.CommitDeploy)
         {
             Logger.AddInternalState("Commiting Deployment :  subscription metadata.");
             UriHelper.ValidateSupportedScheme(commitParams.DeploySourceUri);
             this.CheckDeploymentSubscriptionState(subState, commitParams.DeployManifest);
             this.ValidateFileAssoctiation(subState, commitParams);
             if (commitParams.IsUpdate && !commitParams.IsUpdateInPKTGroup)
             {
                 CheckInstalled(subState);
             }
         }
         if (commitParams.CommitApp)
         {
             Logger.AddInternalState("Commiting Application:  application binaries.");
             UriHelper.ValidateSupportedScheme(commitParams.AppSourceUri);
             if (commitParams.AppGroup != null)
             {
                 CheckInstalled(subState);
             }
             this.CheckApplicationPayload(commitParams);
         }
         bool      flag = false;
         bool      identityGroupFound       = false;
         bool      locationGroupFound       = false;
         string    identityGroupProductName = "";
         ArrayList list = this._compStore.CollectCrossGroupApplications(commitParams.DeploySourceUri, commitParams.DeployManifest.Identity, ref identityGroupFound, ref locationGroupFound, ref identityGroupProductName);
         if (list.Count > 0)
         {
             flag = true;
             Logger.AddInternalState("This installation is a Cross Group: identityGroupFound=" + identityGroupFound.ToString() + ",locationGroupFound=" + locationGroupFound.ToString());
         }
         if ((subState.IsShellVisible && identityGroupFound) && locationGroupFound)
         {
             throw new DeploymentException(ExceptionTypes.GroupMultipleMatch, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_GroupMultipleMatch"), new object[] { identityGroupProductName }));
         }
         subState = this.GetSubscriptionState(commitParams.DeployManifest);
         this._compStore.CommitApplication(subState, commitParams);
         if (flag)
         {
             uint num;
             Logger.AddInternalState("Performing cross group migration.");
             System.Deployment.Internal.Isolation.IActContext context = System.Deployment.Internal.Isolation.IsolationInterop.CreateActContext(subState.CurrentBind.ComPointer);
             context.PrepareForExecution(IntPtr.Zero, IntPtr.Zero);
             context.SetApplicationRunningState(0, 1, out num);
             context.SetApplicationRunningState(0, 2, out num);
             Logger.AddInternalState("Uninstalling all cross groups.");
             foreach (ComponentStore.CrossGroupApplicationData data in list)
             {
                 if (data.CrossGroupType == ComponentStore.CrossGroupApplicationData.GroupType.LocationGroup)
                 {
                     if (data.SubState.appType == AppType.CustomHostSpecified)
                     {
                         Logger.AddInternalState("UninstallCustomHostSpecifiedSubscription : " + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallCustomHostSpecifiedSubscription(data.SubState);
                     }
                     else if (data.SubState.appType == AppType.CustomUX)
                     {
                         Logger.AddInternalState("UninstallCustomUXSubscription : " + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallCustomUXSubscription(data.SubState);
                     }
                     else if (data.SubState.IsShellVisible)
                     {
                         Logger.AddInternalState("UninstallSubscription : " + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null"));
                         this.UninstallSubscription(data.SubState);
                     }
                 }
                 else if (data.CrossGroupType == ComponentStore.CrossGroupApplicationData.GroupType.IdentityGroup)
                 {
                     Logger.AddInternalState("Not uninstalled :" + ((data.SubState.SubscriptionId != null) ? data.SubState.SubscriptionId.ToString() : "null") + ". It is in the identity group.");
                 }
             }
         }
         if ((commitParams.IsConfirmed && subState.IsInstalled) && (subState.IsShellVisible && (commitParams.appType != AppType.CustomUX)))
         {
             this.UpdateSubscriptionExposure(subState);
         }
         if (commitParams.appType == AppType.CustomUX)
         {
             ShellExposure.ShellExposureInformation shellExposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(subState.SubscriptionId);
             ShellExposure.UpdateShellExtensions(subState, ref shellExposureInformation);
         }
         OnDeploymentAdded(subState);
     }
 }
Exemplo n.º 16
0
        private void MaintainSubscriptionInternal(string textualSubId)
        {
            bool flag1 = false;

            string[] strArray = new string[4]
            {
                "Maintain_Exception",
                "Maintain_Completed",
                "Maintain_Failed",
                "Maintain_FailedMsg"
            };
            bool      flag2          = false;
            Exception exception      = (Exception)null;
            bool      flag3          = false;
            string    linkUrlMessage = Resources.GetString("ErrorMessage_GenericLinkUrlMessage");
            string    linkUrl        = (string)null;
            string    str            = (string)null;

            Logger.StartCurrentThreadLogging();
            Logger.SetTextualSubscriptionIdentity(textualSubId);
            using (UserInterface userInterface = new UserInterface())
            {
                MaintenanceInfo maintenanceInfo = new MaintenanceInfo();
                try
                {
                    UserInterfaceInfo info = new UserInterfaceInfo();
                    Logger.AddPhaseInformation(Resources.GetString("PhaseLog_StoreQueryForMaintenanceInfo"));
                    SubscriptionState subscriptionState = this.GetSubscriptionState(textualSubId);
                    bool flag4;
                    try
                    {
                        subscriptionState.SubscriptionStore.CheckInstalledAndShellVisible(subscriptionState);
                        if (subscriptionState.RollbackDeployment == null)
                        {
                            maintenanceInfo.maintenanceFlags |= MaintenanceFlags.RemoveSelected;
                        }
                        else
                        {
                            maintenanceInfo.maintenanceFlags |= MaintenanceFlags.RestorationPossible;
                            maintenanceInfo.maintenanceFlags |= MaintenanceFlags.RestoreSelected;
                        }
                        AssemblyManifest deploymentManifest = subscriptionState.CurrentDeploymentManifest;
                        if (deploymentManifest != null && deploymentManifest.Description != null)
                        {
                            str = deploymentManifest.Description.ErrorReportUrl;
                        }
                        Description effectiveDescription = subscriptionState.EffectiveDescription;
                        info.productName = effectiveDescription.Product;
                        info.supportUrl  = effectiveDescription.SupportUrl;
                        info.formTitle   = string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("UI_MaintenanceTitle"), new object[1]
                        {
                            (object)info.productName
                        });
                        flag4 = true;
                    }
                    catch (DeploymentException ex)
                    {
                        flag4 = false;
                        Logger.AddErrorInformation(Resources.GetString("MaintainLogMsg_FailedStoreLookup"), (Exception)ex);
                        maintenanceInfo.maintenanceFlags |= MaintenanceFlags.RemoveSelected;
                    }
                    catch (FormatException ex)
                    {
                        flag4 = false;
                        Logger.AddErrorInformation(Resources.GetString("MaintainLogMsg_FailedStoreLookup"), (Exception)ex);
                        maintenanceInfo.maintenanceFlags |= MaintenanceFlags.RemoveSelected;
                    }
                    bool flag5 = false;
                    if (flag4)
                    {
                        if (userInterface.ShowMaintenance(info, maintenanceInfo) == UserInterfaceModalResult.Ok)
                        {
                            flag5 = true;
                        }
                    }
                    else
                    {
                        maintenanceInfo.maintenanceFlags = MaintenanceFlags.RemoveSelected;
                        flag5 = true;
                    }
                    if (!flag5)
                    {
                        return;
                    }
                    flag2 = true;
                    if ((maintenanceInfo.maintenanceFlags & MaintenanceFlags.RestoreSelected) != MaintenanceFlags.ClearFlag)
                    {
                        strArray = new string[4]
                        {
                            "Rollback_Exception",
                            "Rollback_Completed",
                            "Rollback_Failed",
                            "Rollback_FailedMsg"
                        };
                        subscriptionState.SubscriptionStore.RollbackSubscription(subscriptionState);
                        flag2 = false;
                        userInterface.ShowMessage(Resources.GetString("UI_RollbackCompletedMsg"), Resources.GetString("UI_RollbackCompletedTitle"));
                    }
                    else if ((maintenanceInfo.maintenanceFlags & MaintenanceFlags.RemoveSelected) != MaintenanceFlags.ClearFlag)
                    {
                        strArray = new string[4]
                        {
                            "Uninstall_Exception",
                            "Uninstall_Completed",
                            "Uninstall_Failed",
                            "Uninstall_FailedMsg"
                        };
                        try
                        {
                            subscriptionState.SubscriptionStore.UninstallSubscription(subscriptionState);
                            flag2 = false;
                        }
                        catch (DeploymentException ex)
                        {
                            Logger.AddErrorInformation(Resources.GetString("MaintainLogMsg_UninstallFailed"), (Exception)ex);
                            flag3 = true;
                            ShellExposure.RemoveSubscriptionShellExposure(subscriptionState);
                            flag3 = false;
                        }
                    }
                    flag1 = true;
                }
                catch (DeploymentException ex)
                {
                    Logger.AddErrorInformation((Exception)ex, Resources.GetString(strArray[0]), new object[1]
                    {
                        (object)textualSubId
                    });
                    exception = (Exception)ex;
                }
                finally
                {
                    Logger.AddPhaseInformation(Resources.GetString(flag1 ? strArray[1] : strArray[2]), new object[1]
                    {
                        (object)textualSubId
                    });
                    if ((uint)(maintenanceInfo.maintenanceFlags & MaintenanceFlags.RestoreSelected) > 0U & flag2 || (maintenanceInfo.maintenanceFlags & MaintenanceFlags.RemoveSelected) != MaintenanceFlags.ClearFlag && flag3 & flag2)
                    {
                        string logFileLocation = Logger.GetLogFilePath();
                        if (!Logger.FlushCurrentThreadLogs())
                        {
                            logFileLocation = (string)null;
                        }
                        if (str != null && exception != null)
                        {
                            Exception innerMostException = this.GetInnerMostException(exception);
                            linkUrl = string.Format("{0}?outer={1}&&inner={2}&&msg={3}", new object[4]
                            {
                                (object)str,
                                (object)exception.GetType().ToString(),
                                (object)innerMostException.GetType().ToString(),
                                (object)innerMostException.Message
                            });
                            if (linkUrl.Length > 2048)
                            {
                                linkUrl = linkUrl.Substring(0, 2048);
                            }
                        }
                        userInterface.ShowError(Resources.GetString("UI_MaintenceErrorTitle"), Resources.GetString(strArray[3]), logFileLocation, linkUrl, linkUrlMessage);
                    }
                    Logger.EndCurrentThreadLogging();
                }
            }
        }
Exemplo n.º 17
0
            public static ShellExposure.ShellExposureInformation CreateShellExposureInformation(DefinitionIdentity subscriptionIdentity)
            {
                ShellExposure.ShellExposureInformation information = null;
                string str  = null;
                string str2 = null;
                string str3 = null;
                string str4 = null;
                string str5 = "";

                using (RegistryKey key = ShellExposure.UninstallRoot.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
                {
                    if (key != null)
                    {
                        using (RegistryKey key2 = key.OpenSubKey(ShellExposure.GenerateArpKeyName(subscriptionIdentity)))
                        {
                            if (key2 != null)
                            {
                                str  = key2.GetValue("ShortcutFolderName") as string;
                                str2 = key2.GetValue("ShortcutFileName") as string;
                                if (key2.GetValue("ShortcutSuiteName") != null)
                                {
                                    str3 = key2.GetValue("ShortcutSuiteName") as string;
                                }
                                else
                                {
                                    str3 = "";
                                }
                                str4 = key2.GetValue("SupportShortcutFileName") as string;
                                if (key2.GetValue("ShortcutAppId") != null)
                                {
                                    str5 = key2.GetValue("ShortcutAppId") as string;
                                }
                                else
                                {
                                    str5 = "";
                                }
                            }
                        }
                    }
                }
                if (((str != null) && (str2 != null)) && (str4 != null))
                {
                    information = new ShellExposure.ShellExposureInformation {
                        _applicationRootFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), str)
                    };
                    if (string.IsNullOrEmpty(str3))
                    {
                        information._applicationFolderPath = information._applicationRootFolderPath;
                    }
                    else
                    {
                        information._applicationFolderPath = Path.Combine(information._applicationRootFolderPath, str3);
                    }
                    information._applicationShortcutPath = Path.Combine(information._applicationFolderPath, str2 + ".appref-ms");
                    information._supportShortcutPath     = Path.Combine(information._applicationFolderPath, str4 + ".url");
                    information._desktopShortcutPath     = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), str2 + ".appref-ms");
                    information._appVendor          = str;
                    information._appProduct         = str2;
                    information._appSupportShortcut = str4;
                    information._shortcutAppId      = str5;
                    information._appSuiteName       = str3;
                }
                return(information);
            }
Exemplo n.º 18
0
        private static void UpdateArpEntry(SubscriptionState subState, ShellExposure.ShellExposureInformation shellExposureInformation)
        {
            DefinitionIdentity subscriptionId = subState.SubscriptionId;
            string             str1           = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "rundll32.exe dfshim.dll,ShArpMaintain {0}", new object[1]
            {
                (object)subscriptionId.ToString()
            });
            string           str2 = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "dfshim.dll,2", new object[0]);
            AssemblyManifest deploymentManifest   = subState.CurrentDeploymentManifest;
            Description      effectiveDescription = subState.EffectiveDescription;

            using (RegistryKey subKey1 = ShellExposure.UninstallRoot.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"))
            {
                using (RegistryKey subKey2 = subKey1.CreateSubKey(ShellExposure.GenerateArpKeyName(subscriptionId)))
                {
                    string[] strArray = new string[24]
                    {
                        "DisplayName",
                        shellExposureInformation.ARPDisplayName,
                        "DisplayIcon",
                        str2,
                        "DisplayVersion",
                        deploymentManifest.Identity.Version.ToString(),
                        "Publisher",
                        effectiveDescription.FilteredPublisher,
                        "UninstallString",
                        str1,
                        "HelpLink",
                        effectiveDescription.SupportUrl,
                        "UrlUpdateInfo",
                        subState.DeploymentProviderUri.AbsoluteUri,
                        "ShortcutFolderName",
                        shellExposureInformation.AppVendor,
                        "ShortcutFileName",
                        shellExposureInformation.AppProduct,
                        "ShortcutSuiteName",
                        shellExposureInformation.AppSuiteName,
                        "SupportShortcutFileName",
                        shellExposureInformation.AppSupportShortcut,
                        "ShortcutAppId",
                        shellExposureInformation.ShortcutAppId
                    };
                    Logger.AddInternalState("Updating ARP entry.");
                    int index = strArray.Length - 2;
                    while (index >= 0)
                    {
                        string name = strArray[index];
                        string str3 = strArray[index + 1];
                        if (str3 != null)
                        {
                            subKey2.SetValue(name, (object)str3);
                        }
                        else
                        {
                            subKey2.DeleteValue(name, false);
                        }
                        index -= 2;
                    }
                }
            }
        }
 private void UpdateSubscriptionExposure(SubscriptionState subState)
 {
     this.CheckInstalledAndShellVisible(subState);
     ShellExposure.UpdateSubscriptionShellExposure(subState);
 }
Exemplo n.º 20
0
        private static void UpdateShortcuts(SubscriptionState subState, ref ShellExposure.ShellExposureInformation shellExposureInformation)
        {
            string      str = string.Format("{0}#{1}", (object)subState.DeploymentProviderUri.AbsoluteUri, (object)subState.SubscriptionId.ToString());
            Description effectiveDescription = subState.EffectiveDescription;

            if (shellExposureInformation != null)
            {
                bool flag1 = true;
                bool flag2 = true;
                bool flag3 = true;
                bool flag4 = true;
                if (string.Compare(effectiveDescription.FilteredPublisher, shellExposureInformation.AppVendor, StringComparison.Ordinal) == 0)
                {
                    flag1 = false;
                    if (Utilities.CompareWithNullEqEmpty(effectiveDescription.FilteredSuiteName, shellExposureInformation.AppSuiteName, StringComparison.Ordinal) == 0)
                    {
                        flag2 = false;
                        if (string.Compare(effectiveDescription.FilteredProduct, shellExposureInformation.AppProduct, StringComparison.Ordinal) == 0)
                        {
                            flag3 = false;
                            if (string.Compare(str, shellExposureInformation.ShortcutAppId, StringComparison.Ordinal) == 0)
                            {
                                flag4 = false;
                            }
                        }
                    }
                }
                if (!flag1 && !flag2 && (!flag3 && !flag4) && System.IO.File.Exists(shellExposureInformation.ApplicationShortcutPath))
                {
                    Logger.AddInternalState("Shortcut folder and files are not updated and application shortcut file already exists: " + shellExposureInformation.ApplicationShortcutPath);
                    return;
                }
                if (flag3)
                {
                    ShellExposure.UnpinShortcut(shellExposureInformation.ApplicationShortcutPath);
                    ShellExposure.MoveDeleteFile(shellExposureInformation.ApplicationShortcutPath);
                    ShellExposure.MoveDeleteFile(shellExposureInformation.SupportShortcutPath);
                    ShellExposure.MoveDeleteFile(shellExposureInformation.DesktopShortcutPath);
                    Logger.AddInternalState("Shortcut files deleted:" + shellExposureInformation.ApplicationShortcutPath + "," + shellExposureInformation.SupportShortcutPath + "," + shellExposureInformation.DesktopShortcutPath);
                }
                if (flag2)
                {
                    Logger.AddInternalState("Attempt deleting shortcut folder:" + shellExposureInformation.ApplicationFolderPath);
                    ShellExposure.MoveDeleteEmptyFolder(shellExposureInformation.ApplicationFolderPath);
                }
                if (flag1)
                {
                    Logger.AddInternalState("Attempt deleting shortcut root folder:" + shellExposureInformation.ApplicationRootFolderPath);
                    ShellExposure.MoveDeleteEmptyFolder(shellExposureInformation.ApplicationRootFolderPath);
                }
                if (flag1 | flag2 | flag3)
                {
                    shellExposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, str);
                }
                else
                {
                    Logger.AddInternalState("Shortcut app id has changed. Old value=" + shellExposureInformation.ShortcutAppId + ",New value=" + str);
                    shellExposureInformation.ShortcutAppId = str;
                }
            }
            else
            {
                shellExposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, str);
            }
            try
            {
                Logger.AddInternalState("Create the shortcut directory : " + shellExposureInformation.ApplicationFolderPath);
                Directory.CreateDirectory(shellExposureInformation.ApplicationFolderPath);
                ShellExposure.GenerateAppShortcut(subState, shellExposureInformation);
                ShellExposure.GenerateSupportShortcut(subState, shellExposureInformation);
            }
            catch (Exception ex)
            {
                ShellExposure.RemoveShortcuts(shellExposureInformation);
                throw;
            }
        }