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

Side by Side Diff: sandbox/win/src/policy_target_test.cc

Issue 1422773008: Fixing remaining VC++ 2015 64-bit build breaks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing unneeded include Created 5 years 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 "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"
11 #include "sandbox/win/src/sandbox_factory.h" 11 #include "sandbox/win/src/sandbox_factory.h"
12 #include "sandbox/win/src/sandbox_utils.h" 12 #include "sandbox/win/src/sandbox_utils.h"
13 #include "sandbox/win/src/target_services.h" 13 #include "sandbox/win/src/target_services.h"
14 #include "sandbox/win/tests/common/controller.h" 14 #include "sandbox/win/tests/common/controller.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 #if defined(OS_WIN)
18 #include "base/win/win_util.h"
19 #endif
20
17 namespace sandbox { 21 namespace sandbox {
18 22
19 #define BINDNTDLL(name) \ 23 #define BINDNTDLL(name) \
20 name ## Function name = reinterpret_cast<name ## Function>( \ 24 name ## Function name = reinterpret_cast<name ## Function>( \
21 ::GetProcAddress(::GetModuleHandle(L"ntdll.dll"), #name)) 25 ::GetProcAddress(::GetModuleHandle(L"ntdll.dll"), #name))
22 26
23 // Reverts to self and verify that SetInformationToken was faked. Returns 27 // Reverts to self and verify that SetInformationToken was faked. Returns
24 // SBOX_TEST_SUCCEEDED if faked and SBOX_TEST_FAILED if not faked. 28 // SBOX_TEST_SUCCEEDED if faked and SBOX_TEST_FAILED if not faked.
25 SBOX_TESTS_COMMAND int PolicyTargetTest_token(int argc, wchar_t **argv) { 29 SBOX_TESTS_COMMAND int PolicyTargetTest_token(int argc, wchar_t **argv) {
26 HANDLE thread_token; 30 HANDLE thread_token;
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 wchar_t prog_name[MAX_PATH]; 379 wchar_t prog_name[MAX_PATH];
376 GetModuleFileNameW(NULL, prog_name, MAX_PATH); 380 GetModuleFileNameW(NULL, prog_name, MAX_PATH);
377 381
378 TargetPolicy* policy = broker->CreatePolicy(); 382 TargetPolicy* policy = broker->CreatePolicy();
379 void* shared_handle = 383 void* shared_handle =
380 policy->AddHandleToShare(read_only_view.handle().GetHandle()); 384 policy->AddHandleToShare(read_only_view.handle().GetHandle());
381 385
382 base::string16 arguments(L"\""); 386 base::string16 arguments(L"\"");
383 arguments += prog_name; 387 arguments += prog_name;
384 arguments += L"\" -child 0 shared_memory_handle "; 388 arguments += L"\" -child 0 shared_memory_handle ";
385 arguments += base::UintToString16( 389 arguments += base::UintToString16(base::win::HandleToUint32(shared_handle));
386 reinterpret_cast<unsigned int>(shared_handle));
387 390
388 // Launch the app. 391 // Launch the app.
389 ResultCode result = SBOX_ALL_OK; 392 ResultCode result = SBOX_ALL_OK;
390 base::win::ScopedProcessInformation target; 393 base::win::ScopedProcessInformation target;
391 394
392 policy->SetTokenLevel(USER_INTERACTIVE, USER_LOCKDOWN); 395 policy->SetTokenLevel(USER_INTERACTIVE, USER_LOCKDOWN);
393 PROCESS_INFORMATION temp_process_info = {}; 396 PROCESS_INFORMATION temp_process_info = {};
394 result = broker->SpawnTarget(prog_name, arguments.c_str(), policy, 397 result = broker->SpawnTarget(prog_name, arguments.c_str(), policy,
395 &temp_process_info); 398 &temp_process_info);
396 policy->Release(); 399 policy->Release();
397 400
398 EXPECT_EQ(SBOX_ALL_OK, result); 401 EXPECT_EQ(SBOX_ALL_OK, result);
399 if (result == SBOX_ALL_OK) 402 if (result == SBOX_ALL_OK)
400 target.Set(temp_process_info); 403 target.Set(temp_process_info);
401 404
402 EXPECT_EQ(1, ::ResumeThread(target.thread_handle())); 405 EXPECT_EQ(1, ::ResumeThread(target.thread_handle()));
403 406
404 EXPECT_EQ(WAIT_TIMEOUT, 407 EXPECT_EQ(WAIT_TIMEOUT,
405 ::WaitForSingleObject(target.process_handle(), 2000)); 408 ::WaitForSingleObject(target.process_handle(), 2000));
406 409
407 EXPECT_TRUE(::TerminateProcess(target.process_handle(), 0)); 410 EXPECT_TRUE(::TerminateProcess(target.process_handle(), 0));
408 411
409 ::WaitForSingleObject(target.process_handle(), INFINITE); 412 ::WaitForSingleObject(target.process_handle(), INFINITE);
410 } 413 }
411 414
412 } // namespace sandbox 415 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/interception_unittest.cc ('k') | third_party/WebKit/Source/build/scripts/make_css_property_names.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698