Skip to content

Conversation

@Trouffman
Copy link
Collaborator

@Trouffman Trouffman commented May 27, 2025

This PR focus only on the Windows installer changes:

  • Update to new recommended plugin install location
  • Remove obsolete installer settings

Reason & Argument for this change

Remove Obsolete installer settings.
Update to new recommended install location.
Use recommended comments character
@Trouffman Trouffman self-assigned this May 27, 2025
@Trouffman Trouffman added ci windows Build relate to building issues (all platform) labels May 27, 2025
@Trouffman
Copy link
Collaborator Author

Trouffman commented May 28, 2025

The new location does not allow to add the firewall rules anymore.

Also the FW rules are added every time there is a new install We should be able to target an existing rules and update it instead of re-adding all the time.

Suggestion to fix :
Check if rule exist

  • if yes : update
  • if no : create

Not sure if this could be done in the "run" section or needs to be "moved" to the Code section and then called.

@Trouffman
Copy link
Collaborator Author

The firewall rules added to the windows Firewall does not work anymore with the new plugin location.

Fully reworked

All the OBS-NDI removal is now managed as the "last step" to avoid too early deletion.

Added log entry for debug if we run the installer with /LOG

Rely more on the [Code] section for consistency.

Added an option to select the removal of obs-ndi / add to firewall to be skipped.

@BitRate27
Copy link
Contributor

Looks like there are 1 too many folder levels in the install of distroav.
It installs in c:\ProgramData\obs-studio\plugins\distroav\distroav and should be in c:\ProgramData\obs-studio\plugins\distroav.

@Trouffman
Copy link
Collaborator Author

Update OP with all the changes in this PR.

Latest build should fix the issue reported by @BitRate27 in a previous comment.

@BitRate27
Copy link
Contributor

The plugin is now installed correctly with the latest change.

Problem now is the in/out firewall rules are not added. The log file says:

2025-05-28 17:41:06.471   Update Firewall out Rule OBS - DistroAV: Successful.
2025-05-28 17:41:06.584   Update Firewall in Rule OBS - DistroAV: Successful.

So end result is OBS Studio not allowed through firewall. No rule was created in the firewall which included OBS or DistroAV in the name or group.

Add validation to the firewall rules process
@BitRate27
Copy link
Contributor

BitRate27 commented May 29, 2025

In addition to doing a proper check on success of the netsh command, you also need to remove group= and new as those are not recognized arguments for the advfirewall context.

https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/dd734783(v=ws.10)

This code works on my tests:

function SetFirewallRules(Direction: String): Boolean;
var
  ResultCode: Integer;
begin
  ResultCode := 0;
  // Update firewall rule if exist
  Exec('netsh', 'advfirewall firewall set rule name="' + FirewallRuleName + '" dir=' + Direction + ' action=allow program="' + ExpandConstant('{code:GetOBSDirName}\bin\64bit\obs64.exe') + '" description="' + FirewallRulesDescription + '" enable=yes', '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
  if ( ResultCode = 0 ) then
    begin
     Log('Update Firewall ' + Direction + ' Rule ' + FirewallRuleName + ': Successful.');
      Result := True;
    end
  // Add rule if missing
  else
    begin
      Exec('netsh', 'advfirewall firewall add rule name="' + FirewallRuleName + '" dir=' + Direction + ' action=allow program="' + ExpandConstant('{code:GetOBSDirName}\bin\64bit\obs64.exe') + '" description="' + FirewallRulesDescription + '" enable=yes', '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
      if ( ResultCode = 0 ) then
        begin
          Log('Add Firewall ' + Direction + ' Rule ' + FirewallRuleName + ': Successful.');
          Result := True;
        end
      else
        begin
          Log('Add Firewall ' + Direction + ' Rule ' + FirewallRuleName + ': Failed.');
          Result := False;
        end;
    end;
end;

@Trouffman
Copy link
Collaborator Author

@BitRate27 this last commit implement your changes request.

Test to do :

Removing OBS-NDI (low priority)

  • OBS NDI 4.10. or 4.14 is installed prior to distroav and gets removed
  • OBS-NDI files exist in the obs folder but not installed (manual) prior to distroav and gets removed

Adding firewall rules higher priority)

  • Rules in & out are added on first install
  • Rules in & out are updated in re-install

Disclaimer : I have not tested theses

@BitRate27
Copy link
Contributor

The manually installed dll is not being removed. The path to the obs-ndi.dll file is incorrect.

Please change the second DelTree command to this:

      if ( DelTree(ExpandConstant('{code:GetOBSDirName}\obs-plugins\64bit\obs-ndi*'), False, True, True) ) then
        Log('Removed old obs-ndi plugin files: ' + ExpandConstant('{code:GetOBSDirName}\obs-plugins\64bit\obs-ndi*'));

Verified the installed version of obs-ndi is uninstalled and that the locale folder is properly deleted if installed manually.
Note: Tested with 4.14.0 version obs-ndi.dll which actually crashes OBS Studio 31.0.3 if installed.

@Trouffman
Copy link
Collaborator Author

@BitRate27 good catch!

If the test success and install goes as planned, we could merge this.

@BitRate27
Copy link
Contributor

BitRate27 commented May 30, 2025

The latest firewall code doesn't seem to recognize if the rule is already set. It keeps adding the same rule every time the installer is run. Since we can't use the ResultCode to test if the set rule operation was successful, we need to delete the rule if it exists, and add it. Here is the code which will do that without having to check if the rule already exists.

function SetFirewallRules(Direction: String): Boolean;
var
  ResultCode: Integer;
begin
  ResultCode := 0;
  // Delete rule if it exists
  Exec('netsh', 'advfirewall firewall delete rule name="' + FirewallRuleName + '" dir=' + Direction, '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
  // Add firewall rule
  Exec('netsh', 'advfirewall firewall add rule name="' + FirewallRuleName + '" dir=' + Direction + ' action=allow program="' + ExpandConstant('{code:GetOBSDirName}\bin\64bit\obs64.exe') + '" description="' + FirewallRulesDescription + '" enable=yes', '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
  if ( ResultCode = 1 ) then
    begin
      Log('Add Firewall ' + Direction + ' Rule ' + FirewallRuleName + ': Successful.');
      Result := True;
    end
  else
    begin
      Log('Add Firewall ' + Direction + ' Rule ' + FirewallRuleName + ': Failed. Error: ' + IntToStr(ResultCode) + '');
      Result := False;
    end;
end;

I tested this new way by installing multiple times, and we only end up with one OBS - DistroAV rule in the in and out directions.

@Trouffman Trouffman merged commit 09245ce into master Jun 1, 2025
6 checks passed
@Trouffman Trouffman deleted the CI-win-installer-tweak branch June 1, 2025 11:04
@Trouffman
Copy link
Collaborator Author

Thanks all for the great collab on this PR !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build relate to building issues (all platform) ci windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants