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

Side by Side Diff: base/process_util_win.cc

Issue 125260: Don't grant unnecessary handle privileges in OpenProcessHandle. (Closed)
Patch Set: update Created 11 years, 6 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 | « no previous file | chrome/test/chrome_process_util.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_util.h" 5 #include "base/process_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <winternl.h> 8 #include <winternl.h>
9 #include <psapi.h> 9 #include <psapi.h>
10 10
(...skipping 16 matching lines...) Expand all
27 27
28 ProcessId GetCurrentProcId() { 28 ProcessId GetCurrentProcId() {
29 return ::GetCurrentProcessId(); 29 return ::GetCurrentProcessId();
30 } 30 }
31 31
32 ProcessHandle GetCurrentProcessHandle() { 32 ProcessHandle GetCurrentProcessHandle() {
33 return ::GetCurrentProcess(); 33 return ::GetCurrentProcess();
34 } 34 }
35 35
36 bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) { 36 bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) {
37 // TODO(phajdan.jr): Take even more permissions out of this list. 37 // We try to limit privileges granted to the handle. If you need this
38 ProcessHandle result = OpenProcess(PROCESS_DUP_HANDLE | 38 // for test code, consider using OpenPrivilegedProcessHandle instead of
39 PROCESS_TERMINATE | 39 // adding more privileges here.
40 PROCESS_QUERY_INFORMATION | 40 ProcessHandle result = OpenProcess(PROCESS_DUP_HANDLE | PROCESS_TERMINATE,
41 SYNCHRONIZE,
42 FALSE, pid); 41 FALSE, pid);
43 42
44 if (result == INVALID_HANDLE_VALUE) 43 if (result == INVALID_HANDLE_VALUE)
45 return false; 44 return false;
46 45
47 *handle = result; 46 *handle = result;
48 return true; 47 return true;
49 } 48 }
50 49
51 bool OpenPrivilegedProcessHandle(ProcessId pid, ProcessHandle* handle) { 50 bool OpenPrivilegedProcessHandle(ProcessId pid, ProcessHandle* handle) {
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 void EnableTerminationOnHeapCorruption() { 761 void EnableTerminationOnHeapCorruption() {
763 // Ignore the result code. Supported on XP SP3 and Vista. 762 // Ignore the result code. Supported on XP SP3 and Vista.
764 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); 763 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
765 } 764 }
766 765
767 void RaiseProcessToHighPriority() { 766 void RaiseProcessToHighPriority() {
768 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); 767 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
769 } 768 }
770 769
771 } // namespace base 770 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | chrome/test/chrome_process_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698