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_SRC_TARGET_PROCESS_H_ | 5 #ifndef SANDBOX_WIN_SRC_TARGET_PROCESS_H_ |
6 #define SANDBOX_WIN_SRC_TARGET_PROCESS_H_ | 6 #define SANDBOX_WIN_SRC_TARGET_PROCESS_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 22 matching lines...) Expand all Loading... |
33 class ThreadProvider; | 33 class ThreadProvider; |
34 | 34 |
35 // TargetProcess models a target instance (child process). Objects of this | 35 // TargetProcess models a target instance (child process). Objects of this |
36 // class are owned by the Policy used to create them. | 36 // class are owned by the Policy used to create them. |
37 class TargetProcess { | 37 class TargetProcess { |
38 public: | 38 public: |
39 // The constructor takes ownership of |initial_token|, |lockdown_token| | 39 // The constructor takes ownership of |initial_token|, |lockdown_token| |
40 // and |lowbox_token|. | 40 // and |lowbox_token|. |
41 TargetProcess(base::win::ScopedHandle initial_token, | 41 TargetProcess(base::win::ScopedHandle initial_token, |
42 base::win::ScopedHandle lockdown_token, | 42 base::win::ScopedHandle lockdown_token, |
43 base::win::ScopedHandle lowbox_token, | |
44 HANDLE job, | 43 HANDLE job, |
45 ThreadProvider* thread_pool); | 44 ThreadProvider* thread_pool); |
46 ~TargetProcess(); | 45 ~TargetProcess(); |
47 | 46 |
48 // TODO(cpu): Currently there does not seem to be a reason to implement | 47 // TODO(cpu): Currently there does not seem to be a reason to implement |
49 // reference counting for this class since is internal, but kept the | 48 // reference counting for this class since is internal, but kept the |
50 // the same interface so the interception framework does not need to be | 49 // the same interface so the interception framework does not need to be |
51 // touched at this point. | 50 // touched at this point. |
52 void AddRef() {} | 51 void AddRef() {} |
53 void Release() {} | 52 void Release() {} |
54 | 53 |
55 // Creates the new target process. The process is created suspended. | 54 // Creates the new target process. The process is created suspended. |
56 ResultCode Create(const wchar_t* exe_path, | 55 ResultCode Create(const wchar_t* exe_path, |
57 const wchar_t* command_line, | 56 const wchar_t* command_line, |
58 bool inherit_handles, | 57 bool inherit_handles, |
59 const base::win::StartupInformation& startup_info, | 58 const base::win::StartupInformation& startup_info, |
60 base::win::ScopedProcessInformation* target_info, | 59 base::win::ScopedProcessInformation* target_info, |
61 DWORD* win_error); | 60 DWORD* win_error); |
62 | 61 |
| 62 // Assign a new lowbox token to the process post creation. The process |
| 63 // must still be in its initial suspended state, however this still |
| 64 // might fail in the presence of third-party software. |
| 65 ResultCode AssignLowBoxToken(const base::win::ScopedHandle& token); |
| 66 |
63 // Destroys the target process. | 67 // Destroys the target process. |
64 void Terminate(); | 68 void Terminate(); |
65 | 69 |
66 // Creates the IPC objects such as the BrokerDispatcher and the | 70 // Creates the IPC objects such as the BrokerDispatcher and the |
67 // IPC server. The IPC server uses the services of the thread_pool. | 71 // IPC server. The IPC server uses the services of the thread_pool. |
68 ResultCode Init(Dispatcher* ipc_dispatcher, | 72 ResultCode Init(Dispatcher* ipc_dispatcher, |
69 void* policy, | 73 void* policy, |
70 uint32_t shared_IPC_size, | 74 uint32_t shared_IPC_size, |
71 uint32_t shared_policy_size, | 75 uint32_t shared_policy_size, |
72 DWORD* win_error); | 76 DWORD* win_error); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 111 |
108 private: | 112 private: |
109 // Details of the target process. | 113 // Details of the target process. |
110 base::win::ScopedProcessInformation sandbox_process_info_; | 114 base::win::ScopedProcessInformation sandbox_process_info_; |
111 // The token associated with the process. It provides the core of the | 115 // The token associated with the process. It provides the core of the |
112 // sbox security. | 116 // sbox security. |
113 base::win::ScopedHandle lockdown_token_; | 117 base::win::ScopedHandle lockdown_token_; |
114 // The token given to the initial thread so that the target process can | 118 // The token given to the initial thread so that the target process can |
115 // start. It has more powers than the lockdown_token. | 119 // start. It has more powers than the lockdown_token. |
116 base::win::ScopedHandle initial_token_; | 120 base::win::ScopedHandle initial_token_; |
117 // The lowbox token associated with the process. This token is set after the | |
118 // process creation. | |
119 base::win::ScopedHandle lowbox_token_; | |
120 // Kernel handle to the shared memory used by the IPC server. | 121 // Kernel handle to the shared memory used by the IPC server. |
121 base::win::ScopedHandle shared_section_; | 122 base::win::ScopedHandle shared_section_; |
122 // Job object containing the target process. | 123 // Job object containing the target process. |
123 HANDLE job_; | 124 HANDLE job_; |
124 // Reference to the IPC subsystem. | 125 // Reference to the IPC subsystem. |
125 std::unique_ptr<SharedMemIPCServer> ipc_server_; | 126 std::unique_ptr<SharedMemIPCServer> ipc_server_; |
126 // Provides the threads used by the IPC. This class does not own this pointer. | 127 // Provides the threads used by the IPC. This class does not own this pointer. |
127 ThreadProvider* thread_pool_; | 128 ThreadProvider* thread_pool_; |
128 // Base address of the main executable | 129 // Base address of the main executable |
129 void* base_address_; | 130 void* base_address_; |
130 // Full name of the target executable. | 131 // Full name of the target executable. |
131 std::unique_ptr<wchar_t, base::FreeDeleter> exe_name_; | 132 std::unique_ptr<wchar_t, base::FreeDeleter> exe_name_; |
132 | 133 |
133 // Function used for testing. | 134 // Function used for testing. |
134 friend TargetProcess* MakeTestTargetProcess(HANDLE process, | 135 friend TargetProcess* MakeTestTargetProcess(HANDLE process, |
135 HMODULE base_address); | 136 HMODULE base_address); |
136 | 137 |
137 DISALLOW_IMPLICIT_CONSTRUCTORS(TargetProcess); | 138 DISALLOW_IMPLICIT_CONSTRUCTORS(TargetProcess); |
138 }; | 139 }; |
139 | 140 |
140 // Creates a mock TargetProcess used for testing interceptions. | 141 // Creates a mock TargetProcess used for testing interceptions. |
141 // TODO(cpu): It seems that this method is not going to be used anymore. | 142 // TODO(cpu): It seems that this method is not going to be used anymore. |
142 TargetProcess* MakeTestTargetProcess(HANDLE process, HMODULE base_address); | 143 TargetProcess* MakeTestTargetProcess(HANDLE process, HMODULE base_address); |
143 | 144 |
144 | 145 |
145 } // namespace sandbox | 146 } // namespace sandbox |
146 | 147 |
147 #endif // SANDBOX_WIN_SRC_TARGET_PROCESS_H_ | 148 #endif // SANDBOX_WIN_SRC_TARGET_PROCESS_H_ |
OLD | NEW |