| 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" |
| 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 void CloseProcessHandle(ProcessHandle process) { | |
| 24 CloseHandle(process); | |
| 25 } | |
| 26 | |
| 27 ProcessId GetProcId(ProcessHandle process) { | 23 ProcessId GetProcId(ProcessHandle process) { |
| 28 // This returns 0 if we have insufficient rights to query the process handle. | 24 // This returns 0 if we have insufficient rights to query the process handle. |
| 29 return GetProcessId(process); | 25 return GetProcessId(process); |
| 30 } | 26 } |
| 31 | 27 |
| 32 bool GetProcessIntegrityLevel(ProcessHandle process, IntegrityLevel *level) { | 28 bool GetProcessIntegrityLevel(ProcessHandle process, IntegrityLevel *level) { |
| 33 if (!level) | 29 if (!level) |
| 34 return false; | 30 return false; |
| 35 | 31 |
| 36 if (win::GetVersion() < base::win::VERSION_VISTA) | 32 if (win::GetVersion() < base::win::VERSION_VISTA) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 *level = HIGH_INTEGRITY; | 70 *level = HIGH_INTEGRITY; |
| 75 } else { | 71 } else { |
| 76 NOTREACHED(); | 72 NOTREACHED(); |
| 77 return false; | 73 return false; |
| 78 } | 74 } |
| 79 | 75 |
| 80 return true; | 76 return true; |
| 81 } | 77 } |
| 82 | 78 |
| 83 } // namespace base | 79 } // namespace base |
| OLD | NEW |