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 https://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_freestanding_LoaderPrivateAPI_h
8 #define mozilla_freestanding_LoaderPrivateAPI_h
9 
10 #include "mozilla/LoaderAPIInterfaces.h"
11 
12 namespace mozilla {
13 namespace freestanding {
14 
15 /**
16  * This part of the API is available only to the launcher process.
17  */
18 class NS_NO_VTABLE LoaderPrivateAPI : public nt::LoaderAPI {
19  public:
20   /**
21    * Notify the nt::LoaderObserver that a module load is beginning
22    */
23   virtual void NotifyBeginDllLoad(void** aContext,
24                                   PCUNICODE_STRING aRequestedDllName) = 0;
25   /**
26    * Notify the nt::LoaderObserver that a module load is beginning and set the
27    * begin load timestamp on |aModuleLoadInfo|.
28    */
29   virtual void NotifyBeginDllLoad(ModuleLoadInfo& aModuleLoadInfo,
30                                   void** aContext,
31                                   PCUNICODE_STRING aRequestedDllName) = 0;
32 
33   /**
34    * Set a new nt::LoaderObserver to be used by the launcher process. NB: This
35    * should only happen while the current process is still single-threaded!
36    */
37   virtual void SetObserver(nt::LoaderObserver* aNewObserver) = 0;
38 
39   /**
40    * Returns true if the current nt::LoaderObserver is the launcher process's
41    * built-in observer.
42    */
43   virtual bool IsDefaultObserver() const = 0;
44 
45   /**
46    * Returns the name of a given mapped section address as a local instance of
47    * nt::MemorySectionNameBuf.  This does not involve heap allocation.
48    */
49   virtual nt::MemorySectionNameBuf GetSectionNameBuffer(void* aSectionAddr) = 0;
50 };
51 
52 /**
53  * Ensures that any statics in the freestanding library are initialized.
54  */
55 void EnsureInitialized();
56 
57 extern LoaderPrivateAPI& gLoaderPrivateAPI;
58 
59 }  // namespace freestanding
60 }  // namespace mozilla
61 
62 #endif  // mozilla_freestanding_LoaderPrivateAPI_h
63