Disable Debug Mode in hardcore mode

Debug Mode gives players direct read and write access to memory, which could be used to completely manipulate RetroAchievements logic and therefore is not allowed in hardcore mode.
This commit is contained in:
LillyJadeKatrin 2023-06-07 21:54:49 -04:00
parent c20258d782
commit cb2fa9a1f2
11 changed files with 47 additions and 8 deletions

View File

@ -738,4 +738,15 @@ bool IsDefaultGCIFolderPathConfigured(ExpansionInterface::Slot slot)
{ {
return Config::Get(GetInfoForGCIPath(slot)).empty(); return Config::Get(GetInfoForGCIPath(slot)).empty();
} }
bool IsDebuggingEnabled()
{
#ifdef USE_RETRO_ACHIEVEMENTS
return Config::Get(::Config::MAIN_ENABLE_DEBUGGING) &&
!::Config::Get(::Config::RA_HARDCORE_ENABLED);
#else // USE_RETRO_ACHIEVEMENTS
return Config::Get(::Config::MAIN_ENABLE_DEBUGGING);
#endif // USE_RETRO_ACHIEVEMENTS
}
} // namespace Config } // namespace Config

View File

@ -378,4 +378,5 @@ std::string GetGCIFolderPath(ExpansionInterface::Slot slot, std::optional<DiscIO
std::string GetGCIFolderPath(std::string configured_folder, ExpansionInterface::Slot slot, std::string GetGCIFolderPath(std::string configured_folder, ExpansionInterface::Slot slot,
std::optional<DiscIO::Region> region); std::optional<DiscIO::Region> region);
bool IsDefaultGCIFolderPathConfigured(ExpansionInterface::Slot slot); bool IsDefaultGCIFolderPathConfigured(ExpansionInterface::Slot slot);
bool IsDebuggingEnabled();
} // namespace Config } // namespace Config

View File

@ -219,7 +219,7 @@ TryReplaceFunctionResult TryReplaceFunction(u32 address)
bool IsEnabled(HookFlag flag) bool IsEnabled(HookFlag flag)
{ {
return flag != HLE::HookFlag::Debug || Config::Get(Config::MAIN_ENABLE_DEBUGGING) || return flag != HLE::HookFlag::Debug || Config::IsDebuggingEnabled() ||
Core::System::GetInstance().GetPowerPC().GetMode() == PowerPC::CoreMode::Interpreter; Core::System::GetInstance().GetPowerPC().GetMode() == PowerPC::CoreMode::Interpreter;
} }

View File

