[CPU] Move XEX2 code into XexModule class, autodetect XEX key
Code is mainly just copy/pasted from kernel/util/xex2.cc, I've tried fixing it up to work better in a class, but there's probably some things I missed. Also includes some minor improvements to the XEX loader, like being able to try both XEX keys (retail/devkit) automatically, and some fixes to how the base address is determined. (Previously there was code that would get base address from optional header, code that'd get it from xex_security_info, code that'd use a stored base address value... Now everything reads it from a single stored value instead, which is set either from the xex_security_info, or if it exists from the optional header instead. Maybe this can help improve compatibility with any weird XEX's that don't have a base address optional header?) Compressed XEX loader also has some extra checks to make sure the compressed data hash matches what's expected. Might increase loading times by a fraction, but could save reports from people unknowingly using corrupt XEXs. (still no checks for non-compressed data though, maybe need to compare data with xex_security_info->ImageHash?)
This commit is contained in:
@@ -71,19 +71,18 @@ class UserModule : public XModule {
|
||||
uint32_t* out_section_size) override;
|
||||
|
||||
// Get optional header - FOR HOST USE ONLY!
|
||||
X_STATUS GetOptHeader(xe_xex2_header_keys key, void** out_ptr);
|
||||
X_STATUS GetOptHeader(xex2_header_keys key, void** out_ptr);
|
||||
|
||||
// Get optional header - FOR HOST USE ONLY!
|
||||
template <typename T>
|
||||
X_STATUS GetOptHeader(xe_xex2_header_keys key, T* out_ptr) {
|
||||
X_STATUS GetOptHeader(xex2_header_keys key, T* out_ptr) {
|
||||
return GetOptHeader(key, reinterpret_cast<void**>(out_ptr));
|
||||
}
|
||||
|
||||
// Get optional header that can safely be returned to guest code.
|
||||
X_STATUS GetOptHeader(xe_xex2_header_keys key,
|
||||
uint32_t* out_header_guest_ptr);
|
||||
X_STATUS GetOptHeader(xex2_header_keys key, uint32_t* out_header_guest_ptr);
|
||||
static X_STATUS GetOptHeader(uint8_t* membase, const xex2_header* header,
|
||||
xe_xex2_header_keys key,
|
||||
xex2_header_keys key,
|
||||
uint32_t* out_header_guest_ptr);
|
||||
|
||||
void Dump();
|
||||
|
||||
Reference in New Issue
Block a user