Skip to content

libobs: Resolve bin_path and data_path to absolute paths for modules - #13687

Open
notr1ch wants to merge 1 commit into
obsproject:masterfrom
notr1ch:r1ch/absolute-mod-paths
Open

libobs: Resolve bin_path and data_path to absolute paths for modules#13687
notr1ch wants to merge 1 commit into
obsproject:masterfrom
notr1ch:r1ch/absolute-mod-paths

Conversation

@notr1ch

@notr1ch notr1ch commented Jul 22, 2026

Copy link
Copy Markdown
Member

Description

Many modules create paths based on obs_module_config_path and similar functions, which return a relative path based on the current directory.

This causes a problem on Windows in combination with #11569. The path to the game capture hook DLL is sometimes passed as a relative path when the global hook can't be updated after an OBS update if it's in use. After calling SetDefaultDLLDirectories, the current directory is no longer searched, so the relative path to the hook DLL can't load and we get an inject -4 error.

After this change, inject-helper is launched with both an absolute binary path and absolute argument, so nothing relies on the current directory any more. This commit extends beyond just win-capture though, as any module that was relying on the current directory will now be given absolute paths, which is more reliable in case any random DLL decides to change the CWD.

An unfortunate fixup_path call is needed on Windows, as we have historically only ever used module paths with / as a path separator, and libobs itself also assumes this, so for compatibility we convert Windows \ directory separators back to /.

Motivation and Context

Fix reported inject -4 errors.

How Has This Been Tested?

Forced OBS to inject with local hook DLL and verified full path to inject helper and its arguments were used.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Many modules create paths based on obs_module_config_path and similar
functions, which return a relative path based on the current directory.

This causes a problem on Windows in combination with obsproject#11569. The path
to the game capture hook DLL is sometimes passed as a relative path
when the global hook can't be updated after an OBS update if it's in
use. After calling SetDefaultDLLDirectories, the current directory is
no longer searched, so the relative path to the hook DLL can't load
and we get an inject -4 error.

After this change, inject-helper is launched with both an absolute
binary path and absolute argument, so nothing relies on the current
directory any more. This commit extends beyond just win-capture though,
as any module that was relying on the current directory will now be
given absolute paths, which is more reliable in case any random DLL
decides to change the CWD.

An unfortunate "fixup_path" call is needed on Windows, as we have
historically only ever used module paths with / as a path separator, and
libobs itself also assumes this, so for compatibility we convert Windows
\ directory separators back to /.
@notr1ch
notr1ch force-pushed the r1ch/absolute-mod-paths branch from 49d07e6 to 4203dcd Compare July 23, 2026 00:00
@WizardCM WizardCM added the kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. label Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants