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 "content/common/sandbox_win.h" | 5 #include "content/common/sandbox_win.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // Eviction of injected DLLs is done by the sandbox so that the injected module | 217 // Eviction of injected DLLs is done by the sandbox so that the injected module |
218 // does not get a chance to execute any code. | 218 // does not get a chance to execute any code. |
219 void AddGenericDllEvictionPolicy(sandbox::TargetPolicy* policy) { | 219 void AddGenericDllEvictionPolicy(sandbox::TargetPolicy* policy) { |
220 for (int ix = 0; ix != arraysize(kTroublesomeDlls); ++ix) | 220 for (int ix = 0; ix != arraysize(kTroublesomeDlls); ++ix) |
221 BlacklistAddOneDll(kTroublesomeDlls[ix], true, policy); | 221 BlacklistAddOneDll(kTroublesomeDlls[ix], true, policy); |
222 } | 222 } |
223 | 223 |
224 // Returns the object path prepended with the current logon session. | 224 // Returns the object path prepended with the current logon session. |
225 base::string16 PrependWindowsSessionPath(const base::char16* object) { | 225 base::string16 PrependWindowsSessionPath(const base::char16* object) { |
226 // Cache this because it can't change after process creation. | 226 // Cache this because it can't change after process creation. |
227 static uintptr_t s_session_id = 0; | 227 static DWORD s_session_id = 0; |
228 if (s_session_id == 0) { | 228 if (s_session_id == 0) { |
229 HANDLE token; | 229 HANDLE token; |
230 DWORD session_id_length; | 230 DWORD session_id_length; |
231 DWORD session_id = 0; | 231 DWORD session_id = 0; |
232 | 232 |
233 CHECK(::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)); | 233 CHECK(::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)); |
234 CHECK(::GetTokenInformation(token, TokenSessionId, &session_id, | 234 CHECK(::GetTokenInformation(token, TokenSessionId, &session_id, |
235 sizeof(session_id), &session_id_length)); | 235 sizeof(session_id), &session_id_length)); |
236 CloseHandle(token); | 236 CloseHandle(token); |
237 if (session_id) | 237 if (session_id) |
238 s_session_id = session_id; | 238 s_session_id = session_id; |
239 } | 239 } |
240 | 240 |
241 return base::StringPrintf(L"\\Sessions\\%d%ls", s_session_id, object); | 241 return base::StringPrintf(L"\\Sessions\\%lu%ls", s_session_id, object); |
242 } | 242 } |
243 | 243 |
244 // Checks if the sandbox should be let to run without a job object assigned. | 244 // Checks if the sandbox should be let to run without a job object assigned. |
245 bool ShouldSetJobLevel(const base::CommandLine& cmd_line) { | 245 bool ShouldSetJobLevel(const base::CommandLine& cmd_line) { |
246 if (!cmd_line.HasSwitch(switches::kAllowNoSandboxJob)) | 246 if (!cmd_line.HasSwitch(switches::kAllowNoSandboxJob)) |
247 return true; | 247 return true; |
248 | 248 |
249 // Windows 8 allows nested jobs so we don't need to check if we are in other | 249 // Windows 8 allows nested jobs so we don't need to check if we are in other |
250 // job. | 250 // job. |
251 if (base::win::GetVersion() >= base::win::VERSION_WIN8) | 251 if (base::win::GetVersion() >= base::win::VERSION_WIN8) |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 } | 867 } |
868 | 868 |
869 return false; | 869 return false; |
870 } | 870 } |
871 | 871 |
872 bool BrokerAddTargetPeer(HANDLE peer_process) { | 872 bool BrokerAddTargetPeer(HANDLE peer_process) { |
873 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 873 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
874 } | 874 } |
875 | 875 |
876 } // namespace content | 876 } // namespace content |
OLD | NEW |