diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index db0389563b1e..f15691569075 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -352,9 +352,6 @@ static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID); // General purpose user32.dll hook object static WindowsDllInterceptor sUser32Intercept; -// AddHook success checks -static mozilla::Maybe sHookedGetWindowInfo; - // 2 pixel offset for eTransparencyBorderlessGlass which equals the size of // the default window border Windows paints. Glass will be extended inward // this distance to remove the border. @@ -461,17 +458,17 @@ private: if (!IsWin10OrLater() && GetModuleHandle(L"tiptsf.dll") && !sProcessCaretEventsStub) { sTipTsfInterceptor.Init("tiptsf.dll"); - DebugOnly ok = sTipTsfInterceptor.AddHook("ProcessCaretEvents", - reinterpret_cast(&ProcessCaretEventsHook), - (void**) &sProcessCaretEventsStub); + DebugOnly ok = sProcessCaretEventsStub.Set(sTipTsfInterceptor, + "ProcessCaretEvents", + &ProcessCaretEventsHook); MOZ_ASSERT(ok); } if (!sSendMessageTimeoutWStub) { sUser32Intercept.Init("user32.dll"); - DebugOnly hooked = sUser32Intercept.AddHook("SendMessageTimeoutW", - reinterpret_cast(&SendMessageTimeoutWHook), - (void**) &sSendMessageTimeoutWStub); + DebugOnly hooked = sSendMessageTimeoutWStub.Set(sUser32Intercept, + "SendMessageTimeoutW", + &SendMessageTimeoutWHook); MOZ_ASSERT(hooked); } } @@ -556,8 +553,10 @@ private: } static WindowsDllInterceptor sTipTsfInterceptor; - static WINEVENTPROC sProcessCaretEventsStub; - static decltype(&SendMessageTimeoutW) sSendMessageTimeoutWStub; + static WindowsDllInterceptor::FuncHookType + sProcessCaretEventsStub; + static WindowsDllInterceptor::FuncHookType + sSendMessageTimeoutWStub; static StaticAutoPtr sInstance; HHOOK mHook; @@ -566,8 +565,10 @@ private: }; WindowsDllInterceptor TIPMessageHandler::sTipTsfInterceptor; -WINEVENTPROC TIPMessageHandler::sProcessCaretEventsStub; -decltype(&SendMessageTimeoutW) TIPMessageHandler::sSendMessageTimeoutWStub; +WindowsDllInterceptor::FuncHookType + TIPMessageHandler::sProcessCaretEventsStub; +WindowsDllInterceptor::FuncHookType + TIPMessageHandler::sSendMessageTimeoutWStub; StaticAutoPtr TIPMessageHandler::sInstance; } // namespace mozilla @@ -2472,7 +2473,7 @@ nsWindow::ResetLayout() // margins are set. static const wchar_t kManageWindowInfoProperty[] = L"ManageWindowInfoProperty"; typedef BOOL (WINAPI *GetWindowInfoPtr)(HWND hwnd, PWINDOWINFO pwi); -static GetWindowInfoPtr sGetWindowInfoPtrStub = nullptr; +static WindowsDllInterceptor::FuncHookType sGetWindowInfoPtrStub; BOOL WINAPI GetWindowInfoHook(HWND hWnd, PWINDOWINFO pwi) @@ -2500,18 +2501,15 @@ nsWindow::UpdateGetWindowInfoCaptionStatus(bool aActiveCaption) if (!mWnd) return; - if (sHookedGetWindowInfo.isNothing()) { - sUser32Intercept.Init("user32.dll"); - sHookedGetWindowInfo = - Some(sUser32Intercept.AddHook("GetWindowInfo", - reinterpret_cast(GetWindowInfoHook), - (void**) &sGetWindowInfoPtrStub)); - if (!sHookedGetWindowInfo.value()) { - return; - } + sUser32Intercept.Init("user32.dll"); + sGetWindowInfoPtrStub.Set(sUser32Intercept, "GetWindowInfo", + &GetWindowInfoHook); + if (!sGetWindowInfoPtrStub) { + return; } + // Update our internally tracked caption status - SetPropW(mWnd, kManageWindowInfoProperty, + SetPropW(mWnd, kManageWindowInfoProperty, reinterpret_cast(static_cast(aActiveCaption) + 1)); }