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 "sandbox/win/tests/common/controller.h" | 5 #include "sandbox/win/tests/common/controller.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 if (0 == _wcsicmp(argv[3], L"ping")) | 309 if (0 == _wcsicmp(argv[3], L"ping")) |
310 return SBOX_TEST_PING_OK; | 310 return SBOX_TEST_PING_OK; |
311 | 311 |
312 // If the caller shared a shared memory handle with us attempt to open it | 312 // If the caller shared a shared memory handle with us attempt to open it |
313 // in read only mode and sleep infinitely if we succeed. | 313 // in read only mode and sleep infinitely if we succeed. |
314 if (0 == _wcsicmp(argv[3], L"shared_memory_handle")) { | 314 if (0 == _wcsicmp(argv[3], L"shared_memory_handle")) { |
315 HANDLE raw_handle = nullptr; | 315 HANDLE raw_handle = nullptr; |
316 base::StringToUint(argv[4], reinterpret_cast<unsigned int*>(&raw_handle)); | 316 base::StringToUint(argv[4], reinterpret_cast<unsigned int*>(&raw_handle)); |
317 if (raw_handle == nullptr) | 317 if (raw_handle == nullptr) |
318 return SBOX_TEST_INVALID_PARAMETER; | 318 return SBOX_TEST_INVALID_PARAMETER; |
319 base::SharedMemoryHandle shared_handle(raw_handle, | 319 base::SharedMemoryHandle shared_handle(raw_handle, 0u, |
320 base::UnguessableToken::Create()); | 320 base::UnguessableToken::Create()); |
321 base::SharedMemory read_only_view(shared_handle, true); | 321 base::SharedMemory read_only_view(shared_handle, true); |
322 if (!read_only_view.Map(0)) | 322 if (!read_only_view.Map(0)) |
323 return SBOX_TEST_INVALID_PARAMETER; | 323 return SBOX_TEST_INVALID_PARAMETER; |
324 std::string contents(reinterpret_cast<char*>(read_only_view.memory())); | 324 std::string contents(reinterpret_cast<char*>(read_only_view.memory())); |
325 if (contents != "Hello World") | 325 if (contents != "Hello World") |
326 return SBOX_TEST_INVALID_PARAMETER; | 326 return SBOX_TEST_INVALID_PARAMETER; |
327 Sleep(INFINITE); | 327 Sleep(INFINITE); |
328 return SBOX_TEST_TIMED_OUT; | 328 return SBOX_TEST_TIMED_OUT; |
329 } | 329 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 | 368 |
369 target->LowerToken(); | 369 target->LowerToken(); |
370 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) { | 370 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) { |
371 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; | 371 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; |
372 } | 372 } |
373 | 373 |
374 return command(argc - 4, argv + 4); | 374 return command(argc - 4, argv + 4); |
375 } | 375 } |
376 | 376 |
377 } // namespace sandbox | 377 } // namespace sandbox |
OLD | NEW |