Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1764)

Unified Diff: base/process_util_win.cc

Issue 17910003: Split memory-related routines out of base/process_util.h into base/process/memory.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process_util_unittest_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_win.cc
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 5fadf4ac6430d7c808306d10aeffd143658b6c33..22301057747fd9ec313e0cac731fda6589d6c269 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -50,18 +50,6 @@ static const int kWaitInterval = 2000;
// process goes away.
const DWORD kProcessKilledExitCode = 1;
-// HeapSetInformation function pointer.
-typedef BOOL (WINAPI* HeapSetFn)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T);
-
-void OnNoMemory() {
- // Kill the process. This is important for security, since WebKit doesn't
- // NULL-check many memory allocations. If a malloc fails, returns NULL, and
- // the buffer is then used, it provides a handy mapping of memory starting at
- // address 0 for an attacker to utilize.
- __debugbreak();
- _exit(1);
-}
-
class TimerExpiredTask : public win::ObjectWatcher::Delegate {
public:
explicit TimerExpiredTask(ProcessHandle process);
@@ -183,17 +171,6 @@ ProcessHandle GetCurrentProcessHandle() {
return ::GetCurrentProcess();
}
-HMODULE GetModuleFromAddress(void* address) {
- HMODULE instance = NULL;
- if (!::GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
- GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
- static_cast<char*>(address),
- &instance)) {
- NOTREACHED();
- }
- return instance;
-}
-
bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) {
// We try to limit privileges granted to the handle. If you need this
// for test code, consider using OpenPrivilegedProcessHandle instead of
@@ -632,50 +609,6 @@ void EnsureProcessTerminated(ProcessHandle process) {
base::TimeDelta::FromMilliseconds(kWaitInterval));
}
-bool EnableLowFragmentationHeap() {
- HMODULE kernel32 = GetModuleHandle(L"kernel32.dll");
- HeapSetFn heap_set = reinterpret_cast<HeapSetFn>(GetProcAddress(
- kernel32,
- "HeapSetInformation"));
-
- // On Windows 2000, the function is not exported. This is not a reason to
- // fail.
- if (!heap_set)
- return true;
-
- unsigned number_heaps = GetProcessHeaps(0, NULL);
- if (!number_heaps)
- return false;
-
- // Gives us some extra space in the array in case a thread is creating heaps
- // at the same time we're querying them.
- static const int MARGIN = 8;
- scoped_ptr<HANDLE[]> heaps(new HANDLE[number_heaps + MARGIN]);
- number_heaps = GetProcessHeaps(number_heaps + MARGIN, heaps.get());
- if (!number_heaps)
- return false;
-
- for (unsigned i = 0; i < number_heaps; ++i) {
- ULONG lfh_flag = 2;
- // Don't bother with the result code. It may fails on heaps that have the
- // HEAP_NO_SERIALIZE flag. This is expected and not a problem at all.
- heap_set(heaps[i],
- HeapCompatibilityInformation,
- &lfh_flag,
- sizeof(lfh_flag));
- }
- return true;
-}
-
-void EnableTerminationOnHeapCorruption() {
- // Ignore the result code. Supported on XP SP3 and Vista.
- HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
-}
-
-void EnableTerminationOnOutOfMemory() {
- std::set_new_handler(&OnNoMemory);
-}
-
void RaiseProcessToHighPriority() {
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
}
« no previous file with comments | « base/process_util_unittest_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698