Example #1
0
        protected void UninstallWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            String InfPath = (String)e.Argument;
            String DevPath = String.Empty, InstanceId = String.Empty;

            try
            {
                UInt32  Result         = 0;
                Boolean RebootRequired = false;

                if (cbService.Checked)
                {
                    IDictionary       State   = new Hashtable();
                    AssemblyInstaller Service = new AssemblyInstaller(Directory.GetCurrentDirectory() + @"\ScpService.exe", null);

                    State.Clear(); Service.UseNewContext = true;

                    if (Stop(ScpService))
                    {
                        Logger(DifxLog.DIFXAPI_INFO, 0, ScpService + " Stopped.");
                    }

                    try
                    {
                        Service.Uninstall(State);
                        Scp_Service_Configured = true;
                    }
                    catch { }
                }

                if (cbBluetooth.Checked)
                {
                    Result = Installer.Uninstall(InfPath + @"BthWinUsb.inf", DifxFlags.DRIVER_PACKAGE_DELETE_FILES, out RebootRequired); Reboot |= RebootRequired;
                    if (Result == 0)
                    {
                        BTH_Driver_Configured = true;
                    }
                }

                Result = Installer.Uninstall(InfPath + @"Ds3WinUsb.inf", DifxFlags.DRIVER_PACKAGE_DELETE_FILES, out RebootRequired); Reboot |= RebootRequired;
                if (Result == 0)
                {
                    DS3_Driver_Configured = true;
                }

                if (cbService.Checked && Devcon.Find(new Guid(DS3_BUS_CLASS_GUID), ref DevPath, ref InstanceId))
                {
                    if (Devcon.Remove(new Guid(DS3_BUS_CLASS_GUID), DevPath, InstanceId))
                    {
                        Logger(DifxLog.DIFXAPI_SUCCESS, 0, "Virtual Bus Removed");
                        Bus_Device_Configured = true;
                    }
                    else
                    {
                        Logger(DifxLog.DIFXAPI_ERROR, 0, "Virtual Bus Removal Failure");
                    }
                }
            }
            catch { }
        }
Example #2
0
        protected void InstallWorker_DoWork(object sender, DoWorkEventArgs e) 
        {
            String InfPath = (String) e.Argument;
            String DevPath = String.Empty, InstanceId = String.Empty;

            try
            {
                UInt32  Result = 0;
                Boolean RebootRequired = false;

                DifxFlags Flags = DifxFlags.DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT;

                if (cbForce.Checked) Flags |= DifxFlags.DRIVER_PACKAGE_FORCE;

                if (cbBus.Checked)
                {
                    if (!Devcon.Find(new Guid(DS3_BUS_CLASS_GUID), ref DevPath, ref InstanceId))
                    {
                        if (Devcon.Create("System", new Guid("{4D36E97D-E325-11CE-BFC1-08002BE10318}"), "root\\ScpVBus\0\0"))
                        {
                            Logger(DifxLog.DIFXAPI_SUCCESS, 0, "Virtual Bus Created");
                            Bus_Device_Configured = true;
                        }
                    }

                    Result = Installer.Install(InfPath + @"ScpVBus.inf", Flags, out RebootRequired); Reboot |= RebootRequired;
                    if (Result == 0) Bus_Driver_Configured = true;
                }

                if (cbBluetooth.Checked)
                {
                    Result = Installer.Install(InfPath + @"BthWinUsb.inf", Flags, out RebootRequired); Reboot |= RebootRequired;
                    if (Result == 0) BTH_Driver_Configured = true;
                }


                if (cbDS3.Checked)
                {
                    Result = Installer.Install(InfPath + @"Ds3WinUsb.inf", Flags, out RebootRequired); Reboot |= RebootRequired;
                    if (Result == 0) DS3_Driver_Configured = true;
                }

                if (cbService.Checked)
                {
                    IDictionary       State = new Hashtable();
                    AssemblyInstaller Service = new AssemblyInstaller(Directory.GetCurrentDirectory() + @"\ScpService.exe", null);

                    State.Clear(); Service.UseNewContext = true;

                    Service.Install(State);
                    Service.Commit (State);

                    if (Start(ScpService)) Logger(DifxLog.DIFXAPI_INFO, 0, ScpService + " Started.");
                    else Reboot = true;

                    Scp_Service_Configured = true;
                }
            }
            catch { }
        }
