fort/deploy/FortFirewall.iss

258 lines
8.4 KiB
Plaintext
Raw Normal View History

2017-09-11 10:49:25 +00:00
2023-05-05 18:52:59 +00:00
#define SRC_PATH AddBackslash(SourcePath) + "..\src"
2021-01-03 12:24:56 +00:00
2021-02-08 09:09:22 +00:00
#include SRC_PATH + "\version\fort_version.h"
2017-09-11 10:49:25 +00:00
2021-03-31 12:42:36 +00:00
#define APP_EXE_NAME APP_BASE + ".exe"
#define APP_ICO_NAME APP_BASE + ".ico"
#define APP_SVC_NAME APP_BASE + "Svc"
2017-09-11 10:49:25 +00:00
#define APP_EXE StringChange("{app}\%exe%", "%exe%", APP_EXE_NAME)
2023-05-05 18:52:59 +00:00
#define LANG_PATH AddBackslash(SourcePath) + "languages"
2017-09-11 10:49:25 +00:00
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
2021-04-01 08:50:58 +00:00
SetupMutex=Global\{#APP_BASE}Setup
; TODO: COMPAT: Remove {#APP_NAME} from AppMutex after v4.1.0
AppMutex={#APP_NAME},{#APP_BASE}
2017-09-11 10:49:25 +00:00
AppName={#APP_NAME}
AppVersion={#APP_VERSION_STR}
2019-04-24 17:41:11 +00:00
VersionInfoVersion={#APP_VERSION_STR}
2017-09-11 10:49:25 +00:00
AppVerName={#APP_NAME}
2019-04-24 17:41:11 +00:00
AppCopyright={#APP_LEGALCOPYRIGHT}
2017-09-11 10:49:25 +00:00
AppPublisher={#APP_PUBLISHER}
AppPublisherURL={#APP_URL}
AppSupportURL={#APP_URL}
AppUpdatesURL={#APP_UPDATES_URL}
DefaultGroupName={#APP_NAME}
DefaultDirName={pf}\{#APP_NAME}
2017-09-11 10:49:25 +00:00
AlwaysShowDirOnReadyPage=yes
AlwaysShowGroupOnReadyPage=yes
AllowNoIcons=yes
OutputDir=out
2021-03-31 12:42:36 +00:00
OutputBaseFilename={#APP_BASE}-{#APP_VERSION_STR}
2019-03-10 18:03:59 +00:00
Uninstallable=not IsTaskSelected('portable')
2017-09-11 10:49:25 +00:00
UninstallFilesDir={app}\uninst
2021-01-03 12:24:56 +00:00
UninstallDisplayIcon={uninstallexe}
SetupIconFile={#SRC_PATH}\ui_bin\{#APP_ICO_NAME}
2017-09-11 10:49:25 +00:00
ArchitecturesInstallIn64BitMode=x64
Compression=lzma2/ultra
SolidCompression=yes
[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl,{#LANG_PATH}\Default.isl"
Name: "de"; MessagesFile: "compiler:Languages\German.isl,{#LANG_PATH}\German.isl"
Name: "fr"; MessagesFile: "compiler:Languages\French.isl,{#LANG_PATH}\French.isl"
Name: "it"; MessagesFile: "compiler:Languages\Italian.isl,{#LANG_PATH}\Italian.isl"
Name: "ko"; MessagesFile: "compiler:Languages\Korean.isl,{#LANG_PATH}\Korean.isl"
Name: "pt"; MessagesFile: "compiler:Languages\Portuguese.isl,{#LANG_PATH}\Portuguese.isl"
Name: "pt_BR"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl,{#LANG_PATH}\BrazilianPortuguese.isl"
Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl,{#LANG_PATH}\Russian.isl"
Name: "sl"; MessagesFile: "compiler:Languages\Slovenian.isl,{#LANG_PATH}\Slovenian.isl"
Name: "zh_CN"; MessagesFile: "{#LANG_PATH}\ChineseSimplified.isl"
2017-09-14 04:33:29 +00:00
2019-03-10 18:03:59 +00:00
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"
Name: "explorer"; Description: "{cm:WindowsExplorerIntegration}"
2023-05-07 21:08:42 +00:00
Name: "service"; Description: "{cm:WindowsService}"
Name: "portable"; Description: "{cm:Portable}"; Flags: unchecked
2019-03-10 18:03:59 +00:00
2017-09-11 10:49:25 +00:00
[Files]
2019-04-08 11:39:00 +00:00
Source: "build\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "{#APP_EXE_NAME}.example.ini"; DestDir: "{app}"; Flags: ignoreversion
2017-09-11 10:49:25 +00:00
[Icons]
; Start menu shortcut
Name: "{group}\{#APP_NAME}"; Filename: "{#APP_EXE}"; WorkingDir: "{app}"; \
Parameters: "--lang {code:LanguageName}"
; Uninstaller shortcut
2019-04-11 04:58:43 +00:00
Name: "{group}\{cm:UninstallProgram,{#APP_NAME}}"; Filename: "{uninstallexe}"
; Desktop shortcut
Name: "{commondesktop}\{#APP_NAME}"; Filename: "{#APP_EXE}"; WorkingDir: "{app}"; \
Parameters: "--lang {code:LanguageName}"; Tasks: desktopicon
2017-09-11 10:49:25 +00:00
[Run]
; 1. Uninstall -> 2. Install Driver -> 3. Portable -> 4. Service
2021-05-23 13:44:02 +00:00
Filename: "{#APP_EXE}"; Parameters: "-u"
Filename: "{app}\driver\scripts\reinstall.bat"; Description: "Re-install driver"
Filename: "{#APP_EXE}"; Parameters: "-i portable"; Tasks: portable
Filename: "{#APP_EXE}"; Parameters: "-i service"; Tasks: service
Filename: "{#APP_EXE}"; Parameters: "-i explorer"; Tasks: explorer
Filename: "sc.exe"; Parameters: "start {#APP_SVC_NAME}"; Description: "Start service"; \
Flags: nowait; Tasks: service
Filename: "https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads"; \
Description: "Install the latest Visual C++ x86 redistributable!"; Flags: shellexec postinstall; \
Check: not VCRedist86Exists()
2017-09-11 10:49:25 +00:00
[UninstallRun]
2021-05-23 13:44:02 +00:00
Filename: "{#APP_EXE}"; Parameters: "-u"; RunOnceId: "Uninstall"
Filename: "{app}\driver\scripts\uninstall.bat"; RunOnceId: "UninsDriver"
2017-09-11 10:49:25 +00:00
2018-02-19 15:02:13 +00:00
[InstallDelete]
Type: filesandordirs; Name: "{app}\driver"
Type: filesandordirs; Name: "{app}\i18n"
Type: files; Name: "{app}\README*.*"
2021-09-05 08:38:24 +00:00
; TODO: COMPAT: Remove the following 4 lines after v4.1.0
Type: filesandordirs; Name: "{app}\plugins"
Type: files; Name: "{app}\curl*.*"
Type: files; Name: "{app}\qt*.*"
2021-09-05 08:38:24 +00:00
Type: files; Name: "{app}\ChangeLog"
2018-02-19 15:02:13 +00:00
[Registry]
Root: HKLM; Subkey: "System\CurrentControlSet\Services\EventLog\System\fortfw"; Flags: uninsdeletekey
Root: HKLM; Subkey: "System\CurrentControlSet\Services\EventLog\System\fortfw"; \
ValueType: string; ValueName: "EventMessageFile"; ValueData: "{#APP_EXE}"
Root: HKLM; Subkey: "System\CurrentControlSet\Services\EventLog\System\fortfw"; \
ValueType: dword; ValueName: "TypesSupported"; ValueData: "7"
Root: HKLM; Subkey: "SOFTWARE\{#APP_NAME}"; Flags: dontcreatekey uninsdeletekeyifempty
Root: HKLM; Subkey: "SOFTWARE\{#APP_NAME}"; ValueName: "passwordHash"; Flags: dontcreatekey uninsdeletevalue
[Code]
function LanguageName(Param: String): String;
begin
Result := ActiveLanguage;
end;
function VCRedist86Exists(): Boolean;
begin
Result := FileExists(ExpandConstant('{syswow64}\vcruntime140.dll'));
end;
function HVCIEnabled(): Boolean;
var
EnabledValue: Cardinal;
begin
Result := RegQueryDWordValue(HKEY_LOCAL_MACHINE,
'SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity',
'Enabled', EnabledValue)
and (EnabledValue = 1);
end;
2023-03-10 11:04:49 +00:00
function AskPassword(): String;
var
Form: TSetupForm;
OKButton, CancelButton: TButton;
PwdEdit: TPasswordEdit;
begin
Form := CreateCustomForm();
try
Form.ClientWidth := ScaleX(256);
Form.ClientHeight := ScaleY(100);
Form.Caption := ExpandConstant('{cm:UninstallPassword}');
2023-03-10 11:04:49 +00:00
Form.BorderIcons := [biSystemMenu];
Form.BorderStyle := bsDialog;
Form.Center;
OKButton := TButton.Create(Form);
OKButton.Parent := Form;
OKButton.Width := ScaleX(75);
OKButton.Height := ScaleY(23);
OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 50);
OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
OKButton.Caption := ExpandConstant('{cm:UninstallPasswordOK}');
2023-03-10 11:04:49 +00:00
OKButton.ModalResult := mrOk;
OKButton.Default := true;
CancelButton := TButton.Create(Form);
CancelButton.Parent := Form;
CancelButton.Width := ScaleX(75);
CancelButton.Height := ScaleY(23);
CancelButton.Left := Form.ClientWidth - ScaleX(75 + 50);
CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
CancelButton.Caption := ExpandConstant('{cm:UninstallPasswordCancel}');
2023-03-10 11:04:49 +00:00
CancelButton.ModalResult := mrCancel;
CancelButton.Cancel := True;
PwdEdit := TPasswordEdit.Create(Form);
PwdEdit.Parent := Form;
PwdEdit.Width := ScaleX(210);
PwdEdit.Height := ScaleY(23);
PwdEdit.Left := ScaleX(23);
PwdEdit.Top := ScaleY(23);
Form.ActiveControl := PwdEdit;
if Form.ShowModal() = mrOk then
begin
Result := PwdEdit.Text;
2023-03-10 11:04:49 +00:00
end;
finally
Form.Free();
end;
end;
function CheckPasswordHash(): Boolean;
var
passwordHash: String;
begin
RegQueryStringValue(HKEY_LOCAL_MACHINE, ExpandConstant('SOFTWARE\{#APP_NAME}'),
'passwordHash', passwordHash);
if passwordHash = '' then
begin
Result := True;
Exit;
end;
if GetSHA1OfString(AskPassword()) <> passwordHash then
2023-03-10 11:04:49 +00:00
begin
SuppressibleMsgBox(ExpandConstant('{cm:WrongPassword}'), mbError, MB_OK, IDOK);
2023-03-10 11:04:49 +00:00
Result := False;
Exit;
end;
Result := True;
end;
function InitializeSetup: Boolean;
begin
if HVCIEnabled() then
begin
SuppressibleMsgBox(ExpandConstant('{cm:NotCompatibleWithHVCI}'), mbCriticalError, MB_OK, IDOK);
Result := False;
Exit;
end;
2023-03-10 11:04:49 +00:00
Result := CheckPasswordHash();
end;
function InitializeUninstall(): Boolean;
begin
Result := CheckPasswordHash();
end;
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
ResultCode: Integer;
begin
if Exec('sc.exe', ExpandConstant('stop {#APP_SVC_NAME}'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
if ResultCode = 0 then Sleep(100); // Let the service to stop
2023-03-10 11:04:49 +00:00
Result := '';
2023-03-10 11:04:49 +00:00
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
case CurUninstallStep of
usPostUninstall:
begin
if MsgBox(ExpandConstant('{cm:IsDeleteData}'), mbConfirmation, MB_YESNO or MB_DEFBUTTON2) = IDYES then
begin
DelTree(ExpandConstant('{%ProgramData}\{#APP_NAME}'), True, True, True);
DelTree(ExpandConstant('{localappdata}\{#APP_NAME}'), True, True, True);
end;
end;
end;
end;