1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

Patch: new 'load' syntax

[load, path_name1] - load sequence
[load, path_name2, -0x40] - same, but modify the addresses by -64
This commit is contained in:
Nekotekina 2017-09-17 17:33:59 +03:00
parent bc098d6b9c
commit 18d472b7e1
2 changed files with 31 additions and 1 deletions

View File

@ -10,6 +10,7 @@ void fmt_class_string<patch_type>::format(std::string& out, u64 arg)
{ {
switch (value) switch (value)
{ {
case patch_type::load: return "load";
case patch_type::byte: return "byte"; case patch_type::byte: return "byte";
case patch_type::le16: return "le16"; case patch_type::le16: return "le16";
case patch_type::le32: return "le32"; case patch_type::le32: return "le32";
@ -45,10 +46,33 @@ void patch_engine::append(const std::string& patch)
struct patch info{}; struct patch info{};
info.type = static_cast<patch_type>(type64); info.type = static_cast<patch_type>(type64);
info.offset = patch[1].as<u32>(); info.offset = patch[1].as<u32>(0);
switch (info.type) 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<u32>(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::bef32:
case patch_type::lef32: case patch_type::lef32:
{ {
@ -90,6 +114,11 @@ std::size_t patch_engine::apply(const std::string& name, u8* dst) const
switch (p.type) switch (p.type)
{ {
case patch_type::load:
{
// Invalid in this context
break;
}
case patch_type::byte: case patch_type::byte:
{ {
*ptr = static_cast<u8>(p.value); *ptr = static_cast<u8>(p.value);

View File

@ -7,6 +7,7 @@
enum class patch_type enum class patch_type
{ {
load,
byte, byte,
le16, le16,
le32, le32,