|
|
@@ -79,7 +79,7 @@ var
|
|
|
InitNoIcons, InitSilent, InitVerySilent, InitNoRestart, InitCloseApplications,
|
|
|
InitNoCloseApplications, InitForceCloseApplications, InitNoForceCloseApplications,
|
|
|
InitLogCloseApplications, InitRestartApplications, InitNoRestartApplications,
|
|
|
- InitNoCancel, InitNoStyle: Boolean;
|
|
|
+ InitNoCancel, InitNoStyle, InitRedirectionGuard, InitNoRedirectionGuard: Boolean;
|
|
|
InitSetupType: String;
|
|
|
InitComponents, InitTasks: TStringList;
|
|
|
InitComponentsSpecified: Boolean;
|
|
|
@@ -213,6 +213,8 @@ procedure NotifyAfterInstallEntry(const AfterInstall: String);
|
|
|
procedure NotifyAfterInstallFileEntry(const FileEntry: PSetupFileEntry);
|
|
|
procedure NotifyBeforeInstallEntry(const BeforeInstall: String);
|
|
|
procedure NotifyBeforeInstallFileEntry(const FileEntry: PSetupFileEntry);
|
|
|
+procedure RedirectionGuardConfigure(const AEnable: Boolean);
|
|
|
+function RedirectionGuardEnabled: Boolean;
|
|
|
function PreviousInstallCompleted(const WizardComponents, WizardTasks: TStringList): Boolean;
|
|
|
function CodeRegisterExtraCloseApplicationsResource(const DisableFsRedir: Boolean; const AFilename: String): Boolean;
|
|
|
procedure RegisterResourcesWithRestartManager(const WizardComponents, WizardTasks: TStringList);
|
|
|
@@ -704,6 +706,8 @@ begin
|
|
|
InitNoRestartApplications := GetIniBool(Section, 'NoRestartApplications', InitNoRestartApplications, FileName);
|
|
|
InitNoCancel := GetIniBool(Section, 'NoCancel', InitNoCancel, FileName);
|
|
|
InitNoStyle := GetIniBool(Section, 'NoStyle', InitNoStyle, FileName);
|
|
|
+ InitRedirectionGuard := GetIniBool(Section, 'RedirectionGuard', InitRedirectionGuard, FileName);
|
|
|
+ InitNoRedirectionGuard := GetIniBool(Section, 'NoRedirectionGuard', InitNoRedirectionGuard, FileName);
|
|
|
InitPassword := GetIniString(Section, 'Password', InitPassword, FileName);
|
|
|
InitRestartExitCode := GetIniInt(Section, 'RestartExitCode', InitRestartExitCode, 0, 0, FileName);
|
|
|
WantToSuppressMsgBoxes := GetIniBool(Section, 'SuppressMsgBoxes', WantToSuppressMsgBoxes, FileName);
|
|
|
@@ -2469,6 +2473,44 @@ begin
|
|
|
SetActiveLanguage(I);
|
|
|
end;
|
|
|
|
|
|
+var
|
|
|
+ IsRedirectionGuardEnabled: Boolean;
|
|
|
+
|
|
|
+procedure RedirectionGuardConfigure(const AEnable: Boolean);
|
|
|
+const
|
|
|
+ ProcessRedirectionTrustPolicy = TProcessMitigationPolicy(16);
|
|
|
+var
|
|
|
+ SetProcessMitigationPolicyFunc: function(MitigationPolicy: TProcessMitigationPolicy;
|
|
|
+ lpBuffer: PVOID; dwLength: SIZE_T): BOOL; stdcall;
|
|
|
+begin
|
|
|
+ var Status: String;
|
|
|
+
|
|
|
+ if AEnable then begin
|
|
|
+ SetProcessMitigationPolicyFunc := GetProcAddress(GetModuleHandle(kernel32),
|
|
|
+ PAnsiChar('SetProcessMitigationPolicy'));
|
|
|
+ if Assigned(SetProcessMitigationPolicyFunc) then begin
|
|
|
+ const Flags: DWORD = 1; { = EnforceRedirectionTrust bit set }
|
|
|
+ if SetProcessMitigationPolicyFunc(ProcessRedirectionTrustPolicy, @Flags, SizeOf(Flags)) then begin
|
|
|
+ IsRedirectionGuardEnabled := True;
|
|
|
+ Status := 'Enabled in enforcing mode'
|
|
|
+ end else begin
|
|
|
+ const ErrorCode = GetLastError;
|
|
|
+ Status := Format('Could not enable (SetProcessMitigationPolicy failed with error code %u)',
|
|
|
+ [ErrorCode]);
|
|
|
+ end;
|
|
|
+ end else
|
|
|
+ Status := 'Could not enable (SetProcessMitigationPolicy unavailable)';
|
|
|
+ end else
|
|
|
+ Status := 'Not enabling';
|
|
|
+
|
|
|
+ LogFmt('RedirectionGuard status for current process: %s', [Status]);
|
|
|
+end;
|
|
|
+
|
|
|
+function RedirectionGuardEnabled: Boolean;
|
|
|
+begin
|
|
|
+ Result := IsRedirectionGuardEnabled;
|
|
|
+end;
|
|
|
+
|
|
|
procedure LogCompatibilityMode;
|
|
|
var
|
|
|
S: String;
|
|
|
@@ -3198,6 +3240,10 @@ begin
|
|
|
InitRestartApplications := True
|
|
|
else if SameText(ParamName, '/NoRestartApplications') then
|
|
|
InitNoRestartApplications := True
|
|
|
+ else if SameText(ParamName, '/RedirectionGuard') then
|
|
|
+ InitRedirectionGuard := True
|
|
|
+ else if SameText(ParamName, '/NoRedirectionGuard') then
|
|
|
+ InitNoRedirectionGuard := True
|
|
|
else if SameText(ParamName, '/NoIcons') then
|
|
|
InitNoIcons := True
|
|
|
else if SameText(ParamName, '/NoCancel') then
|
|
|
@@ -3547,6 +3593,10 @@ begin
|
|
|
|
|
|
Log64BitInstallMode;
|
|
|
|
|
|
+ const EnableRedirectionGuard = InitRedirectionGuard or
|
|
|
+ ((shRedirectionGuard in SetupHeader.Options) and not InitNoRedirectionGuard);
|
|
|
+ RedirectionGuardConfigure(EnableRedirectionGuard);
|
|
|
+
|
|
|
{ Test code. Originally planned to call DeleteResidualTempUninstallDirs
|
|
|
during Setup's startup too, but decided against it; it's not really
|
|
|
necessary and could slow down the startup (slightly). }
|