mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:15:15 +00:00
UI: Portable: Reinstall an old driver
This commit is contained in:
parent
afe906b61b
commit
be47b3f6b3
12
src/driver/scripts/check-reinstall.bat
Normal file
12
src/driver/scripts/check-reinstall.bat
Normal file
@ -0,0 +1,12 @@
|
||||
@rem Check existing driver file's timestamp or reinstall it
|
||||
|
||||
@call "%~dp0setup-vars.bat"
|
||||
|
||||
|
||||
@if exist "%DSTPATH%" (
|
||||
xcopy /L /D /Y "%SRCPATH%" "%DSTPATH%" | findstr /B /C:"0 " >NUL && goto EXIT
|
||||
)
|
||||
|
||||
"%~dp0reinstall.bat" %*
|
||||
|
||||
:EXIT
|
@ -1,16 +1,6 @@
|
||||
@rem Install driver
|
||||
|
||||
@set ARCH=x86
|
||||
@if "%PROCESSOR_ARCHITECTURE%" == "AMD64" @set ARCH=x86_64
|
||||
@if "%PROCESSOR_ARCHITECTURE%" == "ARM64" @set ARCH=ARM64
|
||||
|
||||
@set BASENAME=fortfw
|
||||
@set FILENAME=%BASENAME%.sys
|
||||
@set SRCPATH=%~dp0..\%ARCH%\%FILENAME%
|
||||
@set DSTPATH=%SystemRoot%\System32\drivers\%FILENAME%
|
||||
|
||||
@set DRIVERSVC=%BASENAME%
|
||||
@set DISPNAME=Fort Firewall Driver
|
||||
@call "%~dp0setup-vars.bat"
|
||||
|
||||
|
||||
@rem Copy driver to system storage
|
||||
@ -20,7 +10,7 @@
|
||||
@goto EXIT
|
||||
)
|
||||
|
||||
copy "%SRCPATH%" "%DSTPATH%"
|
||||
robocopy "%SRCPATH%" "%DSTPATH%"
|
||||
@if ERRORLEVEL 1 (
|
||||
@echo Error: Cannot copy driver to system
|
||||
@set RCODE=%ERRORLEVEL%
|
||||
|
16
src/driver/scripts/setup-vars.bat
Normal file
16
src/driver/scripts/setup-vars.bat
Normal file
@ -0,0 +1,16 @@
|
||||
@rem Setup variables
|
||||
|
||||
@set ARCH=x86
|
||||
@if "%PROCESSOR_ARCHITECTURE%" == "AMD64" @set ARCH=x86_64
|
||||
@if "%PROCESSOR_ARCHITECTURE%" == "ARM64" @set ARCH=ARM64
|
||||
|
||||
@set BASENAME=fortfw
|
||||
@set FILENAME=%BASENAME%.sys
|
||||
|
||||
@set SRCPATH=%~dp0..\%ARCH%\%FILENAME%
|
||||
@set DSTPATH=%SystemRoot%\System32\drivers\%FILENAME%
|
||||
|
||||
@set DRIVERSVC=%BASENAME%
|
||||
@set DISPNAME=Fort Firewall Driver
|
||||
|
||||
@set FORTSVC=FortFirewallSvc
|
@ -1,10 +1,6 @@
|
||||
@rem Uninstall driver
|
||||
|
||||
@set BASENAME=fortfw
|
||||
@set DSTPATH=%SystemRoot%\System32\drivers\%BASENAME%.sys
|
||||
|
||||
@set DRIVERSVC=%BASENAME%
|
||||
@set FORTSVC=FortFirewallSvc
|
||||
@call "%~dp0setup-vars.bat"
|
||||
|
||||
|
||||
@rem Stop and delete the FortFirewall service
|
||||
|
@ -136,6 +136,11 @@ bool DriverManager::writeData(quint32 code, QByteArray &buf)
|
||||
return res;
|
||||
}
|
||||
|
||||
bool DriverManager::checkReinstallDriver()
|
||||
{
|
||||
return executeCommand("check-reinstall.bat");
|
||||
}
|
||||
|
||||
bool DriverManager::reinstallDriver()
|
||||
{
|
||||
return executeCommand("reinstall.bat");
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
|
||||
void setUp() override;
|
||||
|
||||
bool checkReinstallDriver();
|
||||
bool reinstallDriver();
|
||||
bool uninstallDriver();
|
||||
|
||||
|
@ -178,10 +178,12 @@ void FortManager::initialize()
|
||||
setupTaskManager();
|
||||
setupServiceInfoManager();
|
||||
|
||||
checkReinstallDriver();
|
||||
setupDriver();
|
||||
|
||||
loadConf();
|
||||
|
||||
checkInstallDriver();
|
||||
checkDriverOpened();
|
||||
checkStartService();
|
||||
}
|
||||
|
||||
@ -281,7 +283,7 @@ bool FortManager::installDriver()
|
||||
IoC<DriverManager>()->reinstallDriver();
|
||||
|
||||
if (IoC<FortSettings>()->hasService()) {
|
||||
// Re-install the service and app restart required to continue
|
||||
// Install the service and app restart required to continue
|
||||
StartupUtil::setServiceInstalled(true);
|
||||
processRestartRequired(tr("Driver reinstalled"));
|
||||
} else {
|
||||
@ -332,19 +334,35 @@ void FortManager::closeDriver()
|
||||
QCoreApplication::sendPostedEvents(this);
|
||||
}
|
||||
|
||||
void FortManager::checkInstallDriver()
|
||||
bool FortManager::canInstallDriver() const
|
||||
{
|
||||
auto driverManager = IoC<DriverManager>();
|
||||
|
||||
if (driverManager->isDeviceOpened())
|
||||
return;
|
||||
|
||||
const auto settings = IoC<FortSettings>();
|
||||
|
||||
const bool canInstallDriver = (settings->canInstallDriver() || settings->isPortable());
|
||||
const bool isMasterAdmin = (settings->isMaster() && settings->isUserAdmin());
|
||||
|
||||
if (canInstallDriver && isMasterAdmin) {
|
||||
return (canInstallDriver && isMasterAdmin);
|
||||
}
|
||||
|
||||
void FortManager::checkReinstallDriver()
|
||||
{
|
||||
if (!canInstallDriver())
|
||||
return;
|
||||
|
||||
IoC<DriverManager>()->checkReinstallDriver();
|
||||
|
||||
if (IoC<FortSettings>()->hasService()) {
|
||||
// Install the service
|
||||
StartupUtil::setServiceInstalled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void FortManager::checkDriverOpened()
|
||||
{
|
||||
if (IoC<DriverManager>()->isDeviceOpened())
|
||||
return;
|
||||
|
||||
if (canInstallDriver()) {
|
||||
installDriver();
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,9 @@ private:
|
||||
bool setupDriver();
|
||||
void closeDriver();
|
||||
|
||||
void checkInstallDriver();
|
||||
bool canInstallDriver() const;
|
||||
void checkReinstallDriver();
|
||||
void checkDriverOpened();
|
||||
void checkStartService();
|
||||
|
||||
void setupEnvManager();
|
||||
|
Loading…
Reference in New Issue
Block a user