Bug 1460022: Part 8 - Update DLL blocklist to work with revised DLL interceptor interface; r=mhowell
☠☠ backed out by 9cfc3fe9fe38 ☠ ☠
authorAaron Klotz <aklotz@mozilla.com>
Wed, 27 Jun 2018 11:51:10 -0600
changeset 482692 d4a036b976e65d417fa571788e7dd111038d2c4c
parent 482691 5f3dfde41e384ad6374a22cdd5d4964bd0602491
child 482693 be7032cddad2709068fb4606e10167697ba1944d
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhowell
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 8 - Update DLL blocklist to work with revised DLL interceptor interface; r=mhowell
mozglue/build/WindowsDllBlocklist.cpp
--- a/mozglue/build/WindowsDllBlocklist.cpp
+++ b/mozglue/build/WindowsDllBlocklist.cpp
@@ -85,24 +85,24 @@ printf_stderr(const char *fmt, ...)
   vfprintf(fp, fmt, args);
   va_end(args);
 
   fclose(fp);
 }
 
 
 typedef MOZ_NORETURN_PTR void (__fastcall* BaseThreadInitThunk_func)(BOOL aIsInitialThread, void* aStartAddress, void* aThreadParam);
-static BaseThreadInitThunk_func stub_BaseThreadInitThunk = nullptr;
+static WindowsDllInterceptor::FuncHookType<BaseThreadInitThunk_func> stub_BaseThreadInitThunk;
 
 typedef NTSTATUS (NTAPI *LdrLoadDll_func) (PWCHAR filePath, PULONG flags, PUNICODE_STRING moduleFileName, PHANDLE handle);
-static LdrLoadDll_func stub_LdrLoadDll;
+static WindowsDllInterceptor::FuncHookType<LdrLoadDll_func> stub_LdrLoadDll;
 
 #ifdef _M_AMD64
 typedef decltype(RtlInstallFunctionTableCallback)* RtlInstallFunctionTableCallback_func;
-static RtlInstallFunctionTableCallback_func stub_RtlInstallFunctionTableCallback;
+static WindowsDllInterceptor::FuncHookType<RtlInstallFunctionTableCallback_func> stub_RtlInstallFunctionTableCallback;
 
 extern uint8_t* sMsMpegJitCodeRegionStart;
 extern size_t sMsMpegJitCodeRegionSize;
 
 BOOLEAN WINAPI patched_RtlInstallFunctionTableCallback(DWORD64 TableIdentifier,
   DWORD64 BaseAddress, DWORD Length, PGET_RUNTIME_FUNCTION_CALLBACK Callback,
   PVOID Context, PCWSTR OutOfProcessCallbackDll)
 {
@@ -657,17 +657,18 @@ DllBlocklist_Initialize(uint32_t aInitFl
 
   NtDllIntercept.Init("ntdll.dll");
 
   ReentrancySentinel::InitializeStatics();
 
   // We specifically use a detour, because there are cases where external
   // code also tries to hook LdrLoadDll, and doesn't know how to relocate our
   // nop space patches. (Bug 951827)
-  bool ok = NtDllIntercept.AddDetour("LdrLoadDll", reinterpret_cast<intptr_t>(patched_LdrLoadDll), (void**) &stub_LdrLoadDll);
+  bool ok = stub_LdrLoadDll.SetDetour(NtDllIntercept, "LdrLoadDll",
+                                      &patched_LdrLoadDll);
 
   if (!ok) {
     sBlocklistInitFailed = true;
 #ifdef DEBUG
     printf_stderr("LdrLoadDll hook failed, no dll blocklisting active\n");
 #endif
   }
 
@@ -678,28 +679,28 @@ DllBlocklist_Initialize(uint32_t aInitFl
     ::LoadLibraryW(L"user32.dll");
   }
 
   Kernel32Intercept.Init("kernel32.dll");
 
 #ifdef _M_AMD64
   if (!IsWin8OrLater()) {
     // The crash that this hook works around is only seen on Win7.
-    Kernel32Intercept.AddHook("RtlInstallFunctionTableCallback",
-                              reinterpret_cast<intptr_t>(patched_RtlInstallFunctionTableCallback),
-                              (void**)&stub_RtlInstallFunctionTableCallback);
+    stub_RtlInstallFunctionTableCallback.Set(Kernel32Intercept,
+                                             "RtlInstallFunctionTableCallback",
+                                             &patched_RtlInstallFunctionTableCallback);
   }
 #endif
 
   // Bug 1361410: WRusr.dll will overwrite our hook and cause a crash.
   // Workaround: If we detect WRusr.dll, don't hook.
   if (!GetModuleHandleW(L"WRusr.dll")) {
-    if(!Kernel32Intercept.AddDetour("BaseThreadInitThunk",
-                                    reinterpret_cast<intptr_t>(patched_BaseThreadInitThunk),
-                                    (void**) &stub_BaseThreadInitThunk)) {
+    if (!stub_BaseThreadInitThunk.SetDetour(Kernel32Intercept,
+                                            "BaseThreadInitThunk",
+                                            &patched_BaseThreadInitThunk)) {
 #ifdef DEBUG
     printf_stderr("BaseThreadInitThunk hook failed\n");
 #endif
     }
   }
 
 #if defined(NIGHTLY_BUILD)
   // Populate a list of thread start addresses to block.