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_WIN_TESTS_COMMON_CONTROLLER_H_ | 5 #ifndef SANDBOX_WIN_TESTS_COMMON_CONTROLLER_H_ |
6 #define SANDBOX_WIN_TESTS_COMMON_CONTROLLER_H_ | 6 #define SANDBOX_WIN_TESTS_COMMON_CONTROLLER_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 // Sets the timeout value for the child to run the command and return. | 99 // Sets the timeout value for the child to run the command and return. |
100 void SetTimeout(DWORD timeout_ms); | 100 void SetTimeout(DWORD timeout_ms); |
101 | 101 |
102 // Sets TestRunner to return without waiting for the process to exit. | 102 // Sets TestRunner to return without waiting for the process to exit. |
103 void SetAsynchronous(bool is_async) { is_async_ = is_async; } | 103 void SetAsynchronous(bool is_async) { is_async_ = is_async; } |
104 | 104 |
105 // Sets TestRunner to return without waiting for the process to exit. | 105 // Sets TestRunner to return without waiting for the process to exit. |
106 void SetUnsandboxed(bool is_no_sandbox) { no_sandbox_ = is_no_sandbox; } | 106 void SetUnsandboxed(bool is_no_sandbox) { no_sandbox_ = is_no_sandbox; } |
107 | 107 |
| 108 // Sets whether TestRunner should disable CSRSS or not (default true). |
| 109 // Any test that needs to spawn a child process needs to set this to false. |
| 110 void SetDisableCsrss(bool disable_csrss) { disable_csrss_ = disable_csrss; } |
| 111 |
108 // Sets the desired state for the test to run. | 112 // Sets the desired state for the test to run. |
109 void SetTestState(SboxTestsState desired_state); | 113 void SetTestState(SboxTestsState desired_state); |
110 | 114 |
111 // Sets a flag whether the process should be killed when the TestRunner is | 115 // Sets a flag whether the process should be killed when the TestRunner is |
112 // destroyed. | 116 // destroyed. |
113 void SetKillOnDestruction(bool value) { kill_on_destruction_ = value; } | 117 void SetKillOnDestruction(bool value) { kill_on_destruction_ = value; } |
114 | 118 |
115 // Returns the pointers to the policy object. It can be used to modify | 119 // Returns the pointers to the policy object. It can be used to modify |
116 // the policy manually. | 120 // the policy manually. |
117 TargetPolicy* GetPolicy(); | 121 TargetPolicy* GetPolicy(); |
118 | 122 |
119 BrokerServices* broker() { return broker_; } | 123 BrokerServices* broker() { return broker_; } |
120 | 124 |
121 // Returns the process handle for an asynchronous test. | 125 // Returns the process handle for an asynchronous test. |
122 HANDLE process() { return target_process_.Get(); } | 126 HANDLE process() { return target_process_.Get(); } |
123 | 127 |
124 // Returns the process ID for an asynchronous test. | 128 // Returns the process ID for an asynchronous test. |
125 DWORD process_id() { return target_process_id_; } | 129 DWORD process_id() { return target_process_id_; } |
126 | 130 |
127 private: | 131 private: |
128 // Initializes the data in the object. Sets is_init_ to tree if the | 132 // Initializes the data in the object. Sets is_init_ to tree if the |
129 // function succeeds. This is meant to be called from the constructor. | 133 // function succeeds. This is meant to be called from the constructor. |
130 void Init(JobLevel job_level, TokenLevel startup_token, | 134 void Init(JobLevel job_level, |
| 135 TokenLevel startup_token, |
131 TokenLevel main_token); | 136 TokenLevel main_token); |
132 | 137 |
133 // The actual runner. | 138 // The actual runner. |
134 int InternalRunTest(const wchar_t* command); | 139 int InternalRunTest(const wchar_t* command); |
135 | 140 |
136 BrokerServices* broker_; | 141 BrokerServices* broker_; |
137 TargetPolicy* policy_; | 142 TargetPolicy* policy_; |
138 DWORD timeout_; | 143 DWORD timeout_; |
139 SboxTestsState state_; | 144 SboxTestsState state_; |
140 bool is_init_; | 145 bool is_init_; |
141 bool is_async_; | 146 bool is_async_; |
142 bool no_sandbox_; | 147 bool no_sandbox_; |
| 148 bool disable_csrss_; |
143 bool kill_on_destruction_; | 149 bool kill_on_destruction_; |
144 base::win::ScopedHandle target_process_; | 150 base::win::ScopedHandle target_process_; |
145 DWORD target_process_id_; | 151 DWORD target_process_id_; |
146 }; | 152 }; |
147 | 153 |
148 // Returns the broker services. | 154 // Returns the broker services. |
149 BrokerServices* GetBroker(); | 155 BrokerServices* GetBroker(); |
150 | 156 |
151 // Constructs a full path to a file inside the system32 (or syswow64) folder. | 157 // Constructs a full path to a file inside the system32 (or syswow64) folder. |
152 base::string16 MakePathToSys(const wchar_t* name, bool is_obj_man_path); | 158 base::string16 MakePathToSys(const wchar_t* name, bool is_obj_man_path); |
153 | 159 |
154 // Runs the given test on the target process. | 160 // Runs the given test on the target process. |
155 int DispatchCall(int argc, wchar_t **argv); | 161 int DispatchCall(int argc, wchar_t **argv); |
156 | 162 |
157 } // namespace sandbox | 163 } // namespace sandbox |
158 | 164 |
159 #endif // SANDBOX_WIN_TESTS_COMMON_CONTROLLER_H_ | 165 #endif // SANDBOX_WIN_TESTS_COMMON_CONTROLLER_H_ |
OLD | NEW |