Patches: Fix potential RPCS3 crashes due to invalid patches

This commit is contained in:
Eladash 2023-07-12 20:43:33 +03:00 committed by Elad Ashkenazi
parent c0280b43f2
commit 083b4f0d3b
5 changed files with 114 additions and 29 deletions

View file

@ -53,13 +53,14 @@ enum class patch_type
bef32,
bef64,
utf8, // Text of string (not null-terminated automatically)
c_utf8, // Text of string (null-terminated automatically)
move_file, // Move file
hide_file, // Hide file
};
static constexpr bool patch_type_uses_hex_offset(patch_type type)
{
return type >= patch_type::alloc && type <= patch_type::utf8;
return type >= patch_type::alloc && type <= patch_type::c_utf8;
}
enum class patch_configurable_type
@ -213,7 +214,7 @@ public:
void append_title_patches(const std::string& title_id);
// Apply patch (returns the number of entries applied)
std::basic_string<u32> apply(const std::string& name, std::function<u8*(u32)> mem_translate, u32 filesz = -1, u32 min_addr = 0);
std::basic_string<u32> apply(const std::string& name, std::function<u8*(u32, u32)> mem_translate, u32 filesz = -1, u32 min_addr = 0);
// Deallocate memory used by patches
void unload(const std::string& name);