diff options
-rw-r--r-- | chrome_elf/blacklist/blacklist.cc | 12 | ||||
-rw-r--r-- | chrome_elf/chrome_elf_util.cc | 16 | ||||
-rw-r--r-- | chrome_elf/chrome_elf_util.h | 4 | ||||
-rw-r--r-- | chrome_elf/create_file/chrome_create_file.cc | 3 |
4 files changed, 22 insertions, 13 deletions
diff --git a/chrome_elf/blacklist/blacklist.cc b/chrome_elf/blacklist/blacklist.cc index 73383d5..5ce3773 100644 --- a/chrome_elf/blacklist/blacklist.cc +++ b/chrome_elf/blacklist/blacklist.cc @@ -9,6 +9,7 @@ #include "base/basictypes.h" #include "chrome_elf/blacklist/blacklist_interceptions.h" #include "chrome_elf/chrome_elf_constants.h" +#include "chrome_elf/chrome_elf_util.h" #include "sandbox/win/src/interception_internal.h" #include "sandbox/win/src/internal_types.h" #include "sandbox/win/src/sandbox_utils.h" @@ -141,17 +142,6 @@ class OSInfo { DISALLOW_COPY_AND_ASSIGN(OSInfo); }; -bool IsNonBrowserProcess() { - typedef bool (*IsSandboxedProcessFunc)(); - IsSandboxedProcessFunc is_sandboxed_process = - reinterpret_cast<IsSandboxedProcessFunc>( - GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); - if (is_sandboxed_process && is_sandboxed_process()) - return true; - - return false; -} - // Record that the thunk setup completed succesfully and close the registry // key handle since it is no longer needed. void RecordSuccessfulThunkSetup(HKEY* key) { diff --git a/chrome_elf/chrome_elf_util.cc b/chrome_elf/chrome_elf_util.cc index fc99ae4..a547d0b 100644 --- a/chrome_elf/chrome_elf_util.cc +++ b/chrome_elf/chrome_elf_util.cc @@ -191,3 +191,19 @@ bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled) { return false; } + +bool IsNonBrowserProcess() { + typedef bool (*IsSandboxedProcessFunc)(); + IsSandboxedProcessFunc is_sandboxed_process_func = + reinterpret_cast<IsSandboxedProcessFunc>( + GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); + bool is_sandboxed_process = + is_sandboxed_process_func && is_sandboxed_process_func(); + + // TODO(robertshield): Drop the command line check when we drop support for + // enabling chrome_elf in unsandboxed processes. + wchar_t* command_line = GetCommandLine(); + bool has_process_type_flag = command_line && wcsstr(command_line, L"--type"); + + return (has_process_type_flag || is_sandboxed_process); +} diff --git a/chrome_elf/chrome_elf_util.h b/chrome_elf/chrome_elf_util.h index a81e54f..e87dc7f 100644 --- a/chrome_elf/chrome_elf_util.h +++ b/chrome_elf/chrome_elf_util.h @@ -24,4 +24,8 @@ bool AreUsageStatsEnabled(const wchar_t* exe_path); // if stats collecting is permitted by this policy and false if not. bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled); +// Returns true if invoked in a Chrome process other than the main browser +// process. False otherwise. +bool IsNonBrowserProcess(); + #endif // CHROME_ELF_CHROME_ELF_UTIL_H_ diff --git a/chrome_elf/create_file/chrome_create_file.cc b/chrome_elf/create_file/chrome_create_file.cc index 1b8515f..9521ecb2 100644 --- a/chrome_elf/create_file/chrome_create_file.cc +++ b/chrome_elf/create_file/chrome_create_file.cc @@ -254,8 +254,7 @@ HANDLE CreateFileNTDLL( bool ShouldBypass(LPCWSTR file_path) { // Do not redirect in non-browser processes. - wchar_t* command_line = ::GetCommandLine(); - if (command_line && wcsstr(command_line, L"--type")) + if (IsNonBrowserProcess()) return false; // If the shell functions are not present, forward the call to kernel32. |