Bug 1605248: Convert LoaderObserver::Clear to LoaderObserver::Disable; r=mhowell

We rename `LoaderObserver::Clear` to `LoaderObserver::Disable` to more accurately
reflect the following behaviour change:

Not only does the `Disable` call free any enqueued module load events, it also
ensures that no further module loads will be saved in the future. This reflects
the reality that any `mozglue` client that calls `Disable` has no intention of
ever processing these events.

Differential Revision: https://phabricator.services.mozilla.com/D57897

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Aaron Klotz 2019-12-19 22:20:37 +00:00
parent 72918a2e58
commit 844739bc32
3 changed files with 10 additions and 4 deletions

View file

@ -80,6 +80,10 @@ void LoaderObserver::OnEndDllLoad(void* aContext, NTSTATUS aNtStatus,
// No dll services, save for later // No dll services, save for later
AutoExclusiveLock lock(mLock); AutoExclusiveLock lock(mLock);
if (!mEnabled) {
return;
}
if (!mModuleLoads) { if (!mModuleLoads) {
mModuleLoads = new ModuleLoadInfoVec(); mModuleLoads = new ModuleLoadInfoVec();
} }
@ -116,13 +120,14 @@ void LoaderObserver::Forward(detail::DllServicesBase* aNext) {
delete moduleLoads; delete moduleLoads;
} }
void LoaderObserver::Clear() { void LoaderObserver::Disable() {
ModuleLoadInfoVec* moduleLoads = nullptr; ModuleLoadInfoVec* moduleLoads = nullptr;
{ // Scope for lock { // Scope for lock
AutoExclusiveLock lock(mLock); AutoExclusiveLock lock(mLock);
moduleLoads = mModuleLoads; moduleLoads = mModuleLoads;
mModuleLoads = nullptr; mModuleLoads = nullptr;
mEnabled = false;
} }
delete moduleLoads; delete moduleLoads;

View file

@ -19,7 +19,7 @@ namespace glue {
class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS LoaderObserver final class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS LoaderObserver final
: public nt::LoaderObserver { : public nt::LoaderObserver {
public: public:
constexpr LoaderObserver() : mModuleLoads(nullptr) {} constexpr LoaderObserver() : mModuleLoads(nullptr), mEnabled(true) {}
void OnBeginDllLoad(void** aContext, void OnBeginDllLoad(void** aContext,
PCUNICODE_STRING aPreliminaryDllName) final; PCUNICODE_STRING aPreliminaryDllName) final;
@ -31,11 +31,12 @@ class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS LoaderObserver final
void OnForward(ModuleLoadInfoVec&& aInfo) final; void OnForward(ModuleLoadInfoVec&& aInfo) final;
void Forward(mozilla::glue::detail::DllServicesBase* aSvc); void Forward(mozilla::glue::detail::DllServicesBase* aSvc);
void Clear(); void Disable();
private: private:
Win32SRWLock mLock; Win32SRWLock mLock;
ModuleLoadInfoVec* mModuleLoads; ModuleLoadInfoVec* mModuleLoads;
bool mEnabled;
}; };
} // namespace glue } // namespace glue

View file

@ -769,5 +769,5 @@ MFBT_API void DllBlocklist_SetBasicDllServices(
} }
aSvc->SetAuthenticodeImpl(GetAuthenticode()); aSvc->SetAuthenticodeImpl(GetAuthenticode());
gMozglueLoaderObserver.Clear(); gMozglueLoaderObserver.Disable();
} }