Initial support for xex patching
This commit is contained in:
@@ -406,6 +406,9 @@ object_ref<UserModule> KernelState::LoadUserModule(
|
||||
}
|
||||
|
||||
module->Dump();
|
||||
emulator_->patcher()->ApplyPatchesForTitle(memory_, module->title_id(),
|
||||
module->hash());
|
||||
emulator_->on_patch_apply();
|
||||
|
||||
if (module->is_dll_module() && module->entry_point() && call_entry) {
|
||||
// Call DllMain(DLL_PROCESS_ATTACH):
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "xenia/base/byte_stream.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/xxhash.h"
|
||||
#include "xenia/cpu/elf_module.h"
|
||||
#include "xenia/cpu/processor.h"
|
||||
#include "xenia/cpu/xex_module.h"
|
||||
@@ -72,6 +73,12 @@ X_STATUS UserModule::LoadFromFile(const std::string_view path) {
|
||||
|
||||
// Load the module.
|
||||
result = LoadFromMemory(mmap->data(), mmap->size());
|
||||
if (XSUCCEEDED(result)) {
|
||||
XXH3_state_t hash_state;
|
||||
XXH3_64bits_reset(&hash_state);
|
||||
XXH3_64bits_update(&hash_state, mmap->data(), mmap->size());
|
||||
hash_ = XXH3_64bits_digest(&hash_state);
|
||||
}
|
||||
} else {
|
||||
std::vector<uint8_t> buffer(fs_entry->size());
|
||||
|
||||
@@ -93,6 +100,12 @@ X_STATUS UserModule::LoadFromFile(const std::string_view path) {
|
||||
// Load the module.
|
||||
result = LoadFromMemory(buffer.data(), bytes_read);
|
||||
|
||||
// Generate xex hash
|
||||
XXH3_state_t hash_state;
|
||||
XXH3_64bits_reset(&hash_state);
|
||||
XXH3_64bits_update(&hash_state, buffer.data(), bytes_read);
|
||||
hash_ = XXH3_64bits_digest(&hash_state);
|
||||
|
||||
// Close the file.
|
||||
file->Destroy();
|
||||
}
|
||||
@@ -128,6 +141,7 @@ X_STATUS UserModule::LoadFromFile(const std::string_view path) {
|
||||
}
|
||||
}
|
||||
|
||||
XELOGI("Module hash: {:16X} for {}", hash_, name_);
|
||||
return LoadXexContinue();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ class UserModule : public XModule {
|
||||
|
||||
const std::string& path() const override { return path_; }
|
||||
const std::string& name() const override { return name_; }
|
||||
uint64_t hash() const { return hash_; }
|
||||
|
||||
enum ModuleFormat {
|
||||
kModuleFormatUndefined = 0,
|
||||
@@ -100,6 +101,7 @@ class UserModule : public XModule {
|
||||
|
||||
std::string name_;
|
||||
std::string path_;
|
||||
uint64_t hash_ = -1;
|
||||
|
||||
uint32_t guest_xex_header_ = 0;
|
||||
ModuleFormat module_format_ = kModuleFormatUndefined;
|
||||
|
||||
Reference in New Issue
Block a user