From: Jesper Dam Date: Fri, 28 Oct 2011 13:54:30 +0000 (+0200) Subject: Find dbus-daemon executable next to dbus shared libaray on windows. X-Git-Tag: dbus-1.4.18~15^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d52b86d3e774ed515039f47b2a35ec645362a97b;p=thirdparty%2Fdbus.git Find dbus-daemon executable next to dbus shared libaray on windows. If the dbus shared library and the daemon executable are both in a dir that is not part of the default search path and dbus-1.dll is dynamically loaded with LoadLibrary(), it will fail to locate and launch the daemon without this patch. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41558 Reviewed-by: Ralf Habacker --- diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index a8c60bdaa..3bcf86acf 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2861,11 +2861,25 @@ _dbus_get_autolaunch_address (const char *scope, DBusString *address, if (!SearchPathA(NULL, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile)) { - printf ("please add the path to %s to your PATH environment variable\n", daemon_name); - printf ("or start the daemon manually\n\n"); - goto out; + // Look in directory containing dbus shared library + HMODULE hmod = _dbus_win_get_dll_hmodule(); + char dbus_module_path[MAX_PATH]; + DWORD rc = GetModuleFileNameA(hmod, dbus_module_path, sizeof(dbus_module_path)); + if (rc > 0) + { + char *ext_idx = strrchr(dbus_module_path, '\\'); + if (ext_idx) + *ext_idx = '\0'; + if (!SearchPathA(dbus_module_path, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile)) + { + printf ("please add the path to %s to your PATH environment variable\n", daemon_name); + printf ("or start the daemon manually\n\n"); + goto out; + } + } } + // Create process ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si);