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

Side by Side Diff: base/process/memory_win.cc

Issue 1852143002: win: Remove GetModuleFromAddress, deduplicate __ImageBase code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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/memory.h" 5 #include "base/process/memory.h"
6 6
7 #include <new.h> 7 #include <new.h>
8 #include <psapi.h> 8 #include <psapi.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 void EnableTerminationOnHeapCorruption() { 53 void EnableTerminationOnHeapCorruption() {
54 // Ignore the result code. Supported on XP SP3 and Vista. 54 // Ignore the result code. Supported on XP SP3 and Vista.
55 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); 55 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
56 } 56 }
57 57
58 void EnableTerminationOnOutOfMemory() { 58 void EnableTerminationOnOutOfMemory() {
59 _set_new_handler(&OnNoMemory); 59 _set_new_handler(&OnNoMemory);
60 _set_new_mode(1); 60 _set_new_mode(1);
61 } 61 }
62 62
63 HMODULE GetModuleFromAddress(void* address) {
64 HMODULE instance = NULL;
65 if (!::GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
66 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
67 static_cast<char*>(address),
68 &instance)) {
69 NOTREACHED();
70 }
71 return instance;
72 }
73
74 // Implemented using a weak symbol. 63 // Implemented using a weak symbol.
75 bool UncheckedMalloc(size_t size, void** result) { 64 bool UncheckedMalloc(size_t size, void** result) {
76 *result = malloc_unchecked(size); 65 *result = malloc_unchecked(size);
77 return *result != NULL; 66 return *result != NULL;
78 } 67 }
79 68
80 } // namespace base 69 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698