mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-19 17:35:06 -04:00
exo/mariko fatal: save fatal error binaries to the SD
This commit is contained in:
parent
5f6942aec8
commit
b32c9bf17c
20 changed files with 24419 additions and 12 deletions
52
exosphere/mariko_fatal/source/fatal_save_context.cpp
Normal file
52
exosphere/mariko_fatal/source/fatal_save_context.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <exosphere.hpp>
|
||||
#include "fatal_save_context.hpp"
|
||||
#include "fs/fatal_fs_api.hpp"
|
||||
|
||||
namespace ams::secmon::fatal {
|
||||
|
||||
Result SaveFatalErrorContext(const ams::impl::FatalErrorContext *ctx) {
|
||||
/* Mount the SD card. */
|
||||
R_UNLESS(fs::MountSdCard(), fs::ResultPartitionNotFound());
|
||||
|
||||
/* Unmount the SD card once we're done. */
|
||||
ON_SCOPE_EXIT { fs::UnmountSdCard(); };
|
||||
|
||||
/* Create and open the file. */
|
||||
fs::FileHandle file;
|
||||
{
|
||||
/* Generate the file path. */
|
||||
char path[0x40];
|
||||
util::TSNPrintf(path, sizeof(path), "/atmosphere/fatal_errors/report_%016" PRIx64 ".bin", ctx->report_identifier);
|
||||
|
||||
/* Create the file. */
|
||||
R_TRY(fs::CreateFile(path, sizeof(*ctx)));
|
||||
|
||||
/* Open the file. */
|
||||
R_TRY(fs::OpenFile(std::addressof(file), path, fs::OpenMode_ReadWrite));
|
||||
}
|
||||
|
||||
/* Ensure we close the file when done with it. */
|
||||
ON_SCOPE_EXIT { fs::CloseFile(file); };
|
||||
|
||||
/* Write the context to the file. */
|
||||
R_TRY(fs::WriteFile(file, 0, ctx, sizeof(*ctx), fs::WriteOption::Flush));
|
||||
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue