2020-11-27 09:09:48 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
2023-11-02 08:53:46 +01:00
|
|
|
|
|
|
|
#include <wolv/utils/expected.hpp>
|
2020-11-27 09:09:48 +01:00
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
2023-11-25 12:43:48 +01:00
|
|
|
namespace prv {
|
|
|
|
class Provider;
|
|
|
|
}
|
2020-11-27 09:09:48 +01:00
|
|
|
|
2023-01-25 10:38:04 +01:00
|
|
|
enum class IPSError {
|
|
|
|
AddressOutOfRange,
|
|
|
|
PatchTooLarge,
|
|
|
|
InvalidPatchHeader,
|
|
|
|
InvalidPatchFormat,
|
|
|
|
MissingEOF
|
|
|
|
};
|
2020-11-27 09:09:48 +01:00
|
|
|
|
2023-11-25 12:43:48 +01:00
|
|
|
class Patches {
|
|
|
|
public:
|
|
|
|
Patches() = default;
|
|
|
|
Patches(std::map<u64, u8> &&patches) : m_patches(std::move(patches)) {}
|
2023-01-25 10:38:04 +01:00
|
|
|
|
2023-11-25 12:43:48 +01:00
|
|
|
static wolv::util::Expected<Patches, IPSError> fromProvider(hex::prv::Provider *provider);
|
|
|
|
static wolv::util::Expected<Patches, IPSError> fromIPSPatch(const std::vector<u8> &ipsPatch);
|
|
|
|
static wolv::util::Expected<Patches, IPSError> fromIPS32Patch(const std::vector<u8> &ipsPatch);
|
|
|
|
|
|
|
|
wolv::util::Expected<std::vector<u8>, IPSError> toIPSPatch() const;
|
|
|
|
wolv::util::Expected<std::vector<u8>, IPSError> toIPS32Patch() const;
|
|
|
|
|
|
|
|
const auto& get() const { return this->m_patches; }
|
|
|
|
auto& get() { return this->m_patches; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::map<u64, u8> m_patches;
|
|
|
|
};
|
2020-11-27 09:09:48 +01:00
|
|
|
}
|