[Kernel/Memory] Check for required protect_bits combinations

This commit is contained in:
Gliniak 2021-12-15 11:33:58 +01:00
parent 6b45cf8447
commit 283accd876
1 changed files with 8 additions and 2 deletions

View File

@ -425,8 +425,14 @@ DECLARE_XBOXKRNL_EXPORT2(MmQueryAddressProtect, kMemory, kImplemented,
void MmSetAddressProtect_entry(lpvoid_t base_address, dword_t region_size,
dword_t protect_bits) {
if (!protect_bits) {
XELOGE("MmSetAddressProtect: Failed due to incorrect protect_bits");
constexpr uint32_t required_protect_bits =
X_PAGE_NOACCESS | X_PAGE_READONLY | X_PAGE_READWRITE |
X_PAGE_EXECUTE_READ | X_PAGE_EXECUTE_READWRITE;
if (xe::bit_count(protect_bits & required_protect_bits) != 1) {
// Many titles use invalid combination with zero valid bits set.
// We're skipping assertion for these cases to prevent unnecessary spam.
assert_false(xe::bit_count(protect_bits & required_protect_bits) > 1);
return;
}