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

Unified Diff: sandbox/src/restricted_token_utils.cc

Issue 10493002: Revert 130716 - Use ScopedProcessInformation and other RAII types in sandbox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/src/process_policy_test.cc ('k') | sandbox/src/target_process.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/src/restricted_token_utils.cc
===================================================================
--- sandbox/src/restricted_token_utils.cc (revision 140102)
+++ sandbox/src/restricted_token_utils.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -10,7 +10,6 @@
#include "base/logging.h"
#include "base/win/scoped_handle.h"
-#include "base/win/scoped_process_information.h"
#include "base/win/windows_version.h"
#include "sandbox/src/job.h"
#include "sandbox/src/restricted_token.h"
@@ -183,7 +182,7 @@
// Start the process
STARTUPINFO startup_info = {0};
- base::win::ScopedProcessInformation process_info;
+ PROCESS_INFORMATION process_info = {0};
if (!::CreateProcessAsUser(primary_token.Get(),
NULL, // No application name.
@@ -195,30 +194,30 @@
NULL, // Use the environment of the caller.
NULL, // Use current directory of the caller.
&startup_info,
- process_info.Receive())) {
+ &process_info)) {
return ::GetLastError();
}
+ base::win::ScopedHandle thread_handle(process_info.hThread);
+ base::win::ScopedHandle process_handle(process_info.hProcess);
+
// Change the token of the main thread of the new process for the
// impersonation token with more rights.
- {
- HANDLE temp_thread = process_info.thread_handle();
- if (!::SetThreadToken(&temp_thread, impersonation_token.Get())) {
- ::TerminateProcess(process_info.process_handle(),
- 0); // exit code
- return ::GetLastError();
- }
+ if (!::SetThreadToken(&process_info.hThread, impersonation_token.Get())) {
+ ::TerminateProcess(process_handle.Get(),
+ 0); // exit code
+ return ::GetLastError();
}
- err_code = job.AssignProcessToJob(process_info.process_handle());
+ err_code = job.AssignProcessToJob(process_handle.Get());
if (ERROR_SUCCESS != err_code) {
- ::TerminateProcess(process_info.process_handle(),
+ ::TerminateProcess(process_handle.Get(),
0); // exit code
return ::GetLastError();
}
// Start the application
- ::ResumeThread(process_info.thread_handle());
+ ::ResumeThread(thread_handle.Get());
(*job_handle_ret) = job.Detach();
« no previous file with comments | « sandbox/src/process_policy_test.cc ('k') | sandbox/src/target_process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698