Chromium Code Reviews| Index: base/win/scoped_handle.cc |
| diff --git a/base/win/scoped_handle.cc b/base/win/scoped_handle.cc |
| index 99dae66e3b2cc1610ea54c9d9e24750446b0566b..5c1ee8a3a406989dcc4e301b98a11b4c7a6aeff4 100644 |
| --- a/base/win/scoped_handle.cc |
| +++ b/base/win/scoped_handle.cc |
| @@ -22,6 +22,9 @@ __declspec(dllexport) void* GetHandleVerifier(); |
| typedef void* (*GetHandleVerifierFn)(); |
| } |
| +// http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx |
| +extern "C" IMAGE_DOS_HEADER __ImageBase; |
| + |
| namespace { |
| struct HandleHash { |
| @@ -85,6 +88,7 @@ class ActiveVerifier { |
| const void* pc1, const void* pc2); |
| virtual void Disable(); |
| virtual void OnHandleBeingClosed(HANDLE handle); |
| + virtual void GetModule(HMODULE* module) const; |
| private: |
| ~ActiveVerifier(); // Not implemented. |
| @@ -242,6 +246,10 @@ void ActiveVerifier::OnHandleBeingClosed(HANDLE handle) { |
| CHECK(false); // CloseHandle called on tracked handle. |
| } |
| +void ActiveVerifier::GetModule(HMODULE* module) const { |
| + *module = reinterpret_cast<HMODULE>(&__ImageBase); |
| +} |
| + |
| } // namespace |
| void* GetHandleVerifier() { |
| @@ -276,5 +284,14 @@ void OnHandleBeingClosed(HANDLE handle) { |
| return ActiveVerifier::Get()->OnHandleBeingClosed(handle); |
| } |
| +HMODULE GetHandleVerifierModuleForTesting() { |
| + HMODULE module = nullptr; |
| + |
| + // Must pass by reference in order to avoid tail-call optimization. |
|
scottmg
2016/03/11 22:13:09
This seems a bit hokey. Would __declspec(noinline)
Will Harris
2016/03/11 22:23:44
I needed this when using tracked_objects::GetProgr
Will Harris
2016/03/11 23:07:47
I simplified this, seems __ImageBase is less sensi
|
| + g_active_verifier->GetModule(&module); |
| + |
| + return module; |
| +} |
| + |
| } // namespace win |
| } // namespace base |