From ab8281b7117104094eee069fef19436f0880b0aa Mon Sep 17 00:00:00 2001 From: emoose Date: Mon, 20 Jan 2020 01:17:19 +0000 Subject: [PATCH] [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. --- src/xenia/kernel/xboxkrnl/xboxkrnl_modules.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_modules.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_modules.cc index 6283ce762..9b755b06f 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_modules.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_modules.cc @@ -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(XEX_HEADER_SYSTEM_FLAGS, &flags); + module->GetOptHeader((xex2_header_keys)header_id, &flags); return (flags & mask) > 0; }