rpcs3/Utilities/bin_patch.h
Malcolm Jestadt ad8988afd3 Embedded SPU elf patching
- PS3 games include both PPU and SPU code in their PPU executables, so to make patching games that make use of the same SPU libraries easier, we add a system to find and patch them.
- Patches for this system still use SPU LS (Local Storage) addresses despite the fact that we aren't loading anything into SPU LS at this time. The patches are checked against each segment and patched in place.
2020-01-28 02:13:37 +03:00

45 lines
732 B
C++

#pragma once
#include "BEType.h"
#include <vector>
#include <string>
#include <unordered_map>
enum class patch_type
{
load,
byte,
le16,
le32,
le64,
lef32,
lef64,
be16,
be32,
be64,
bef32,
bef64,
};
class patch_engine
{
struct patch
{
patch_type type;
u32 offset;
u64 value;
};
// Database
std::unordered_map<std::string, std::vector<patch>> m_map;
public:
// Load from file
void append(const std::string& path);
// Apply patch (returns the number of entries applied)
std::size_t apply(const std::string& name, u8* dst) const;
// Apply patch with a check that the address exists in SPU local storage
std::size_t apply_with_ls_check(const std::string&name, u8*dst, u32 filesz, u32 ls_addr) const;
};