OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "base/process/process.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/process/kill.h" | 9 #include "base/process/kill.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 | 48 |
49 // static | 49 // static |
50 Process Process::OpenWithExtraPriviles(ProcessId pid) { | 50 Process Process::OpenWithExtraPriviles(ProcessId pid) { |
51 DWORD access = kBasicProcessAccess | PROCESS_DUP_HANDLE | PROCESS_VM_READ; | 51 DWORD access = kBasicProcessAccess | PROCESS_DUP_HANDLE | PROCESS_VM_READ; |
52 ProcessHandle handle = ::OpenProcess(access, FALSE, pid); | 52 ProcessHandle handle = ::OpenProcess(access, FALSE, pid); |
53 return Process(handle); | 53 return Process(handle); |
54 } | 54 } |
55 | 55 |
56 // static | 56 // static |
| 57 Process Process::OpenWithAccess(ProcessId pid, DWORD desired_access) { |
| 58 return Process(::OpenProcess(desired_access, FALSE, pid)); |
| 59 } |
| 60 |
| 61 // static |
57 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { | 62 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { |
58 DCHECK_NE(handle, ::GetCurrentProcess()); | 63 DCHECK_NE(handle, ::GetCurrentProcess()); |
59 ProcessHandle out_handle; | 64 ProcessHandle out_handle; |
60 if (!::DuplicateHandle(GetCurrentProcess(), handle, | 65 if (!::DuplicateHandle(GetCurrentProcess(), handle, |
61 GetCurrentProcess(), &out_handle, | 66 GetCurrentProcess(), &out_handle, |
62 0, FALSE, DUPLICATE_SAME_ACCESS)) { | 67 0, FALSE, DUPLICATE_SAME_ACCESS)) { |
63 return Process(); | 68 return Process(); |
64 } | 69 } |
65 return Process(out_handle); | 70 return Process(out_handle); |
66 } | 71 } |
(...skipping 21 matching lines...) Expand all Loading... |
88 GetCurrentProcess(), | 93 GetCurrentProcess(), |
89 &out_handle, | 94 &out_handle, |
90 0, | 95 0, |
91 FALSE, | 96 FALSE, |
92 DUPLICATE_SAME_ACCESS)) { | 97 DUPLICATE_SAME_ACCESS)) { |
93 return Process(); | 98 return Process(); |
94 } | 99 } |
95 return Process(out_handle); | 100 return Process(out_handle); |
96 } | 101 } |
97 | 102 |
98 ProcessId Process::pid() const { | 103 ProcessId Process::Pid() const { |
99 DCHECK(IsValid()); | 104 DCHECK(IsValid()); |
100 return GetProcId(Handle()); | 105 return GetProcId(Handle()); |
101 } | 106 } |
102 | 107 |
103 bool Process::is_current() const { | 108 bool Process::is_current() const { |
104 return is_current_process_; | 109 return is_current_process_; |
105 } | 110 } |
106 | 111 |
107 void Process::Close() { | 112 void Process::Close() { |
108 is_current_process_ = false; | 113 is_current_process_ = false; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 166 |
162 return (::SetPriorityClass(Handle(), priority) != 0); | 167 return (::SetPriorityClass(Handle(), priority) != 0); |
163 } | 168 } |
164 | 169 |
165 int Process::GetPriority() const { | 170 int Process::GetPriority() const { |
166 DCHECK(IsValid()); | 171 DCHECK(IsValid()); |
167 return ::GetPriorityClass(Handle()); | 172 return ::GetPriorityClass(Handle()); |
168 } | 173 } |
169 | 174 |
170 } // namespace base | 175 } // namespace base |
OLD | NEW |