Bug 1460022: Part 9 - Update sandboxing code to work with revised DLL interceptor interface; r=bobowen
authorAaron Klotz <aklotz@mozilla.com>
Wed, 27 Jun 2018 11:51:29 -0600
changeset 424939 097d82eb192888b55fc00cc6ccba78098afda4cf
parent 424938 528b5685d597db2680e356bbd67fc52e575e3853
child 424940 9c21c99f6b7703765f86b5860c0d4e5462e7ed2a
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)
reviewersbobowen
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 9 - Update sandboxing code to work with revised DLL interceptor interface; r=bobowen
security/sandbox/win/SandboxInitialization.cpp
--- a/security/sandbox/win/SandboxInitialization.cpp
+++ b/security/sandbox/win/SandboxInitialization.cpp
@@ -10,26 +10,27 @@
 #include "nsWindowsDllInterceptor.h"
 #include "sandbox/win/src/sandbox_factory.h"
 #include "mozilla/sandboxing/permissionsService.h"
 
 namespace mozilla {
 namespace sandboxing {
 
 typedef BOOL(WINAPI* CloseHandle_func) (HANDLE hObject);
-static CloseHandle_func stub_CloseHandle = nullptr;
+static WindowsDllInterceptor::FuncHookType<CloseHandle_func> stub_CloseHandle;
 
 typedef BOOL(WINAPI* DuplicateHandle_func)(HANDLE hSourceProcessHandle,
                                            HANDLE hSourceHandle,
                                            HANDLE hTargetProcessHandle,
                                            LPHANDLE lpTargetHandle,
                                            DWORD dwDesiredAccess,
                                            BOOL bInheritHandle,
                                            DWORD dwOptions);
-static DuplicateHandle_func stub_DuplicateHandle = nullptr;
+static WindowsDllInterceptor::FuncHookType<DuplicateHandle_func>
+  stub_DuplicateHandle;
 
 static BOOL WINAPI
 patched_CloseHandle(HANDLE hObject)
 {
   // Check all handles being closed against the sandbox's tracked handles.
   base::win::OnHandleBeingClosed(hObject);
   return stub_CloseHandle(hObject);
 }
@@ -57,27 +58,24 @@ patched_DuplicateHandle(HANDLE hSourcePr
 
 static WindowsDllInterceptor Kernel32Intercept;
 
 static bool
 EnableHandleCloseMonitoring()
 {
   Kernel32Intercept.Init("kernel32.dll");
   bool hooked =
-    Kernel32Intercept.AddHook("CloseHandle",
-                              reinterpret_cast<intptr_t>(patched_CloseHandle),
-                              (void**)&stub_CloseHandle);
+    stub_CloseHandle.Set(Kernel32Intercept, "CloseHandle", &patched_CloseHandle);
   if (!hooked) {
     return false;
   }
 
   hooked =
-    Kernel32Intercept.AddHook("DuplicateHandle",
-                              reinterpret_cast<intptr_t>(patched_DuplicateHandle),
-                              (void**)&stub_DuplicateHandle);
+    stub_DuplicateHandle.Set(Kernel32Intercept, "DuplicateHandle",
+                             &patched_DuplicateHandle);
   if (!hooked) {
     return false;
   }
 
   return true;
 }
 
 static bool