示例#1
0
        private void Window_Initialized(object sender, EventArgs e)
        {
            Log.InfoFormat("SCP Driver Installer {0} [Built: {1}]", Assembly.GetExecutingAssembly().GetName().Version,
                           AssemblyHelper.LinkerTimestamp);

            _installer             = Difx.Instance;
            _installer.OnLogEvent += Logger;

            var info = OsInfoHelper.OsInfo;

            _valid = OsInfoHelper.OsParse(info);

            Log.InfoFormat("{0} detected", info);

            // get all local USB devices
            foreach (var usbDevice in WdiWrapper.Instance.UsbDeviceList)
            {
                BluetoothStackPanel.Children.Add(new CheckBox
                {
                    Content = usbDevice
                });

                DualShock3StackPanel.Children.Add(new CheckBox
                {
                    Content = usbDevice
                });

                DualShock4StackPanel.Children.Add(new CheckBox
                {
                    Content = usbDevice
                });
            }
        }
        public async Task DownloadAndInstallXbox360DriverAsync()
        {
            var tempPath = Path.Combine(TempPathRoot, "XBOX360DRV");

            //const string args = "/install /passive /norestart";

            if (Environment.Is64BitProcess)
            {
                var targetFile = Path.Combine(tempPath, "Xbox360_64Eng.exe");

                switch (OsInfoHelper.OsParse(OsInfoHelper.OsInfo))
                {
                case OsType.Vista:
                    await XboxDrvVistaX64Downloader.DownloadAsync(targetFile);

                    break;

                case OsType.Win7:
                    await XboxDrvWin7X64Downloader.DownloadAsync(targetFile);

                    break;
                }

                await Task.Run(() =>
                {
                    var process = Process.Start(targetFile);
                    if (process != null)
                    {
                        process.WaitForExit();
                    }
                });
            }
            else
            {
                var targetFile = Path.Combine(tempPath, "Xbox360_32Eng.exe");

                switch (OsInfoHelper.OsParse(OsInfoHelper.OsInfo))
                {
                case OsType.Vista:
                    await XboxDrvVistaX86Downloader.DownloadAsync(targetFile);

                    break;

                case OsType.Win7:
                    await XboxDrvWin7X86Downloader.DownloadAsync(targetFile);

                    break;
                }

                await Task.Run(() =>
                {
                    var process = Process.Start(targetFile);
                    if (process != null)
                    {
                        process.WaitForExit();
                    }
                });
            }
        }
