diff --git a/Utilities/bin_patch.cpp b/Utilities/bin_patch.cpp index a4060c8dba..afdfb5e875 100644 --- a/Utilities/bin_patch.cpp +++ b/Utilities/bin_patch.cpp @@ -10,6 +10,7 @@ void fmt_class_string::format(std::string& out, u64 arg) { switch (value) { + case patch_type::load: return "load"; case patch_type::byte: return "byte"; case patch_type::le16: return "le16"; case patch_type::le32: return "le32"; @@ -45,10 +46,33 @@ void patch_engine::append(const std::string& patch) struct patch info{}; info.type = static_cast(type64); - info.offset = patch[1].as(); + info.offset = patch[1].as(0); switch (info.type) { + case patch_type::load: + { + // Special syntax: copy named sequence (must be loaded before) + const auto found = m_map.find(patch[1].Scalar()); + + if (found != m_map.end()) + { + // Address modifier (optional) + const u32 mod = patch[2].as(0); + + for (const auto& rd : found->second) + { + info = rd; + info.offset += mod; + data.emplace_back(info); + } + + continue; + } + + // TODO: error + break; + } case patch_type::bef32: case patch_type::lef32: { @@ -90,6 +114,11 @@ std::size_t patch_engine::apply(const std::string& name, u8* dst) const switch (p.type) { + case patch_type::load: + { + // Invalid in this context + break; + } case patch_type::byte: { *ptr = static_cast(p.value); diff --git a/Utilities/bin_patch.h b/Utilities/bin_patch.h index 9869de61bf..40212633ea 100644 --- a/Utilities/bin_patch.h +++ b/Utilities/bin_patch.h @@ -7,6 +7,7 @@ enum class patch_type { + load, byte, le16, le32,