Core: add helper function to apply a memory patch and mark the 'PPCPatches' as final

This commit is contained in:
iwubcode 2022-12-22 17:33:53 -06:00
parent ce92350140
commit 4743d74985
4 changed files with 27 additions and 3 deletions

View File

@ -42,6 +42,7 @@ public:
bool HasEnabledPatch(u32 address) const;
void RemovePatch(std::size_t index);
void ClearPatches();
virtual void ApplyExistingPatch(std::size_t index) = 0;
protected:
virtual void Patch(std::size_t index) = 0;

View File

@ -50,6 +50,7 @@ public:
virtual bool HasEnabledPatch(u32 address) const = 0;
virtual void RemovePatch(std::size_t index) = 0;
virtual void ClearPatches() = 0;
virtual void ApplyExistingPatch(std::size_t index) = 0;
// Threads
virtual Debug::Threads GetThreads() const = 0;

View File

@ -23,9 +23,8 @@
#include "Core/PowerPC/PPCSymbolDB.h"
#include "Core/PowerPC/PowerPC.h"
void PPCPatches::Patch(std::size_t index)
void ApplyMemoryPatch(Common::Debug::MemoryPatch& patch)
{
auto& patch = m_patches[index];
if (patch.value.empty())
return;
@ -50,6 +49,18 @@ void PPCPatches::Patch(std::size_t index)
}
}
void PPCPatches::ApplyExistingPatch(std::size_t index)
{
auto& patch = m_patches[index];
ApplyMemoryPatch(patch);
}
void PPCPatches::Patch(std::size_t index)
{
auto& patch = m_patches[index];
ApplyMemoryPatch(patch);
}
PPCDebugInterface::PPCDebugInterface() = default;
PPCDebugInterface::~PPCDebugInterface() = default;
@ -168,6 +179,11 @@ void PPCDebugInterface::ClearPatches()
m_patches.ClearPatches();
}
void PPCDebugInterface::ApplyExistingPatch(std::size_t index)
{
m_patches.ApplyExistingPatch(index);
}
Common::Debug::Threads PPCDebugInterface::GetThreads() const
{
Common::Debug::Threads threads;

View File

@ -12,8 +12,13 @@
#include "Common/DebugInterface.h"
#include "Core/NetworkCaptureLogger.h"
class PPCPatches : public Common::Debug::MemoryPatches
void ApplyMemoryPatch(Common::Debug::MemoryPatch& patch);
class PPCPatches final : public Common::Debug::MemoryPatches
{
public:
void ApplyExistingPatch(std::size_t index) override;
private:
void Patch(std::size_t index) override;
};
@ -52,6 +57,7 @@ public:
bool HasEnabledPatch(u32 address) const override;
void RemovePatch(std::size_t index) override;
void ClearPatches() override;
void ApplyExistingPatch(std::size_t index) override;
// Threads
Common::Debug::Threads GetThreads() const override;