From 35a3a60631fff6504d11b6bac1064892ee2874f4 Mon Sep 17 00:00:00 2001 From: emoose Date: Sun, 5 Jan 2020 19:18:18 +0000 Subject: [PATCH] Fix heap corruption by XEXP header patch not resizing headers correctly This should hopefully fix GTA IV's TU (for media ID 6AC07221 at least) --- src/xenia/cpu/xex_module.cc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index 84ad278c3..f469c51e0 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -250,15 +250,7 @@ int XexModule::ApplyPatch(XexModule* module) { // Patch base XEX header uint32_t original_image_size = module->image_size(); - uint32_t header_target_size = patch_header->delta_headers_target_offset + - patch_header->delta_headers_source_size; - - if (!header_target_size) { - header_target_size = - patch_header->size_of_target_headers; // unsure which is more correct.. - } - - size_t mem_size = module->xex_header_mem_.size(); + uint32_t header_target_size = patch_header->size_of_target_headers; // Increase xex header buffer length if needed if (header_target_size > module->xex_header_mem_.size()) {