[Kernel] Support reading XEX privileges > 31

These get stored in different header IDs, 0-31 is inside 0x30000, 32-63 is in 0x30100, and 64+ is probably in 0x30200, etc.
Not sure if any games actually try checking these extended privileges, but hopefully this code should help if any do.
This commit is contained in:
emoose 2020-01-20 01:17:19 +00:00 committed by illusion
parent 7cde420634
commit cafb2c0d5b
1 changed files with 6 additions and 2 deletions

View File

@ -27,7 +27,7 @@ dword_result_t XexCheckExecutablePrivilege(dword_t privilege) {
// Privilege is bit position in xe_xex2_system_flags enum - so:
// Privilege=6 -> 0x00000040 -> XEX_SYSTEM_INSECURE_SOCKETS
uint32_t mask = 1 << privilege;
uint32_t mask = 1 << (privilege % 32);
auto module = kernel_state()->GetExecutableModule();
if (!module) {
@ -70,8 +70,12 @@ dword_result_t XexCheckExecutablePrivilege(dword_t privilege) {
}
}
uint32_t header_id = XEX_HEADER_SYSTEM_FLAGS; // header ID 0x30000
// Privileges 32+ are stored in 0x30100, 64+ probably in 0x30200...
header_id += (privilege / 32) << 8;
uint32_t flags = 0;
module->GetOptHeader<uint32_t>(XEX_HEADER_SYSTEM_FLAGS, &flags);
module->GetOptHeader<uint32_t>((xex2_header_keys)header_id, &flags);
return (flags & mask) > 0;
}