diff options
| author | Scott Mansell <phiren@gmail.com> | 2023-02-13 16:08:36 +1300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-13 16:08:36 +1300 |
| commit | a4729a026f97599bbccf9f900d548fba9e391ad3 (patch) | |
| tree | eee7b79d2758d64f44aba40e627b058b3f5a9a1a /Source/Core/Common/Debug/MemoryPatches.cpp | |
| parent | f37113204fe8e930c4e33e5e0149fbe0309fe425 (diff) | |
| parent | 6f0266e8deb9b9d46fb6f291db696fed06c1bed0 (diff) | |
Merge pull request #11554 from JosJuice/host-lock-cpu
DolphinQt: Properly lock CPU before accessing emulated memory
Diffstat (limited to 'Source/Core/Common/Debug/MemoryPatches.cpp')
| -rw-r--r-- | Source/Core/Common/Debug/MemoryPatches.cpp | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/Source/Core/Common/Debug/MemoryPatches.cpp b/Source/Core/Common/Debug/MemoryPatches.cpp index f48e6e5bb5..d4f7e92379 100644 --- a/Source/Core/Common/Debug/MemoryPatches.cpp +++ b/Source/Core/Common/Debug/MemoryPatches.cpp @@ -23,36 +23,37 @@ MemoryPatch::MemoryPatch(u32 address_, u32 value_) MemoryPatches::MemoryPatches() = default; MemoryPatches::~MemoryPatches() = default; -void MemoryPatches::SetPatch(u32 address, u32 value) +void MemoryPatches::SetPatch(const Core::CPUThreadGuard& guard, u32 address, u32 value) { const std::size_t index = m_patches.size(); m_patches.emplace_back(address, value); - Patch(index); + Patch(guard, index); } -void MemoryPatches::SetPatch(u32 address, std::vector<u8> value) +void MemoryPatches::SetPatch(const Core::CPUThreadGuard& guard, u32 address, std::vector<u8> value) { - UnsetPatch(address); + UnsetPatch(guard, address); const std::size_t index = m_patches.size(); m_patches.emplace_back(address, std::move(value)); - Patch(index); + Patch(guard, index); } -void MemoryPatches::SetFramePatch(u32 address, u32 value) +void MemoryPatches::SetFramePatch(const Core::CPUThreadGuard& guard, u32 address, u32 value) { const std::size_t index = m_patches.size(); m_patches.emplace_back(address, value); m_patches.back().type = MemoryPatch::ApplyType::EachFrame; - Patch(index); + Patch(guard, index); } -void MemoryPatches::SetFramePatch(u32 address, std::vector<u8> value) +void MemoryPatches::SetFramePatch(const Core::CPUThreadGuard& guard, u32 address, + std::vector<u8> value) { - UnsetPatch(address); + UnsetPatch(guard, address); const std::size_t index = m_patches.size(); m_patches.emplace_back(address, std::move(value)); m_patches.back().type = MemoryPatch::ApplyType::EachFrame; - Patch(index); + Patch(guard, index); } const std::vector<MemoryPatch>& MemoryPatches::GetPatches() const @@ -60,7 +61,7 @@ const std::vector<MemoryPatch>& MemoryPatches::GetPatches() const return m_patches; } -void MemoryPatches::UnsetPatch(u32 address) +void MemoryPatches::UnsetPatch(const Core::CPUThreadGuard& guard, u32 address) { const auto it = std::find_if(m_patches.begin(), m_patches.end(), [address](const auto& patch) { return patch.address == address; }); @@ -69,23 +70,23 @@ void MemoryPatches::UnsetPatch(u32 address) return; const std::size_t index = std::distance(m_patches.begin(), it); - RemovePatch(index); + RemovePatch(guard, index); } -void MemoryPatches::EnablePatch(std::size_t index) +void MemoryPatches::EnablePatch(const Core::CPUThreadGuard& guard, std::size_t index) { if (m_patches[index].is_enabled == MemoryPatch::State::Enabled) return; m_patches[index].is_enabled = MemoryPatch::State::Enabled; - Patch(index); + Patch(guard, index); } -void MemoryPatches::DisablePatch(std::size_t index) +void MemoryPatches::DisablePatch(const Core::CPUThreadGuard& guard, std::size_t index) { if (m_patches[index].is_enabled == MemoryPatch::State::Disabled) return; m_patches[index].is_enabled = MemoryPatch::State::Disabled; - Patch(index); + Patch(guard, index); } bool MemoryPatches::HasEnabledPatch(u32 address) const @@ -95,19 +96,19 @@ bool MemoryPatches::HasEnabledPatch(u32 address) const }); } -void MemoryPatches::RemovePatch(std::size_t index) +void MemoryPatches::RemovePatch(const Core::CPUThreadGuard& guard, std::size_t index) { - DisablePatch(index); + DisablePatch(guard, index); UnPatch(index); m_patches.erase(m_patches.begin() + index); } -void MemoryPatches::ClearPatches() +void MemoryPatches::ClearPatches(const Core::CPUThreadGuard& guard) { const std::size_t size = m_patches.size(); for (std::size_t index = 0; index < size; ++index) { - DisablePatch(index); + DisablePatch(guard, index); UnPatch(index); } m_patches.clear(); |
