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