示例#3
0
        private void ScpForm_Load(object sender, EventArgs e)
        {
            Log.InfoFormat("SCP Driver Installer {0} [{1}]", Application.ProductVersion, DateTime.Now);

            _installer             = Difx.Instance;
            _installer.OnLogEvent += Logger;

            var info = OsInfoHelper.OsInfo;

            _valid = OsInfoHelper.OsParse(info);

            Log.InfoFormat("{0} detected", info);

            if (_valid == OsType.Invalid)
            {
                btnInstall.Enabled   = false;
                btnUninstall.Enabled = false;

                Log.Error("Could not find a valid configuration");
            }
            else
            {
                btnInstall.Enabled   = true;
                btnUninstall.Enabled = true;

                Log.InfoFormat("Selected {0} configuration", _valid);
            }

            Icon = Resources.Scp_All;

            if (!OsInfoHelper.IsVc2013Installed)
            {
                MessageBox.Show(Resources.ScpForm_VcppMissingText, Resources.ScpForm_VcppMissingHead,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }
        }
示例#4
0
        private async void ViewModelOnInstallButtonClicked(object sender, EventArgs eventArgs)
        {
            #region Pre-Installation

            _saved = Cursor;
            Cursor = Cursors.Wait;
            InstallGrid.IsEnabled           = !InstallGrid.IsEnabled;
            MainProgressBar.IsIndeterminate = !MainProgressBar.IsIndeterminate;

            #endregion

            #region Driver Installation

            await Task.Run(() =>
            {
                string devPath   = string.Empty, instanceId = string.Empty;
                var forceInstall = _viewModel.ForceDriverInstallation;

                try
                {
                    uint result = 0;

                    var flags = DifxFlags.DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT;

                    if (forceInstall)
                    {
                        flags |= DifxFlags.DRIVER_PACKAGE_FORCE;
                    }

                    var rebootRequired = false;
                    var busInfPath     = Path.Combine(GlobalConfiguration.AppDirectory,
                                                      "System", "ScpVBus.inf");
                    Log.DebugFormat("ScpVBus.inf path: {0}", busInfPath);

                    // check for existance of Scp VBus
                    if (!Devcon.Find(Settings.Default.VirtualBusClassGuid, ref devPath, ref instanceId))
                    {
                        // if not detected, install Inf-file in Windows Driver Store
                        if (Devcon.Install(busInfPath, ref rebootRequired))
                        {
                            Log.Info("Virtual Bus Driver pre-installed in Windows Driver Store successfully");

                            if (Devcon.Create("System", new Guid("{4D36E97D-E325-11CE-BFC1-08002BE10318}"),
                                              "root\\ScpVBus\0\0"))
                            {
                                Logger(DifxLog.DIFXAPI_SUCCESS, 0, "Virtual Bus Created");
                                _busDeviceConfigured = true;
                            }
                            else
                            {
                                Log.Fatal("Virtual Bus Device creation failed");
                                return;
                            }
                        }
                        else
                        {
                            Log.FatalFormat("Virtual Bus Driver pre-installation failed with Win32 error {0}",
                                            (uint)Marshal.GetLastWin32Error());
                            return;
                        }
                    }

                    // install Virtual Bus driver
                    result = _installer.Install(busInfPath, flags,
                                                out rebootRequired);

                    _reboot |= rebootRequired;
                    if (result == 0)
                    {
                        _busDriverConfigured = true;
                    }

                    // install Xbox 360 driver if requested (Vista/7 only)
                    if (_viewModel.IsXbox360DriverNeeded && _viewModel.InstallXbox360Driver)
                    {
                        string driverPath = string.Empty, os = OsInfoHelper.OsInfo;

                        switch (OsInfoHelper.OsParse(os))
                        {
                        case OsType.Vista:
                            driverPath = Path.Combine(GlobalConfiguration.AppDirectory,
                                                      @"Xbox360\driver\vista_xp\xusb21.inf");
                            break;

                        case OsType.Win7:
                            driverPath = Path.Combine(GlobalConfiguration.AppDirectory,
                                                      @"Xbox360\driver\win7\xusb21.inf");
                            break;

                        default:
                            Log.WarnFormat(
                                "Microsoft Xbox 360 controller driver installation for unknown OS requested, won't install driver");
                            break;
                        }

                        if (driverPath != string.Empty)
                        {
                            Log.DebugFormat("{0} detected, {1} driver selected", os, driverPath);
                            Log.InfoFormat("Installing Microsoft Xbox 360 controller driver in Windows Driver Store");

                            if (Devcon.Install(driverPath, ref rebootRequired))
                            {
                                Log.Info("Successfully installed Microsoft Xbox 360 controller driver");
                            }
                            else
                            {
                                Log.ErrorFormat("Couldn't install Microsoft Xbox 360 controller drivers [{0}]",
                                                driverPath);
                            }
                        }
                    }

                    if (_viewModel.InstallWindowsService)
                    {
                        IDictionary state = new Hashtable();
                        var service       =
                            new AssemblyInstaller(Path.Combine(GlobalConfiguration.AppDirectory, "ScpService.exe"), null);

                        state.Clear();
                        service.UseNewContext = true;

                        service.Install(state);
                        service.Commit(state);

                        if (StartService(Settings.Default.ScpServiceName))
                        {
                            Logger(DifxLog.DIFXAPI_INFO, 0, Settings.Default.ScpServiceName + " Started.");
                        }
                        else
                        {
                            _reboot = true;
                        }

                        _scpServiceConfigured = true;
                    }
                }
                catch (Win32Exception w32Ex)
                {
                    switch (w32Ex.NativeErrorCode)
                    {
                    case 1073:     // ERROR_SERVICE_EXISTS
                        Log.Info("Service already exists, attempting to restart...");

                        StopService(Settings.Default.ScpServiceName);
                        Log.Info("Service stopped successfully");

                        StartService(Settings.Default.ScpServiceName);
                        Log.Info("Service started successfully");
                        break;

                    default:
                        Log.ErrorFormat("Win32-Error during installation: {0}", w32Ex);
                        break;
                    }
                }
                catch (InvalidOperationException iopex)
                {
                    Log.ErrorFormat("Error during installation: {0}", iopex.Message);
                }
                catch (Exception ex)
                {
                    Log.ErrorFormat("Error during installation: {0}", ex);
                }
            });

            #endregion

            #region Post-Installation

            MainProgressBar.IsIndeterminate = !MainProgressBar.IsIndeterminate;
            InstallGrid.IsEnabled           = !InstallGrid.IsEnabled;
            Cursor = _saved;

            if (_reboot)
            {
                Log.InfoFormat("[Reboot Required]");
            }

            if (_scpServiceConfigured)
            {
                Log.Info("SCP DSx Service installed");
            }

            if (_busDeviceConfigured)
            {
                Log.Info("Bus Device installed");
            }

            if (_busDriverConfigured)
            {
                Log.Info("Bus Driver installed");
            }

            if (_ds3DriverConfigured)
            {
                Log.Info("DualShock 3 USB Driver installed");
            }

            if (_bthDriverConfigured)
            {
                Log.Info("Bluetooth Driver installed");
            }

            if (_ds4DriverConfigured)
            {
                Log.Info("DualShock 4 USB Driver installed");
            }

            #endregion
        }