/
MemoryPatches.h
52 lines (42 loc) · 1.04 KB
/
MemoryPatches.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <cstddef>
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
namespace Common::Debug
{
struct MemoryPatch
{
enum class State
{
Enabled,
Disabled
};
MemoryPatch(u32 address, std::vector<u8> value);
MemoryPatch(u32 address, u32 value);
u32 address;
std::vector<u8> value;
State is_enabled = State::Enabled;
};
class MemoryPatches
{
public:
MemoryPatches();
virtual ~MemoryPatches();
void SetPatch(u32 address, u32 value);
void SetPatch(u32 address, std::vector<u8> value);
const std::vector<MemoryPatch>& GetPatches() const;
void UnsetPatch(u32 address);
void EnablePatch(std::size_t index);
void DisablePatch(std::size_t index);
bool HasEnabledPatch(u32 address) const;
void RemovePatch(std::size_t index);
void ClearPatches();
protected:
virtual void Patch(std::size_t index) = 0;
std::vector<MemoryPatch> m_patches;
};
} // namespace Common::Debug