OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <fcntl.h> | 7 #include <fcntl.h> |
8 #include <io.h> | 8 #include <io.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #include <userenv.h> | 10 #include <userenv.h> |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 ProcessId GetCurrentProcId() { | 170 ProcessId GetCurrentProcId() { |
171 return ::GetCurrentProcessId(); | 171 return ::GetCurrentProcessId(); |
172 } | 172 } |
173 | 173 |
174 ProcessHandle GetCurrentProcessHandle() { | 174 ProcessHandle GetCurrentProcessHandle() { |
175 return ::GetCurrentProcess(); | 175 return ::GetCurrentProcess(); |
176 } | 176 } |
177 | 177 |
178 HMODULE GetModuleFromAddress(void* address) { | 178 HMODULE GetModuleFromAddress(void* address) { |
179 HMODULE hinst = NULL; | 179 HMODULE instance = NULL; |
180 if (!::GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, | 180 if (!::GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | |
| 181 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, |
181 static_cast<char*>(address), | 182 static_cast<char*>(address), |
182 &hinst)) { | 183 &instance)) { |
183 NOTREACHED(); | 184 NOTREACHED(); |
184 } | 185 } |
185 return hinst; | 186 return instance; |
186 } | 187 } |
187 | 188 |
188 bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) { | 189 bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) { |
189 // We try to limit privileges granted to the handle. If you need this | 190 // We try to limit privileges granted to the handle. If you need this |
190 // for test code, consider using OpenPrivilegedProcessHandle instead of | 191 // for test code, consider using OpenPrivilegedProcessHandle instead of |
191 // adding more privileges here. | 192 // adding more privileges here. |
192 ProcessHandle result = OpenProcess(PROCESS_DUP_HANDLE | PROCESS_TERMINATE, | 193 ProcessHandle result = OpenProcess(PROCESS_DUP_HANDLE | PROCESS_TERMINATE, |
193 FALSE, pid); | 194 FALSE, pid); |
194 | 195 |
195 if (result == NULL) | 196 if (result == NULL) |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 | 996 |
996 PERFORMANCE_INFORMATION info; | 997 PERFORMANCE_INFORMATION info; |
997 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { | 998 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { |
998 DLOG(ERROR) << "Failed to fetch internal performance info."; | 999 DLOG(ERROR) << "Failed to fetch internal performance info."; |
999 return 0; | 1000 return 0; |
1000 } | 1001 } |
1001 return (info.CommitTotal * system_info.dwPageSize) / 1024; | 1002 return (info.CommitTotal * system_info.dwPageSize) / 1024; |
1002 } | 1003 } |
1003 | 1004 |
1004 } // namespace base | 1005 } // namespace base |
OLD | NEW |