diff --git a/browser/app/winlauncher/DllBlocklistWin.cpp b/browser/app/winlauncher/DllBlocklistWin.cpp index a88a0747348f..a7c55882e7a4 100644 --- a/browser/app/winlauncher/DllBlocklistWin.cpp +++ b/browser/app/winlauncher/DllBlocklistWin.cpp @@ -357,21 +357,13 @@ InitializeDllBlocklistOOP(HANDLE aChildProcess) { mozilla::CrossProcessDllInterceptor intcpt(aChildProcess); intcpt.Init(L"ntdll.dll"); - bool ok = stub_NtMapViewOfSection.SetDetour(intcpt, "NtMapViewOfSection", + bool ok = stub_NtMapViewOfSection.SetDetour(aChildProcess, intcpt, + "NtMapViewOfSection", &patched_NtMapViewOfSection); if (!ok) { return false; } - // Set the child process's copy of stub_NtMapViewOfSection - SIZE_T bytesWritten; - ok = !!::WriteProcessMemory(aChildProcess, &stub_NtMapViewOfSection, - &stub_NtMapViewOfSection, - sizeof(stub_NtMapViewOfSection), &bytesWritten); - if (!ok) { - return false; - } - // Because aChildProcess has just been created in a suspended state, its // dynamic linker has not yet been initialized, thus its executable has // not yet been linked with ntdll.dll. If the blocklist hook intercepts a @@ -407,6 +399,8 @@ InitializeDllBlocklistOOP(HANDLE aChildProcess) ptrdiff_t iatLength = (curIatThunk - firstIatThunk) * sizeof(IMAGE_THUNK_DATA); + SIZE_T bytesWritten; + { // Scope for prot AutoVirtualProtect prot(firstIatThunk, iatLength, PAGE_READWRITE, aChildProcess); diff --git a/browser/components/originattributes/test/browser/browser.ini b/browser/components/originattributes/test/browser/browser.ini index 7e8bf358db93..ace5a1a438ce 100644 --- a/browser/components/originattributes/test/browser/browser.ini +++ b/browser/components/originattributes/test/browser/browser.ini @@ -65,7 +65,7 @@ skip-if = verify [browser_favicon_firstParty.js] [browser_favicon_userContextId.js] [browser_firstPartyIsolation.js] -skip-if = verify +skip-if = verify || debug #Bug 1345346 [browser_firstPartyIsolation_about_newtab.js] [browser_firstPartyIsolation_aboutPages.js] [browser_firstPartyIsolation_blobURI.js] diff --git a/devtools/client/debugger/test/mochitest/browser2.ini b/devtools/client/debugger/test/mochitest/browser2.ini index a2f926b14cf7..01909a43f344 100644 --- a/devtools/client/debugger/test/mochitest/browser2.ini +++ b/devtools/client/debugger/test/mochitest/browser2.ini @@ -313,7 +313,7 @@ uses-unsafe-cpows = true skip-if = e10s && debug [browser_dbg_search-symbols.js] uses-unsafe-cpows = true -skip-if = (e10s && debug) || os == "linux" # Bug 1132375 +skip-if = (e10s && debug) || os == "linux" || (os == "win" && !debug) # Bug 1132375 # Bug 1465683 [browser_dbg_searchbox-help-popup-01.js] uses-unsafe-cpows = true skip-if = e10s && debug diff --git a/gfx/layers/wr/WebRenderBridgeParent.cpp b/gfx/layers/wr/WebRenderBridgeParent.cpp index ea3cbfe56ed1..89c499b982f1 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.cpp +++ b/gfx/layers/wr/WebRenderBridgeParent.cpp @@ -1155,8 +1155,8 @@ WebRenderBridgeParent::RecvClearCachedResources() // Schedule generate frame to clean up Pipeline ScheduleGenerateFrame(); // Remove animations. - for (std::unordered_set::iterator iter = mActiveAnimations.begin(); iter != mActiveAnimations.end(); iter++) { - mAnimStorage->ClearById(*iter); + for (const auto& id : mActiveAnimations) { + mAnimStorage->ClearById(id); } mActiveAnimations.clear(); std::queue().swap(mCompositorAnimationsToDelete); // clear queue @@ -1680,8 +1680,8 @@ WebRenderBridgeParent::ClearResources() mApi->SendTransaction(txn); - for (std::unordered_set::iterator iter = mActiveAnimations.begin(); iter != mActiveAnimations.end(); iter++) { - mAnimStorage->ClearById(*iter); + for (const auto& id : mActiveAnimations) { + mAnimStorage->ClearById(id); } mActiveAnimations.clear(); std::queue().swap(mCompositorAnimationsToDelete); // clear queue diff --git a/mozglue/misc/nsWindowsDllInterceptor.h b/mozglue/misc/nsWindowsDllInterceptor.h index 4ae504257b56..473ef201a4fc 100644 --- a/mozglue/misc/nsWindowsDllInterceptor.h +++ b/mozglue/misc/nsWindowsDllInterceptor.h @@ -84,32 +84,32 @@ namespace mozilla { namespace interceptor { +template +struct OriginalFunctionPtrTraits; + +template +struct OriginalFunctionPtrTraits +{ + using ReturnType = R; +}; + +#if defined(_M_IX86) +template +struct OriginalFunctionPtrTraits +{ + using ReturnType = R; +}; + +template +struct OriginalFunctionPtrTraits +{ + using ReturnType = R; +}; +#endif // defined(_M_IX86) + template class FuncHook final { - template - struct OriginalFunctionPtrTraits; - - template - struct OriginalFunctionPtrTraits - { - using ReturnType = R; - }; - -#if defined(_M_IX86) - template - struct OriginalFunctionPtrTraits - { - using ReturnType = R; - }; - - template - struct OriginalFunctionPtrTraits - { - using ReturnType = R; - }; -#endif // defined(_M_IX86) - public: using ThisType = FuncHook; using ReturnType = typename OriginalFunctionPtrTraits::ReturnType; @@ -221,15 +221,99 @@ private: INIT_ONCE mInitOnce; }; +template +class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS FuncHookCrossProcess final +{ +public: + using ThisType = FuncHookCrossProcess; + using ReturnType = typename OriginalFunctionPtrTraits::ReturnType; + +#if defined(DEBUG) + FuncHookCrossProcess() {} +#endif // defined(DEBUG) + + bool Set(HANDLE aProcess, InterceptorT& aInterceptor, const char* aName, + FuncPtrT aHookDest) + { + if (!aInterceptor.AddHook(aName, reinterpret_cast(aHookDest), + reinterpret_cast(&mOrigFunc))) { + return false; + } + + return CopyStubToChildProcess(aProcess); + } + + bool SetDetour(HANDLE aProcess, InterceptorT& aInterceptor, const char* aName, + FuncPtrT aHookDest) + { + if (!aInterceptor.AddDetour(aName, reinterpret_cast(aHookDest), + reinterpret_cast(&mOrigFunc))) { + return false; + } + + return CopyStubToChildProcess(aProcess); + } + + explicit operator bool() const + { + return !!mOrigFunc; + } + + /** + * NB: This operator is only meaningful when invoked in the target process! + */ + template + ReturnType operator()(ArgsType... aArgs) const + { + return mOrigFunc(std::forward(aArgs)...); + } + +#if defined(DEBUG) + FuncHookCrossProcess(const FuncHookCrossProcess&) = delete; + FuncHookCrossProcess(FuncHookCrossProcess&&) = delete; + FuncHookCrossProcess& operator=(const FuncHookCrossProcess&) = delete; + FuncHookCrossProcess& operator=(FuncHookCrossProcess&& aOther) = delete; +#endif // defined(DEBUG) + +private: + bool CopyStubToChildProcess(HANDLE aProcess) + { + SIZE_T bytesWritten; + return !!::WriteProcessMemory(aProcess, &mOrigFunc, &mOrigFunc, + sizeof(mOrigFunc), &bytesWritten); + } + +private: + FuncPtrT mOrigFunc; +}; + enum { kDefaultTrampolineSize = 128 }; +template +struct TypeResolver; + +template +struct TypeResolver +{ + template + using FuncHookType = FuncHook; +}; + +template +struct TypeResolver +{ + template + using FuncHookType = FuncHookCrossProcess; +}; + template > -class WindowsDllInterceptor final +class WindowsDllInterceptor final : public TypeResolver> { typedef WindowsDllInterceptor ThisType; @@ -372,13 +456,12 @@ private: return mDetourPatcher.AddHook(aProc, aHookDest, aOrigFunc); } -public: - template - using FuncHookType = FuncHook; - private: template friend class FuncHook; + + template + friend class FuncHookCrossProcess; }; } // namespace interceptor diff --git a/mozglue/tests/interceptor/TestDllInterceptorCrossProcess.cpp b/mozglue/tests/interceptor/TestDllInterceptorCrossProcess.cpp index c29d132ba9b0..7a2ee3737504 100644 --- a/mozglue/tests/interceptor/TestDllInterceptorCrossProcess.cpp +++ b/mozglue/tests/interceptor/TestDllInterceptorCrossProcess.cpp @@ -73,22 +73,14 @@ int ParentMain() mozilla::CrossProcessDllInterceptor intcpt(childProcess.get()); intcpt.Init("TestDllInterceptorCrossProcess.exe"); - if (!gOrigReturnResult.Set(intcpt, "ReturnResult", &ReturnResultHook)) { + if (!gOrigReturnResult.Set(childProcess.get(), intcpt, "ReturnResult", + &ReturnResultHook)) { printf("TEST-UNEXPECTED-FAIL | DllInterceptorCrossProcess | Failed to add hook\n"); return 1; } printf("TEST-PASS | DllInterceptorCrossProcess | Hook added\n"); - // Let's save the original hook - SIZE_T bytesWritten; - if (!::WriteProcessMemory(childProcess.get(), &gOrigReturnResult, - &gOrigReturnResult, sizeof(gOrigReturnResult), - &bytesWritten)) { - printf("TEST-UNEXPECTED-FAIL | DllInterceptorCrossProcess | Failed to write original function pointer\n"); - return 1; - } - if (::ResumeThread(childMainThread.get()) == static_cast(-1)) { printf("TEST-UNEXPECTED-FAIL | DllInterceptorCrossProcess | Failed to resume child thread\n"); return 1; diff --git a/testing/config/tooltool-manifests/androidarm_4_3/mach-emulator.manifest b/testing/config/tooltool-manifests/androidarm_4_3/mach-emulator.manifest index e066c30e8fc8..bdb5baf737e8 100644 --- a/testing/config/tooltool-manifests/androidarm_4_3/mach-emulator.manifest +++ b/testing/config/tooltool-manifests/androidarm_4_3/mach-emulator.manifest @@ -1,10 +1,10 @@ [ { - "size": 138424593, + "size": 136616367, "visibility": "public", - "digest": "1746b9c86d982492152567967aecdde147293f9f1d7b230821c191943fca8c39641276343ea4b1b2fc8eafb92f7b37507917ef7e2e1fd5b7f9b37d94050cec40", + "digest": "2e13e2ca795dc48ebcfe455bb1f9ec13c3d8b5095521acf94326ea44881aee8802b9021e19c93607db828ce8673fe421685c427c5cf31ced03a461f859dcd5dc", "algorithm": "sha512", - "filename": "AVDs-armv7a-android-4.3.1_r1-build-2018-06-07.tar.gz", + "filename": "AVDs-armv7a-android-4.3.1_r1-build-2018-07-06.tar.gz", "unpack": true } ]