NtLoaderAPI.cpp (1138B)
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 #include "mozilla/LoaderAPIInterfaces.h" 8 9 #include "freestanding/CheckForCaller.h" 10 #include "freestanding/LoaderPrivateAPI.h" 11 12 namespace mozilla { 13 14 extern "C" MOZ_EXPORT nt::LoaderAPI* GetNtLoaderAPI( 15 nt::LoaderObserver* aNewObserver) { 16 // Make sure the caller is inside mozglue.dll - we don't want to allow 17 // external access to this function, as it contains details about 18 // the SharedSection which is used to sandbox future child processes. 19 const bool isCallerMozglue = 20 CheckForAddress(RETURN_ADDRESS(), L"mozglue.dll"); 21 MOZ_ASSERT(isCallerMozglue); 22 if (!isCallerMozglue) { 23 return nullptr; 24 } 25 26 freestanding::EnsureInitialized(); 27 freestanding::LoaderPrivateAPI& api = freestanding::gLoaderPrivateAPI; 28 api.SetObserver(aNewObserver); 29 30 return &api; 31 } 32 33 } // namespace mozilla