Bug 1460022: Part 13 - Update profiler to use revised DLL interceptor interface; r=njn
authorAaron Klotz <aklotz@mozilla.com>
Wed, 27 Jun 2018 14:23:29 -0600
changeset 424943 ff25e66da36e4c95363e684880085f99d845da2a
parent 424942 1cdba0bde1857d2c8611fceaaa5f1d9fc6168ff6
child 424944 a355ad34b92b9b75bce1667db40a62063ead215f
child 424977 cc3401e78e8bbae22e6dbc854e525ceae4923bcf
push id104944
push useraklotz@mozilla.com
push dateWed, 04 Jul 2018 02:23:52 +0000
treeherdermozilla-inbound@ff25e66da36e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1460022
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1460022: Part 13 - Update profiler to use revised DLL interceptor interface; r=njn
tools/profiler/core/platform-win32.cpp
--- a/tools/profiler/core/platform-win32.cpp
+++ b/tools/profiler/core/platform-win32.cpp
@@ -298,32 +298,34 @@ Registers::SyncPopulate()
   PopulateRegsFromContext(*this, &context);
 }
 #endif
 
 #if defined(GP_PLAT_amd64_windows)
 static WindowsDllInterceptor NtDllIntercept;
 
 typedef NTSTATUS (NTAPI *LdrUnloadDll_func)(HMODULE module);
-static LdrUnloadDll_func stub_LdrUnloadDll;
+static WindowsDllInterceptor::FuncHookType<LdrUnloadDll_func>
+  stub_LdrUnloadDll;
 
 static NTSTATUS NTAPI
 patched_LdrUnloadDll(HMODULE module)
 {
   // Prevent the stack walker from suspending this thread when LdrUnloadDll
   // holds the RtlLookupFunctionEntry lock.
   AutoSuppressStackWalking suppress;
   return stub_LdrUnloadDll(module);
 }
 
 // These pointers are disguised as PVOID to avoid pulling in obscure headers
 typedef PVOID (WINAPI *LdrResolveDelayLoadedAPI_func)(PVOID ParentModuleBase,
   PVOID DelayloadDescriptor, PVOID FailureDllHook, PVOID FailureSystemHook,
   PVOID ThunkAddress, ULONG Flags);
-static LdrResolveDelayLoadedAPI_func stub_LdrResolveDelayLoadedAPI;
+static WindowsDllInterceptor::FuncHookType<LdrResolveDelayLoadedAPI_func>
+  stub_LdrResolveDelayLoadedAPI;
 
 static PVOID WINAPI
 patched_LdrResolveDelayLoadedAPI(PVOID ParentModuleBase,
   PVOID DelayloadDescriptor, PVOID FailureDllHook, PVOID FailureSystemHook,
   PVOID ThunkAddress, ULONG Flags)
 {
   // Prevent the stack walker from suspending this thread when
   // LdrResolveDelayLoadAPI holds the RtlLookupFunctionEntry lock.
@@ -331,26 +333,18 @@ patched_LdrResolveDelayLoadedAPI(PVOID P
   return stub_LdrResolveDelayLoadedAPI(ParentModuleBase, DelayloadDescriptor,
                                        FailureDllHook, FailureSystemHook,
                                        ThunkAddress, Flags);
 }
 
 void
 InitializeWin64ProfilerHooks()
 {
-  static bool initialized = false;
-  if (initialized) {
-    return;
-  }
-  initialized = true;
-
   NtDllIntercept.Init("ntdll.dll");
-  NtDllIntercept.AddHook("LdrUnloadDll",
-                         reinterpret_cast<intptr_t>(patched_LdrUnloadDll),
-                         (void**)&stub_LdrUnloadDll);
+  stub_LdrUnloadDll.Set(NtDllIntercept, "LdrUnloadDll", &patched_LdrUnloadDll);
   if (IsWin8OrLater()) { // LdrResolveDelayLoadedAPI was introduced in Win8
-    NtDllIntercept.AddHook("LdrResolveDelayLoadedAPI",
-                           reinterpret_cast<intptr_t>(patched_LdrResolveDelayLoadedAPI),
-                           (void**)&stub_LdrResolveDelayLoadedAPI);
+    stub_LdrResolveDelayLoadedAPI.Set(NtDllIntercept,
+                                      "LdrResolveDelayLoadedAPI",
+                                      &patched_LdrResolveDelayLoadedAPI);
   }
 }
 #endif // defined(GP_PLAT_amd64_windows)