@ -236,7 +236,7 @@ void Interpreter::Run()
core_timing.Advance(); core_timing.Advance();
// we have to check exceptions at branches apparently (or maybe just rfi?) // we have to check exceptions at branches apparently (or maybe just rfi?)
if (Config::Get(Config::MAIN_ENABLE_DEBUGGING)) if (Config::IsDebuggingEnabled())
{ {
#ifdef SHOW_HISTORY #ifdef SHOW_HISTORY
s_pc_block_vec.push_back(m_ppc_state.pc); s_pc_block_vec.push_back(m_ppc_state.pc);

View File

@ -44,7 +44,7 @@ void Jit64AsmRoutineManager::Regenerate()
void Jit64AsmRoutineManager::Generate() void Jit64AsmRoutineManager::Generate()
{ {
const bool enable_debugging = Config::Get(Config::MAIN_ENABLE_DEBUGGING); const bool enable_debugging = Config::IsDebuggingEnabled();
enter_code = AlignCode16(); enter_code = AlignCode16();
// We need to own the beginning of RSP, so we do an extra stack adjustment // We need to own the beginning of RSP, so we do an extra stack adjustment

View File

@ -30,7 +30,7 @@ void JitArm64::GenerateAsm()
{ {
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes; const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
const bool enable_debugging = Config::Get(Config::MAIN_ENABLE_DEBUGGING); const bool enable_debugging = Config::IsDebuggingEnabled();
// This value is all of the callee saved registers that we are required to save. // This value is all of the callee saved registers that we are required to save.
// According to the AACPS64 we need to save R19 ~ R30 and Q8 ~ Q15. // According to the AACPS64 we need to save R19 ~ R30 and Q8 ~ Q15.

View File

@ -160,7 +160,7 @@ void JITWidget::Update()
PPCAnalyst::BlockRegStats fpa; PPCAnalyst::BlockRegStats fpa;
PPCAnalyst::CodeBlock code_block; PPCAnalyst::CodeBlock code_block;
PPCAnalyst::PPCAnalyzer analyzer; PPCAnalyst::PPCAnalyzer analyzer;
analyzer.SetDebuggingEnabled(Config::Get(Config::MAIN_ENABLE_DEBUGGING)); analyzer.SetDebuggingEnabled(Config::IsDebuggingEnabled());
analyzer.SetBranchFollowingEnabled(Config::Get(Config::MAIN_JIT_FOLLOW_BRANCH)); analyzer.SetBranchFollowingEnabled(Config::Get(Config::MAIN_JIT_FOLLOW_BRANCH));
analyzer.SetFloatExceptionsEnabled(Config::Get(Config::MAIN_FLOAT_EXCEPTIONS)); analyzer.SetFloatExceptionsEnabled(Config::Get(Config::MAIN_FLOAT_EXCEPTIONS));
analyzer.SetDivByZeroExceptionsEnabled(Config::Get(Config::MAIN_DIVIDE_BY_ZERO_EXCEPTIONS)); analyzer.SetDivByZeroExceptionsEnabled(Config::Get(Config::MAIN_DIVIDE_BY_ZERO_EXCEPTIONS));

View File

@ -257,7 +257,7 @@ void HotkeyScheduler::Run()
if (auto bt = WiiUtils::GetBluetoothRealDevice()) if (auto bt = WiiUtils::GetBluetoothRealDevice())
bt->UpdateSyncButtonState(IsHotkey(HK_TRIGGER_SYNC_BUTTON, true)); bt->UpdateSyncButtonState(IsHotkey(HK_TRIGGER_SYNC_BUTTON, true));
if (Config::Get(Config::MAIN_ENABLE_DEBUGGING)) if (Config::IsDebuggingEnabled())
{ {
CheckDebuggingHotkeys(); CheckDebuggingHotkeys();
} }

View File

@ -33,6 +33,7 @@
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Core/Config/AchievementSettings.h"
#include "Core/Config/GraphicsSettings.h" #include "Core/Config/GraphicsSettings.h"
#include "Core/Config/MainSettings.h" #include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
@ -563,6 +564,10 @@ void Settings::SetCheatsEnabled(bool enabled)
void Settings::SetDebugModeEnabled(bool enabled) void Settings::SetDebugModeEnabled(bool enabled)
{ {
#ifdef USE_RETRO_ACHIEVEMENTS
if (Config::Get(Config::RA_HARDCORE_ENABLED))
enabled = false;
#endif // USE_RETRO_ACHIEVEMENTS
if (IsDebugModeEnabled() != enabled) if (IsDebugModeEnabled() != enabled)
{ {
Config::SetBaseOrCurrent(Config::MAIN_ENABLE_DEBUGGING, enabled); Config::SetBaseOrCurrent(Config::MAIN_ENABLE_DEBUGGING, enabled);

View File

@ -19,9 +19,11 @@
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Core/Config/AchievementSettings.h"
#include "Core/Config/MainSettings.h" #include "Core/Config/MainSettings.h"
#include "Core/Config/UISettings.h" #include "Core/Config/UISettings.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/SignalBlocking.h" #include "DolphinQt/QtUtils/SignalBlocking.h"
#include "DolphinQt/Settings.h" #include "DolphinQt/Settings.h"
@ -84,6 +86,9 @@ InterfacePane::InterfacePane(QWidget* parent) : QWidget(parent)
CreateLayout(); CreateLayout();
LoadConfig(); LoadConfig();
ConnectLayout(); ConnectLayout();
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
&InterfacePane::LoadConfig);
} }
void InterfacePane::CreateLayout() void InterfacePane::CreateLayout()
@ -151,7 +156,7 @@ void InterfacePane::CreateUI()
m_checkbox_use_builtin_title_database = new QCheckBox(tr("Use Built-In Database of Game Names")); m_checkbox_use_builtin_title_database = new QCheckBox(tr("Use Built-In Database of Game Names"));
m_checkbox_use_covers = m_checkbox_use_covers =
new QCheckBox(tr("Download Game Covers from GameTDB.com for Use in Grid Mode")); new QCheckBox(tr("Download Game Covers from GameTDB.com for Use in Grid Mode"));
m_checkbox_show_debugging_ui = new QCheckBox(tr("Enable Debugging UI")); m_checkbox_show_debugging_ui = new ToolTipCheckBox(tr("Enable Debugging UI"));
m_checkbox_focused_hotkeys = new QCheckBox(tr("Hotkeys Require Window Focus")); m_checkbox_focused_hotkeys = new QCheckBox(tr("Hotkeys Require Window Focus"));
m_checkbox_disable_screensaver = new QCheckBox(tr("Inhibit Screensaver During Emulation")); m_checkbox_disable_screensaver = new QCheckBox(tr("Inhibit Screensaver During Emulation"));
@ -249,6 +254,21 @@ void InterfacePane::LoadConfig()
->setChecked(Config::Get(Config::MAIN_USE_BUILT_IN_TITLE_DATABASE)); ->setChecked(Config::Get(Config::MAIN_USE_BUILT_IN_TITLE_DATABASE));
SignalBlocking(m_checkbox_show_debugging_ui) SignalBlocking(m_checkbox_show_debugging_ui)
->setChecked(Settings::Instance().IsDebugModeEnabled()); ->setChecked(Settings::Instance().IsDebugModeEnabled());
#ifdef USE_RETRO_ACHIEVEMENTS
bool hardcore = Config::Get(Config::RA_HARDCORE_ENABLED);
SignalBlocking(m_checkbox_show_debugging_ui)->setEnabled(!hardcore);
if (hardcore)
{
m_checkbox_show_debugging_ui->SetDescription(
tr("<dolphin_emphasis>Disabled in Hardcore Mode.</dolphin_emphasis>"));
}
else
{
m_checkbox_show_debugging_ui->SetDescription({});
}
#endif // USE_RETRO_ACHIEVEMENTS
SignalBlocking(m_combobox_language) SignalBlocking(m_combobox_language)
->setCurrentIndex(m_combobox_language->findData( ->setCurrentIndex(m_combobox_language->findData(
QString::fromStdString(Config::Get(Config::MAIN_INTERFACE_LANGUAGE)))); QString::fromStdString(Config::Get(Config::MAIN_INTERFACE_LANGUAGE))));

View File

@ -10,6 +10,7 @@ class QComboBox;
class QLabel; class QLabel;
class QRadioButton; class QRadioButton;
class QVBoxLayout; class QVBoxLayout;
class ToolTipCheckBox;
class InterfacePane final : public QWidget class InterfacePane final : public QWidget
{ {
@ -36,7 +37,8 @@ private:
QLabel* m_label_userstyle; QLabel* m_label_userstyle;
QCheckBox* m_checkbox_top_window; QCheckBox* m_checkbox_top_window;
QCheckBox* m_checkbox_use_builtin_title_database; QCheckBox* m_checkbox_use_builtin_title_database;
QCheckBox* m_checkbox_show_debugging_ui; QCheckBox* m_checkbox_use_userstyle;
ToolTipCheckBox* m_checkbox_show_debugging_ui;
QCheckBox* m_checkbox_focused_hotkeys; QCheckBox* m_checkbox_focused_hotkeys;
QCheckBox* m_checkbox_use_covers; QCheckBox* m_checkbox_use_covers;
QCheckBox* m_checkbox_disable_screensaver; QCheckBox* m_checkbox_disable_screensaver;