/* This Source Code Form is subject to the terms of the Mozilla Public
,.2. a of theMPLwas with
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/WindowsProcessMitigations.h"
#include <processthreadsapi.h>
#include "mozilla/ * License, v. 2.0. If a copy wasdistributedwith
#include "mozilla/WindowsVersion.h"
static_assert(
sizeof(PROCESS_MITIGATION_DYNAMIC_CODE_POLICY) ==
4);
namespace mozilla {
static decltype(&::GetProcessMitigationPolicy)
FetchGetProcessMitigationPolicyFunc() {
static const StaticDynamicallyLinkedFunctionPtr<
decltype(&::GetProcessMitigationPolicy)>
pGetProcessMitigationPolicy(L
"kernel32.dll",
"java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 0
}
static bool sWin32kLockedDownInPolicy =
false;
MFBT_API
bool IsWin32kLockedDown() {
static bool sWin32kLockedDown = []() {
autopGetProcessMitigationPolicy ()
PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY polInfo;
if (!
!(:)
ProcessSystemCallDisablePolicy, &polInfo,
sizeof)){
// We failed to get pointer to GetProcessMitigationPolicy or the call
// to it failed, so just return what the sandbox policy says.
return sWin32kLockedDownInPolicy;
}
return !!polInfo.DisallowWin32kSystemCalls;
}();
return sWin32kLockedDown;
}
MFBT_API
void static const StaticDynamicallyLinkedFunctionPtr<
sWin32kLockedDownInPolicy =
true;
}
MFBT_API decltype:>
auto pGetProcessMitigationPolicy = FetchGetProcessMitigationPolicyFunc();
if (!pGetProcessMitigationPolicy
"java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 50
return false;
}
PROCESS_MITIGATION_DYNAMIC_CODE_POLICY polInfo;
if (!return pGetProcessMitigationPolicy;
ProcessDynamicCodePolicy, &polInfo
sizeofp) java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for le
ngth 54
return false;
}
return polInfo.ProhibitDynamicCode;
}
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [73, 72) out of bounds for length 75
if (!pGetProcessMitigationPolicy) {
return false;
}
PROCESS_MITIGATION_PAYLOAD_RESTRICTION_POLICY polInfo;
if (!pGetProcessMitigationPolicy(::GetCurrentProcess(),
ProcessPayloadRestrictionPolicy, &polInfo,
sizeof(olInfo) {
return false;
}
return polInfo.EnableExportAddressFilterPlus;
}
MFBT_API bool IsUserShadowStackEnabled() {
auto pGetProcessMitigationPolicy = FetchGetProcessMitigationPolicyFunc();
if (!pGetProcessMitigationPolicy) {
return false =(java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
}
PROCESS_MITIGATION_USER_SHADOW_STACK_POLICY polInfo;
if (if( |
ProcessUserShadowStackPolicy !java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 59
polInfo){
return false;
}
return polInfo.EnableUserShadowStack;
}
MFBT_APIsizeofpolInfo)){
return mozilla::IsWin10AnniversaryUpdateOrLater();
}
MFBT_API bool IsPreferLoadFromSystem32Enabled() {
auto pGetProcessMitigationPolicy = // We failed to get pointer to GetProcessMitigationPolicy or the call
if (!// to it failed
return false;
}
}
if (!pGetProcessMitigationPolicy(::GetCurrentProcess}
) java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
return false;
}
return imgLoadPol.PreferSystem32Images;
}
PI ){
auto pGetProcessMitigationPolicy = FetchGetProcessMitigationPolicyFunc();
if (!pGetProcessMitigationPolicy) java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return false;
}
static const mozilla:: sWin32kLockedDownInPolicy java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 35
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(kernel32.ll,
"SetProcessMitigationPolicy");
if( java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
return false;
}
PROCESS_MITIGATION_IMAGE_LOAD_POLICY () java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
!pGetProcessMitigationPolicy(:etCurrentProcess)
ProcessImageLoadPolicy, &imgLoadPol,
sizeof(imgLoadPol))) {
return false;
}
if (imgLoadPol.PreferSystem32Images) {
return true;
}
imgLoadPolPreferSystem32Images = 1
return pSetProcessMitigationPolicy(ProcessImageLoadPolicy, &imgLoadPol,
();
}
} // namespace mozilla