1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_glue_LoaderObserver_h
8 #define mozilla_glue_LoaderObserver_h
9 
10 #include "mozilla/Attributes.h"
11 #include "mozilla/LoaderAPIInterfaces.h"
12 #include "mozilla/glue/WindowsDllServices.h"
13 #include "mozilla/glue/WinUtils.h"
14 #include "mozilla/UniquePtr.h"
15 
16 namespace mozilla {
17 namespace glue {
18 
19 class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS LoaderObserver final
20     : public nt::LoaderObserver {
21  public:
LoaderObserver()22   constexpr LoaderObserver() : mModuleLoads(nullptr), mEnabled(true) {}
23 
24   void OnBeginDllLoad(void** aContext,
25                       PCUNICODE_STRING aPreliminaryDllName) final;
26   bool SubstituteForLSP(PCUNICODE_STRING aLspLeafName,
27                         PHANDLE aOutHandle) final;
28   void OnEndDllLoad(void* aContext, NTSTATUS aNtStatus,
29                     ModuleLoadInfo&& aModuleLoadInfo) final;
30   void Forward(nt::LoaderObserver* aNext) final;
31   void OnForward(ModuleLoadInfoVec&& aInfo) final;
32 
33   void Forward(mozilla::glue::detail::DllServicesBase* aSvc);
34   void Disable();
35 
36  private:
37   Win32SRWLock mLock;
38   ModuleLoadInfoVec* mModuleLoads;
39   bool mEnabled;
40 };
41 
42 }  // namespace glue
43 }  // namespace mozilla
44 
45 #endif  // mozilla_glue_LoaderObserver_h
46