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/. */
7 #ifndef mozilla_LoaderAPIInterfaces_h
8 #define mozilla_LoaderAPIInterfaces_h
10 #include "mozilla/ModuleLoadInfo.h"
15 class NS_NO_VTABLE LoaderObserver
{
18 * Notification that a DLL load has begun.
20 * @param aContext Outparam that allows this observer to store any context
21 * information pertaining to the current load.
22 * @param aRequestedDllName The DLL name requested by whatever invoked the
23 * loader. This name may not match the effective
24 * name of the DLL once the loader has completed
27 virtual void OnBeginDllLoad(void** aContext
,
28 PCUNICODE_STRING aRequestedDllName
) = 0;
31 * Query the observer to determine whether the DLL named |aLSPLeafName| needs
32 * to be substituted with another module, and substitute the module handle
35 * @return true when substitution occurs, otherwise false
37 virtual bool SubstituteForLSP(PCUNICODE_STRING aLSPLeafName
,
38 PHANDLE aOutHandle
) = 0;
41 * Notification that a DLL load has ended.
43 * @param aContext The context that was set by the corresponding call to
45 * @param aNtStatus The NTSTATUS returned by LdrLoadDll
46 * @param aModuleLoadInfo Telemetry information that was gathered about the
49 virtual void OnEndDllLoad(void* aContext
, NTSTATUS aNtStatus
,
50 ModuleLoadInfo
&& aModuleLoadInfo
) = 0;
53 * Called to inform the observer that it is no longer active and, if
54 * necessary, call aNext->OnForward() with any accumulated telemetry
57 virtual void Forward(LoaderObserver
* aNext
) = 0;
60 * Receives a vector of module load telemetry from a previous LoaderObserver.
62 virtual void OnForward(ModuleLoadInfoVec
&& aInfo
) = 0;
65 class NS_NO_VTABLE LoaderAPI
{
68 * Construct a new ModuleLoadInfo structure and notify the LoaderObserver
69 * that a library load is beginning.
71 virtual ModuleLoadInfo
ConstructAndNotifyBeginDllLoad(
72 void** aContext
, PCUNICODE_STRING aRequestedDllName
) = 0;
75 * Query to determine whether the DLL named |aLSPLeafName| needs to be
76 * substituted with another module, and substitute the module handle when
79 * @return true when substitution occurs, otherwise false
81 virtual bool SubstituteForLSP(PCUNICODE_STRING aLSPLeafName
,
82 PHANDLE aOutHandle
) = 0;
85 * Notification that a DLL load has ended.
87 virtual void NotifyEndDllLoad(void* aContext
, NTSTATUS aLoadNtStatus
,
88 ModuleLoadInfo
&& aModuleLoadInfo
) = 0;
91 * Given the address of a mapped section, obtain the name of the file that is
94 virtual AllocatedUnicodeString
GetSectionName(void* aSectionAddr
) = 0;
96 using InitDllBlocklistOOPFnPtr
= LauncherVoidResultWithLineInfo (*)(
97 const wchar_t*, HANDLE
, const IMAGE_THUNK_DATA
*);
100 * Return a pointer to the cross-process DLL Blocklist Init function.
101 * Used by sandboxBroker::LaunchApp.
103 virtual InitDllBlocklistOOPFnPtr
GetDllBlocklistInitFn() = 0;
107 } // namespace mozilla
109 #endif // mozilla_LoaderAPIInterfaces_h