[Kernel] Add command-line flag to toggle XEX patching.

This commit is contained in:
gibbed 2018-11-20 14:48:32 -06:00
parent 7e78a79a2d
commit 2247742494
1 changed files with 20 additions and 16 deletions

View File

@ -20,6 +20,8 @@
#include "xenia/kernel/xfile.h" #include "xenia/kernel/xfile.h"
#include "xenia/kernel/xthread.h" #include "xenia/kernel/xthread.h"
DEFINE_bool(xex_apply_patches, true, "Apply XEX patches.");
namespace xe { namespace xe {
namespace kernel { namespace kernel {
@ -100,27 +102,29 @@ X_STATUS UserModule::LoadFromFile(std::string path) {
return result; return result;
} }
// Search for xexp patch file if (FLAGS_xex_apply_patches) {
auto patch_entry = kernel_state()->file_system()->ResolvePath(path_ + "p"); // Search for xexp patch file
auto patch_entry = kernel_state()->file_system()->ResolvePath(path_ + "p");
if (patch_entry) { if (patch_entry) {
auto patch_path = patch_entry->absolute_path(); auto patch_path = patch_entry->absolute_path();
XELOGI("Loading XEX patch from %s", patch_path.c_str()); XELOGI("Loading XEX patch from %s", patch_path.c_str());
auto patch_module = object_ref<UserModule>(new UserModule(kernel_state_)); auto patch_module = object_ref<UserModule>(new UserModule(kernel_state_));
result = patch_module->LoadFromFile(patch_path); result = patch_module->LoadFromFile(patch_path);
if (!result) { if (!result) {
result = patch_module->xex_module()->ApplyPatch(xex_module()); result = patch_module->xex_module()->ApplyPatch(xex_module());
if (result) { if (result) {
XELOGE("Failed to apply XEX patch, code: %d", result); XELOGE("Failed to apply XEX patch, code: %d", result);
}
} else {
XELOGE("Failed to load XEX patch, code: %d", result);
} }
} else {
XELOGE("Failed to load XEX patch, code: %d", result);
}
if (result) { if (result) {
return X_STATUS_UNSUCCESSFUL; return X_STATUS_UNSUCCESSFUL;
}
} }
} }