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

Side by Side Diff: base/process/process_handle_win.cc

Issue 868543002: Move OpenProcessHandle to Process::Open. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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
« no previous file with comments | « base/process/process_handle_posix.cc ('k') | base/process/process_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/process/process_handle.h" 5 #include "base/process/process_handle.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/win/scoped_handle.h" 10 #include "base/win/scoped_handle.h"
11 #include "base/win/windows_version.h" 11 #include "base/win/windows_version.h"
12 12
13 namespace base { 13 namespace base {
14 14
15 ProcessId GetCurrentProcId() { 15 ProcessId GetCurrentProcId() {
16 return ::GetCurrentProcessId(); 16 return ::GetCurrentProcessId();
17 } 17 }
18 18
19 ProcessHandle GetCurrentProcessHandle() { 19 ProcessHandle GetCurrentProcessHandle() {
20 return ::GetCurrentProcess(); 20 return ::GetCurrentProcess();
21 } 21 }
22 22
23 bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) {
24 // We try to limit privileges granted to the handle. If you need this
25 // for test code, consider using OpenPrivilegedProcessHandle instead of
26 // adding more privileges here.
27 ProcessHandle result = OpenProcess(PROCESS_TERMINATE |
28 PROCESS_QUERY_INFORMATION |
29 SYNCHRONIZE,
30 FALSE, pid);
31
32 if (result == NULL)
33 return false;
34
35 *handle = result;
36 return true;
37 }
38
39 void CloseProcessHandle(ProcessHandle process) { 23 void CloseProcessHandle(ProcessHandle process) {
40 CloseHandle(process); 24 CloseHandle(process);
41 } 25 }
42 26
43 ProcessId GetProcId(ProcessHandle process) { 27 ProcessId GetProcId(ProcessHandle process) {
44 // This returns 0 if we have insufficient rights to query the process handle. 28 // This returns 0 if we have insufficient rights to query the process handle.
45 return GetProcessId(process); 29 return GetProcessId(process);
46 } 30 }
47 31
48 bool GetProcessIntegrityLevel(ProcessHandle process, IntegrityLevel *level) { 32 bool GetProcessIntegrityLevel(ProcessHandle process, IntegrityLevel *level) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 *level = HIGH_INTEGRITY; 74 *level = HIGH_INTEGRITY;
91 } else { 75 } else {
92 NOTREACHED(); 76 NOTREACHED();
93 return false; 77 return false;
94 } 78 }
95 79
96 return true; 80 return true;
97 } 81 }
98 82
99 } // namespace base 83 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_handle_posix.cc ('k') | base/process/process_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698