Fixing decryption key choice to be more robust.

This commit is contained in:
Ben Vanik 2013-02-06 03:07:57 -08:00
parent da23c00d31
commit 2521d64615
1 changed files with 2 additions and 1 deletions

View File

@ -415,7 +415,7 @@ int xe_xex2_decrypt_key(xe_xex2_header_t *header) {
// Guess key based on file info.
// TODO: better way to finding out which key to use?
const uint8_t *xexkey;
if (header->file_format_info.encryption_type == XEX_ENCRYPTION_NORMAL) {
if (header->execution_info.title_id) {
xexkey = xe_xex2_retail_key;
} else {
xexkey = xe_xex2_devkit_key;
@ -763,6 +763,7 @@ int xe_xex2_load_pe(xe_xex2_ref xex) {
// Verify DOS signature (MZ).
const IMAGE_DOS_HEADER* doshdr = (const IMAGE_DOS_HEADER*)p;
if (doshdr->e_magic != IMAGE_DOS_SIGNATURE) {
XELOGE(XT("PE signature mismatch; likely bad decryption/decompression"));
return 1;
}