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

Unified Diff: base/debug/profiler.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, 9 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
Index: base/debug/profiler.cc
diff --git a/base/debug/profiler.cc b/base/debug/profiler.cc
index a205d1f82defab85666c915ef6309fac0479e109..15d1d8ccd0f6fb2f36289bdf4e8ca33c203ad5a0 100644
--- a/base/debug/profiler.cc
+++ b/base/debug/profiler.cc
@@ -13,6 +13,7 @@
#include "build/build_config.h"
#if defined(OS_WIN)
+#include "base/win/current_module.h"
#include "base/win/pe_image.h"
#endif // defined(OS_WIN)
@@ -108,9 +109,6 @@ MoveDynamicSymbol GetProfilerMoveDynamicSymbolFunc() {
#else // defined(OS_WIN)
-// http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
-extern "C" IMAGE_DOS_HEADER __ImageBase;
-
bool IsBinaryInstrumented() {
enum InstrumentationCheckState {
UNINITIALIZED,
@@ -121,8 +119,7 @@ bool IsBinaryInstrumented() {
static InstrumentationCheckState state = UNINITIALIZED;
if (state == UNINITIALIZED) {
- HMODULE this_module = reinterpret_cast<HMODULE>(&__ImageBase);
- base::win::PEImage image(this_module);
+ base::win::PEImage image(CURRENT_MODULE());
// Check to be sure our image is structured as we'd expect.
DCHECK(image.VerifyMagic());
@@ -192,8 +189,7 @@ FunctionType FindFunctionInImports(const char* function_name) {
if (!IsBinaryInstrumented())
return NULL;
- HMODULE this_module = reinterpret_cast<HMODULE>(&__ImageBase);
- base::win::PEImage image(this_module);
+ base::win::PEImage image(CURRENT_MODULE());
FunctionSearchContext ctx = { function_name, NULL };
image.EnumImportChunks(FindResolutionFunctionInImports, &ctx);

Powered by Google App Engine
This is Rietveld 408576698