From a38db34934aaac1188b8aa9e63b09d2021ef5a40 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 5 Feb 2024 22:01:58 +0100 Subject: [PATCH] early-access version 4116 --- README.md | 2 +- dist/languages/.tx/config | 1 + src/common/typed_address.h | 80 +++++++++---------- src/core/memory/cheat_engine.cpp | 25 ++++-- src/core/memory/cheat_engine.h | 6 +- src/core/memory/dmnt_cheat_vm.cpp | 17 ++-- src/core/memory/dmnt_cheat_vm.h | 4 +- src/yuzu/configuration/configure_per_game.cpp | 3 + 8 files changed, 77 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 2e4a0e8f4..1006ba56a 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 4115. +This is the source code for early-access 4116. ## Legal Notice diff --git a/dist/languages/.tx/config b/dist/languages/.tx/config index 6f990d14e..266a33d2e 100755 --- a/dist/languages/.tx/config +++ b/dist/languages/.tx/config @@ -11,3 +11,4 @@ type = QT file_filter = ../../src/android/app/src/main/res/values-/strings.xml source_file = ../../src/android/app/src/main/res/values/strings.xml type = ANDROID +lang_map = ja_JP:ja, ko_KR:ko, pt_BR:pt-rBR, pt_PT:pt-rPT, ru_RU:ru, vi_VN:vi, zh_CN:zh-rCN, zh_TW:zh-rTW diff --git a/src/common/typed_address.h b/src/common/typed_address.h index 64f4a07c2..d5e743583 100755 --- a/src/common/typed_address.h +++ b/src/common/typed_address.h @@ -186,68 +186,68 @@ static_assert(std::is_trivially_destructible_v); static_assert(std::is_trivially_destructible_v); static_assert(std::is_trivially_destructible_v); -static_assert(Null == 0); +static_assert(Null == 0U); static_assert(Null == Null); static_assert(Null == Null); static_assert(Null == Null); // Constructor/assignment validations. static_assert([] { - const PhysicalAddress a(5); + const PhysicalAddress a(5U); PhysicalAddress b(a); return b; -}() == PhysicalAddress(5)); +}() == PhysicalAddress(5U)); static_assert([] { - const PhysicalAddress a(5); - PhysicalAddress b(10); + const PhysicalAddress a(5U); + PhysicalAddress b(10U); b = a; return b; -}() == PhysicalAddress(5)); +}() == PhysicalAddress(5U)); // Arithmetic validations. -static_assert(PhysicalAddress(10) + 5 == PhysicalAddress(15)); -static_assert(PhysicalAddress(10) - 5 == PhysicalAddress(5)); +static_assert(PhysicalAddress(10U) + 5U == PhysicalAddress(15U)); +static_assert(PhysicalAddress(10U) - 5U == PhysicalAddress(5U)); static_assert([] { - PhysicalAddress v(10); - v += 5; + PhysicalAddress v(10U); + v += 5U; return v; -}() == PhysicalAddress(15)); +}() == PhysicalAddress(15U)); static_assert([] { - PhysicalAddress v(10); - v -= 5; + PhysicalAddress v(10U); + v -= 5U; return v; -}() == PhysicalAddress(5)); -static_assert(PhysicalAddress(10)++ == PhysicalAddress(10)); -static_assert(++PhysicalAddress(10) == PhysicalAddress(11)); -static_assert(PhysicalAddress(10)-- == PhysicalAddress(10)); -static_assert(--PhysicalAddress(10) == PhysicalAddress(9)); +}() == PhysicalAddress(5U)); +static_assert(PhysicalAddress(10U)++ == PhysicalAddress(10U)); +static_assert(++PhysicalAddress(10U) == PhysicalAddress(11U)); +static_assert(PhysicalAddress(10U)-- == PhysicalAddress(10U)); +static_assert(--PhysicalAddress(10U) == PhysicalAddress(9U)); // Logical validations. -static_assert((PhysicalAddress(0b11111111) >> 1) == 0b01111111); -static_assert((PhysicalAddress(0b10101010) >> 1) == 0b01010101); -static_assert((PhysicalAddress(0b11111111) << 1) == 0b111111110); -static_assert((PhysicalAddress(0b01010101) << 1) == 0b10101010); -static_assert((PhysicalAddress(0b11111111) & 0b01010101) == 0b01010101); -static_assert((PhysicalAddress(0b11111111) & 0b10101010) == 0b10101010); -static_assert((PhysicalAddress(0b01010101) & 0b10101010) == 0b00000000); -static_assert((PhysicalAddress(0b00000000) | 0b01010101) == 0b01010101); -static_assert((PhysicalAddress(0b11111111) | 0b01010101) == 0b11111111); -static_assert((PhysicalAddress(0b10101010) | 0b01010101) == 0b11111111); +static_assert((PhysicalAddress(0b11111111U) >> 1) == 0b01111111U); +static_assert((PhysicalAddress(0b10101010U) >> 1) == 0b01010101U); +static_assert((PhysicalAddress(0b11111111U) << 1) == 0b111111110U); +static_assert((PhysicalAddress(0b01010101U) << 1) == 0b10101010U); +static_assert((PhysicalAddress(0b11111111U) & 0b01010101U) == 0b01010101U); +static_assert((PhysicalAddress(0b11111111U) & 0b10101010U) == 0b10101010U); +static_assert((PhysicalAddress(0b01010101U) & 0b10101010U) == 0b00000000U); +static_assert((PhysicalAddress(0b00000000U) | 0b01010101U) == 0b01010101U); +static_assert((PhysicalAddress(0b11111111U) | 0b01010101U) == 0b11111111U); +static_assert((PhysicalAddress(0b10101010U) | 0b01010101U) == 0b11111111U); // Comparisons. -static_assert(PhysicalAddress(0) == PhysicalAddress(0)); -static_assert(PhysicalAddress(0) != PhysicalAddress(1)); -static_assert(PhysicalAddress(0) < PhysicalAddress(1)); -static_assert(PhysicalAddress(0) <= PhysicalAddress(1)); -static_assert(PhysicalAddress(1) > PhysicalAddress(0)); -static_assert(PhysicalAddress(1) >= PhysicalAddress(0)); +static_assert(PhysicalAddress(0U) == PhysicalAddress(0U)); +static_assert(PhysicalAddress(0U) != PhysicalAddress(1U)); +static_assert(PhysicalAddress(0U) < PhysicalAddress(1U)); +static_assert(PhysicalAddress(0U) <= PhysicalAddress(1U)); +static_assert(PhysicalAddress(1U) > PhysicalAddress(0U)); +static_assert(PhysicalAddress(1U) >= PhysicalAddress(0U)); -static_assert(!(PhysicalAddress(0) == PhysicalAddress(1))); -static_assert(!(PhysicalAddress(0) != PhysicalAddress(0))); -static_assert(!(PhysicalAddress(1) < PhysicalAddress(0))); -static_assert(!(PhysicalAddress(1) <= PhysicalAddress(0))); -static_assert(!(PhysicalAddress(0) > PhysicalAddress(1))); -static_assert(!(PhysicalAddress(0) >= PhysicalAddress(1))); +static_assert(!(PhysicalAddress(0U) == PhysicalAddress(1U))); +static_assert(!(PhysicalAddress(0U) != PhysicalAddress(0U))); +static_assert(!(PhysicalAddress(1U) < PhysicalAddress(0U))); +static_assert(!(PhysicalAddress(1U) <= PhysicalAddress(0U))); +static_assert(!(PhysicalAddress(0U) > PhysicalAddress(1U))); +static_assert(!(PhysicalAddress(0U) >= PhysicalAddress(1U))); } // namespace Common diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp index 1a34a392f..53cce8b00 100755 --- a/src/core/memory/cheat_engine.cpp +++ b/src/core/memory/cheat_engine.cpp @@ -47,12 +47,23 @@ StandardVmCallbacks::StandardVmCallbacks(System& system_, const CheatProcessMeta StandardVmCallbacks::~StandardVmCallbacks() = default; -void StandardVmCallbacks::MemoryRead(VAddr address, void* data, u64 size) { - system.ApplicationMemory().ReadBlock(SanitizeAddress(address), data, size); +void StandardVmCallbacks::MemoryReadUnsafe(VAddr address, void* data, u64 size) { + // Return zero on invalid address + if (!IsAddressInRange(address) || !system.ApplicationMemory().IsValidVirtualAddress(address)) { + std::memset(data, 0, size); + return; + } + + system.ApplicationMemory().ReadBlock(address, data, size); } -void StandardVmCallbacks::MemoryWrite(VAddr address, const void* data, u64 size) { - system.ApplicationMemory().WriteBlock(SanitizeAddress(address), data, size); +void StandardVmCallbacks::MemoryWriteUnsafe(VAddr address, const void* data, u64 size) { + // Skip invalid memory write address + if (!IsAddressInRange(address) || !system.ApplicationMemory().IsValidVirtualAddress(address)) { + return; + } + + system.ApplicationMemory().WriteBlock(address, data, size); } u64 StandardVmCallbacks::HidKeysDown() { @@ -82,7 +93,7 @@ void StandardVmCallbacks::CommandLog(std::string_view data) { data.back() == '\n' ? data.substr(0, data.size() - 1) : data); } -VAddr StandardVmCallbacks::SanitizeAddress(VAddr in) const { +bool StandardVmCallbacks::IsAddressInRange(VAddr in) const { if ((in < metadata.main_nso_extents.base || in >= metadata.main_nso_extents.base + metadata.main_nso_extents.size) && (in < metadata.heap_extents.base || @@ -97,10 +108,10 @@ VAddr StandardVmCallbacks::SanitizeAddress(VAddr in) const { "the cheat may be incorrect. However, this may be normal early in execution if " "the game has not properly set up yet.", in); - return 0; ///< Invalid addresses will hard crash + return false; ///< Invalid addresses will hard crash } - return in; + return true; } CheatParser::~CheatParser() = default; diff --git a/src/core/memory/cheat_engine.h b/src/core/memory/cheat_engine.h index bcedc38b5..4d4e1144b 100755 --- a/src/core/memory/cheat_engine.h +++ b/src/core/memory/cheat_engine.h @@ -27,14 +27,14 @@ public: StandardVmCallbacks(System& system_, const CheatProcessMetadata& metadata_); ~StandardVmCallbacks() override; - void MemoryRead(VAddr address, void* data, u64 size) override; - void MemoryWrite(VAddr address, const void* data, u64 size) override; + void MemoryReadUnsafe(VAddr address, void* data, u64 size) override; + void MemoryWriteUnsafe(VAddr address, const void* data, u64 size) override; u64 HidKeysDown() override; void DebugLog(u8 id, u64 value) override; void CommandLog(std::string_view data) override; private: - VAddr SanitizeAddress(VAddr address) const; + bool IsAddressInRange(VAddr address) const; const CheatProcessMetadata& metadata; Core::System& system; diff --git a/src/core/memory/dmnt_cheat_vm.cpp b/src/core/memory/dmnt_cheat_vm.cpp index 54d1197a0..b4db02765 100755 --- a/src/core/memory/dmnt_cheat_vm.cpp +++ b/src/core/memory/dmnt_cheat_vm.cpp @@ -773,7 +773,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { case 2: case 4: case 8: - callbacks->MemoryWrite(dst_address, &dst_value, store_static->bit_width); + callbacks->MemoryWriteUnsafe(dst_address, &dst_value, store_static->bit_width); break; } } else if (auto begin_cond = std::get_if(&cur_opcode.opcode)) { @@ -786,7 +786,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { case 2: case 4: case 8: - callbacks->MemoryRead(src_address, &src_value, begin_cond->bit_width); + callbacks->MemoryReadUnsafe(src_address, &src_value, begin_cond->bit_width); break; } // Check against condition. @@ -857,8 +857,8 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { case 2: case 4: case 8: - callbacks->MemoryRead(src_address, ®isters[ldr_memory->reg_index], - ldr_memory->bit_width); + callbacks->MemoryReadUnsafe(src_address, ®isters[ldr_memory->reg_index], + ldr_memory->bit_width); break; } } else if (auto str_static = std::get_if(&cur_opcode.opcode)) { @@ -874,7 +874,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { case 2: case 4: case 8: - callbacks->MemoryWrite(dst_address, &dst_value, str_static->bit_width); + callbacks->MemoryWriteUnsafe(dst_address, &dst_value, str_static->bit_width); break; } // Increment register if relevant. @@ -1032,7 +1032,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { case 2: case 4: case 8: - callbacks->MemoryWrite(dst_address, &dst_value, str_register->bit_width); + callbacks->MemoryWriteUnsafe(dst_address, &dst_value, str_register->bit_width); break; } @@ -1111,7 +1111,8 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { case 2: case 4: case 8: - callbacks->MemoryRead(cond_address, &cond_value, begin_reg_cond->bit_width); + callbacks->MemoryReadUnsafe(cond_address, &cond_value, + begin_reg_cond->bit_width); break; } } @@ -1253,7 +1254,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { case 2: case 4: case 8: - callbacks->MemoryRead(val_address, &log_value, debug_log->bit_width); + callbacks->MemoryReadUnsafe(val_address, &log_value, debug_log->bit_width); break; } } diff --git a/src/core/memory/dmnt_cheat_vm.h b/src/core/memory/dmnt_cheat_vm.h index 667f02914..5e27d47c0 100755 --- a/src/core/memory/dmnt_cheat_vm.h +++ b/src/core/memory/dmnt_cheat_vm.h @@ -266,8 +266,8 @@ public: public: virtual ~Callbacks(); - virtual void MemoryRead(VAddr address, void* data, u64 size) = 0; - virtual void MemoryWrite(VAddr address, const void* data, u64 size) = 0; + virtual void MemoryReadUnsafe(VAddr address, void* data, u64 size) = 0; + virtual void MemoryWriteUnsafe(VAddr address, const void* data, u64 size) = 0; virtual u64 HidKeysDown() = 0; diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index 35a801585..01249fb20 100755 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp @@ -73,8 +73,11 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st ui->tabWidget->addTab(graphics_advanced_tab.get(), tr("Adv. Graphics")); ui->tabWidget->addTab(audio_tab.get(), tr("Audio")); ui->tabWidget->addTab(input_tab.get(), tr("Input Profiles")); + // Only show Linux tab on Unix + linux_tab->setVisible(false); #ifdef __unix__ + linux_tab->setVisible(true); ui->tabWidget->addTab(linux_tab.get(), tr("Linux")); #endif