| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 10 matching lines...) Expand all Loading... |
| 21 typedef BOOL (WINAPI* HeapSetFn)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T); | 21 typedef BOOL (WINAPI* HeapSetFn)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T); |
| 22 | 22 |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 namespace process_util { | 25 namespace process_util { |
| 26 | 26 |
| 27 int GetCurrentProcId() { | 27 int GetCurrentProcId() { |
| 28 return ::GetCurrentProcessId(); | 28 return ::GetCurrentProcessId(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 ProcessHandle GetCurrentProcessHandle() { |
| 32 return ::GetCurrentProcess(); |
| 33 } |
| 34 |
| 31 // Helper for GetProcId() | 35 // Helper for GetProcId() |
| 32 bool GetProcIdViaGetProcessId(ProcessHandle process, DWORD* id) { | 36 bool GetProcIdViaGetProcessId(ProcessHandle process, DWORD* id) { |
| 33 // Dynamically get a pointer to GetProcessId(). | 37 // Dynamically get a pointer to GetProcessId(). |
| 34 typedef DWORD (WINAPI *GetProcessIdFunction)(HANDLE); | 38 typedef DWORD (WINAPI *GetProcessIdFunction)(HANDLE); |
| 35 static GetProcessIdFunction GetProcessIdPtr = NULL; | 39 static GetProcessIdFunction GetProcessIdPtr = NULL; |
| 36 static bool initialize_get_process_id = true; | 40 static bool initialize_get_process_id = true; |
| 37 if (initialize_get_process_id) { | 41 if (initialize_get_process_id) { |
| 38 initialize_get_process_id = false; | 42 initialize_get_process_id = false; |
| 39 HMODULE kernel32_handle = GetModuleHandle(L"kernel32.dll"); | 43 HMODULE kernel32_handle = GetModuleHandle(L"kernel32.dll"); |
| 40 if (!kernel32_handle) { | 44 if (!kernel32_handle) { |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 sizeof(lfh_flag)); | 596 sizeof(lfh_flag)); |
| 593 } | 597 } |
| 594 return true; | 598 return true; |
| 595 } | 599 } |
| 596 | 600 |
| 597 void RaiseProcessToHighPriority() { | 601 void RaiseProcessToHighPriority() { |
| 598 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); | 602 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); |
| 599 } | 603 } |
| 600 | 604 |
| 601 } // namespace process_util | 605 } // namespace process_util |
| OLD | NEW |