Bug 1511438 Part 1: Replace ProcessTypeRequiresWinEventHook with XRE_Win32kCallsAllowed. r=froydnj
authorBob Owen <bobowencode@gmail.com>
Tue, 29 Jan 2019 08:49:13 +0000
changeset 455737 3a9c07fcc2ebb478ab21740f9d10d1af914bdac7
parent 455736 e741f3208ec83a53f26747af1acacb4d1263cab3
child 455738 55a7c08b3b67c472266f383b14cc4ca3803849c9
push id111543
push userbobowencode@gmail.com
push dateTue, 29 Jan 2019 08:49:43 +0000
treeherdermozilla-inbound@55a7c08b3b67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1511438
milestone67.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 1511438 Part 1: Replace ProcessTypeRequiresWinEventHook with XRE_Win32kCallsAllowed. r=froydnj ProcessTypeRequiresWinEventHook was added when attempting to turn on win32k lockdown for GMP processes. Having a less specific, but globally accessible, function will make it more useful while applying win32k lockdown to other process types.
ipc/glue/WindowsMessageLoop.cpp
toolkit/xre/nsAppRunner.cpp
xpcom/build/nsXULAppAPI.h
--- a/ipc/glue/WindowsMessageLoop.cpp
+++ b/ipc/glue/WindowsMessageLoop.cpp
@@ -629,37 +629,28 @@ bool TimeoutHasExpired(const TimeoutData
 }
 
 }  // namespace
 
 namespace mozilla {
 namespace ipc {
 namespace windows {
 
-static bool ProcessTypeRequiresWinEventHook() {
-  switch (XRE_GetProcessType()) {
-    case GeckoProcessType_GMPlugin:
-      return false;
-    default:
-      return true;
-  }
-}
-
 void InitUIThread() {
   // If we aren't setup before a call to NotifyWorkerThread, we'll hang
   // on startup.
   if (!gUIThreadId) {
     gUIThreadId = GetCurrentThreadId();
   }
 
   MOZ_ASSERT(gUIThreadId);
   MOZ_ASSERT(gUIThreadId == GetCurrentThreadId(),
              "Called InitUIThread multiple times on different threads!");
 
-  if (!gWinEventHook && ProcessTypeRequiresWinEventHook()) {
+  if (!gWinEventHook && XRE_Win32kCallsAllowed()) {
     gWinEventHook = SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_DESTROY,
                                     NULL, &WinEventHook, GetCurrentProcessId(),
                                     gUIThreadId, WINEVENT_OUTOFCONTEXT);
     MOZ_ASSERT(gWinEventHook);
 
     // We need to execute this after setting the hook in case the OLE window
     // already existed.
     gCOMWindow = FindCOMWindow();
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -4729,16 +4729,28 @@ bool XRE_UseNativeEventProcessing() {
     }
 
     return sUseNativeEventProcessing;
   }
 
   return true;
 }
 
+#if defined(XP_WIN)
+bool XRE_Win32kCallsAllowed() {
+  switch (XRE_GetProcessType()) {
+    case GeckoProcessType_GMPlugin:
+    case GeckoProcessType_RDD:
+      return false;
+    default:
+      return true;
+  }
+}
+#endif
+
 // If you add anything to this enum, please update about:support to reflect it
 enum {
   kE10sEnabledByUser = 0,
   kE10sEnabledByDefault = 1,
   kE10sDisabledByUser = 2,
   // kE10sDisabledInSafeMode = 3, was removed in bug 1172491.
   // kE10sDisabledForAccessibility = 4,
   // kE10sDisabledForMacGfx = 5, was removed in bug 1068674.
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -446,16 +446,24 @@ XRE_API(bool, XRE_IsE10sParentProcess, (
 XRE_API(bool, XRE_IsSocketProcess, ())
 
 /**
  * Returns true if the appshell should run its own native event loop. Returns
  * false if we should rely solely on the Gecko event loop.
  */
 XRE_API(bool, XRE_UseNativeEventProcessing, ())
 
+#if defined(XP_WIN)
+/**
+ * @returns true if win32k calls are allowed in this process type, false if
+ *          win32k is (or should be) disabled.
+ */
+XRE_API(bool, XRE_Win32kCallsAllowed, ())
+#endif
+
 typedef void (*MainFunction)(void* aData);
 
 XRE_API(nsresult, XRE_InitParentProcess,
         (int aArgc, char* aArgv[], MainFunction aMainFunction,
          void* aMainFunctionExtraData))
 
 XRE_API(int, XRE_RunIPDLTest, (int aArgc, char* aArgv[]))