Example #3
0
        private async void btnUninstall_Click(object sender, EventArgs e)
        {
            #region Pre-Uninstallation

            _saved = Cursor;
            Cursor = Cursors.WaitCursor;

            btnInstall.Enabled   = false;
            btnUninstall.Enabled = false;
            btnExit.Enabled      = false;

            _busDeviceConfigured  = false;
            _busDriverConfigured  = false;
            _ds3DriverConfigured  = false;
            _bthDriverConfigured  = false;
            _scpServiceConfigured = false;

            pbRunning.Style = ProgressBarStyle.Marquee;

            #endregion

            #region Uninstallation

            await Task.Run(() =>
            {
                string devPath = string.Empty, instanceId = string.Empty;

                try
                {
                    uint result         = 0;
                    bool rebootRequired = false;

                    if (cbService.Checked)
                    {
                        IDictionary state = new Hashtable();
                        var service       =
                            new AssemblyInstaller(Directory.GetCurrentDirectory() + @"\ScpService.exe", null);

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

                        if (Stop(Settings.Default.ScpServiceName))
                        {
                            Logger(DifxLog.DIFXAPI_INFO, 0, Settings.Default.ScpServiceName + " Stopped.");
                        }

                        service.Uninstall(state);
                        _scpServiceConfigured = true;
                    }

                    if (cbBluetooth.Checked)
                    {
                        DriverInstaller.UninstallBluetoothDongles(ref rebootRequired);
                        _reboot |= rebootRequired;
                    }

                    if (cbDS3.Checked)
                    {
                        DriverInstaller.UninstallDualShock3Controllers(ref rebootRequired);
                        _reboot |= rebootRequired;
                    }

                    if (cbDs4.Checked)
                    {
                        DriverInstaller.UninstallDualShock4Controllers(ref rebootRequired);
                        _reboot |= rebootRequired;
                    }

                    if (cbBus.Checked && Devcon.Find(Settings.Default.Ds3BusClassGuid, ref devPath, ref instanceId))
                    {
                        if (Devcon.Remove(Settings.Default.Ds3BusClassGuid, devPath, instanceId))
                        {
                            Logger(DifxLog.DIFXAPI_SUCCESS, 0, "Virtual Bus Removed");
                            _busDeviceConfigured = true;

                            _installer.Uninstall(Path.Combine(Settings.Default.InfFilePath, @"ScpVBus.inf"),
                                                 DifxFlags.DRIVER_PACKAGE_DELETE_FILES,
                                                 out rebootRequired);
                            _reboot |= rebootRequired;
                        }
                        else
                        {
                            Logger(DifxLog.DIFXAPI_ERROR, 0, "Virtual Bus Removal Failure");
                        }
                    }
                }
                catch (InstallException instex)
                {
                    if (!(instex.InnerException is Win32Exception))
                    {
                        Log.ErrorFormat("Error during uninstallation: {0}", instex);
                        return;
                    }

                    switch (((Win32Exception)instex.InnerException).NativeErrorCode)
                    {
                    case 1060:     // ERROR_SERVICE_DOES_NOT_EXIST
                        Log.Warn("Service doesn't exist, maybe it was uninstalled before");
                        break;

                    default:
                        Log.ErrorFormat("Win32-Error during uninstallation: {0}", (Win32Exception)instex.InnerException);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Log.ErrorFormat("Error during uninstallation: {0}", ex);
                }
            });

            #endregion

            #region Post-Uninstallation

            pbRunning.Style = ProgressBarStyle.Continuous;

            btnInstall.Enabled   = true;
            btnUninstall.Enabled = true;
            btnExit.Enabled      = true;

            Cursor = _saved;

            Log.Info("Uninstall Succeeded.");
            if (_reboot)
            {
                Log.Info(" [Reboot Required]");
            }

            Log.Info("-- Uninstall Summary --");

            if (_scpServiceConfigured)
            {
                Log.Info("SCP DS3 Service uninstalled");
            }

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

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

            if (_ds3DriverConfigured)
            {
                Log.Info("DS3 USB Driver uninstalled");
            }

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

            #endregion
        }
Example #4
0
        private async void btnInstall_Click(object sender, EventArgs e)
        {
            #region Pre-Installation

            _saved = Cursor;
            Cursor = Cursors.WaitCursor;

            btnInstall.Enabled   = false;
            btnUninstall.Enabled = false;
            btnExit.Enabled      = false;

            _busDeviceConfigured  = false;
            _busDriverConfigured  = false;
            _ds3DriverConfigured  = false;
            _bthDriverConfigured  = false;
            _scpServiceConfigured = false;

            pbRunning.Style = ProgressBarStyle.Marquee;

            #endregion

            #region Installation

            await Task.Run(() =>
            {
                string devPath = string.Empty, instanceId = string.Empty;

                try
                {
                    uint result = 0;
                    bool rebootRequired;

                    var flags = DifxFlags.DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT;

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

                    if (cbBus.Checked)
                    {
                        if (!Devcon.Find(Settings.Default.Ds3BusClassGuid, ref devPath, ref instanceId))
                        {
                            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;
                            }
                        }

                        result = _installer.Install(Path.Combine(Settings.Default.InfFilePath, @"ScpVBus.inf"), flags,
                                                    out rebootRequired);
                        _reboot |= rebootRequired;
                        if (result == 0)
                        {
                            _busDriverConfigured = true;
                        }
                    }

                    if (cbBluetooth.Checked)
                    {
                        result = DriverInstaller.InstallBluetoothDongles(Handle);
                        if (result > 0)
                        {
                            _bthDriverConfigured = true;
                        }
                    }

                    if (cbDS3.Checked)
                    {
                        result = DriverInstaller.InstallDualShock3Controllers(Handle);
                        if (result > 0)
                        {
                            _ds3DriverConfigured = true;
                        }
                    }

                    if (cbDs4.Checked)
                    {
                        result = DriverInstaller.InstallDualShock4Controllers(Handle);
                        if (result > 0)
                        {
                            _ds4DriverConfigured = true;
                        }
                    }

                    if (cbService.Checked)
                    {
                        IDictionary state = new Hashtable();
                        var service       =
                            new AssemblyInstaller(Directory.GetCurrentDirectory() + @"\ScpService.exe", null);

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

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

                        if (Start(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.WarnFormat("Service already exists, skipping installation...");
                        break;

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

            #endregion

            #region Post-Installation

            pbRunning.Style = ProgressBarStyle.Continuous;

            btnInstall.Enabled   = true;
            btnUninstall.Enabled = true;
            btnExit.Enabled      = true;

            Cursor = _saved;

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

            Log.Info("-- Install Summary --");
            if (_scpServiceConfigured)
            {
                Log.Info("SCP DS3 Service installed");
            }

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

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

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

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

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

            #endregion
        }