Esempio n. 1
0
        private void DeleteDriver(ref OperationContext localContext, bool force)
        {
            if (localContext.DriverStoreEntries != null)
            {
                bool          totalResult = true;
                StringBuilder sb          = new StringBuilder();

                if (localContext.DriverStoreEntries.Count == 1)
                {
                    localContext.ResultStatus = driverStore.DeletePackage(localContext.DriverStoreEntries[0], force);
                }
                else
                {
                    foreach (DriverStoreEntry dse in localContext.DriverStoreEntries)
                    {
                        bool   result    = driverStore.DeletePackage(dse, force);
                        string resultTxt = String.Format(
                            "Delete {0} {1}",
                            dse.DriverPublishedName,
                            result ? "succeeded." : "failed.");
                        AppContext.TraceInformation(resultTxt + Environment.NewLine);

                        sb.AppendLine(resultTxt);
                        totalResult &= result;
                    }

                    localContext.ResultStatus = totalResult;
                    localContext.ResultData   = sb.ToString();
                }
            }
        }
Esempio n. 2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            MainButton.IsEnabled = !MainButton.IsEnabled;

            await Task.Run(() =>
            {
                #region Service tasks

                Log.InfoFormat("Stopping \"SCP DS3 Service\"...");
                StopService("SCP DS3 Service");

                Log.InfoFormat("Stopping \"SCP DSx Service\"...");
                StopService("SCP DSx Service");

                Log.InfoFormat("Searching for running processes...");
                foreach (var proc in Process.GetProcessesByName("Ds3Service"))
                {
                    Log.InfoFormat("Killing process: {0}", proc.ProcessName);
                    proc.Kill();
                }

                foreach (var proc in Process.GetProcessesByName("DsxService"))
                {
                    Log.InfoFormat("Killing process: {0}", proc.ProcessName);
                    proc.Kill();
                }

                Log.InfoFormat("Removing service...");
                Process.Start("sc", "delete Ds3Service").WaitForExit();

                Process.Start("sc", "delete DsxService").WaitForExit();

                #endregion

                #region Driver store clean-up

                Log.InfoFormat("Searching the driver store...");
                var storeEntries = DrvStore.EnumeratePackages();

                foreach (var entry in storeEntries.Where(dse => dse.DriverPkgProvider.Equals("Scarlet.Crush Productions")))
                {
                    Log.InfoFormat("Removing package from driver store: {0} by {1}", entry.DriverPublishedName, entry.DriverPkgProvider);
                    DrvStore.DeletePackage(entry, true);
                }

                foreach (var entry in storeEntries.Where(dse => dse.DriverSignerName.Contains("libwdi autogenerated") &&
                                                         dse.DriverPkgProvider.Equals("libusbK")))
                {
                    Log.InfoFormat("Removing package from driver store: {0} by {1}", entry.DriverPublishedName, entry.DriverPkgProvider);
                    DrvStore.DeletePackage(entry, true);
                }

                foreach (var entry in storeEntries.Where(dse => dse.DriverPkgProvider.Contains("MotioninJoy")))
                {
                    Log.InfoFormat("Removing package from driver store: {0} by {1}", entry.DriverPublishedName, entry.DriverPkgProvider);
                    DrvStore.DeletePackage(entry, true);
                }

                #endregion

                #region Driver uninstallation

                string devPath      = string.Empty;
                string instanceId   = string.Empty;
                bool rebootRequired = false;

                DriverInstaller.UninstallBluetoothDongles(ref rebootRequired);

                DriverInstaller.UninstallDualShock3Controllers(ref rebootRequired);

                DriverInstaller.UninstallDualShock4Controllers(ref rebootRequired);

                if (Devcon.Find(Guid.Parse("f679f562-3164-42ce-a4db-e7ddbe723909"), ref devPath, ref instanceId))
                {
                    if (Devcon.Remove(Guid.Parse("f679f562-3164-42ce-a4db-e7ddbe723909"), devPath, instanceId))
                    {
                        Difx.Instance.Uninstall(Path.Combine(@".\System\", @"ScpVBus.inf"),
                                                DifxFlags.DRIVER_PACKAGE_DELETE_FILES,
                                                out rebootRequired);
                    }
                }

                while (Devcon.Find(Guid.Parse("2F87C733-60E0-4355-8515-95D6978418B2"), ref devPath, ref instanceId))
                {
                    Devcon.Remove(Guid.Parse("2F87C733-60E0-4355-8515-95D6978418B2"), devPath, instanceId);
                }

                while (Devcon.Find(Guid.Parse("E2824A09-DBAA-4407-85CA-C8E8FF5F6FFA"), ref devPath, ref instanceId))
                {
                    Devcon.Remove(Guid.Parse("E2824A09-DBAA-4407-85CA-C8E8FF5F6FFA"), devPath, instanceId);
                }

                while (Devcon.Find(Guid.Parse("2ED90CE1-376F-4982-8F7F-E056CBC3CA71"), ref devPath, ref instanceId))
                {
                    Devcon.Remove(Guid.Parse("2ED90CE1-376F-4982-8F7F-E056CBC3CA71"), devPath, instanceId);
                }

                Devcon.Refresh();

                #endregion

                #region Cert store clean-up

                CertStore.Open(OpenFlags.MaxAllowed);

                foreach (var cert in CertStore.Certificates.Cast <X509Certificate2>().Where(c => c.FriendlyName.Contains("libwdi")))
                {
                    Log.InfoFormat("Removing certificate from root certificate store: {0}", cert.SubjectName.Name);
                    CertStore.Remove(cert);
                }

                //Close the store.
                CertStore.Close();

                #endregion
            });

            MainButton.IsEnabled = !MainButton.IsEnabled;

            MessageBox.Show("All steps finished, now try ScpDriverInstaller again! Good luck :)", "Finished",
                            MessageBoxButton.OK, MessageBoxImage.Information);

            Close();
        }