ams: use R_DISCARD everywhere
This commit is contained in:
@@ -679,7 +679,7 @@ namespace ams::tio {
|
||||
|
||||
/* NOTE: Nintendo does not check the output of this call. */
|
||||
s64 read_count = 0;
|
||||
fs::ReadDirectory(std::addressof(read_count), reinterpret_cast<fs::DirectoryEntry *>(body), handle, cur);
|
||||
R_DISCARD(fs::ReadDirectory(std::addressof(read_count), reinterpret_cast<fs::DirectoryEntry *>(body), handle, cur));
|
||||
|
||||
/* Send the current entries. */
|
||||
const ssize_t cur_size = read_count * sizeof(fs::DirectoryEntry);
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace ams::mitm {
|
||||
|
||||
void CreateAutomaticBackups() {
|
||||
/* Create a backup directory, if one doesn't exist. */
|
||||
mitm::fs::CreateAtmosphereSdDirectory("/automatic_backups");
|
||||
R_DISCARD(mitm::fs::CreateAtmosphereSdDirectory("/automatic_backups"));
|
||||
|
||||
/* Initialize PRODINFO and get a reference for the device. */
|
||||
char device_reference[0x40] = {};
|
||||
@@ -127,7 +127,7 @@ namespace ams::mitm {
|
||||
char bis_keys_backup_name[ams::fs::EntryNameLengthMax + 1];
|
||||
GetBackupFileName(bis_keys_backup_name, sizeof(bis_keys_backup_name), device_reference, "BISKEYS.bin");
|
||||
|
||||
mitm::fs::CreateAtmosphereSdFile(bis_keys_backup_name, sizeof(bis_keys), ams::fs::CreateOption_None);
|
||||
R_DISCARD(mitm::fs::CreateAtmosphereSdFile(bis_keys_backup_name, sizeof(bis_keys), ams::fs::CreateOption_None));
|
||||
R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdFile(std::addressof(g_bis_key_file), bis_keys_backup_name, ams::fs::OpenMode_ReadWrite));
|
||||
R_ABORT_UNLESS(fsFileSetSize(std::addressof(g_bis_key_file), sizeof(bis_keys)));
|
||||
R_ABORT_UNLESS(fsFileWrite(std::addressof(g_bis_key_file), 0, bis_keys, sizeof(bis_keys), FsWriteOption_Flush));
|
||||
@@ -153,11 +153,11 @@ namespace ams::mitm {
|
||||
mitm::fs::OpenGlobalSdCardFileSystem();
|
||||
|
||||
/* Mount the sd card at a convenient mountpoint. */
|
||||
ams::fs::MountSdCard(ams::fs::impl::SdCardFileSystemMountName);
|
||||
R_DISCARD(ams::fs::MountSdCard(ams::fs::impl::SdCardFileSystemMountName));
|
||||
|
||||
/* Initialize the reboot manager (load a payload off the SD). */
|
||||
/* Discard result, since it doesn't need to succeed. */
|
||||
mitm::bpc::LoadRebootPayload();
|
||||
R_DISCARD(mitm::bpc::LoadRebootPayload());
|
||||
|
||||
/* Backup Calibration Binary and BIS keys. */
|
||||
CreateAutomaticBackups();
|
||||
@@ -167,7 +167,7 @@ namespace ams::mitm {
|
||||
if (const char *emummc_file_path = emummc::GetFilePath(); emummc_file_path != nullptr) {
|
||||
char emummc_path[ams::fs::EntryNameLengthMax + 1];
|
||||
util::SNPrintf(emummc_path, sizeof(emummc_path), "%s/eMMC", emummc_file_path);
|
||||
mitm::fs::OpenSdFile(std::addressof(g_emummc_file), emummc_path, ams::fs::OpenMode_Read);
|
||||
R_DISCARD(mitm::fs::OpenSdFile(std::addressof(g_emummc_file), emummc_path, ams::fs::OpenMode_Read));
|
||||
}
|
||||
|
||||
/* NOTE: due to an Atmosphere bug, NS accesses to the Nintendo dir accessed /Nintendo/Nintendo */
|
||||
@@ -185,7 +185,7 @@ namespace ams::mitm {
|
||||
/* Ensure Contents directory exists for normal emummc. */
|
||||
/* NOTE: Allowed to fail on already-exists. */
|
||||
util::SNPrintf(emummc_path, sizeof(emummc_path), "%s:/%s/Contents", ams::fs::impl::SdCardFileSystemMountName, emummc::GetNintendoDirPath());
|
||||
ams::fs::CreateDirectory(emummc_path);
|
||||
R_DISCARD(ams::fs::CreateDirectory(emummc_path));
|
||||
|
||||
/* Fix Contents/private */
|
||||
util::SNPrintf(emummc_path, sizeof(emummc_path), "%s:/%s/Contents/private", ams::fs::impl::SdCardFileSystemMountName, emummc::GetNintendoDirPath());
|
||||
|
||||
@@ -436,7 +436,7 @@ namespace ams::mitm {
|
||||
GetBackupFileName(backup_fn, sizeof(backup_fn), info);
|
||||
|
||||
/* Create the file, in case it does not exist. */
|
||||
mitm::fs::CreateAtmosphereSdFile(backup_fn, sizeof(CalibrationInfo), ams::fs::CreateOption_None);
|
||||
R_DISCARD(mitm::fs::CreateAtmosphereSdFile(backup_fn, sizeof(CalibrationInfo), ams::fs::CreateOption_None));
|
||||
|
||||
/* Open the file. */
|
||||
FsFile libnx_file;
|
||||
|
||||
@@ -40,10 +40,10 @@ namespace ams::mitm::socket::resolver {
|
||||
|
||||
if (g_log_enabled) {
|
||||
/* Create the logs directory. */
|
||||
mitm::fs::CreateAtmosphereSdDirectory("/logs");
|
||||
R_DISCARD(mitm::fs::CreateAtmosphereSdDirectory("/logs"));
|
||||
|
||||
/* Create the log file. */
|
||||
mitm::fs::CreateAtmosphereSdFile("/logs/dns_mitm_debug.log", 0, ams::fs::CreateOption_None);
|
||||
R_DISCARD(mitm::fs::CreateAtmosphereSdFile("/logs/dns_mitm_debug.log", 0, ams::fs::CreateOption_None));
|
||||
|
||||
/* Open the log file. */
|
||||
R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdFile(std::addressof(g_log_file), "/logs/dns_mitm_debug.log", ams::fs::OpenMode_ReadWrite | ams::fs::OpenMode_AllowAppend));
|
||||
|
||||
@@ -313,8 +313,8 @@ namespace ams::mitm::socket::resolver {
|
||||
|
||||
/* Open log file. */
|
||||
::FsFile log_file;
|
||||
mitm::fs::DeleteAtmosphereSdFile("/logs/dns_mitm_startup.log");
|
||||
mitm::fs::CreateAtmosphereSdDirectory("/logs");
|
||||
R_DISCARD(mitm::fs::DeleteAtmosphereSdFile("/logs/dns_mitm_startup.log"));
|
||||
R_DISCARD(mitm::fs::CreateAtmosphereSdDirectory("/logs"));
|
||||
R_ABORT_UNLESS(mitm::fs::CreateAtmosphereSdFile("/logs/dns_mitm_startup.log", 0, ams::fs::CreateOption_None));
|
||||
R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdFile(std::addressof(log_file), "/logs/dns_mitm_startup.log", ams::fs::OpenMode_ReadWrite | ams::fs::OpenMode_AllowAppend));
|
||||
ON_SCOPE_EXIT { ::fsFileClose(std::addressof(log_file)); };
|
||||
@@ -325,7 +325,7 @@ namespace ams::mitm::socket::resolver {
|
||||
if (!mitm::fs::HasAtmosphereSdFile("/hosts/default.txt")) {
|
||||
Log(log_file, "Creating /hosts/default.txt because it does not exist.\n");
|
||||
|
||||
mitm::fs::CreateAtmosphereSdDirectory("/hosts");
|
||||
R_DISCARD(mitm::fs::CreateAtmosphereSdDirectory("/hosts"));
|
||||
R_ABORT_UNLESS(mitm::fs::CreateAtmosphereSdFile("/hosts/default.txt", sizeof(DefaultHostsFile) - 1, ams::fs::CreateOption_None));
|
||||
|
||||
::FsFile default_file;
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace ams::mitm::socket::resolver {
|
||||
}
|
||||
|
||||
/* Initialize the socket allocator. */
|
||||
ams::socket::InitializeAllocatorForInternal(g_resolver_allocator_buffer, sizeof(g_resolver_allocator_buffer));
|
||||
R_DISCARD(ams::socket::InitializeAllocatorForInternal(g_resolver_allocator_buffer, sizeof(g_resolver_allocator_buffer)));
|
||||
|
||||
/* Initialize debug. */
|
||||
resolver::InitializeDebug(ShouldEnableDebugLog());
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace ams::mitm::fs {
|
||||
constexpr const fs::Path root_path = fs::MakeConstantPath("/");
|
||||
|
||||
u8 savedata_copy_buffer[2_KB];
|
||||
fssystem::CopyDirectoryRecursively(dirsave_ifs.get(), save_ifs.get(), root_path, root_path, std::addressof(work_entry), savedata_copy_buffer, sizeof(savedata_copy_buffer));
|
||||
R_DISCARD(fssystem::CopyDirectoryRecursively(dirsave_ifs.get(), save_ifs.get(), root_path, root_path, std::addressof(work_entry), savedata_copy_buffer, sizeof(savedata_copy_buffer)));
|
||||
}
|
||||
|
||||
/* Set output. */
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace ams::mitm::settings {
|
||||
}
|
||||
|
||||
Result SetMitmService::GetLanguageCode(sf::Out<settings::LanguageCode> out) {
|
||||
this->EnsureLocale();
|
||||
R_DISCARD(this->EnsureLocale());
|
||||
|
||||
/* If there's no override locale, just use the actual one. */
|
||||
if (AMS_UNLIKELY(!m_is_valid_language)) {
|
||||
@@ -109,7 +109,7 @@ namespace ams::mitm::settings {
|
||||
}
|
||||
|
||||
Result SetMitmService::GetRegionCode(sf::Out<settings::RegionCode> out) {
|
||||
this->EnsureLocale();
|
||||
R_DISCARD(this->EnsureLocale());
|
||||
|
||||
/* If there's no override locale, just use the actual one. */
|
||||
if (AMS_UNLIKELY(!m_is_valid_region)) {
|
||||
|
||||
@@ -490,7 +490,7 @@ namespace ams::boot {
|
||||
}
|
||||
|
||||
if (input_current_limit_ma <= 150) {
|
||||
charger_driver.SetChargerConfiguration(powctl::ChargerConfiguration_ChargeDisable);
|
||||
R_DISCARD(charger_driver.SetChargerConfiguration(powctl::ChargerConfiguration_ChargeDisable));
|
||||
boot::ShutdownSystem();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,10 +262,10 @@ namespace ams::boot {
|
||||
R_ABORT_UNLESS(i2c::driver::OpenSession(std::addressof(i2c_session), i2c::DeviceCode_Max77620Pmic));
|
||||
|
||||
if (g_soc_type == spl::SocType_Mariko) {
|
||||
WriteI2cRegister(i2c_session, 0x18, 0x3A);
|
||||
WriteI2cRegister(i2c_session, 0x1F, 0x71);
|
||||
R_DISCARD(WriteI2cRegister(i2c_session, 0x18, 0x3A));
|
||||
R_DISCARD(WriteI2cRegister(i2c_session, 0x1F, 0x71));
|
||||
}
|
||||
WriteI2cRegister(i2c_session, 0x23, 0xD0);
|
||||
R_DISCARD(WriteI2cRegister(i2c_session, 0x23, 0xD0));
|
||||
|
||||
i2c::driver::CloseSession(i2c_session);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace ams::boot {
|
||||
desired_shutdown_enabled &= use_desired_shutdown;
|
||||
|
||||
if (shutdown_enabled != desired_shutdown_enabled) {
|
||||
battery_driver.SetI2cShutdownEnabled(desired_shutdown_enabled);
|
||||
R_DISCARD(battery_driver.SetI2cShutdownEnabled(desired_shutdown_enabled));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ namespace ams::creport {
|
||||
}
|
||||
|
||||
void TryCreateReportDirectories() {
|
||||
fs::EnsureDirectory("sdmc:/atmosphere/crash_reports/dumps");
|
||||
fs::EnsureDirectory("sdmc:/atmosphere/fatal_reports/dumps");
|
||||
R_DISCARD(fs::EnsureDirectory("sdmc:/atmosphere/crash_reports/dumps"));
|
||||
R_DISCARD(fs::EnsureDirectory("sdmc:/atmosphere/fatal_reports/dumps"));
|
||||
}
|
||||
|
||||
constexpr const char *GetDebugExceptionString(const svc::DebugException type) {
|
||||
@@ -244,7 +244,7 @@ namespace ams::creport {
|
||||
m_result = creport::ResultUserBreak();
|
||||
/* Try to parse out the user break result. */
|
||||
if (hos::GetVersion() >= hos::Version_5_0_0) {
|
||||
svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(std::addressof(m_result)), m_debug_handle, d.info.exception.specific.user_break.address, sizeof(m_result));
|
||||
R_DISCARD(svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(std::addressof(m_result)), m_debug_handle, d.info.exception.specific.user_break.address, sizeof(m_result)));
|
||||
}
|
||||
break;
|
||||
case svc::DebugException_UndefinedSystemCall:
|
||||
@@ -289,7 +289,7 @@ namespace ams::creport {
|
||||
}
|
||||
|
||||
/* Read the dying message. */
|
||||
svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(m_dying_message), m_debug_handle, m_dying_message_address, m_dying_message_size);
|
||||
R_DISCARD(svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(m_dying_message), m_debug_handle, m_dying_message_address, m_dying_message_size));
|
||||
}
|
||||
|
||||
void CrashReport::SaveReport(bool enable_screenshot) {
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace ams {
|
||||
if (R_SUCCEEDED(pgl::Initialize())) {
|
||||
ON_SCOPE_EXIT { pgl::Finalize(); };
|
||||
|
||||
pgl::TerminateProcess(crashed_pid);
|
||||
R_DISCARD(pgl::TerminateProcess(crashed_pid));
|
||||
}
|
||||
} else {
|
||||
/* Use ns to terminate. */
|
||||
|
||||
@@ -38,9 +38,9 @@ namespace ams::creport {
|
||||
~ScopedFile() {
|
||||
if (m_opened) {
|
||||
if (m_cache != nullptr) {
|
||||
this->TryWriteCache();
|
||||
R_DISCARD(this->TryWriteCache());
|
||||
}
|
||||
fs::FlushFile(m_file);
|
||||
R_DISCARD(fs::FlushFile(m_file));
|
||||
fs::CloseFile(m_file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace ams::dmnt {
|
||||
for (size_t i = 0; (bp = static_cast<BreakPoint *>(this->GetBreakPoint(i))) != nullptr; ++i) {
|
||||
if (bp->m_in_use && bp->m_is_step) {
|
||||
AMS_DMNT2_GDB_LOG_DEBUG("BreakPointManager::ClearStep %p 0x%lx (idx=%zu)\n", bp, bp->m_address, i);
|
||||
bp->Clear(m_debug_process);
|
||||
R_DISCARD(bp->Clear(m_debug_process));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace ams::dmnt {
|
||||
BreakPointBase *bp = nullptr;
|
||||
for (size_t i = 0; (bp = static_cast<BreakPointBase *>(this->GetBreakPoint(i))) != nullptr; ++i) {
|
||||
if (bp->m_in_use) {
|
||||
bp->Clear(m_debug_process);
|
||||
R_DISCARD(bp->Clear(m_debug_process));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace ams::dmnt {
|
||||
|
||||
/* Get our process id. */
|
||||
u64 pid_value = 0;
|
||||
svc::GetProcessId(std::addressof(pid_value), m_debug_handle);
|
||||
R_DISCARD(svc::GetProcessId(std::addressof(pid_value), m_debug_handle));
|
||||
|
||||
m_process_id = { pid_value };
|
||||
|
||||
@@ -413,7 +413,7 @@ namespace ams::dmnt {
|
||||
|
||||
/* Get the instruction where we were. */
|
||||
u32 insn = 0;
|
||||
this->ReadMemory(std::addressof(insn), pc, sizeof(insn));
|
||||
R_DISCARD(this->ReadMemory(std::addressof(insn), pc, sizeof(insn)));
|
||||
|
||||
/* Handle by architecture. */
|
||||
bool is_call = false;
|
||||
@@ -471,7 +471,7 @@ namespace ams::dmnt {
|
||||
}
|
||||
|
||||
Result DebugProcess::ClearBreakPoint(uintptr_t address, size_t size) {
|
||||
m_software_breakpoints.ClearBreakPoint(address, size);
|
||||
R_DISCARD(m_software_breakpoints.ClearBreakPoint(address, size));
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ namespace ams::dmnt {
|
||||
}
|
||||
|
||||
Result DebugProcess::ClearHardwareBreakPoint(uintptr_t address, size_t size) {
|
||||
m_hardware_breakpoints.ClearBreakPoint(address, size);
|
||||
R_DISCARD(m_hardware_breakpoints.ClearBreakPoint(address, size));
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
|
||||
@@ -1030,7 +1030,7 @@ namespace ams::dmnt {
|
||||
const auto reason = info.break_reason & ~svc::BreakReason_NotificationOnlyFlag;
|
||||
if (reason == svc::BreakReason_PostLoadDll || reason == svc::BreakReason_PostUnloadDll) {
|
||||
/* Re-collect the process's modules. */
|
||||
m_debug_process.CollectModules();
|
||||
R_DISCARD(m_debug_process.CollectModules());
|
||||
}
|
||||
|
||||
if (m_debug_process.GetOverrideStatus().IsHbl() && reason == svc::BreakReason_PostLoadDll) {
|
||||
@@ -1049,7 +1049,7 @@ namespace ams::dmnt {
|
||||
}
|
||||
|
||||
/* This was just a notification, so we should continue. */
|
||||
m_debug_process.Continue();
|
||||
R_DISCARD(m_debug_process.Continue());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1064,7 +1064,7 @@ namespace ams::dmnt {
|
||||
|
||||
if (!is_svc_break) {
|
||||
AMS_DMNT2_GDB_LOG_ERROR("UserBreak from non-SvcBreak (%08x)\n", insn);
|
||||
m_debug_process.Continue();
|
||||
R_DISCARD(m_debug_process.Continue());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1194,7 +1194,7 @@ namespace ams::dmnt {
|
||||
AMS_DMNT2_GDB_LOG_DEBUG("CreateThread %lx\n", thread_id);
|
||||
|
||||
if (m_debug_process.IsValid()) {
|
||||
m_debug_process.Continue();
|
||||
R_DISCARD(m_debug_process.Continue());
|
||||
} else {
|
||||
AppendReplyFormat(reply_cur, reply_end, "W00");
|
||||
}
|
||||
@@ -1205,7 +1205,7 @@ namespace ams::dmnt {
|
||||
AMS_DMNT2_GDB_LOG_DEBUG("ExitThread %lx\n", thread_id);
|
||||
|
||||
if (m_debug_process.IsValid()) {
|
||||
m_debug_process.Continue();
|
||||
R_DISCARD(m_debug_process.Continue());
|
||||
} else {
|
||||
AppendReplyFormat(reply_cur, reply_end, "W00");
|
||||
}
|
||||
@@ -1227,7 +1227,7 @@ namespace ams::dmnt {
|
||||
break;
|
||||
default:
|
||||
AMS_DMNT2_GDB_LOG_DEBUG("Unhandled ProcessEvent %u %lx\n", static_cast<u32>(d.type), thread_id);
|
||||
m_debug_process.Continue();
|
||||
R_DISCARD(m_debug_process.Continue());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1235,7 +1235,7 @@ namespace ams::dmnt {
|
||||
bool do_break;
|
||||
this->SendPacket(std::addressof(do_break), send_buffer);
|
||||
if (do_break) {
|
||||
m_debug_process.Break();
|
||||
R_DISCARD(m_debug_process.Break());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1250,7 +1250,7 @@ namespace ams::dmnt {
|
||||
|
||||
/* Get the thread context. */
|
||||
svc::ThreadContext thread_context = {};
|
||||
m_debug_process.GetThreadContext(std::addressof(thread_context), thread_id, svc::ThreadContextFlag_General | svc::ThreadContextFlag_Control);
|
||||
R_DISCARD(m_debug_process.GetThreadContext(std::addressof(thread_context), thread_id, svc::ThreadContextFlag_General | svc::ThreadContextFlag_Control));
|
||||
|
||||
/* Add important registers. */
|
||||
/* TODO: aarch32 */
|
||||
@@ -1280,7 +1280,7 @@ namespace ams::dmnt {
|
||||
/* Add the thread core. */
|
||||
{
|
||||
u32 core = 0;
|
||||
m_debug_process.GetThreadCurrentCore(std::addressof(core), thread_id);
|
||||
R_DISCARD(m_debug_process.GetThreadCurrentCore(std::addressof(core), thread_id));
|
||||
|
||||
AppendReplyFormat(m_reply_cur, m_reply_end, ";core:%u;", core);
|
||||
}
|
||||
@@ -1305,7 +1305,7 @@ namespace ams::dmnt {
|
||||
|
||||
/* If we should, break the process. */
|
||||
if (do_break) {
|
||||
m_debug_process.Break();
|
||||
R_DISCARD(m_debug_process.Break());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1721,7 +1721,7 @@ namespace ams::dmnt {
|
||||
}
|
||||
|
||||
void GdbServerImpl::k() {
|
||||
m_debug_process.Terminate();
|
||||
R_DISCARD(m_debug_process.Terminate());
|
||||
m_killed = true;
|
||||
}
|
||||
|
||||
@@ -2369,7 +2369,7 @@ namespace ams::dmnt {
|
||||
|
||||
/* Get the thread core. */
|
||||
u32 core = 0;
|
||||
m_debug_process.GetThreadCurrentCore(std::addressof(core), thread_ids[i]);
|
||||
R_DISCARD(m_debug_process.GetThreadCurrentCore(std::addressof(core), thread_ids[i]));
|
||||
|
||||
/* Get the thread name. */
|
||||
char name[os::ThreadNameLengthMax + 1];
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace ams::dmnt {
|
||||
g_last_bp_ctx_register = g_last_bp_register;
|
||||
for (int i = g_last_bp_ctx_register; i >= static_cast<int>(svc::HardwareBreakPointRegisterName_I0); --i) {
|
||||
const Result result = svc::SetHardwareBreakPoint(static_cast<svc::HardwareBreakPointRegisterName>(i), dbgbcr, svc::PseudoHandle::CurrentProcess);
|
||||
svc::SetHardwareBreakPoint(static_cast<svc::HardwareBreakPointRegisterName>(i), 0, 0);
|
||||
R_DISCARD(svc::SetHardwareBreakPoint(static_cast<svc::HardwareBreakPointRegisterName>(i), 0, 0));
|
||||
|
||||
if (R_FAILED(result)) {
|
||||
if (!svc::ResultInvalidHandle::Includes(result)) {
|
||||
|
||||
@@ -346,7 +346,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
Result ResumeCheatProcessUnsafe() {
|
||||
m_broken_unsafe = false;
|
||||
m_unsafe_break_event.Signal();
|
||||
dmnt::cheat::impl::ContinueCheatProcess(this->GetCheatProcessHandle());
|
||||
R_DISCARD(dmnt::cheat::impl::ContinueCheatProcess(this->GetCheatProcessHandle()));
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
@@ -682,7 +682,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
while (true) {
|
||||
eventLoadRemote(std::addressof(hook), manager->HookToCreateApplicationProcess(), true);
|
||||
if (R_SUCCEEDED(eventWait(std::addressof(hook), std::numeric_limits<u64>::max()))) {
|
||||
manager->AttachToApplicationProcess(true);
|
||||
R_DISCARD(manager->AttachToApplicationProcess(true));
|
||||
}
|
||||
eventClose(std::addressof(hook));
|
||||
}
|
||||
@@ -760,7 +760,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
const auto &value = entry.GetValue();
|
||||
|
||||
/* Use Write SVC directly, to avoid the usual frozen address update logic. */
|
||||
svc::WriteDebugProcessMemory(manager->GetCheatProcessHandle(), reinterpret_cast<uintptr_t>(std::addressof(value.value)), address, value.width);
|
||||
R_DISCARD(svc::WriteDebugProcessMemory(manager->GetCheatProcessHandle(), reinterpret_cast<uintptr_t>(std::addressof(value.value)), address, value.width));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1146,8 +1146,8 @@ namespace ams::dmnt::cheat::impl {
|
||||
{
|
||||
char path[fs::EntryNameLengthMax + 1];
|
||||
util::SNPrintf(path, sizeof(path), "sdmc:/atmosphere/contents/%016lx/cheats/toggles.txt", program_id.value);
|
||||
fs::DeleteFile(path);
|
||||
fs::CreateFile(path, 0);
|
||||
R_DISCARD(fs::DeleteFile(path));
|
||||
R_DISCARD(fs::CreateFile(path, 0));
|
||||
if (R_FAILED(fs::OpenFile(std::addressof(file), path, fs::OpenMode_Write | fs::OpenMode_AllowAppend))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
|
||||
void CheatVirtualMachine::DebugLog(u32 log_id, u64 value) {
|
||||
/* Just unconditionally try to create the log folder. */
|
||||
fs::EnsureDirectory("sdmc:/atmosphere/cheat_vm_logs");
|
||||
R_DISCARD(fs::EnsureDirectory("sdmc:/atmosphere/cheat_vm_logs"));
|
||||
|
||||
fs::FileHandle log_file;
|
||||
{
|
||||
@@ -40,7 +40,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
|
||||
char log_value[18];
|
||||
util::SNPrintf(log_value, sizeof(log_value), "%016lx\n", value);
|
||||
fs::WriteFile(log_file, log_offset, log_value, std::strlen(log_value), fs::WriteOption::Flush);
|
||||
R_DISCARD(fs::WriteFile(log_file, log_offset, log_value, std::strlen(log_value), fs::WriteOption::Flush));
|
||||
}
|
||||
|
||||
void CheatVirtualMachine::OpenDebugLogFile() {
|
||||
@@ -796,7 +796,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
u64 kHeld = 0;
|
||||
|
||||
/* Get Keys held. */
|
||||
hid::GetKeysHeld(std::addressof(kHeld));
|
||||
R_DISCARD(hid::GetKeysHeld(std::addressof(kHeld)));
|
||||
|
||||
this->OpenDebugLogFile();
|
||||
ON_SCOPE_EXIT { this->CloseDebugLogFile(); };
|
||||
@@ -838,7 +838,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, std::addressof(dst_value), cur_opcode.store_static.bit_width);
|
||||
R_DISCARD(dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, std::addressof(dst_value), cur_opcode.store_static.bit_width));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -853,7 +853,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, std::addressof(src_value), cur_opcode.begin_cond.bit_width);
|
||||
R_DISCARD(dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, std::addressof(src_value), cur_opcode.begin_cond.bit_width));
|
||||
break;
|
||||
}
|
||||
/* Check against condition. */
|
||||
@@ -933,7 +933,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, std::addressof(m_registers[cur_opcode.ldr_memory.reg_index]), cur_opcode.ldr_memory.bit_width);
|
||||
R_DISCARD(dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, std::addressof(m_registers[cur_opcode.ldr_memory.reg_index]), cur_opcode.ldr_memory.bit_width));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -952,7 +952,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, std::addressof(dst_value), cur_opcode.str_static.bit_width);
|
||||
R_DISCARD(dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, std::addressof(dst_value), cur_opcode.str_static.bit_width));
|
||||
break;
|
||||
}
|
||||
/* Increment register if relevant. */
|
||||
@@ -1143,7 +1143,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, std::addressof(dst_value), cur_opcode.str_register.bit_width);
|
||||
R_DISCARD(dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, std::addressof(dst_value), cur_opcode.str_register.bit_width));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1214,7 +1214,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(cond_address, std::addressof(cond_value), cur_opcode.begin_reg_cond.bit_width);
|
||||
R_DISCARD(dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(cond_address, std::addressof(cond_value), cur_opcode.begin_reg_cond.bit_width));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1309,10 +1309,10 @@ namespace ams::dmnt::cheat::impl {
|
||||
}
|
||||
break;
|
||||
case CheatVmOpcodeType_PauseProcess:
|
||||
dmnt::cheat::impl::PauseCheatProcessUnsafe();
|
||||
R_DISCARD(dmnt::cheat::impl::PauseCheatProcessUnsafe());
|
||||
break;
|
||||
case CheatVmOpcodeType_ResumeProcess:
|
||||
dmnt::cheat::impl::ResumeCheatProcessUnsafe();
|
||||
R_DISCARD(dmnt::cheat::impl::ResumeCheatProcessUnsafe());
|
||||
break;
|
||||
case CheatVmOpcodeType_DebugLog:
|
||||
{
|
||||
@@ -1356,7 +1356,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(val_address, std::addressof(log_value), cur_opcode.debug_log.bit_width);
|
||||
R_DISCARD(dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(val_address, std::addressof(log_value), cur_opcode.debug_log.bit_width));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +62,9 @@ namespace ams {
|
||||
{
|
||||
u8 disable_report_cleanup = 0;
|
||||
if (settings::fwdbg::GetSettingsItemValue(std::addressof(disable_report_cleanup), sizeof(disable_report_cleanup), "erpt", "disable_automatic_report_cleanup") == sizeof(disable_report_cleanup)) {
|
||||
erpt::srv::SetEnabledAutomaticReportCleanup(disable_report_cleanup == 0);
|
||||
R_DISCARD(erpt::srv::SetEnabledAutomaticReportCleanup(disable_report_cleanup == 0));
|
||||
} else {
|
||||
erpt::srv::SetEnabledAutomaticReportCleanup(true);
|
||||
R_DISCARD(erpt::srv::SetEnabledAutomaticReportCleanup(true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace ams {
|
||||
R_ABORT_UNLESS(erpt::srv::Initialize(erpt::g_memory_heap, erpt::MemoryHeapSize));
|
||||
|
||||
/* Atmosphere always wants to redirect new reports to the SD card, to prevent them from being logged. */
|
||||
erpt::srv::SetRedirectNewReportsToSdCard(true);
|
||||
R_DISCARD(erpt::srv::SetRedirectNewReportsToSdCard(true));
|
||||
|
||||
/* Configure the serial number, OS version, product model, and region. */
|
||||
{
|
||||
|
||||
@@ -105,11 +105,11 @@ namespace ams::fatal::srv {
|
||||
|
||||
void CheckRepairStatus() {
|
||||
if (IsInRepairWithoutVolHeld()) {
|
||||
ThrowFatalForSelf(ResultInRepairWithoutVolHeld());
|
||||
R_DISCARD(ThrowFatalForSelf(ResultInRepairWithoutVolHeld()));
|
||||
}
|
||||
|
||||
if (IsInRepairWithoutTimeReviserCartridge()) {
|
||||
ThrowFatalForSelf(ResultInRepairWithoutTimeReviserCartridge());
|
||||
R_DISCARD(ThrowFatalForSelf(ResultInRepairWithoutTimeReviserCartridge()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace ams::fatal::srv {
|
||||
|
||||
/* Helpers. */
|
||||
void TryEnsureReportDirectories() {
|
||||
fs::EnsureDirectory("sdmc:/atmosphere/fatal_reports/dumps");
|
||||
R_DISCARD(fs::EnsureDirectory("sdmc:/atmosphere/fatal_reports/dumps"));
|
||||
}
|
||||
|
||||
bool TryGetCurrentTimestamp(u64 *out) {
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace ams {
|
||||
|
||||
/* Create the htc misc ipc thread. */
|
||||
os::ThreadType htc_ipc_thread;
|
||||
os::CreateThread(std::addressof(htc_ipc_thread), htc::HtcIpcThreadFunction, nullptr, htc::g_htc_ipc_thread_stack, sizeof(htc::g_htc_ipc_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(htc, HtcIpc));
|
||||
R_DISCARD(os::CreateThread(std::addressof(htc_ipc_thread), htc::HtcIpcThreadFunction, nullptr, htc::g_htc_ipc_thread_stack, sizeof(htc::g_htc_ipc_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(htc, HtcIpc)));
|
||||
os::SetThreadNamePointer(std::addressof(htc_ipc_thread), AMS_GET_SYSTEM_THREAD_NAME(htc, HtcIpc));
|
||||
|
||||
/* Initialize the htcfs server. */
|
||||
@@ -186,7 +186,7 @@ namespace ams {
|
||||
|
||||
/* Create the htcfs ipc thread. */
|
||||
os::ThreadType htcfs_ipc_thread;
|
||||
os::CreateThread(std::addressof(htcfs_ipc_thread), htc::HtcfsIpcThreadFunction, nullptr, htc::g_htcfs_ipc_thread_stack, sizeof(htc::g_htcfs_ipc_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(htc, HtcfsIpc));
|
||||
R_DISCARD(os::CreateThread(std::addressof(htcfs_ipc_thread), htc::HtcfsIpcThreadFunction, nullptr, htc::g_htcfs_ipc_thread_stack, sizeof(htc::g_htcfs_ipc_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(htc, HtcfsIpc)));
|
||||
os::SetThreadNamePointer(std::addressof(htcfs_ipc_thread), AMS_GET_SYSTEM_THREAD_NAME(htc, HtcfsIpc));
|
||||
|
||||
/* Initialize the htcs server. */
|
||||
@@ -196,7 +196,7 @@ namespace ams {
|
||||
/* Create the htcs ipc threads. */
|
||||
os::ThreadType htcs_ipc_threads[htc::NumHtcsIpcThreads];
|
||||
for (size_t i = 0; i < htc::NumHtcsIpcThreads; ++i) {
|
||||
os::CreateThread(std::addressof(htcs_ipc_threads[i]), htc::HtcsIpcThreadFunction, nullptr, htc::g_htcs_ipc_thread_stack[i], sizeof(htc::g_htcs_ipc_thread_stack[i]), AMS_GET_SYSTEM_THREAD_PRIORITY(htc, HtcsIpc));
|
||||
R_DISCARD(os::CreateThread(std::addressof(htcs_ipc_threads[i]), htc::HtcsIpcThreadFunction, nullptr, htc::g_htcs_ipc_thread_stack[i], sizeof(htc::g_htcs_ipc_thread_stack[i]), AMS_GET_SYSTEM_THREAD_PRIORITY(htc, HtcsIpc)));
|
||||
os::SetThreadNamePointer(std::addressof(htcs_ipc_threads[i]), AMS_GET_SYSTEM_THREAD_NAME(htc, HtcsIpc));
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace ams::ldr {
|
||||
Entry m_argument_map[ArgumentMapCount];
|
||||
public:
|
||||
constexpr ArgumentStore() : m_argument_map{} {
|
||||
this->Flush();
|
||||
R_DISCARD(this->Flush());
|
||||
}
|
||||
public:
|
||||
const Entry *Get(ncm::ProgramId program_id);
|
||||
|
||||
@@ -812,7 +812,7 @@ namespace ams::ldr {
|
||||
/* Set the output handle, and ensure that if we fail after this point we clean it up. */
|
||||
out->process_handle = process_handle;
|
||||
out->code_address = param.code_address;
|
||||
ON_RESULT_FAILURE { svc::CloseHandle(process_handle); };
|
||||
ON_RESULT_FAILURE { R_DISCARD(svc::CloseHandle(process_handle)); };
|
||||
|
||||
/* Load all auto load modules. */
|
||||
R_RETURN(LoadAutoLoadModules(out, ctx, argument));
|
||||
@@ -882,7 +882,7 @@ namespace ams::ldr {
|
||||
/* If we're overriding for HBL, perform HTML document redirection. */
|
||||
if (override_status.IsHbl()) {
|
||||
/* Don't validate result, failure is okay. */
|
||||
RedirectHtmlDocumentPathForHbl(loc);
|
||||
R_DISCARD(RedirectHtmlDocumentPathForHbl(loc));
|
||||
}
|
||||
|
||||
/* Clear the external code for the program. */
|
||||
|
||||
@@ -89,8 +89,8 @@ namespace ams::pm::impl {
|
||||
if (m_handle != os::InvalidNativeHandle) {
|
||||
/* Unregister the process. */
|
||||
fsprUnregisterProgram(m_process_id.value);
|
||||
sm::manager::UnregisterProcess(m_process_id);
|
||||
ldr::pm::UnpinProgram(m_pin_id);
|
||||
R_DISCARD(sm::manager::UnregisterProcess(m_process_id));
|
||||
R_DISCARD(ldr::pm::UnpinProgram(m_pin_id));
|
||||
|
||||
/* Close the process's handle. */
|
||||
os::CloseNativeHandle(m_handle);
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace ams::pm::impl {
|
||||
R_TRY(ldr::pm::AtmospherePinProgram(std::addressof(pin_id), fixed_location, override_status));
|
||||
|
||||
/* If we fail after now, unpin. */
|
||||
ON_RESULT_FAILURE { ldr::pm::UnpinProgram(pin_id); };
|
||||
ON_RESULT_FAILURE { R_DISCARD(ldr::pm::UnpinProgram(pin_id)); };
|
||||
|
||||
/* Ensure we can talk to mitm services. */
|
||||
{
|
||||
@@ -486,7 +486,7 @@ namespace ams::pm::impl {
|
||||
/* NOTE: Nintendo does not check the result of this. */
|
||||
if (spl::IsDisabledProgramVerification()) {
|
||||
if (hos::GetVersion() >= hos::Version_10_0_0) {
|
||||
ldr::pm::SetEnabledProgramVerification(false);
|
||||
R_DISCARD(ldr::pm::SetEnabledProgramVerification(false));
|
||||
} else {
|
||||
fsprSetEnabledProgramVerification(false);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace ams::pm::impl {
|
||||
auto list = GetProcessList();
|
||||
|
||||
/* Reset the process's signal. */
|
||||
svc::ResetSignal(process_info->GetHandle());
|
||||
R_DISCARD(svc::ResetSignal(process_info->GetHandle()));
|
||||
|
||||
/* Update the process's state. */
|
||||
const svc::ProcessState old_state = process_info->GetState();
|
||||
|
||||
@@ -54,8 +54,8 @@ namespace ams {
|
||||
void RegisterPrivilegedProcess(os::ProcessId process_id, ncm::ProgramId program_id) {
|
||||
fsprUnregisterProgram(process_id.value);
|
||||
fsprRegisterProgram(process_id.value, process_id.value, NcmStorageId_BuiltInSystem, PrivilegedFileAccessHeader, sizeof(PrivilegedFileAccessHeader), PrivilegedFileAccessControl, sizeof(PrivilegedFileAccessControl), 0);
|
||||
sm::manager::UnregisterProcess(process_id);
|
||||
sm::manager::RegisterProcess(process_id, program_id, cfg::OverrideStatus{}, PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl), PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl));
|
||||
R_DISCARD(sm::manager::UnregisterProcess(process_id));
|
||||
R_DISCARD(sm::manager::RegisterProcess(process_id, program_id, cfg::OverrideStatus{}, PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl), PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl)));
|
||||
}
|
||||
|
||||
void RegisterPrivilegedProcesses() {
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace ams::ro::impl {
|
||||
if (m_process_handle != os::InvalidNativeHandle) {
|
||||
for (size_t i = 0; i < MaxNrrInfos; i++) {
|
||||
if (m_nrr_in_use[i]) {
|
||||
UnmapNrr(m_process_handle, m_nrr_infos[i].mapped_header, m_nrr_infos[i].nrr_heap_address, m_nrr_infos[i].nrr_heap_size, m_nrr_infos[i].mapped_code_address);
|
||||
R_DISCARD(UnmapNrr(m_process_handle, m_nrr_infos[i].mapped_header, m_nrr_infos[i].nrr_heap_address, m_nrr_infos[i].nrr_heap_size, m_nrr_infos[i].mapped_code_address));
|
||||
}
|
||||
}
|
||||
os::CloseNativeHandle(m_process_handle);
|
||||
@@ -659,7 +659,7 @@ namespace ams::ro::impl {
|
||||
|
||||
/* Map the NRO. */
|
||||
R_TRY(MapNro(std::addressof(nro_info->base_address), context->GetProcessHandle(), nro_address, nro_size, bss_address, bss_size));
|
||||
ON_RESULT_FAILURE { UnmapNro(context->GetProcessHandle(), nro_info->base_address, nro_address, nro_size, bss_address, bss_size); };
|
||||
ON_RESULT_FAILURE { R_DISCARD(UnmapNro(context->GetProcessHandle(), nro_info->base_address, nro_address, nro_size, bss_address, bss_size)); };
|
||||
|
||||
/* Parse the NRO. */
|
||||
u64 rx_size = 0, ro_size = 0, rw_size = 0;
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace ams {
|
||||
R_ABORT_UNLESS(g_server_manager.RegisterServer(PortIndex_Ssl, SslServiceName, SslMaxSessions));
|
||||
R_ABORT_UNLESS(g_server_manager.RegisterServer(PortIndex_Es, EsServiceName, EsMaxSessions));
|
||||
if (fw_ver >= hos::Version_5_0_0) {
|
||||
g_server_manager.RegisterServer(PortIndex_Manu, ManuServiceName, ManuMaxSessions);
|
||||
R_DISCARD(g_server_manager.RegisterServer(PortIndex_Manu, ManuServiceName, ManuMaxSessions));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace ams::spl {
|
||||
for (auto i = 0; i < impl::AesKeySlotCount; ++i) {
|
||||
if (m_aes_keyslot_owners[i] == owner) {
|
||||
m_aes_keyslot_owners[i] = nullptr;
|
||||
impl::DeallocateAesKeySlot(impl::AesKeySlotMin + i);
|
||||
R_DISCARD(impl::DeallocateAesKeySlot(impl::AesKeySlotMin + i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user