Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: sandbox/win/tests/common/controller.cc

Issue 2859843002: Add a GUID to base::SharedMemoryHandle. (Closed)
Patch Set: fix guid on android. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/process/process_handle.h" 11 #include "base/process/process_handle.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
14 #include "base/unguessable_token.h"
14 #include "base/win/windows_version.h" 15 #include "base/win/windows_version.h"
15 #include "sandbox/win/src/sandbox_factory.h" 16 #include "sandbox/win/src/sandbox_factory.h"
16 17
17 namespace { 18 namespace {
18 19
19 static const int kDefaultTimeout = 60000; 20 static const int kDefaultTimeout = 60000;
20 21
21 bool IsProcessRunning(HANDLE process) { 22 bool IsProcessRunning(HANDLE process) {
22 DWORD exit_code = 0; 23 DWORD exit_code = 0;
23 if (::GetExitCodeProcess(process, &exit_code)) 24 if (::GetExitCodeProcess(process, &exit_code))
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 if (0 == _wcsicmp(argv[3], L"ping")) 309 if (0 == _wcsicmp(argv[3], L"ping"))
309 return SBOX_TEST_PING_OK; 310 return SBOX_TEST_PING_OK;
310 311
311 // 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
312 // in read only mode and sleep infinitely if we succeed. 313 // in read only mode and sleep infinitely if we succeed.
313 if (0 == _wcsicmp(argv[3], L"shared_memory_handle")) { 314 if (0 == _wcsicmp(argv[3], L"shared_memory_handle")) {
314 HANDLE raw_handle = nullptr; 315 HANDLE raw_handle = nullptr;
315 base::StringToUint(argv[4], reinterpret_cast<unsigned int*>(&raw_handle)); 316 base::StringToUint(argv[4], reinterpret_cast<unsigned int*>(&raw_handle));
316 if (raw_handle == nullptr) 317 if (raw_handle == nullptr)
317 return SBOX_TEST_INVALID_PARAMETER; 318 return SBOX_TEST_INVALID_PARAMETER;
318 base::SharedMemoryHandle shared_handle(raw_handle); 319 base::SharedMemoryHandle shared_handle(raw_handle,
320 base::UnguessableToken::Create());
319 base::SharedMemory read_only_view(shared_handle, true); 321 base::SharedMemory read_only_view(shared_handle, true);
320 if (!read_only_view.Map(0)) 322 if (!read_only_view.Map(0))
321 return SBOX_TEST_INVALID_PARAMETER; 323 return SBOX_TEST_INVALID_PARAMETER;
322 std::string contents(reinterpret_cast<char*>(read_only_view.memory())); 324 std::string contents(reinterpret_cast<char*>(read_only_view.memory()));
323 if (contents != "Hello World") 325 if (contents != "Hello World")
324 return SBOX_TEST_INVALID_PARAMETER; 326 return SBOX_TEST_INVALID_PARAMETER;
325 Sleep(INFINITE); 327 Sleep(INFINITE);
326 return SBOX_TEST_TIMED_OUT; 328 return SBOX_TEST_TIMED_OUT;
327 } 329 }
328 330
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 368
367 target->LowerToken(); 369 target->LowerToken();
368 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) { 370 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) {
369 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 371 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
370 } 372 }
371 373
372 return command(argc - 4, argv + 4); 374 return command(argc - 4, argv + 4);
373 } 375 }
374 376
375 } // namespace sandbox 377 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/process_mitigations_win32k_dispatcher.cc ('k') | tools/gn/bootstrap/bootstrap.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698