2017-03-29 01:54:05 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BEType.h"
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
enum class patch_type
|
|
|
|
{
|
2017-09-17 16:33:59 +02:00
|
|
|
load,
|
2017-03-29 01:54:05 +02:00
|
|
|
byte,
|
|
|
|
le16,
|
|
|
|
le32,
|
|
|
|
le64,
|
2017-07-17 15:34:04 +02:00
|
|
|
lef32,
|
|
|
|
lef64,
|
2017-03-29 01:54:05 +02:00
|
|
|
be16,
|
|
|
|
be32,
|
|
|
|
be64,
|
2017-07-17 15:34:04 +02:00
|
|
|
bef32,
|
|
|
|
bef64,
|
2017-03-29 01:54:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2017-07-17 15:34:04 +02:00
|
|
|
// Apply patch (returns the number of entries applied)
|
|
|
|
std::size_t apply(const std::string& name, u8* dst) const;
|
2017-03-29 01:54:05 +02:00
|
|
|
};
|