Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\fgfs.exe"; ValueType: string; ValueName: ""; ValueData: "{app}\bin\fgfs.exe"; Flags: uninsdeletekey\r
\r
[Code]\r
+const\r
+ NET_FW_SCOPE_ALL = 0;\r
+ NET_FW_IP_VERSION_ANY = 2;\r
+ NET_FW_ACTION_ALLOW = 1;\r
+ NET_FW_RULE_DIR_ALL = 0;\r
+ NET_FW_RULE_DIR_IN = 1;\r
+ NET_FW_RULE_DIR_OUT = 2;\r
+ NET_FW_IP_PROTOCOL_ALL = 0;\r
+ NET_FW_IP_PROTOCOL_TCP = 6;\r
+ NET_FW_IP_PROTOCOL_UDP = 17;\r
+ NET_FW_PROFILE2_DOMAIN = 1;\r
+ NET_FW_PROFILE2_PRIVATE = 2;\r
+ NET_FW_PROFILE2_PUBLIC = 4;\r
+\r
procedure URLLabelOnClick(Sender: TObject);\r
var\r
ErrorCode: Integer;\r
Result := S;\r
end;\r
\r
+procedure AddBasicFirewallException(AppName, FileName: String);\r
+var\r
+ FirewallObject: variant;\r
+ RuleObject: variant;\r
+begin\r
+ try\r
+ FirewallObject := CreateOleObject('HNetCfg.FwMgr');\r
+ RuleObject := CreateOleObject('HNetCfg.FwAuthorizedApplication');\r
+ RuleObject.ProcessImageFileName := FileName;\r
+ RuleObject.Name := AppName;\r
+ RuleObject.Scope := NET_FW_SCOPE_ALL;\r
+ RuleObject.IpVersion := NET_FW_IP_VERSION_ANY;\r
+ RuleObject.Enabled := true;\r
+ FirewallObject.LocalPolicy.CurrentProfile.AuthorizedApplications.Add(RuleObject);\r
+ except\r
+ end;\r
+end;\r
+\r
+procedure AddAdvancedFirewallException(AppName, AppDescription, FileName: String; Protocol: Integer; LocalPorts, RemotePorts: String; Direction: Integer);\r
+var\r
+ FirewallObject: variant;\r
+ RuleObject: variant;\r
+begin\r
+ try\r
+ FirewallObject := CreateOleObject('HNetCfg.FwPolicy2');\r
+ RuleObject := CreateOleObject('HNetCfg.FWRule');\r
+ RuleObject.Name := AppName;\r
+ RuleObject.Description := AppDescription;\r
+ RuleObject.ApplicationName := FileName;\r
+ if (Protocol <> NET_FW_IP_PROTOCOL_ALL) then\r
+ RuleObject.Protocol := Protocol;\r
+ if (LocalPorts <> '') then\r
+ RuleObject.LocalPorts := LocalPorts;\r
+ if (RemotePorts <> '') then\r
+ RuleObject.RemotePorts := RemotePorts;\r
+ if (Direction <> NET_FW_RULE_DIR_ALL) then\r
+ RuleObject.Direction := Direction;\r
+ RuleObject.Enabled := true;\r
+ RuleObject.Grouping := 'FlightGear';\r
+ RuleObject.Profiles := NET_FW_PROFILE2_DOMAIN + NET_FW_PROFILE2_PRIVATE + NET_FW_PROFILE2_PUBLIC;\r
+ RuleObject.Action := NET_FW_ACTION_ALLOW;\r
+ RuleObject.RemoteAddresses := '*';\r
+ FirewallObject.Rules.Add(RuleObject);\r
+ except\r
+ end;\r
+end;\r
+\r
+procedure RemoveFirewallException(AppName, FileName: String);\r
+var\r
+ FirewallObject: variant;\r
+ Version: TWindowsVersion;\r
+begin\r
+ GetWindowsVersionEx(Version);\r
+ try\r
+ if (Version.Major >= 6) then\r
+ begin\r
+ FirewallObject := CreateOleObject('HNetCfg.FwPolicy2');\r
+ FirewallObject.Rules.Remove(AppName);\r
+ end\r
+ else if (Version.Major = 5) and (((Version.Minor = 1) and (Version.ServicePackMajor >= 2)) or ((Version.Minor = 2) and (Version.ServicePackMajor >= 1))) then\r
+ begin\r
+ FirewallObject := CreateOleObject('HNetCfg.FwMgr');\r
+ FirewallObject.LocalPolicy.CurrentProfile.AuthorizedApplications.Remove(FileName);\r
+ end;\r
+ except\r
+ end;\r
+end;\r
+\r
+procedure CurStepChanged(CurStep: TSetupStep);\r
+var\r
+ Version: TWindowsVersion;\r
+begin\r
+ if CurStep = ssPostInstall then\r
+ begin\r
+ GetWindowsVersionEx(Version);\r
+ if (Version.Major >= 6) then\r
+ begin\r
+ { IN and OUT rules must be specified separately, otherwise the firewall will create only the IN rule }\r
+ AddAdvancedFirewallException('FlightGear', 'Allows FlightGear to send and receive data over the multiplayer network and to get METARs.', ExpandConstant('{app}') + '\bin\fgfs.exe', NET_FW_IP_PROTOCOL_ALL, '', '', NET_FW_RULE_DIR_IN);\r
+ AddAdvancedFirewallException('FlightGear', 'Allows FlightGear to send and receive data over the multiplayer network and to get METARs.', ExpandConstant('{app}') + '\bin\fgfs.exe', NET_FW_IP_PROTOCOL_ALL, '', '', NET_FW_RULE_DIR_OUT);\r
+ AddAdvancedFirewallException('FlightGear METAR Utility', 'Allows the FlightGear METAR utility to receive METARs.', ExpandConstant('{app}') + '\bin\metar.exe', NET_FW_IP_PROTOCOL_TCP, '', '80', NET_FW_RULE_DIR_OUT);\r
+ AddAdvancedFirewallException('FlightGear TerraSync', 'Allows TerraSync to download additional scenery while FlightGear is running.', ExpandConstant('{app}') + '\bin\terrasync.exe', NET_FW_IP_PROTOCOL_ALL, '', '', NET_FW_RULE_DIR_IN);\r
+ AddAdvancedFirewallException('FlightGear TerraSync', 'Allows TerraSync to download additional scenery while FlightGear is running.', ExpandConstant('{app}') + '\bin\terrasync.exe', NET_FW_IP_PROTOCOL_ALL, '', '', NET_FW_RULE_DIR_OUT);\r
+ AddAdvancedFirewallException('FlightGear FGCom', 'Allows FGCom to establish a connection to FlightGear and the VoIP server for voice ATC communication.', ExpandConstant('{app}') + '\bin\fgcom.exe', NET_FW_IP_PROTOCOL_ALL, '', '', NET_FW_RULE_DIR_IN);\r
+ AddAdvancedFirewallException('FlightGear FGCom', 'Allows FGCom to establish a connection to FlightGear and the VoIP server for voice ATC communication.', ExpandConstant('{app}') + '\bin\fgcom.exe', NET_FW_IP_PROTOCOL_ALL, '', '', NET_FW_RULE_DIR_OUT);\r
+ end\r
+ else if (Version.Major = 5) and (((Version.Minor = 1) and (Version.ServicePackMajor >= 2)) or ((Version.Minor = 2) and (Version.ServicePackMajor >= 1))) then\r
+ begin\r
+ { The Windows XP/Server 2003 firewall does not block outgoing connections at all, so only listening processes should be added }\r
+ AddBasicFirewallException('FlightGear', ExpandConstant('{app}') + '\bin\fgfs.exe');\r
+ AddBasicFirewallException('FlightGear TerraSync', ExpandConstant('{app}') + '\bin\terrasync.exe');\r
+ AddBasicFirewallException('FlightGear FGCom', ExpandConstant('{app}') + '\bin\fgcom.exe');\r
+ end;\r
+ end;\r
+end;\r
+\r
+procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);\r
+begin\r
+ if CurUninstallStep = usPostUninstall then\r
+ begin\r
+ RemoveFirewallException('FlightGear', ExpandConstant('{app}') + '\bin\fgfs.exe');\r
+ RemoveFirewallException('FlightGear METAR Utility', ExpandConstant('{app}') + '\bin\metar.exe');\r
+ RemoveFirewallException('FlightGear TerraSync', ExpandConstant('{app}') + '\bin\terrasync.exe');\r
+ RemoveFirewallException('FlightGear FGCom', ExpandConstant('{app}') + '\bin\fgcom.exe');\r
+ end;\r
+end;\r