| Index: sandbox/src/process_policy_test.cc
|
| ===================================================================
|
| --- sandbox/src/process_policy_test.cc (revision 144078)
|
| +++ sandbox/src/process_policy_test.cc (working copy)
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -7,6 +7,7 @@
|
|
|
| #include "base/sys_string_conversions.h"
|
| #include "base/win/scoped_handle.h"
|
| +#include "base/win/scoped_process_information.h"
|
| #include "sandbox/src/sandbox.h"
|
| #include "sandbox/src/sandbox_policy.h"
|
| #include "sandbox/src/sandbox_factory.h"
|
| @@ -34,7 +35,7 @@
|
| // unicode and ascii version of the api.
|
| sandbox::SboxTestResult CreateProcessHelper(const std::wstring &exe,
|
| const std::wstring &command) {
|
| - PROCESS_INFORMATION pi;
|
| + base::win::ScopedProcessInformation pi;
|
| STARTUPINFOW si = {sizeof(si)};
|
|
|
| const wchar_t *exe_name = NULL;
|
| @@ -48,7 +49,7 @@
|
| // Create the process with the unicode version of the API.
|
| sandbox::SboxTestResult ret1 = sandbox::SBOX_TEST_FAILED;
|
| if (!::CreateProcessW(exe_name, const_cast<wchar_t*>(cmd_line), NULL, NULL,
|
| - FALSE, 0, NULL, NULL, &si, &pi)) {
|
| + FALSE, 0, NULL, NULL, &si, pi.Receive())) {
|
| DWORD last_error = GetLastError();
|
| if ((ERROR_NOT_ENOUGH_QUOTA == last_error) ||
|
| (ERROR_ACCESS_DENIED == last_error) ||
|
| @@ -61,6 +62,8 @@
|
| ret1 = sandbox::SBOX_TEST_SUCCEEDED;
|
| }
|
|
|
| + pi.Close();
|
| +
|
| // Do the same with the ansi version of the api
|
| STARTUPINFOA sia = {sizeof(sia)};
|
| sandbox::SboxTestResult ret2 = sandbox::SBOX_TEST_FAILED;
|
| @@ -71,7 +74,7 @@
|
| if (!::CreateProcessA(
|
| exe_name ? base::SysWideToMultiByte(exe_name, CP_UTF8).c_str() : NULL,
|
| cmd_line ? const_cast<char*>(narrow_cmd_line.c_str()) : NULL,
|
| - NULL, NULL, FALSE, 0, NULL, NULL, &sia, &pi)) {
|
| + NULL, NULL, FALSE, 0, NULL, NULL, &sia, pi.Receive())) {
|
| DWORD last_error = GetLastError();
|
| if ((ERROR_NOT_ENOUGH_QUOTA == last_error) ||
|
| (ERROR_ACCESS_DENIED == last_error) ||
|
| @@ -170,24 +173,22 @@
|
|
|
| std::wstring path = MakeFullPathToSystem32(argv[0]);
|
|
|
| - PROCESS_INFORMATION pi = {0};
|
| + base::win::ScopedProcessInformation pi;
|
| STARTUPINFOW si = {sizeof(si)};
|
|
|
| if (!::CreateProcessW(path.c_str(), NULL, NULL, NULL, FALSE, CREATE_SUSPENDED,
|
| - NULL, NULL, &si, &pi)) {
|
| + NULL, NULL, &si, pi.Receive())) {
|
| return SBOX_TEST_FAILED;
|
| }
|
|
|
| - base::win::ScopedHandle process(pi.hProcess);
|
| - base::win::ScopedHandle thread(pi.hThread);
|
| -
|
| HANDLE token = NULL;
|
| - BOOL result = ::OpenProcessToken(process.Get(), TOKEN_IMPERSONATE, &token);
|
| + BOOL result =
|
| + ::OpenProcessToken(pi.process_handle(), TOKEN_IMPERSONATE, &token);
|
| DWORD error = ::GetLastError();
|
|
|
| base::win::ScopedHandle token_handle(token);
|
|
|
| - if (!::TerminateProcess(process.Get(), 0))
|
| + if (!::TerminateProcess(pi.process_handle(), 0))
|
| return SBOX_TEST_FAILED;
|
|
|
| if (result && token)
|
|
|