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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 memcpy(writable_shmem.memory(), contents.data(), contents.size()); | 369 memcpy(writable_shmem.memory(), contents.data(), contents.size()); |
370 | 370 |
371 base::SharedMemory read_only_view; | 371 base::SharedMemory read_only_view; |
372 ASSERT_TRUE(read_only_view.Open(name, true)); | 372 ASSERT_TRUE(read_only_view.Open(name, true)); |
373 | 373 |
374 // Get the path to the sandboxed app. | 374 // Get the path to the sandboxed app. |
375 wchar_t prog_name[MAX_PATH]; | 375 wchar_t prog_name[MAX_PATH]; |
376 GetModuleFileNameW(NULL, prog_name, MAX_PATH); | 376 GetModuleFileNameW(NULL, prog_name, MAX_PATH); |
377 | 377 |
378 TargetPolicy* policy = broker->CreatePolicy(); | 378 TargetPolicy* policy = broker->CreatePolicy(); |
379 void* shared_handle = policy->AddHandleToShare( | 379 void* shared_handle = |
380 read_only_view.handle()); | 380 policy->AddHandleToShare(read_only_view.handle().GetHandle()); |
381 | 381 |
382 base::string16 arguments(L"\""); | 382 base::string16 arguments(L"\""); |
383 arguments += prog_name; | 383 arguments += prog_name; |
384 arguments += L"\" -child 0 shared_memory_handle "; | 384 arguments += L"\" -child 0 shared_memory_handle "; |
385 arguments += base::UintToString16( | 385 arguments += base::UintToString16( |
386 reinterpret_cast<unsigned int>(shared_handle)); | 386 reinterpret_cast<unsigned int>(shared_handle)); |
387 | 387 |
388 // Launch the app. | 388 // Launch the app. |
389 ResultCode result = SBOX_ALL_OK; | 389 ResultCode result = SBOX_ALL_OK; |
390 base::win::ScopedProcessInformation target; | 390 base::win::ScopedProcessInformation target; |
(...skipping 12 matching lines...) Expand all Loading... |
403 | 403 |
404 EXPECT_EQ(WAIT_TIMEOUT, | 404 EXPECT_EQ(WAIT_TIMEOUT, |
405 ::WaitForSingleObject(target.process_handle(), 2000)); | 405 ::WaitForSingleObject(target.process_handle(), 2000)); |
406 | 406 |
407 EXPECT_TRUE(::TerminateProcess(target.process_handle(), 0)); | 407 EXPECT_TRUE(::TerminateProcess(target.process_handle(), 0)); |
408 | 408 |
409 ::WaitForSingleObject(target.process_handle(), INFINITE); | 409 ::WaitForSingleObject(target.process_handle(), INFINITE); |
410 } | 410 } |
411 | 411 |
412 } // namespace sandbox | 412 } // namespace sandbox |
OLD | NEW |