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/. */
7 #include "LibrarySandboxPreload.h"
8 #include "nsXPCOMPrivate.h" // for XPCOM_DLL
10 #include "BinaryPath.h"
16 PathString
GetSandboxedRLBoxPath() {
17 nsCOMPtr
<nsIFile
> libFile
;
18 nsresult rv
= mozilla::BinaryPath::GetFile(getter_AddRefs(libFile
));
20 MOZ_CRASH("Library preload failure: Failed to get binary file\n");
23 rv
= libFile
->SetNativeLeafName(XPCOM_DLL
""_ns
);
25 MOZ_CRASH("Library preload failure: Failed to get library file\n");
28 return libFile
->NativePath();
31 PRLibrary
* PreloadLibrary(const PathString
& path
) {
34 libSpec
.type
= PR_LibSpec_PathnameU
;
35 libSpec
.value
.pathname_u
= path
.get();
37 libSpec
.type
= PR_LibSpec_Pathname
;
38 libSpec
.value
.pathname
= path
.get();
40 PRLibrary
* ret
= PR_LoadLibraryWithFlags(libSpec
, PR_LD_LAZY
);
45 } // namespace mozilla