| OLD | NEW |
| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) { | 23 bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) { |
| 24 // We try to limit privileges granted to the handle. If you need this | 24 // We try to limit privileges granted to the handle. If you need this |
| 25 // for test code, consider using OpenPrivilegedProcessHandle instead of | 25 // for test code, consider using OpenPrivilegedProcessHandle instead of |
| 26 // adding more privileges here. | 26 // adding more privileges here. |
| 27 ProcessHandle result = OpenProcess(PROCESS_TERMINATE | | 27 ProcessHandle result = OpenProcess(PROCESS_TERMINATE | |
| 28 PROCESS_QUERY_INFORMATION | | 28 PROCESS_QUERY_INFORMATION | |
| 29 SYNCHRONIZE, | 29 SYNCHRONIZE, |
| 30 FALSE, pid); | 30 FALSE, pid); |
| 31 | 31 |
| 32 if (result == NULL) | 32 if (result == NULL) { |
| 33 DPLOG(ERROR); |
| 33 return false; | 34 return false; |
| 35 } |
| 34 | 36 |
| 35 *handle = result; | 37 *handle = result; |
| 36 return true; | 38 return true; |
| 37 } | 39 } |
| 38 | 40 |
| 39 bool OpenPrivilegedProcessHandle(ProcessId pid, ProcessHandle* handle) { | 41 bool OpenPrivilegedProcessHandle(ProcessId pid, ProcessHandle* handle) { |
| 40 ProcessHandle result = OpenProcess(PROCESS_DUP_HANDLE | | 42 ProcessHandle result = OpenProcess(PROCESS_DUP_HANDLE | |
| 41 PROCESS_TERMINATE | | 43 PROCESS_TERMINATE | |
| 42 PROCESS_QUERY_INFORMATION | | 44 PROCESS_QUERY_INFORMATION | |
| 43 PROCESS_VM_READ | | 45 PROCESS_VM_READ | |
| 44 SYNCHRONIZE, | 46 SYNCHRONIZE, |
| 45 FALSE, pid); | 47 FALSE, pid); |
| 46 | 48 |
| 47 if (result == NULL) | 49 if (result == NULL) { |
| 50 DPLOG(ERROR); |
| 48 return false; | 51 return false; |
| 52 } |
| 49 | 53 |
| 50 *handle = result; | 54 *handle = result; |
| 51 return true; | 55 return true; |
| 52 } | 56 } |
| 53 | 57 |
| 54 bool OpenProcessHandleWithAccess(ProcessId pid, | 58 bool OpenProcessHandleWithAccess(ProcessId pid, |
| 55 uint32 access_flags, | 59 uint32 access_flags, |
| 56 ProcessHandle* handle) { | 60 ProcessHandle* handle) { |
| 57 ProcessHandle result = OpenProcess(access_flags, FALSE, pid); | 61 ProcessHandle result = OpenProcess(access_flags, FALSE, pid); |
| 58 | 62 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 *level = HIGH_INTEGRITY; | 121 *level = HIGH_INTEGRITY; |
| 118 } else { | 122 } else { |
| 119 NOTREACHED(); | 123 NOTREACHED(); |
| 120 return false; | 124 return false; |
| 121 } | 125 } |
| 122 | 126 |
| 123 return true; | 127 return true; |
| 124 } | 128 } |
| 125 | 129 |
| 126 } // namespace base | 130 } // namespace base |
| OLD | NEW |