Index: base/win/scoped_handle.cc |
diff --git a/base/win/scoped_handle.cc b/base/win/scoped_handle.cc |
index 99dae66e3b2cc1610ea54c9d9e24750446b0566b..91aae13f8952ee7933952677dca70bb58ac67d11 100644 |
--- a/base/win/scoped_handle.cc |
+++ b/base/win/scoped_handle.cc |
@@ -12,8 +12,10 @@ |
#include "base/debug/stack_trace.h" |
#include "base/hash.h" |
#include "base/lazy_instance.h" |
+#include "base/location.h" |
#include "base/logging.h" |
#include "base/macros.h" |
+#include "base/process/memory.h" |
#include "base/synchronization/lock_impl.h" |
#include "base/threading/thread_local.h" |
@@ -85,6 +87,7 @@ class ActiveVerifier { |
const void* pc1, const void* pc2); |
virtual void Disable(); |
virtual void OnHandleBeingClosed(HANDLE handle); |
+ virtual bool GetCodeAddress(const void** pc) const; |
private: |
~ActiveVerifier(); // Not implemented. |
@@ -242,6 +245,15 @@ void ActiveVerifier::OnHandleBeingClosed(HANDLE handle) { |
CHECK(false); // CloseHandle called on tracked handle. |
} |
+bool ActiveVerifier::GetCodeAddress(const void** pc) const { |
+ if (enabled_) { |
+ *pc = tracked_objects::GetProgramCounter(); |
+ return true; |
+ } |
+ |
+ return false; |
+} |
+ |
} // namespace |
void* GetHandleVerifier() { |
@@ -276,5 +288,15 @@ void OnHandleBeingClosed(HANDLE handle) { |
return ActiveVerifier::Get()->OnHandleBeingClosed(handle); |
} |
+HMODULE GetHandleVerifierModuleForTesting() { |
+ const void* pc = nullptr; |
+ |
+ bool success = g_active_verifier->GetCodeAddress(&pc); |
+ if (success) |
+ return base::GetModuleFromAddress(pc); |
scottmg
2016/03/11 19:02:18
Can you just use &__ImageBase instead?
.. Oh, I s
Will Harris
2016/03/11 20:35:31
I've actually changed this to use __ImageBase insi
|
+ |
+ return nullptr; |
+} |
+ |
} // namespace win |
} // namespace base |