Commit 386c2e2e authored by rockot's avatar rockot Committed by Commit bot

Service Manager: Override DLL search path when launching services in component builds

Service executables don't live alongside other build artifacts, so in component builds
Windows doesn't normally know where to look for them at runtime. This overrides the
DLL search path temporarily before launching any service child process.

BUG=None
R=ben@chromium.org

Review-Url: https://codereview.chromium.org/2574653002
Cr-Commit-Position: refs/heads/master@{#438086}
parent 2d6dcff9
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/base_paths.h" #include "base/base_paths.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -41,6 +42,28 @@ ...@@ -41,6 +42,28 @@
#include "services/service_manager/public/cpp/standalone_service/mach_broker.h" #include "services/service_manager/public/cpp/standalone_service/mach_broker.h"
#endif #endif
#if defined(OS_WIN) && defined(COMPONENT_BUILD)
#include <windows.h>
namespace {
class ScopedDllDirectoryOverride {
public:
explicit ScopedDllDirectoryOverride(const base::FilePath& path) {
SetDllDirectory(path.value().c_str());
}
~ScopedDllDirectoryOverride() {
SetDllDirectory(NULL);
}
private:
DISALLOW_COPY_AND_ASSIGN(ScopedDllDirectoryOverride);
};
} // namespace
#endif // defined(OS_WIN) && defined(COMPONENT_BUILD)
namespace service_manager { namespace service_manager {
ChildProcessHost::ChildProcessHost(base::TaskRunner* launch_process_runner, ChildProcessHost::ChildProcessHost(base::TaskRunner* launch_process_runner,
...@@ -205,6 +228,8 @@ void ChildProcessHost::DoLaunch( ...@@ -205,6 +228,8 @@ void ChildProcessHost::DoLaunch(
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
MachBroker* mach_broker = MachBroker::GetInstance(); MachBroker* mach_broker = MachBroker::GetInstance();
base::AutoLock locker(mach_broker->GetLock()); base::AutoLock locker(mach_broker->GetLock());
#elif defined(OS_WIN) && defined(COMPONENT_BUILD)
ScopedDllDirectoryOverride dll_override(exe_dir);
#endif #endif
child_process_ = base::LaunchProcess(*child_command_line, options); child_process_ = base::LaunchProcess(*child_command_line, options);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment