Bug 1241921: Remove CreateWindow* hooks from IPC glue; r=jimm

MozReview-Commit-ID: 5YZxwMzMrtx
This commit is contained in:
Aaron Klotz
2016-10-17 12:06:58 -06:00
parent 9538d1cde4
commit 6eea26edaa

View File

@@ -14,7 +14,6 @@
#include "nsServiceManagerUtils.h"
#include "nsString.h"
#include "nsIXULAppInfo.h"
#include "nsWindowsDllInterceptor.h"
#include "WinUtils.h"
#include "mozilla/ArrayUtils.h"
@@ -437,95 +436,6 @@ ProcessOrDeferMessage(HWND hwnd,
return res;
}
/*
* It is bad to subclass a window when neutering is active because you'll end
* up subclassing the *neutered* window procedure instead of the real window
* procedure. Since CreateWindow* fires WM_CREATE (and could thus trigger
* neutering), we intercept these calls and suppress neutering for the duration
* of the call. This ensures that any subsequent subclassing replaces the
* correct window procedure.
*/
WindowsDllInterceptor sUser32Interceptor;
typedef HWND (WINAPI *CreateWindowExWPtr)(DWORD,LPCWSTR,LPCWSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID);
typedef HWND (WINAPI *CreateWindowExAPtr)(DWORD,LPCSTR,LPCSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID);
typedef HWND (WINAPI *CreateWindowWPtr)(LPCWSTR,LPCWSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID);
typedef HWND (WINAPI *CreateWindowAPtr)(LPCSTR,LPCSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID);
CreateWindowExWPtr sCreateWindowExWStub = nullptr;
CreateWindowExAPtr sCreateWindowExAStub = nullptr;
CreateWindowWPtr sCreateWindowWStub = nullptr;
CreateWindowAPtr sCreateWindowAStub = nullptr;
HWND WINAPI
CreateWindowExWHook(DWORD aExStyle, LPCWSTR aClassName, LPCWSTR aWindowName,
DWORD aStyle, int aX, int aY, int aWidth, int aHeight,
HWND aParent, HMENU aMenu, HINSTANCE aInstance,
LPVOID aParam)
{
SuppressedNeuteringRegion doNotNeuterThisWindowYet;
return sCreateWindowExWStub(aExStyle, aClassName, aWindowName, aStyle, aX, aY,
aWidth, aHeight, aParent, aMenu, aInstance, aParam);
}
HWND WINAPI
CreateWindowExAHook(DWORD aExStyle, LPCSTR aClassName, LPCSTR aWindowName,
DWORD aStyle, int aX, int aY, int aWidth, int aHeight,
HWND aParent, HMENU aMenu, HINSTANCE aInstance,
LPVOID aParam)
{
SuppressedNeuteringRegion doNotNeuterThisWindowYet;
return sCreateWindowExAStub(aExStyle, aClassName, aWindowName, aStyle, aX, aY,
aWidth, aHeight, aParent, aMenu, aInstance, aParam);
}
HWND WINAPI
CreateWindowWHook(LPCWSTR aClassName, LPCWSTR aWindowName, DWORD aStyle, int aX,
int aY, int aWidth, int aHeight, HWND aParent, HMENU aMenu,
HINSTANCE aInstance, LPVOID aParam)
{
SuppressedNeuteringRegion doNotNeuterThisWindowYet;
return sCreateWindowWStub(aClassName, aWindowName, aStyle, aX, aY, aWidth,
aHeight, aParent, aMenu, aInstance, aParam);
}
HWND WINAPI
CreateWindowAHook(LPCSTR aClassName, LPCSTR aWindowName, DWORD aStyle, int aX,
int aY, int aWidth, int aHeight, HWND aParent, HMENU aMenu,
HINSTANCE aInstance, LPVOID aParam)
{
SuppressedNeuteringRegion doNotNeuterThisWindowYet;
return sCreateWindowAStub(aClassName, aWindowName, aStyle, aX, aY, aWidth,
aHeight, aParent, aMenu, aInstance, aParam);
}
void
InitCreateWindowHook()
{
// Forcing these interceptions to be detours due to conflicts with
// NVIDIA Optimus DLLs that are injected into our process.
sUser32Interceptor.Init("user32.dll");
if (!sCreateWindowExWStub) {
sUser32Interceptor.AddDetour("CreateWindowExW",
reinterpret_cast<intptr_t>(CreateWindowExWHook),
(void**) &sCreateWindowExWStub);
}
if (!sCreateWindowExAStub) {
sUser32Interceptor.AddDetour("CreateWindowExA",
reinterpret_cast<intptr_t>(CreateWindowExAHook),
(void**) &sCreateWindowExAStub);
}
if (!sCreateWindowWStub) {
sUser32Interceptor.AddDetour("CreateWindowW",
reinterpret_cast<intptr_t>(CreateWindowWHook),
(void**) &sCreateWindowWStub);
}
if (!sCreateWindowAStub) {
sUser32Interceptor.AddDetour("CreateWindowA",
reinterpret_cast<intptr_t>(CreateWindowAHook),
(void**) &sCreateWindowAStub);
}
}
} // namespace
// We need the pointer value of this in PluginInstanceChild.
@@ -802,8 +712,6 @@ InitUIThread()
gCOMWindow = FindCOMWindow();
}
MOZ_ASSERT(gWinEventHook);
InitCreateWindowHook();
}
} // namespace windows