Fix process spawning with static build on Windows

On Windows, process spawning needs an external helper exe which is found
relatively to the glib DLL file. If glib has been built statically this
file doesn't exist anymore and reference path is not the DLL path
anymore but the current executable path.

This patch searches for the helper exe taking as starting point the
current executable path, relative 'bin', 'lib', 'glib' and 'gio' folders
and then gets one level up until the root path. If this search doesn't
give result then the helper exe is searched using the PATH variable.
This commit is contained in:
Loic Le Page
2022-01-05 18:06:01 +01:00
parent 94f4ec85c6
commit 41f8bbd02d
6 changed files with 130 additions and 54 deletions

View File

@@ -40,7 +40,9 @@ void g_clock_win32_init (void);
void g_crash_handler_win32_init (void);
void g_crash_handler_win32_deinit (void);
gboolean _g_win32_call_rtl_version (OSVERSIONINFOEXW *info);
extern HMODULE glib_dll;
gchar *g_win32_find_helper_executable_path (const gchar *process_name, void *dll_handle);
#endif
#endif /* __GLIB_INIT_H__ */