OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sandbox/win/tests/common/controller.h" | 5 #include "sandbox/win/tests/common/controller.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
11 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
14 #include "base/win/windows_version.h" | 14 #include "base/win/windows_version.h" |
15 #include "sandbox/win/src/sandbox_factory.h" | 15 #include "sandbox/win/src/sandbox_factory.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 static const int kDefaultTimeout = 60000; | 19 static const int kDefaultTimeout = 60000; |
20 | 20 |
| 21 bool IsProcessRunning(HANDLE process) { |
| 22 DWORD exit_code = 0; |
| 23 if (::GetExitCodeProcess(process, &exit_code)) |
| 24 return exit_code == STILL_ACTIVE; |
| 25 return false; |
| 26 } |
| 27 |
| 28 } // namespace |
| 29 |
| 30 namespace sandbox { |
| 31 |
21 // Constructs a full path to a file inside the system32 folder. | 32 // Constructs a full path to a file inside the system32 folder. |
22 base::string16 MakePathToSys32(const wchar_t* name, bool is_obj_man_path) { | 33 base::string16 MakePathToSys32(const wchar_t* name, bool is_obj_man_path) { |
23 wchar_t windows_path[MAX_PATH] = {0}; | 34 wchar_t windows_path[MAX_PATH] = {0}; |
24 if (0 == ::GetSystemWindowsDirectoryW(windows_path, MAX_PATH)) | 35 if (0 == ::GetSystemWindowsDirectoryW(windows_path, MAX_PATH)) |
25 return base::string16(); | 36 return base::string16(); |
26 | 37 |
27 base::string16 full_path(windows_path); | 38 base::string16 full_path(windows_path); |
28 if (full_path.empty()) | 39 if (full_path.empty()) |
29 return full_path; | 40 return full_path; |
30 | 41 |
(...skipping 16 matching lines...) Expand all Loading... |
47 return full_path; | 58 return full_path; |
48 | 59 |
49 if (is_obj_man_path) | 60 if (is_obj_man_path) |
50 full_path.insert(0, L"\\??\\"); | 61 full_path.insert(0, L"\\??\\"); |
51 | 62 |
52 full_path += L"\\SysWOW64\\"; | 63 full_path += L"\\SysWOW64\\"; |
53 full_path += name; | 64 full_path += name; |
54 return full_path; | 65 return full_path; |
55 } | 66 } |
56 | 67 |
57 bool IsProcessRunning(HANDLE process) { | |
58 DWORD exit_code = 0; | |
59 if (::GetExitCodeProcess(process, &exit_code)) | |
60 return exit_code == STILL_ACTIVE; | |
61 return false; | |
62 } | |
63 | |
64 } // namespace | |
65 | |
66 namespace sandbox { | |
67 | |
68 base::string16 MakePathToSys(const wchar_t* name, bool is_obj_man_path) { | 68 base::string16 MakePathToSys(const wchar_t* name, bool is_obj_man_path) { |
69 return (base::win::OSInfo::GetInstance()->wow64_status() == | 69 return (base::win::OSInfo::GetInstance()->wow64_status() == |
70 base::win::OSInfo::WOW64_ENABLED) ? | 70 base::win::OSInfo::WOW64_ENABLED) ? |
71 MakePathToSysWow64(name, is_obj_man_path) : | 71 MakePathToSysWow64(name, is_obj_man_path) : |
72 MakePathToSys32(name, is_obj_man_path); | 72 MakePathToSys32(name, is_obj_man_path); |
73 } | 73 } |
74 | 74 |
75 BrokerServices* GetBroker() { | 75 BrokerServices* GetBroker() { |
76 static BrokerServices* broker = SandboxFactory::GetBrokerServices(); | 76 static BrokerServices* broker = SandboxFactory::GetBrokerServices(); |
77 static bool is_initialized = false; | 77 static bool is_initialized = false; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 361 |
362 target->LowerToken(); | 362 target->LowerToken(); |
363 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) { | 363 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) { |
364 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; | 364 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; |
365 } | 365 } |
366 | 366 |
367 return command(argc - 4, argv + 4); | 367 return command(argc - 4, argv + 4); |
368 } | 368 } |
369 | 369 |
370 } // namespace sandbox | 370 } // namespace sandbox |
OLD | NEW |