Fixed incorrect hash generation + lint fixes
This commit is contained in:
@@ -930,8 +930,6 @@ bool XexModule::Load(const std::string_view name, const std::string_view path,
|
|||||||
name_ = name;
|
name_ = name;
|
||||||
path_ = path;
|
path_ = path;
|
||||||
|
|
||||||
uint8_t* data = memory()->TranslateVirtual(base_address_);
|
|
||||||
|
|
||||||
// Load in the XEX basefile
|
// Load in the XEX basefile
|
||||||
// We'll try using both XEX2 keys to see if any give a valid PE
|
// We'll try using both XEX2 keys to see if any give a valid PE
|
||||||
int result_code = ReadImage(xex_addr, xex_length, false);
|
int result_code = ReadImage(xex_addr, xex_length, false);
|
||||||
|
|||||||
@@ -73,12 +73,6 @@ X_STATUS UserModule::LoadFromFile(const std::string_view path) {
|
|||||||
|
|
||||||
// Load the module.
|
// Load the module.
|
||||||
result = LoadFromMemory(mmap->data(), mmap->size());
|
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 {
|
} else {
|
||||||
std::vector<uint8_t> buffer(fs_entry->size());
|
std::vector<uint8_t> buffer(fs_entry->size());
|
||||||
|
|
||||||
@@ -100,12 +94,6 @@ X_STATUS UserModule::LoadFromFile(const std::string_view path) {
|
|||||||
// Load the module.
|
// Load the module.
|
||||||
result = LoadFromMemory(buffer.data(), bytes_read);
|
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.
|
// Close the file.
|
||||||
file->Destroy();
|
file->Destroy();
|
||||||
}
|
}
|
||||||
@@ -141,6 +129,8 @@ X_STATUS UserModule::LoadFromFile(const std::string_view path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CalculateHash();
|
||||||
|
|
||||||
XELOGI("Module hash: {:016X} for {}", hash_, name_);
|
XELOGI("Module hash: {:016X} for {}", hash_, name_);
|
||||||
return LoadXexContinue();
|
return LoadXexContinue();
|
||||||
}
|
}
|
||||||
@@ -818,5 +808,13 @@ void UserModule::Dump() {
|
|||||||
xe::logging::AppendLogLine(xe::LogLevel::Info, 'i', sb.to_string_view());
|
xe::logging::AppendLogLine(xe::LogLevel::Info, 'i', sb.to_string_view());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UserModule::CalculateHash() {
|
||||||
|
uint8_t* base_adr = memory()->TranslateVirtual(xex_module()->base_address());
|
||||||
|
|
||||||
|
XXH3_state_t hash_state;
|
||||||
|
XXH3_64bits_reset(&hash_state);
|
||||||
|
XXH3_64bits_update(&hash_state, base_adr, xex_module()->image_size());
|
||||||
|
hash_ = XXH3_64bits_digest(&hash_state);
|
||||||
|
}
|
||||||
} // namespace kernel
|
} // namespace kernel
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ class UserModule : public XModule {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
X_STATUS LoadXexContinue();
|
X_STATUS LoadXexContinue();
|
||||||
|
void CalculateHash();
|
||||||
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::string path_;
|
std::string path_;
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
#include "xenia/patcher/patch_db.h"
|
#include "xenia/patcher/patch_db.h"
|
||||||
|
|
||||||
DEFINE_bool(apply_patches, true, "Enables custom patching functionality", "General");
|
DEFINE_bool(apply_patches, true, "Enables custom patching functionality",
|
||||||
|
"General");
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace patcher {
|
namespace patcher {
|
||||||
@@ -183,7 +184,7 @@ std::vector<PatchFileEntry> PatchDB::GetTitlePatches(uint32_t title_id,
|
|||||||
return title_patches;
|
return title_patches;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PatchDB::ReadHash(PatchFileEntry &patchEntry,
|
void PatchDB::ReadHash(PatchFileEntry& patchEntry,
|
||||||
std::shared_ptr<cpptoml::table> patch_toml_fields) {
|
std::shared_ptr<cpptoml::table> patch_toml_fields) {
|
||||||
auto title_hashes = patch_toml_fields->get_array_of<std::string>("hash");
|
auto title_hashes = patch_toml_fields->get_array_of<std::string>("hash");
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class PatchDB {
|
|||||||
{"be16", PatchData(sizeof(uint16_t), PatchDataType::be16)},
|
{"be16", PatchData(sizeof(uint16_t), PatchDataType::be16)},
|
||||||
{"be8", PatchData(sizeof(uint8_t), PatchDataType::be8)}};
|
{"be8", PatchData(sizeof(uint8_t), PatchDataType::be8)}};
|
||||||
|
|
||||||
void ReadHash(PatchFileEntry &patchEntry,
|
void ReadHash(PatchFileEntry& patchEntry,
|
||||||
std::shared_ptr<cpptoml::table> patch_toml_fields);
|
std::shared_ptr<cpptoml::table> patch_toml_fields);
|
||||||
};
|
};
|
||||||
} // namespace patcher
|
} // namespace patcher
|
||||||
|
|||||||
Reference in New Issue
Block a user