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 #ifndef SANDBOX_TESTS_COMMON_CONTROLLER_H_ | 5 #ifndef SANDBOX_TESTS_COMMON_CONTROLLER_H_ |
6 #define SANDBOX_TESTS_COMMON_CONTROLLER_H__ | 6 #define SANDBOX_TESTS_COMMON_CONTROLLER_H__ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // Starts a child process in the sandbox and ask it to run |command|. Returns | 88 // Starts a child process in the sandbox and ask it to run |command|. Returns |
89 // a SboxTestResult. By default, the test runs AFTER_REVERT. | 89 // a SboxTestResult. By default, the test runs AFTER_REVERT. |
90 int RunTest(const wchar_t* command); | 90 int RunTest(const wchar_t* command); |
91 | 91 |
92 // Sets the timeout value for the child to run the command and return. | 92 // Sets the timeout value for the child to run the command and return. |
93 void SetTimeout(DWORD timeout_ms); | 93 void SetTimeout(DWORD timeout_ms); |
94 | 94 |
95 // Sets TestRunner to return without waiting for the process to exit. | 95 // Sets TestRunner to return without waiting for the process to exit. |
96 void SetAsynchronous(bool is_async) { is_async_ = is_async; } | 96 void SetAsynchronous(bool is_async) { is_async_ = is_async; } |
97 | 97 |
| 98 // Sets TestRunner to return without waiting for the process to exit. |
| 99 void SetUnsandboxed(bool is_no_sandbox) { no_sandbox_ = is_no_sandbox; } |
| 100 |
98 // Sets the desired state for the test to run. | 101 // Sets the desired state for the test to run. |
99 void SetTestState(SboxTestsState desired_state); | 102 void SetTestState(SboxTestsState desired_state); |
100 | 103 |
101 // Returns the pointers to the policy object. It can be used to modify | 104 // Returns the pointers to the policy object. It can be used to modify |
102 // the policy manually. | 105 // the policy manually. |
103 TargetPolicy* GetPolicy(); | 106 TargetPolicy* GetPolicy(); |
104 | 107 |
105 // Return the process handle for an asynchronous test. | 108 // Return the process handle for an asynchronous test. |
106 HANDLE process() { return target_process_; } | 109 HANDLE process() { return target_process_; } |
107 | 110 |
108 // Return the process ID for an asynchronous test. | 111 // Return the process ID for an asynchronous test. |
109 DWORD process_id() { return target_process_id_; } | 112 DWORD process_id() { return target_process_id_; } |
110 | 113 |
111 private: | 114 private: |
112 // Initializes the data in the object. Sets is_init_ to tree if the | 115 // Initializes the data in the object. Sets is_init_ to tree if the |
113 // function succeeds. This is meant to be called from the constructor. | 116 // function succeeds. This is meant to be called from the constructor. |
114 void Init(JobLevel job_level, TokenLevel startup_token, | 117 void Init(JobLevel job_level, TokenLevel startup_token, |
115 TokenLevel main_token); | 118 TokenLevel main_token); |
116 | 119 |
117 // The actual runner. | 120 // The actual runner. |
118 int InternalRunTest(const wchar_t* command); | 121 int InternalRunTest(const wchar_t* command); |
119 | 122 |
120 BrokerServices* broker_; | 123 BrokerServices* broker_; |
121 TargetPolicy* policy_; | 124 TargetPolicy* policy_; |
122 DWORD timeout_; | 125 DWORD timeout_; |
123 SboxTestsState state_; | 126 SboxTestsState state_; |
124 bool is_init_; | 127 bool is_init_; |
125 bool is_async_; | 128 bool is_async_; |
| 129 bool no_sandbox_; |
126 base::win::ScopedHandle target_process_; | 130 base::win::ScopedHandle target_process_; |
127 DWORD target_process_id_; | 131 DWORD target_process_id_; |
128 }; | 132 }; |
129 | 133 |
130 // Returns the broker services. | 134 // Returns the broker services. |
131 BrokerServices* GetBroker(); | 135 BrokerServices* GetBroker(); |
132 | 136 |
133 // Constructs a full path to a file inside the system32 (or syswow64) folder. | 137 // Constructs a full path to a file inside the system32 (or syswow64) folder. |
134 std::wstring MakePathToSys(const wchar_t* name, bool is_obj_man_path); | 138 std::wstring MakePathToSys(const wchar_t* name, bool is_obj_man_path); |
135 | 139 |
136 // Runs the given test on the target process. | 140 // Runs the given test on the target process. |
137 int DispatchCall(int argc, wchar_t **argv); | 141 int DispatchCall(int argc, wchar_t **argv); |
138 | 142 |
139 } // namespace sandbox | 143 } // namespace sandbox |
140 | 144 |
141 #endif // SANDBOX_TESTS_COMMON_CONTROLLER_H_ | 145 #endif // SANDBOX_TESTS_COMMON_CONTROLLER_H_ |
OLD | NEW |