| 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 "base/memory/shared_memory.h" | 5 #include "base/memory/shared_memory.h" | 
| 6 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" | 
| 7 #include "base/strings/string_piece.h" | 7 #include "base/strings/string_piece.h" | 
| 8 #include "base/win/scoped_process_information.h" | 8 #include "base/win/scoped_process_information.h" | 
| 9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" | 
| 10 #include "sandbox/win/src/sandbox.h" | 10 #include "sandbox/win/src/sandbox.h" | 
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 249   PROCESS_INFORMATION temp_process_info = {}; | 249   PROCESS_INFORMATION temp_process_info = {}; | 
| 250   result = broker->SpawnTarget(prog_name, arguments.c_str(), policy, | 250   result = broker->SpawnTarget(prog_name, arguments.c_str(), policy, | 
| 251                                &temp_process_info); | 251                                &temp_process_info); | 
| 252   base::string16 desktop_name = policy->GetAlternateDesktop(); | 252   base::string16 desktop_name = policy->GetAlternateDesktop(); | 
| 253   policy->Release(); | 253   policy->Release(); | 
| 254 | 254 | 
| 255   EXPECT_EQ(SBOX_ALL_OK, result); | 255   EXPECT_EQ(SBOX_ALL_OK, result); | 
| 256   if (result == SBOX_ALL_OK) | 256   if (result == SBOX_ALL_OK) | 
| 257     target.Set(temp_process_info); | 257     target.Set(temp_process_info); | 
| 258 | 258 | 
| 259   EXPECT_EQ(1, ::ResumeThread(target.thread_handle())); | 259   EXPECT_EQ(1u, ::ResumeThread(target.thread_handle())); | 
| 260 | 260 | 
| 261   EXPECT_EQ(WAIT_TIMEOUT, ::WaitForSingleObject(target.process_handle(), 2000)); | 261   EXPECT_EQ(static_cast<DWORD>(WAIT_TIMEOUT), | 
|  | 262             ::WaitForSingleObject(target.process_handle(), 2000)); | 
| 262 | 263 | 
| 263   EXPECT_NE(::GetThreadDesktop(target.thread_id()), | 264   EXPECT_NE(::GetThreadDesktop(target.thread_id()), | 
| 264             ::GetThreadDesktop(::GetCurrentThreadId())); | 265             ::GetThreadDesktop(::GetCurrentThreadId())); | 
| 265 | 266 | 
| 266   HDESK desk = ::OpenDesktop(desktop_name.c_str(), 0, FALSE, DESKTOP_ENUMERATE); | 267   HDESK desk = ::OpenDesktop(desktop_name.c_str(), 0, FALSE, DESKTOP_ENUMERATE); | 
| 267   EXPECT_TRUE(NULL != desk); | 268   EXPECT_TRUE(NULL != desk); | 
| 268   EXPECT_TRUE(::CloseDesktop(desk)); | 269   EXPECT_TRUE(::CloseDesktop(desk)); | 
| 269   EXPECT_TRUE(::TerminateProcess(target.process_handle(), 0)); | 270   EXPECT_TRUE(::TerminateProcess(target.process_handle(), 0)); | 
| 270 | 271 | 
| 271   ::WaitForSingleObject(target.process_handle(), INFINITE); | 272   ::WaitForSingleObject(target.process_handle(), INFINITE); | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 312   PROCESS_INFORMATION temp_process_info = {}; | 313   PROCESS_INFORMATION temp_process_info = {}; | 
| 313   result = broker->SpawnTarget(prog_name, arguments.c_str(), policy, | 314   result = broker->SpawnTarget(prog_name, arguments.c_str(), policy, | 
| 314                                &temp_process_info); | 315                                &temp_process_info); | 
| 315   base::string16 desktop_name = policy->GetAlternateDesktop(); | 316   base::string16 desktop_name = policy->GetAlternateDesktop(); | 
| 316   policy->Release(); | 317   policy->Release(); | 
| 317 | 318 | 
| 318   EXPECT_EQ(SBOX_ALL_OK, result); | 319   EXPECT_EQ(SBOX_ALL_OK, result); | 
| 319   if (result == SBOX_ALL_OK) | 320   if (result == SBOX_ALL_OK) | 
| 320     target.Set(temp_process_info); | 321     target.Set(temp_process_info); | 
| 321 | 322 | 
| 322   EXPECT_EQ(1, ::ResumeThread(target.thread_handle())); | 323   EXPECT_EQ(1u, ::ResumeThread(target.thread_handle())); | 
| 323 | 324 | 
| 324   EXPECT_EQ(WAIT_TIMEOUT, ::WaitForSingleObject(target.process_handle(), 2000)); | 325   EXPECT_EQ(static_cast<DWORD>(WAIT_TIMEOUT), | 
|  | 326             ::WaitForSingleObject(target.process_handle(), 2000)); | 
| 325 | 327 | 
| 326   EXPECT_NE(::GetThreadDesktop(target.thread_id()), | 328   EXPECT_NE(::GetThreadDesktop(target.thread_id()), | 
| 327             ::GetThreadDesktop(::GetCurrentThreadId())); | 329             ::GetThreadDesktop(::GetCurrentThreadId())); | 
| 328 | 330 | 
| 329   ASSERT_FALSE(desktop_name.empty()); | 331   ASSERT_FALSE(desktop_name.empty()); | 
| 330 | 332 | 
| 331   // Make sure there is a backslash, for the window station name. | 333   // Make sure there is a backslash, for the window station name. | 
| 332   EXPECT_NE(desktop_name.find_first_of(L'\\'), base::string16::npos); | 334   EXPECT_NE(desktop_name.find_first_of(L'\\'), base::string16::npos); | 
| 333 | 335 | 
| 334   // Isolate the desktop name. | 336   // Isolate the desktop name. | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 392   policy->SetTokenLevel(USER_INTERACTIVE, USER_LOCKDOWN); | 394   policy->SetTokenLevel(USER_INTERACTIVE, USER_LOCKDOWN); | 
| 393   PROCESS_INFORMATION temp_process_info = {}; | 395   PROCESS_INFORMATION temp_process_info = {}; | 
| 394   result = broker->SpawnTarget(prog_name, arguments.c_str(), policy, | 396   result = broker->SpawnTarget(prog_name, arguments.c_str(), policy, | 
| 395                                &temp_process_info); | 397                                &temp_process_info); | 
| 396   policy->Release(); | 398   policy->Release(); | 
| 397 | 399 | 
| 398   EXPECT_EQ(SBOX_ALL_OK, result); | 400   EXPECT_EQ(SBOX_ALL_OK, result); | 
| 399   if (result == SBOX_ALL_OK) | 401   if (result == SBOX_ALL_OK) | 
| 400     target.Set(temp_process_info); | 402     target.Set(temp_process_info); | 
| 401 | 403 | 
| 402   EXPECT_EQ(1, ::ResumeThread(target.thread_handle())); | 404   EXPECT_EQ(1u, ::ResumeThread(target.thread_handle())); | 
| 403 | 405 | 
| 404   EXPECT_EQ(WAIT_TIMEOUT, | 406   EXPECT_EQ(static_cast<DWORD>(WAIT_TIMEOUT), | 
| 405             ::WaitForSingleObject(target.process_handle(), 2000)); | 407             ::WaitForSingleObject(target.process_handle(), 2000)); | 
| 406 | 408 | 
| 407   EXPECT_TRUE(::TerminateProcess(target.process_handle(), 0)); | 409   EXPECT_TRUE(::TerminateProcess(target.process_handle(), 0)); | 
| 408 | 410 | 
| 409   ::WaitForSingleObject(target.process_handle(), INFINITE); | 411   ::WaitForSingleObject(target.process_handle(), INFINITE); | 
| 410 } | 412 } | 
| 411 | 413 | 
| 412 }  // namespace sandbox | 414 }  // namespace sandbox | 
| OLD | NEW | 
|---|