ams: replace most remaining operator & with std::addressof

This commit is contained in:
Michael Scire
2021-10-09 14:49:53 -07:00
parent ce8aacef21
commit 1ab0bd1765
109 changed files with 587 additions and 586 deletions

View File

@@ -28,7 +28,7 @@ namespace ams::mitm::fs {
/* Helpers. */
Result EnsureSdInitialized() {
R_UNLESS(serviceIsActive(&g_sd_filesystem.s), ams::fs::ResultSdCardNotPresent());
R_UNLESS(serviceIsActive(std::addressof(g_sd_filesystem.s)), ams::fs::ResultSdCardNotPresent());
return ResultSuccess();
}
@@ -39,17 +39,17 @@ namespace ams::mitm::fs {
}
void OpenGlobalSdCardFileSystem() {
R_ABORT_UNLESS(fsOpenSdCardFileSystem(&g_sd_filesystem));
R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(g_sd_filesystem)));
}
Result CreateSdFile(const char *path, s64 size, s32 option) {
R_TRY(EnsureSdInitialized());
return fsFsCreateFile(&g_sd_filesystem, path, size, option);
return fsFsCreateFile(std::addressof(g_sd_filesystem), path, size, option);
}
Result DeleteSdFile(const char *path) {
R_TRY(EnsureSdInitialized());
return fsFsDeleteFile(&g_sd_filesystem, path);
return fsFsDeleteFile(std::addressof(g_sd_filesystem), path);
}
bool HasSdFile(const char *path) {
@@ -58,7 +58,7 @@ namespace ams::mitm::fs {
}
FsDirEntryType type;
if (R_FAILED(fsFsGetEntryType(&g_sd_filesystem, path, &type))) {
if (R_FAILED(fsFsGetEntryType(std::addressof(g_sd_filesystem), path, std::addressof(type)))) {
return false;
}
@@ -85,7 +85,7 @@ namespace ams::mitm::fs {
Result OpenSdFile(FsFile *out, const char *path, u32 mode) {
R_TRY(EnsureSdInitialized());
return fsFsOpenFile(&g_sd_filesystem, path, mode, out);
return fsFsOpenFile(std::addressof(g_sd_filesystem), path, mode, out);
}
Result OpenAtmosphereSdFile(FsFile *out, const char *path, u32 mode) {
@@ -114,7 +114,7 @@ namespace ams::mitm::fs {
Result CreateSdDirectory(const char *path) {
R_TRY(EnsureSdInitialized());
return fsFsCreateDirectory(&g_sd_filesystem, path);
return fsFsCreateDirectory(std::addressof(g_sd_filesystem), path);
}
Result CreateAtmosphereSdDirectory(const char *path) {
@@ -125,7 +125,7 @@ namespace ams::mitm::fs {
Result OpenSdDirectory(FsDir *out, const char *path, u32 mode) {
R_TRY(EnsureSdInitialized());
return fsFsOpenDirectory(&g_sd_filesystem, path, mode, out);
return fsFsOpenDirectory(std::addressof(g_sd_filesystem), path, mode, out);
}
Result OpenAtmosphereSdDirectory(FsDir *out, const char *path, u32 mode) {
@@ -188,22 +188,22 @@ namespace ams::mitm::fs {
/* Check if romfs.bin is present. */
{
FsFile romfs_file;
if (R_SUCCEEDED(OpenAtmosphereSdFile(&romfs_file, program_id, "romfs.bin", OpenMode_Read))) {
fsFileClose(&romfs_file);
if (R_SUCCEEDED(OpenAtmosphereSdFile(std::addressof(romfs_file), program_id, "romfs.bin", OpenMode_Read))) {
fsFileClose(std::addressof(romfs_file));
return true;
}
}
/* Check for romfs folder with content. */
FsDir romfs_dir;
if (R_FAILED(OpenAtmosphereSdRomfsDirectory(&romfs_dir, program_id, "", OpenDirectoryMode_All))) {
if (R_FAILED(OpenAtmosphereSdRomfsDirectory(std::addressof(romfs_dir), program_id, "", OpenDirectoryMode_All))) {
return false;
}
ON_SCOPE_EXIT { fsDirClose(&romfs_dir); };
ON_SCOPE_EXIT { fsDirClose(std::addressof(romfs_dir)); };
/* Verify the folder has at least one entry. */
s64 num_entries = 0;
return R_SUCCEEDED(fsDirGetEntryCount(&romfs_dir, &num_entries)) && num_entries > 0;
return R_SUCCEEDED(fsDirGetEntryCount(std::addressof(romfs_dir), std::addressof(num_entries))) && num_entries > 0;
}
Result SaveAtmosphereSdFile(FsFile *out, ncm::ProgramId program_id, const char *path, void *data, size_t size) {
@@ -215,17 +215,17 @@ namespace ams::mitm::fs {
/* Unconditionally create. */
/* Don't check error, as a failure here should be okay. */
FsFile f;
fsFsCreateFile(&g_sd_filesystem, fixed_path, size, 0);
fsFsCreateFile(std::addressof(g_sd_filesystem), fixed_path, size, 0);
/* Try to open. */
R_TRY(fsFsOpenFile(&g_sd_filesystem, fixed_path, OpenMode_ReadWrite, &f));
auto file_guard = SCOPE_GUARD { fsFileClose(&f); };
R_TRY(fsFsOpenFile(std::addressof(g_sd_filesystem), fixed_path, OpenMode_ReadWrite, std::addressof(f)));
auto file_guard = SCOPE_GUARD { fsFileClose(std::addressof(f)); };
/* Try to set the size. */
R_TRY(fsFileSetSize(&f, static_cast<s64>(size)));
R_TRY(fsFileSetSize(std::addressof(f), static_cast<s64>(size)));
/* Try to write data. */
R_TRY(fsFileWrite(&f, 0, data, size, FsWriteOption_Flush));
R_TRY(fsFileWrite(std::addressof(f), 0, data, size, FsWriteOption_Flush));
/* Set output. */
file_guard.Cancel();
@@ -242,14 +242,14 @@ namespace ams::mitm::fs {
/* Unconditionally create. */
/* Don't check error, as a failure here should be okay. */
FsFile f;
fsFsCreateFile(&g_sd_filesystem, fixed_path, size, 0);
fsFsCreateFile(std::addressof(g_sd_filesystem), fixed_path, size, 0);
/* Try to open. */
R_TRY(fsFsOpenFile(&g_sd_filesystem, fixed_path, OpenMode_ReadWrite, &f));
auto file_guard = SCOPE_GUARD { fsFileClose(&f); };
R_TRY(fsFsOpenFile(std::addressof(g_sd_filesystem), fixed_path, OpenMode_ReadWrite, std::addressof(f)));
auto file_guard = SCOPE_GUARD { fsFileClose(std::addressof(f)); };
/* Try to set the size. */
R_TRY(fsFileSetSize(&f, static_cast<s64>(size)));
R_TRY(fsFileSetSize(std::addressof(f), static_cast<s64>(size)));
/* Set output. */
file_guard.Cancel();

View File

@@ -128,9 +128,9 @@ namespace ams::mitm {
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_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdFile(&g_bis_key_file, bis_keys_backup_name, ams::fs::OpenMode_ReadWrite));
R_ABORT_UNLESS(fsFileSetSize(&g_bis_key_file, sizeof(bis_keys)));
R_ABORT_UNLESS(fsFileWrite(&g_bis_key_file, 0, bis_keys, sizeof(bis_keys), FsWriteOption_Flush));
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));
/* NOTE: g_bis_key_file is intentionally not closed here. This prevents any other process from opening it. */
}
@@ -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(&g_emummc_file, emummc_path, ams::fs::OpenMode_Read);
mitm::fs::OpenSdFile(std::addressof(g_emummc_file), emummc_path, ams::fs::OpenMode_Read);
}
}

View File

@@ -297,28 +297,28 @@ namespace ams::mitm {
void ReadStorageCalibrationBinary(CalibrationInfo *out) {
FsStorage calibration_binary_storage;
R_ABORT_UNLESS(fsOpenBisStorage(&calibration_binary_storage, FsBisPartitionId_CalibrationBinary));
ON_SCOPE_EXIT { fsStorageClose(&calibration_binary_storage); };
R_ABORT_UNLESS(fsOpenBisStorage(std::addressof(calibration_binary_storage), FsBisPartitionId_CalibrationBinary));
ON_SCOPE_EXIT { fsStorageClose(std::addressof(calibration_binary_storage)); };
R_ABORT_UNLESS(fsStorageRead(&calibration_binary_storage, 0, out, sizeof(*out)));
R_ABORT_UNLESS(fsStorageRead(std::addressof(calibration_binary_storage), 0, out, sizeof(*out)));
}
constexpr inline const u8 SecureCalibrationBinaryBackupIv[crypto::Aes128CtrDecryptor::IvSize] = {};
void ReadStorageEncryptedSecureCalibrationBinaryBackupUnsafe(SecureCalibrationInfoBackup *out) {
FsStorage calibration_binary_storage;
R_ABORT_UNLESS(fsOpenBisStorage(&calibration_binary_storage, FsBisPartitionId_CalibrationBinary));
ON_SCOPE_EXIT { fsStorageClose(&calibration_binary_storage); };
R_ABORT_UNLESS(fsOpenBisStorage(std::addressof(calibration_binary_storage), FsBisPartitionId_CalibrationBinary));
ON_SCOPE_EXIT { fsStorageClose(std::addressof(calibration_binary_storage)); };
R_ABORT_UNLESS(fsStorageRead(&calibration_binary_storage, SecureCalibrationInfoBackupOffset, out, sizeof(*out)));
R_ABORT_UNLESS(fsStorageRead(std::addressof(calibration_binary_storage), SecureCalibrationInfoBackupOffset, out, sizeof(*out)));
}
void WriteStorageEncryptedSecureCalibrationBinaryBackupUnsafe(const SecureCalibrationInfoBackup *src) {
FsStorage calibration_binary_storage;
R_ABORT_UNLESS(fsOpenBisStorage(&calibration_binary_storage, FsBisPartitionId_CalibrationBinary));
ON_SCOPE_EXIT { fsStorageClose(&calibration_binary_storage); };
R_ABORT_UNLESS(fsOpenBisStorage(std::addressof(calibration_binary_storage), FsBisPartitionId_CalibrationBinary));
ON_SCOPE_EXIT { fsStorageClose(std::addressof(calibration_binary_storage)); };
R_ABORT_UNLESS(fsStorageWrite(&calibration_binary_storage, SecureCalibrationInfoBackupOffset, src, sizeof(*src)));
R_ABORT_UNLESS(fsStorageWrite(std::addressof(calibration_binary_storage), SecureCalibrationInfoBackupOffset, src, sizeof(*src)));
}
void GenerateSecureCalibrationBinaryBackupKey(void *dst, size_t dst_size) {

View File

@@ -135,13 +135,13 @@ namespace ams::mitm::bpc {
/* Open payload file. */
FsFile payload_file;
R_TRY(fs::OpenAtmosphereSdFile(&payload_file, "/reboot_payload.bin", ams::fs::OpenMode_Read));
ON_SCOPE_EXIT { fsFileClose(&payload_file); };
R_TRY(fs::OpenAtmosphereSdFile(std::addressof(payload_file), "/reboot_payload.bin", ams::fs::OpenMode_Read));
ON_SCOPE_EXIT { fsFileClose(std::addressof(payload_file)); };
/* Read payload file. Discard result. */
{
size_t actual_size;
fsFileRead(&payload_file, 0, g_reboot_payload, sizeof(g_reboot_payload), FsReadOption_None, &actual_size);
fsFileRead(std::addressof(payload_file), 0, g_reboot_payload, sizeof(g_reboot_payload), FsReadOption_None, std::addressof(actual_size));
}
/* NOTE: Preferred reboot type will be parsed from settings later on. */

View File

@@ -27,7 +27,7 @@ namespace ams::mitm::bpc {
}
void AtmosphereService::RebootToFatalError(const ams::FatalErrorContext &ctx) {
bpc::RebootForFatalError(&ctx);
bpc::RebootForFatalError(std::addressof(ctx));
}
void AtmosphereService::SetRebootPayload(const ams::sf::InBuffer &payload) {

View File

@@ -24,7 +24,7 @@ namespace ams::mitm::socket::resolver {
ssize_t SerializeRedirectedHostEnt(u8 * const dst, size_t dst_size, const char *hostname, ams::socket::InAddrT redirect_addr) {
struct in_addr addr = { .s_addr = redirect_addr };
struct in_addr *addr_list[2] = { &addr, nullptr };
struct in_addr *addr_list[2] = { std::addressof(addr), nullptr };
struct hostent ent = {
.h_name = const_cast<char *>(hostname),

View File

@@ -116,7 +116,7 @@ namespace ams::mitm::fs {
bool GetSettingsItemBooleanValue(const char *name, const char *key) {
u8 tmp = 0;
AMS_ABORT_UNLESS(settings::fwdbg::GetSettingsItemValue(&tmp, sizeof(tmp), name, key) == sizeof(tmp));
AMS_ABORT_UNLESS(settings::fwdbg::GetSettingsItemValue(std::addressof(tmp), sizeof(tmp), name, key) == sizeof(tmp));
return (tmp != 0);
}
@@ -133,20 +133,20 @@ namespace ams::mitm::fs {
Result OpenHblWebContentFileSystem(sf::Out<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> &out, ncm::ProgramId program_id) {
/* Verify eligibility. */
bool is_hbl;
R_UNLESS(R_SUCCEEDED(pm::info::IsHblProgramId(&is_hbl, program_id)), sm::mitm::ResultShouldForwardToSession());
R_UNLESS(R_SUCCEEDED(pm::info::IsHblProgramId(std::addressof(is_hbl), program_id)), sm::mitm::ResultShouldForwardToSession());
R_UNLESS(is_hbl, sm::mitm::ResultShouldForwardToSession());
/* Hbl html directory must exist. */
{
FsDir d;
R_UNLESS(R_SUCCEEDED(mitm::fs::OpenSdDirectory(&d, AtmosphereHblWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession());
fsDirClose(&d);
R_UNLESS(R_SUCCEEDED(mitm::fs::OpenSdDirectory(std::addressof(d), AtmosphereHblWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession());
fsDirClose(std::addressof(d));
}
/* Open the SD card using fs.mitm's session. */
FsFileSystem sd_fs;
R_TRY(fsOpenSdCardFileSystem(&sd_fs));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)};
R_TRY(fsOpenSdCardFileSystem(std::addressof(sd_fs)));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(sd_fs.s))};
std::unique_ptr<fs::fsa::IFileSystem> sd_ifs = std::make_unique<fs::RemoteFileSystem>(sd_fs);
out.SetValue(MakeSharedFileSystem(std::make_shared<fs::ReadOnlyFileSystem>(std::make_unique<fssystem::SubDirectoryFileSystem>(std::move(sd_ifs), AtmosphereHblWebContentDir)), false), target_object_id);
@@ -157,14 +157,14 @@ namespace ams::mitm::fs {
/* Directory must exist. */
{
FsDir d;
R_UNLESS(R_SUCCEEDED(mitm::fs::OpenAtmosphereSdDirectory(&d, program_id, ProgramWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession());
fsDirClose(&d);
R_UNLESS(R_SUCCEEDED(mitm::fs::OpenAtmosphereSdDirectory(std::addressof(d), program_id, ProgramWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession());
fsDirClose(std::addressof(d));
}
/* Open the SD card using fs.mitm's session. */
FsFileSystem sd_fs;
R_TRY(fsOpenSdCardFileSystem(&sd_fs));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)};
R_TRY(fsOpenSdCardFileSystem(std::addressof(sd_fs)));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(sd_fs.s))};
std::unique_ptr<fs::fsa::IFileSystem> sd_ifs = std::make_unique<fs::RemoteFileSystem>(sd_fs);
/* Format the subdirectory path. */
@@ -231,8 +231,8 @@ namespace ams::mitm::fs {
/* Create a new SD card filesystem. */
FsFileSystem sd_fs;
R_TRY(fsOpenSdCardFileSystemFwd(this->forward_service.get(), &sd_fs));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)};
R_TRY(fsOpenSdCardFileSystemFwd(this->forward_service.get(), std::addressof(sd_fs)));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(sd_fs.s))};
/* Return output filesystem. */
std::shared_ptr<fs::fsa::IFileSystem> redir_fs = std::make_shared<fssystem::DirectoryRedirectionFileSystem>(std::make_shared<RemoteFileSystem>(sd_fs), "/Nintendo", emummc::GetNintendoDirPath());
@@ -260,13 +260,13 @@ namespace ams::mitm::fs {
/* Verify we can open the save. */
static_assert(sizeof(fs::SaveDataAttribute) == sizeof(::FsSaveDataAttribute));
FsFileSystem save_fs;
R_UNLESS(R_SUCCEEDED(fsOpenSaveDataFileSystemFwd(this->forward_service.get(), &save_fs, space_id, reinterpret_cast<const FsSaveDataAttribute *>(&attribute))), sm::mitm::ResultShouldForwardToSession());
R_UNLESS(R_SUCCEEDED(fsOpenSaveDataFileSystemFwd(this->forward_service.get(), std::addressof(save_fs), space_id, reinterpret_cast<const FsSaveDataAttribute *>(std::addressof(attribute)))), sm::mitm::ResultShouldForwardToSession());
std::unique_ptr<fs::fsa::IFileSystem> save_ifs = std::make_unique<fs::RemoteFileSystem>(save_fs);
/* Mount the SD card using fs.mitm's session. */
FsFileSystem sd_fs;
R_TRY(fsOpenSdCardFileSystem(&sd_fs));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)};
R_TRY(fsOpenSdCardFileSystem(std::addressof(sd_fs)));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(sd_fs.s))};
std::shared_ptr<fs::fsa::IFileSystem> sd_ifs = std::make_shared<fs::RemoteFileSystem>(sd_fs);
/* Verify that we can open the save directory, and that it exists. */
@@ -278,7 +278,7 @@ namespace ams::mitm::fs {
bool is_new_save = false;
{
fs::DirectoryEntryType ent;
R_TRY_CATCH(sd_ifs->GetEntryType(&ent, save_dir_path)) {
R_TRY_CATCH(sd_ifs->GetEntryType(std::addressof(ent), save_dir_path)) {
R_CATCH(fs::ResultPathNotFound) { is_new_save = true; }
R_CATCH_ALL() { /* ... */ }
} R_END_TRY_CATCH;
@@ -310,8 +310,8 @@ namespace ams::mitm::fs {
/* Try to open a storage for the partition. */
FsStorage bis_storage;
R_TRY(fsOpenBisStorageFwd(this->forward_service.get(), &bis_storage, bis_partition_id));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&bis_storage.s)};
R_TRY(fsOpenBisStorageFwd(this->forward_service.get(), std::addressof(bis_storage), bis_partition_id));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(bis_storage.s))};
const bool is_sysmodule = ncm::IsSystemProgramId(this->client_info.program_id);
const bool is_hbl = this->client_info.override_status.IsHbl();
@@ -355,8 +355,8 @@ namespace ams::mitm::fs {
/* Try to open the process romfs. */
FsStorage data_storage;
R_TRY(fsOpenDataStorageByCurrentProcessFwd(this->forward_service.get(), &data_storage));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&data_storage.s)};
R_TRY(fsOpenDataStorageByCurrentProcessFwd(this->forward_service.get(), std::addressof(data_storage)));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(data_storage.s))};
/* Get a scoped lock. */
std::scoped_lock lk(g_data_storage_lock);
@@ -376,7 +376,7 @@ namespace ams::mitm::fs {
/* Create the layered storage. */
FsFile data_file;
if (R_SUCCEEDED(OpenAtmosphereSdFile(&data_file, this->client_info.program_id, "romfs.bin", OpenMode_Read))) {
if (R_SUCCEEDED(OpenAtmosphereSdFile(std::addressof(data_file), this->client_info.program_id, "romfs.bin", OpenMode_Read))) {
auto layered_storage = std::make_shared<LayeredRomfsStorage>(std::make_unique<ReadOnlyStorageAdapter>(new RemoteStorage(data_storage)), std::make_unique<ReadOnlyStorageAdapter>(new FileStorage(new RemoteFile(data_file))), this->client_info.program_id);
layered_storage->BeginInitialize();
new_storage = std::move(layered_storage);
@@ -386,7 +386,7 @@ namespace ams::mitm::fs {
new_storage = std::move(layered_storage);
}
SetStorageCacheEntry(this->client_info.program_id, &new_storage);
SetStorageCacheEntry(this->client_info.program_id, std::addressof(new_storage));
out.SetValue(MakeSharedStorage(new_storage), target_object_id);
}
@@ -405,8 +405,8 @@ namespace ams::mitm::fs {
/* Try to open the process romfs. */
FsStorage data_storage;
R_TRY(fsOpenDataStorageByDataIdFwd(this->forward_service.get(), &data_storage, static_cast<u64>(data_id), static_cast<NcmStorageId>(storage_id)));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&data_storage.s)};
R_TRY(fsOpenDataStorageByDataIdFwd(this->forward_service.get(), std::addressof(data_storage), static_cast<u64>(data_id), static_cast<NcmStorageId>(storage_id)));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(data_storage.s))};
/* Get a scoped lock. */
std::scoped_lock lk(g_data_storage_lock);
@@ -426,7 +426,7 @@ namespace ams::mitm::fs {
/* Create the layered storage. */
FsFile data_file;
if (R_SUCCEEDED(OpenAtmosphereSdFile(&data_file, data_id, "romfs.bin", OpenMode_Read))) {
if (R_SUCCEEDED(OpenAtmosphereSdFile(std::addressof(data_file), data_id, "romfs.bin", OpenMode_Read))) {
auto layered_storage = std::make_shared<LayeredRomfsStorage>(std::make_unique<ReadOnlyStorageAdapter>(new RemoteStorage(data_storage)), std::make_unique<ReadOnlyStorageAdapter>(new FileStorage(new RemoteFile(data_file))), data_id);
layered_storage->BeginInitialize();
new_storage = std::move(layered_storage);
@@ -436,7 +436,7 @@ namespace ams::mitm::fs {
new_storage = std::move(layered_storage);
}
SetStorageCacheEntry(data_id, &new_storage);
SetStorageCacheEntry(data_id, std::addressof(new_storage));
out.SetValue(MakeSharedStorage(new_storage), target_object_id);
}
@@ -456,8 +456,8 @@ namespace ams::mitm::fs {
/* Try to open the process romfs. */
FsStorage data_storage;
R_TRY(fsOpenDataStorageWithProgramIndexFwd(this->forward_service.get(), &data_storage, program_index));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&data_storage.s)};
R_TRY(fsOpenDataStorageWithProgramIndexFwd(this->forward_service.get(), std::addressof(data_storage), program_index));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(data_storage.s))};
/* Get a scoped lock. */
std::scoped_lock lk(g_data_storage_lock);
@@ -477,7 +477,7 @@ namespace ams::mitm::fs {
/* Create the layered storage. */
FsFile data_file;
if (R_SUCCEEDED(OpenAtmosphereSdFile(&data_file, program_id, "romfs.bin", OpenMode_Read))) {
if (R_SUCCEEDED(OpenAtmosphereSdFile(std::addressof(data_file), program_id, "romfs.bin", OpenMode_Read))) {
auto layered_storage = std::make_shared<LayeredRomfsStorage>(std::make_unique<ReadOnlyStorageAdapter>(new RemoteStorage(data_storage)), std::make_unique<ReadOnlyStorageAdapter>(new FileStorage(new RemoteFile(data_file))), program_id);
layered_storage->BeginInitialize();
new_storage = std::move(layered_storage);
@@ -487,7 +487,7 @@ namespace ams::mitm::fs {
new_storage = std::move(layered_storage);
}
SetStorageCacheEntry(program_id, &new_storage);
SetStorageCacheEntry(program_id, std::addressof(new_storage));
out.SetValue(MakeSharedStorage(new_storage), target_object_id);
}

View File

@@ -31,7 +31,7 @@ namespace ams::mitm::fs {
void RomfsInitializerThreadFunction(void *) {
while (true) {
uintptr_t storage_uptr = 0;
g_req_mq.Receive(&storage_uptr);
g_req_mq.Receive(std::addressof(storage_uptr));
std::shared_ptr<LayeredRomfsStorage> layered_storage = reinterpret_cast<LayeredRomfsStorage *>(storage_uptr)->GetShared();
g_ack_mq.Send(storage_uptr);
layered_storage->InitializeImpl();
@@ -54,7 +54,7 @@ namespace ams::mitm::fs {
g_req_mq.Send(storage_uptr);
uintptr_t ack = 0;
g_ack_mq.Receive(&ack);
g_ack_mq.Receive(std::addressof(ack));
AMS_ABORT_UNLESS(ack == storage_uptr);
}
@@ -92,7 +92,7 @@ namespace ams::mitm::fs {
builder.AddStorageFiles(this->storage_romfs.get(), romfs::DataSourceType::Storage);
}
builder.Build(&this->source_infos);
builder.Build(std::addressof(this->source_infos));
this->is_initialized = true;
this->initialize_event.Signal();
@@ -140,11 +140,11 @@ namespace ams::mitm::fs {
case romfs::DataSourceType::LooseSdFile:
{
FsFile file;
R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdRomfsFile(&file, this->program_id, cur_source.loose_source_info.path, OpenMode_Read));
ON_SCOPE_EXIT { fsFileClose(&file); };
R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdRomfsFile(std::addressof(file), this->program_id, cur_source.loose_source_info.path, OpenMode_Read));
ON_SCOPE_EXIT { fsFileClose(std::addressof(file)); };
u64 out_read = 0;
R_ABORT_UNLESS(fsFileRead(&file, offset_within_source, cur_dst, cur_read_size, FsReadOption_None, &out_read));
R_ABORT_UNLESS(fsFileRead(std::addressof(file), offset_within_source, cur_dst, cur_read_size, FsReadOption_None, std::addressof(out_read)));
AMS_ABORT_UNLESS(out_read == cur_read_size);
}
break;
@@ -154,7 +154,7 @@ namespace ams::mitm::fs {
case romfs::DataSourceType::Metadata:
{
size_t out_read = 0;
R_ABORT_UNLESS(cur_source.metadata_source_info.file->Read(&out_read, offset_within_source, cur_dst, cur_read_size));
R_ABORT_UNLESS(cur_source.metadata_source_info.file->Read(std::addressof(out_read), offset_within_source, cur_dst, cur_read_size));
AMS_ABORT_UNLESS(out_read == cur_read_size);
}
break;

View File

@@ -145,7 +145,7 @@ namespace ams::mitm::fs {
private:
ALWAYS_INLINE void Read(size_t ofs, void *dst, size_t sz) {
u64 read_size;
R_ABORT_UNLESS(fsFileRead(this->file, this->offset + ofs, dst, sz, 0, &read_size));
R_ABORT_UNLESS(fsFileRead(this->file, this->offset + ofs, dst, sz, 0, std::addressof(read_size)));
AMS_ABORT_UNLESS(read_size == sz);
}
@@ -317,9 +317,9 @@ namespace ams::mitm::fs {
/* Get number of child directories. */
s64 num_child_dirs = 0;
{
OpenFileSystemRomfsDirectory(&dir, this->program_id, parent, OpenDirectoryMode_Directory, fs);
ON_SCOPE_EXIT { fsDirClose(&dir); };
R_ABORT_UNLESS(fsDirGetEntryCount(&dir, &num_child_dirs));
OpenFileSystemRomfsDirectory(std::addressof(dir), this->program_id, parent, OpenDirectoryMode_Directory, fs);
ON_SCOPE_EXIT { fsDirClose(std::addressof(dir)); };
R_ABORT_UNLESS(fsDirGetEntryCount(std::addressof(dir), std::addressof(num_child_dirs)));
}
AMS_ABORT_UNLESS(num_child_dirs >= 0);
@@ -330,12 +330,12 @@ namespace ams::mitm::fs {
s64 cur_child_dir_ind = 0;
{
OpenFileSystemRomfsDirectory(&dir, this->program_id, parent, OpenDirectoryMode_All, fs);
ON_SCOPE_EXIT { fsDirClose(&dir); };
OpenFileSystemRomfsDirectory(std::addressof(dir), this->program_id, parent, OpenDirectoryMode_All, fs);
ON_SCOPE_EXIT { fsDirClose(std::addressof(dir)); };
s64 read_entries = 0;
while (true) {
R_ABORT_UNLESS(fsDirRead(&dir, &read_entries, 1, &this->dir_entry));
R_ABORT_UNLESS(fsDirRead(std::addressof(dir), std::addressof(read_entries), 1, std::addressof(this->dir_entry)));
if (read_entries != 1) {
break;
}
@@ -345,7 +345,7 @@ namespace ams::mitm::fs {
AMS_ABORT_UNLESS(child_dirs != nullptr);
BuildDirectoryContext *real_child = nullptr;
this->AddDirectory(&real_child, parent, std::make_unique<BuildDirectoryContext>(this->dir_entry.name, strlen(this->dir_entry.name)));
this->AddDirectory(std::addressof(real_child), parent, std::make_unique<BuildDirectoryContext>(this->dir_entry.name, strlen(this->dir_entry.name)));
AMS_ABORT_UNLESS(real_child != nullptr);
child_dirs[cur_child_dir_ind++] = real_child;
AMS_ABORT_UNLESS(cur_child_dir_ind <= num_child_dirs);
@@ -392,7 +392,7 @@ namespace ams::mitm::fs {
{
const DirectoryEntry *cur_child = dir_table.GetEntry(cur_child_offset);
this->AddDirectory(&real_child, parent, std::make_unique<BuildDirectoryContext>(cur_child->name, cur_child->name_size));
this->AddDirectory(std::addressof(real_child), parent, std::make_unique<BuildDirectoryContext>(cur_child->name, cur_child->name_size));
AMS_ABORT_UNLESS(real_child != nullptr);
next_child_offset = cur_child->sibling;
@@ -409,25 +409,25 @@ namespace ams::mitm::fs {
void Builder::AddSdFiles() {
/* Open Sd Card filesystem. */
FsFileSystem sd_filesystem;
R_ABORT_UNLESS(fsOpenSdCardFileSystem(&sd_filesystem));
ON_SCOPE_EXIT { fsFsClose(&sd_filesystem); };
R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(sd_filesystem)));
ON_SCOPE_EXIT { fsFsClose(std::addressof(sd_filesystem)); };
/* If there is no romfs folder on the SD, don't bother continuing. */
{
FsDir dir;
if (R_FAILED(mitm::fs::OpenAtmosphereRomfsDirectory(&dir, this->program_id, this->root->path.get(), OpenDirectoryMode_Directory, &sd_filesystem))) {
if (R_FAILED(mitm::fs::OpenAtmosphereRomfsDirectory(std::addressof(dir), this->program_id, this->root->path.get(), OpenDirectoryMode_Directory, std::addressof(sd_filesystem)))) {
return;
}
fsDirClose(&dir);
fsDirClose(std::addressof(dir));
}
this->cur_source_type = DataSourceType::LooseSdFile;
this->VisitDirectory(&sd_filesystem, this->root);
this->VisitDirectory(std::addressof(sd_filesystem), this->root);
}
void Builder::AddStorageFiles(ams::fs::IStorage *storage, DataSourceType source_type) {
Header header;
R_ABORT_UNLESS(storage->Read(0, &header, sizeof(Header)));
R_ABORT_UNLESS(storage->Read(0, std::addressof(header), sizeof(Header)));
AMS_ABORT_UNLESS(header.header_size == sizeof(Header));
/* Read tables. */
@@ -444,8 +444,8 @@ namespace ams::mitm::fs {
/* Open an SD card filesystem. */
FsFileSystem sd_filesystem;
R_ABORT_UNLESS(fsOpenSdCardFileSystem(&sd_filesystem));
ON_SCOPE_EXIT { fsFsClose(&sd_filesystem); };
R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(sd_filesystem)));
ON_SCOPE_EXIT { fsFsClose(std::addressof(sd_filesystem)); };
/* Calculate hash table sizes. */
const size_t num_dir_hash_table_entries = GetHashTableSize(this->num_dirs);
@@ -460,7 +460,7 @@ namespace ams::mitm::fs {
/* Open metadata file. */
const size_t metadata_size = this->dir_hash_table_size + this->dir_table_size + this->file_hash_table_size + this->file_table_size;
FsFile metadata_file;
R_ABORT_UNLESS(mitm::fs::CreateAndOpenAtmosphereSdFile(&metadata_file, this->program_id, "romfs_metadata.bin", metadata_size));
R_ABORT_UNLESS(mitm::fs::CreateAndOpenAtmosphereSdFile(std::addressof(metadata_file), this->program_id, "romfs_metadata.bin", metadata_size));
/* Ensure later hash tables will have correct defaults. */
static_assert(EmptyEntry == 0xFFFFFFFF);
@@ -534,13 +534,13 @@ namespace ams::mitm::fs {
u32 *file_hash_table = reinterpret_cast<u32 *>(fht_buf);
std::memset(file_hash_table, 0xFF, this->file_hash_table_size);
ON_SCOPE_EXIT {
R_ABORT_UNLESS(fsFileWrite(&metadata_file, this->dir_hash_table_size + this->dir_table_size, file_hash_table, this->file_hash_table_size, FsWriteOption_None));
R_ABORT_UNLESS(fsFileWrite(std::addressof(metadata_file), this->dir_hash_table_size + this->dir_table_size, file_hash_table, this->file_hash_table_size, FsWriteOption_None));
std::free(fht_buf);
};
/* Write the file table. */
{
FileTableWriter file_table(&metadata_file, this->dir_hash_table_size + this->dir_table_size + this->file_hash_table_size, this->file_table_size);
FileTableWriter file_table(std::addressof(metadata_file), this->dir_hash_table_size + this->dir_table_size + this->file_hash_table_size, this->file_table_size);
for (const auto &it : this->files) {
BuildFileContext *cur_file = it.get();
@@ -602,13 +602,13 @@ namespace ams::mitm::fs {
u32 *dir_hash_table = reinterpret_cast<u32 *>(dht_buf);
std::memset(dir_hash_table, 0xFF, this->dir_hash_table_size);
ON_SCOPE_EXIT {
R_ABORT_UNLESS(fsFileWrite(&metadata_file, 0, dir_hash_table, this->dir_hash_table_size, FsWriteOption_None));
R_ABORT_UNLESS(fsFileWrite(std::addressof(metadata_file), 0, dir_hash_table, this->dir_hash_table_size, FsWriteOption_None));
std::free(dht_buf);
};
/* Write the file table. */
{
DirectoryTableWriter dir_table(&metadata_file, this->dir_hash_table_size, this->dir_table_size);
DirectoryTableWriter dir_table(std::addressof(metadata_file), this->dir_hash_table_size, this->dir_table_size);
for (const auto &it : this->directories) {
BuildDirectoryContext *cur_dir = it.get();
@@ -657,7 +657,7 @@ namespace ams::mitm::fs {
/* Save metadata to the SD card, to save on memory space. */
{
R_ABORT_UNLESS(fsFileFlush(&metadata_file));
R_ABORT_UNLESS(fsFileFlush(std::addressof(metadata_file)));
out_infos->emplace_back(header->dir_hash_table_ofs, metadata_size, DataSourceType::Metadata, new RemoteFile(metadata_file));
}
}

View File

@@ -26,7 +26,7 @@ namespace ams::mitm::ns {
/* Always succeed for web applets asking about HBL. */
/* This enables hbl html. */
bool is_hbl;
if (R_SUCCEEDED(pm::info::IsHblProgramId(&is_hbl, application_id)) && is_hbl) {
if (R_SUCCEEDED(pm::info::IsHblProgramId(std::addressof(is_hbl), application_id)) && is_hbl) {
nswebResolveApplicationContentPath(this->srv.get(), static_cast<u64>(application_id), static_cast<NcmContentType>(content_type));
return ResultSuccess();
}
@@ -40,8 +40,8 @@ namespace ams::mitm::ns {
Result NsWebMitmService::GetDocumentInterface(sf::Out<sf::SharedPointer<impl::IDocumentInterface>> out) {
/* Open a document interface. */
NsDocumentInterface doc;
R_TRY(nsGetDocumentInterfaceFwd(this->forward_service.get(), &doc));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&doc.s)};
R_TRY(nsGetDocumentInterfaceFwd(this->forward_service.get(), std::addressof(doc)));
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(doc.s))};
out.SetValue(sf::CreateSharedObjectEmplaced<impl::IDocumentInterface, NsDocumentService>(this->client_info, std::make_unique<NsDocumentInterface>(doc)), target_object_id);
return ResultSuccess();

View File

@@ -177,11 +177,11 @@ namespace ams::settings::fwdbg {
template<typename T>
Result ParseSettingsItemIntegralValue(SdKeyValueStoreEntry &out, const char *value_str) {
R_TRY(AllocateValue(&out.value, sizeof(T)));
R_TRY(AllocateValue(std::addressof(out.value), sizeof(T)));
out.value_size = sizeof(T);
T value = static_cast<T>(strtoul(value_str, nullptr, 0));
std::memcpy(out.value, &value, sizeof(T));
std::memcpy(out.value, std::addressof(value), sizeof(T));
return ResultSuccess();
}
@@ -191,7 +191,7 @@ namespace ams::settings::fwdbg {
R_TRY(ValidateSettingsItemKey(key));
u8 dummy_value = 0;
SdKeyValueStoreEntry test_entry { .name = name, .key = key, .value = &dummy_value, .value_size = sizeof(dummy_value) };
SdKeyValueStoreEntry test_entry { .name = name, .key = key, .value = std::addressof(dummy_value), .value_size = sizeof(dummy_value) };
auto *begin = g_entries;
auto *end = begin + g_num_entries;
@@ -199,7 +199,7 @@ namespace ams::settings::fwdbg {
R_UNLESS(it != end, settings::ResultSettingsItemNotFound());
R_UNLESS(*it == test_entry, settings::ResultSettingsItemNotFound());
*out = &*it;
*out = std::addressof(*it);
return ResultSuccess();
}
@@ -223,12 +223,12 @@ namespace ams::settings::fwdbg {
SdKeyValueStoreEntry new_value = {};
/* Find name and key. */
R_TRY(FindSettingsName(&new_value.name, name));
R_TRY(FindSettingsItemKey(&new_value.key, key));
R_TRY(FindSettingsName(std::addressof(new_value.name), name));
R_TRY(FindSettingsItemKey(std::addressof(new_value.key), key));
if (strncasecmp(type, "str", type_len) == 0 || strncasecmp(type, "string", type_len) == 0) {
const size_t size = value_len + 1;
R_TRY(AllocateValue(&new_value.value, size));
R_TRY(AllocateValue(std::addressof(new_value.value), size));
std::memcpy(new_value.value, value_str, size);
new_value.value_size = size;
} else if (strncasecmp(type, "hex", type_len) == 0 || strncasecmp(type, "bytes", type_len) == 0) {
@@ -237,7 +237,7 @@ namespace ams::settings::fwdbg {
R_UNLESS(IsHexadecimal(value_str), settings::ResultInvalidFormatSettingsItemValue());
const size_t size = value_len / 2;
R_TRY(AllocateValue(&new_value.value, size));
R_TRY(AllocateValue(std::addressof(new_value.value), size));
new_value.value_size = size;
u8 *data = reinterpret_cast<u8 *>(new_value.value);
@@ -300,7 +300,7 @@ namespace ams::settings::fwdbg {
AMS_ABORT_UNLESS(file != nullptr);
Result parse_result = ResultSuccess();
util::ini::ParseFile(file.get(), &parse_result, SystemSettingsIniHandler);
util::ini::ParseFile(file.get(), std::addressof(parse_result), SystemSettingsIniHandler);
R_TRY(parse_result);
return ResultSuccess();
@@ -422,7 +422,7 @@ namespace ams::settings::fwdbg {
Result GetSdCardKeyValueStoreSettingsItemValueSize(size_t *out_size, const char *name, const char *key) {
SdKeyValueStoreEntry *entry = nullptr;
R_TRY(GetEntry(&entry, name, key));
R_TRY(GetEntry(std::addressof(entry), name, key));
*out_size = entry->value_size;
return ResultSuccess();
@@ -432,7 +432,7 @@ namespace ams::settings::fwdbg {
R_UNLESS(dst != nullptr, settings::ResultNullSettingsItemValueBuffer());
SdKeyValueStoreEntry *entry = nullptr;
R_TRY(GetEntry(&entry, name, key));
R_TRY(GetEntry(std::addressof(entry), name, key));
const size_t size = std::min(entry->value_size, dst_size);
if (size > 0) {

View File

@@ -54,7 +54,7 @@ namespace ams::creport {
if (std::strcmp(this->modules[i].name, "") != 0) {
file.WriteFormat(" Name: %s\n", module.name);
}
file.DumpMemory(" Build Id: ", &module.build_id[0], sizeof(module.build_id));
file.DumpMemory(" Build Id: ", module.build_id, sizeof(module.build_id));
}
}
@@ -77,7 +77,7 @@ namespace ams::creport {
void ModuleList::TryAddModule(uintptr_t guess) {
/* Try to locate module from guess. */
uintptr_t base_address = 0;
if (!this->TryFindModule(&base_address, guess)) {
if (!this->TryFindModule(std::addressof(base_address), guess)) {
return;
}
@@ -94,7 +94,7 @@ namespace ams::creport {
/* Get the region extents. */
svc::MemoryInfo mi;
svc::PageInfo pi;
if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, this->debug_handle, cur_address))) {
if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), this->debug_handle, cur_address))) {
break;
}
@@ -129,20 +129,20 @@ namespace ams::creport {
/* Query the memory region our guess falls in. */
svc::MemoryInfo mi;
svc::PageInfo pi;
if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, this->debug_handle, guess))) {
if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), this->debug_handle, guess))) {
return false;
}
/* If we fall into a RW region, it may be rwdata. Query the region before it, which may be rodata or text. */
if (mi.permission == svc::MemoryPermission_ReadWrite) {
if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, mi.base_address - 4))) {
if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, mi.base_address - 4))) {
return false;
}
}
/* If we fall into an RO region, it may be rodata. Query the region before it, which should be text. */
if (mi.permission == svc::MemoryPermission_Read) {
if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, mi.base_address - 4))) {
if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, mi.base_address - 4))) {
return false;
}
}
@@ -155,7 +155,7 @@ namespace ams::creport {
/* Modules are a series of contiguous (text/rodata/rwdata) regions. */
/* Iterate backwards until we find unmapped memory, to find the start of the set of modules loaded here. */
while (mi.base_address > 0) {
if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, mi.base_address - 4))) {
if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, mi.base_address - 4))) {
return false;
}
@@ -181,7 +181,7 @@ namespace ams::creport {
svc::PageInfo pi;
/* Verify .rodata is read-only. */
if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, this->debug_handle, ro_start_address)) || mi.permission != svc::MemoryPermission_Read) {
if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), this->debug_handle, ro_start_address)) || mi.permission != svc::MemoryPermission_Read) {
return;
}
@@ -228,7 +228,7 @@ namespace ams::creport {
/* Verify .rodata is read-only. */
svc::MemoryInfo mi;
svc::PageInfo pi;
if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, this->debug_handle, ro_start_address)) || mi.permission != svc::MemoryPermission_Read) {
if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), this->debug_handle, ro_start_address)) || mi.permission != svc::MemoryPermission_Read) {
return;
}

View File

@@ -132,7 +132,7 @@ namespace ams::creport {
}
/* Get the thread context. */
if (R_FAILED(svc::GetDebugThreadContext(&this->context, debug_handle, this->thread_id, svc::ThreadContextFlag_All))) {
if (R_FAILED(svc::GetDebugThreadContext(std::addressof(this->context), debug_handle, this->thread_id, svc::ThreadContextFlag_All))) {
return false;
}
@@ -151,21 +151,21 @@ namespace ams::creport {
if (R_SUCCEEDED(svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(thread_tls), debug_handle, this->tls_address, sizeof(thread_tls)))) {
std::memcpy(this->tls, thread_tls, sizeof(this->tls));
/* Try to detect libnx threads, and skip name parsing then. */
if (*(reinterpret_cast<u32 *>(&thread_tls[0x1E0])) != LibnxThreadVarMagic) {
if (*(reinterpret_cast<u32 *>(std::addressof(thread_tls[0x1E0]))) != LibnxThreadVarMagic) {
u8 thread_type[0x1C0];
const u64 thread_type_addr = *(reinterpret_cast<u64 *>(&thread_tls[0x1F8]));
const u64 thread_type_addr = *(reinterpret_cast<u64 *>(std::addressof(thread_tls[0x1F8])));
if (R_SUCCEEDED(svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(thread_type), debug_handle, thread_type_addr, sizeof(thread_type)))) {
/* Get the thread version. */
const u16 thread_version = *reinterpret_cast<u16 *>(&thread_type[0x46]);
const u16 thread_version = *reinterpret_cast<u16 *>(std::addressof(thread_type[0x46]));
if (thread_version == 0 || thread_version == 0xFFFF) {
/* Check thread name is actually at thread name. */
static_assert(0x1A8 - 0x188 == NameLengthMax, "NameLengthMax definition!");
if (*(reinterpret_cast<u64 *>(&thread_type[0x1A8])) == thread_type_addr + 0x188) {
if (*(reinterpret_cast<u64 *>(std::addressof(thread_type[0x1A8]))) == thread_type_addr + 0x188) {
std::memcpy(this->name, thread_type + 0x188, NameLengthMax);
}
} else if (thread_version == 1) {
static_assert(0x1A0 - 0x180 == NameLengthMax, "NameLengthMax definition!");
if (*(reinterpret_cast<u64 *>(&thread_type[0x1A0])) == thread_type_addr + 0x180) {
if (*(reinterpret_cast<u64 *>(std::addressof(thread_type[0x1A0]))) == thread_type_addr + 0x180) {
std::memcpy(this->name, thread_type + 0x180, NameLengthMax);
}
}
@@ -179,9 +179,9 @@ namespace ams::creport {
/* Dump stack trace. */
if (is_64_bit) {
ReadStackTrace<u64>(&this->stack_trace_size, this->stack_trace, StackTraceSizeMax, debug_handle, this->context.fp);
ReadStackTrace<u64>(std::addressof(this->stack_trace_size), this->stack_trace, StackTraceSizeMax, debug_handle, this->context.fp);
} else {
ReadStackTrace<u32>(&this->stack_trace_size, this->stack_trace, StackTraceSizeMax, debug_handle, this->context.fp);
ReadStackTrace<u32>(std::addressof(this->stack_trace_size), this->stack_trace, StackTraceSizeMax, debug_handle, this->context.fp);
}
return true;
@@ -191,14 +191,14 @@ namespace ams::creport {
/* Query stack region. */
svc::MemoryInfo mi;
svc::PageInfo pi;
if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, this->context.sp))) {
if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, this->context.sp))) {
return;
}
/* Check if sp points into the stack. */
if (mi.state != svc::MemoryState_Stack) {
/* It's possible that sp is below the stack... */
if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, mi.base_address + mi.size)) || mi.state != svc::MemoryState_Stack) {
if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, mi.base_address + mi.size)) || mi.state != svc::MemoryState_Stack) {
return;
}
}
@@ -219,24 +219,24 @@ namespace ams::creport {
void ThreadInfo::DumpBinary(ScopedFile &file) {
/* Dump id and context. */
file.Write(&this->thread_id, sizeof(this->thread_id));
file.Write(&this->context, sizeof(this->context));
file.Write(std::addressof(this->thread_id), sizeof(this->thread_id));
file.Write(std::addressof(this->context), sizeof(this->context));
/* Dump TLS info and name. */
file.Write(&this->tls_address, sizeof(this->tls_address));
file.Write(&this->tls, sizeof(this->tls));
file.Write(&this->name, sizeof(this->name));
file.Write(std::addressof(this->tls_address), sizeof(this->tls_address));
file.Write(std::addressof(this->tls), sizeof(this->tls));
file.Write(std::addressof(this->name), sizeof(this->name));
/* Dump stack extents and stack dump. */
file.Write(&this->stack_bottom, sizeof(this->stack_bottom));
file.Write(&this->stack_top, sizeof(this->stack_top));
file.Write(&this->stack_dump_base, sizeof(this->stack_dump_base));
file.Write(&this->stack_dump, sizeof(this->stack_dump));
file.Write(std::addressof(this->stack_bottom), sizeof(this->stack_bottom));
file.Write(std::addressof(this->stack_top), sizeof(this->stack_top));
file.Write(std::addressof(this->stack_dump_base), sizeof(this->stack_dump_base));
file.Write(std::addressof(this->stack_dump), sizeof(this->stack_dump));
/* Dump stack trace. */
{
const u64 sts = this->stack_trace_size;
file.Write(&sts, sizeof(sts));
file.Write(std::addressof(sts), sizeof(sts));
}
file.Write(this->stack_trace, this->stack_trace_size);
}
@@ -244,9 +244,9 @@ namespace ams::creport {
void ThreadList::DumpBinary(ScopedFile &file, u64 crashed_thread_id) {
const u32 magic = DumpedThreadInfoMagic;
const u32 count = this->thread_count;
file.Write(&magic, sizeof(magic));
file.Write(&count, sizeof(count));
file.Write(&crashed_thread_id, sizeof(crashed_thread_id));
file.Write(std::addressof(magic), sizeof(magic));
file.Write(std::addressof(count), sizeof(count));
file.Write(std::addressof(crashed_thread_id), sizeof(crashed_thread_id));
for (size_t i = 0; i < this->thread_count; i++) {
this->threads[i].DumpBinary(file);
}
@@ -259,7 +259,7 @@ namespace ams::creport {
s32 num_threads;
u64 thread_ids[ThreadCountMax];
{
if (R_FAILED(svc::GetThreadList(&num_threads, thread_ids, ThreadCountMax, debug_handle))) {
if (R_FAILED(svc::GetThreadList(std::addressof(num_threads), thread_ids, ThreadCountMax, debug_handle))) {
return;
}
num_threads = std::min(size_t(num_threads), ThreadCountMax);

View File

@@ -195,7 +195,7 @@ namespace ams::dmnt::cheat::impl {
/* Clear metadata. */
static_assert(util::is_pod<decltype(this->cheat_process_metadata)>::value, "CheatProcessMetadata definition!");
std::memset(&this->cheat_process_metadata, 0, sizeof(this->cheat_process_metadata));
std::memset(std::addressof(this->cheat_process_metadata), 0, sizeof(this->cheat_process_metadata));
/* Clear cheat list. */
this->ResetAllCheatEntries();
@@ -219,8 +219,8 @@ namespace ams::dmnt::cheat::impl {
/* Note: This function *MUST* be called only with the cheat lock held. */
os::ProcessId pid;
bool has_cheat_process = this->cheat_process_debug_handle != os::InvalidNativeHandle;
has_cheat_process &= R_SUCCEEDED(os::GetProcessId(&pid, this->cheat_process_debug_handle));
has_cheat_process &= R_SUCCEEDED(pm::dmnt::GetApplicationProcessId(&pid));
has_cheat_process &= R_SUCCEEDED(os::GetProcessId(std::addressof(pid), this->cheat_process_debug_handle));
has_cheat_process &= R_SUCCEEDED(pm::dmnt::GetApplicationProcessId(std::addressof(pid)));
has_cheat_process &= (pid == this->cheat_process_metadata.process_id);
if (!has_cheat_process) {
@@ -241,7 +241,7 @@ namespace ams::dmnt::cheat::impl {
os::NativeHandle HookToCreateApplicationProcess() const {
os::NativeHandle h;
R_ABORT_UNLESS(pm::dmnt::HookToCreateApplicationProcess(&h));
R_ABORT_UNLESS(pm::dmnt::HookToCreateApplicationProcess(std::addressof(h)));
return h;
}
@@ -254,12 +254,12 @@ namespace ams::dmnt::cheat::impl {
/* Learn whether we should enable cheats by default. */
{
u8 en = 0;
if (settings::fwdbg::GetSettingsItemValue(&en, sizeof(en), "atmosphere", "dmnt_cheats_enabled_by_default") == sizeof(en)) {
if (settings::fwdbg::GetSettingsItemValue(std::addressof(en), sizeof(en), "atmosphere", "dmnt_cheats_enabled_by_default") == sizeof(en)) {
this->enable_cheats_by_default = (en != 0);
}
en = 0;
if (settings::fwdbg::GetSettingsItemValue( &en, sizeof(en), "atmosphere", "dmnt_always_save_cheat_toggles") == sizeof(en)) {
if (settings::fwdbg::GetSettingsItemValue( std::addressof(en), sizeof(en), "atmosphere", "dmnt_always_save_cheat_toggles") == sizeof(en)) {
this->always_save_cheat_toggles = (en != 0);
}
}
@@ -293,7 +293,7 @@ namespace ams::dmnt::cheat::impl {
R_TRY(this->EnsureCheatProcess());
std::memcpy(out, &this->cheat_process_metadata, sizeof(*out));
std::memcpy(out, std::addressof(this->cheat_process_metadata), sizeof(*out));
return ResultSuccess();
}
@@ -327,7 +327,7 @@ namespace ams::dmnt::cheat::impl {
if (proc_addr <= address && address < proc_addr + size) {
const size_t offset = (address - proc_addr);
const size_t copy_size = std::min(sizeof(value.value), size - offset);
std::memcpy(&value.value, reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(data) + offset), copy_size);
std::memcpy(std::addressof(value.value), reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(data) + offset), copy_size);
}
}
@@ -356,7 +356,7 @@ namespace ams::dmnt::cheat::impl {
svc::PageInfo page_info;
u64 address = 0, count = 0;
do {
if (R_FAILED(svc::QueryDebugProcessMemory(&mem_info, &page_info, this->GetCheatProcessHandle(), address))) {
if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mem_info), std::addressof(page_info), this->GetCheatProcessHandle(), address))) {
break;
}
@@ -380,7 +380,7 @@ namespace ams::dmnt::cheat::impl {
svc::PageInfo page_info;
u64 address = 0, total_count = 0, written_count = 0;
do {
if (R_FAILED(svc::QueryDebugProcessMemory(&mem_info, &page_info, this->GetCheatProcessHandle(), address))) {
if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mem_info), std::addressof(page_info), this->GetCheatProcessHandle(), address))) {
break;
}
@@ -420,7 +420,7 @@ namespace ams::dmnt::cheat::impl {
R_TRY(this->EnsureCheatProcess());
svc::PageInfo page_info;
return svc::QueryDebugProcessMemory(mapping, &page_info, this->GetCheatProcessHandle(), address);
return svc::QueryDebugProcessMemory(mapping, std::addressof(page_info), this->GetCheatProcessHandle(), address);
}
Result PauseCheatProcess() {
@@ -646,7 +646,7 @@ namespace ams::dmnt::cheat::impl {
FrozenAddressValue value = {};
value.width = width;
R_TRY(this->ReadCheatProcessMemoryUnsafe(address, &value.value, width));
R_TRY(this->ReadCheatProcessMemoryUnsafe(address, std::addressof(value.value), width));
FrozenAddressMapEntry *entry = AllocateFrozenAddress(address, value);
R_UNLESS(entry != nullptr, dmnt::cheat::ResultFrozenAddressOutOfResource());
@@ -677,11 +677,11 @@ namespace ams::dmnt::cheat::impl {
CheatProcessManager *this_ptr = reinterpret_cast<CheatProcessManager *>(_this);
Event hook;
while (true) {
eventLoadRemote(&hook, this_ptr->HookToCreateApplicationProcess(), true);
if (R_SUCCEEDED(eventWait(&hook, std::numeric_limits<u64>::max()))) {
eventLoadRemote(std::addressof(hook), this_ptr->HookToCreateApplicationProcess(), true);
if (R_SUCCEEDED(eventWait(std::addressof(hook), std::numeric_limits<u64>::max()))) {
this_ptr->AttachToApplicationProcess(true);
}
eventClose(&hook);
eventClose(std::addressof(hook));
}
}
@@ -747,7 +747,7 @@ namespace ams::dmnt::cheat::impl {
/* Execute program only if it has opcodes. */
if (this_ptr->cheat_vm.GetProgramSize()) {
this_ptr->cheat_vm.Execute(&this_ptr->cheat_process_metadata);
this_ptr->cheat_vm.Execute(std::addressof(this_ptr->cheat_process_metadata));
}
}
@@ -792,7 +792,7 @@ namespace ams::dmnt::cheat::impl {
}
/* Get the application process's ID. */
R_ABORT_UNLESS_IF_NEW_PROCESS(pm::dmnt::GetApplicationProcessId(&this->cheat_process_metadata.process_id));
R_ABORT_UNLESS_IF_NEW_PROCESS(pm::dmnt::GetApplicationProcessId(std::addressof(this->cheat_process_metadata.process_id)));
auto proc_guard = SCOPE_GUARD {
if (on_process_launch) {
this->StartProcess(this->cheat_process_metadata.process_id);
@@ -806,7 +806,7 @@ namespace ams::dmnt::cheat::impl {
ncm::ProgramLocation loc = {};
cfg::OverrideStatus status = {};
R_ABORT_UNLESS_IF_NEW_PROCESS(pm::dmnt::AtmosphereGetProcessInfo(&proc_h, &loc, &status, this->cheat_process_metadata.process_id));
R_ABORT_UNLESS_IF_NEW_PROCESS(pm::dmnt::AtmosphereGetProcessInfo(std::addressof(proc_h), std::addressof(loc), std::addressof(status), this->cheat_process_metadata.process_id));
ON_SCOPE_EXIT { os::CloseNativeHandle(proc_h); };
this->cheat_process_metadata.program_id = loc.program_id;
@@ -830,7 +830,7 @@ namespace ams::dmnt::cheat::impl {
s32 num_modules;
/* TODO: ldr::dmnt:: */
R_ABORT_UNLESS_IF_NEW_PROCESS(ldrDmntGetProcessModuleInfo(static_cast<u64>(this->cheat_process_metadata.process_id), proc_modules, util::size(proc_modules), &num_modules));
R_ABORT_UNLESS_IF_NEW_PROCESS(ldrDmntGetProcessModuleInfo(static_cast<u64>(this->cheat_process_metadata.process_id), proc_modules, util::size(proc_modules), std::addressof(num_modules)));
/* All applications must have two modules. */
/* Only accept one (which means we're attaching to HBL) */

View File

@@ -676,7 +676,7 @@ namespace ams::dmnt::cheat::impl {
const size_t desired_depth = this->condition_depth - 1;
CheatVmOpcode skip_opcode;
while (this->condition_depth > desired_depth && this->DecodeNextOpcode(&skip_opcode)) {
while (this->condition_depth > desired_depth && this->DecodeNextOpcode(std::addressof(skip_opcode))) {
/* Decode instructions until we see end of the current conditional block. */
/* NOTE: This is broken in gateway's implementation. */
/* Gateway currently checks for "0x2" instead of "0x20000000" */
@@ -770,7 +770,7 @@ namespace ams::dmnt::cheat::impl {
u64 kHeld = 0;
/* Get Keys held. */
hid::GetKeysHeld(&kHeld);
hid::GetKeysHeld(std::addressof(kHeld));
this->OpenDebugLogFile();
ON_SCOPE_EXIT { this->CloseDebugLogFile(); };
@@ -784,7 +784,7 @@ namespace ams::dmnt::cheat::impl {
this->ResetState();
/* Loop until program finishes. */
while (this->DecodeNextOpcode(&cur_opcode)) {
while (this->DecodeNextOpcode(std::addressof(cur_opcode))) {
this->LogToDebugFile("Instruction Ptr: %04x\n", (u32)this->instruction_ptr);
for (size_t i = 0; i < NumRegisters; i++) {
@@ -794,7 +794,7 @@ namespace ams::dmnt::cheat::impl {
for (size_t i = 0; i < NumRegisters; i++) {
this->LogToDebugFile("SavedRegs[%02x]: %016lx\n", i, this->saved_values[i]);
}
this->LogOpcode(&cur_opcode);
this->LogOpcode(std::addressof(cur_opcode));
/* Increment conditional depth, if relevant. */
if (cur_opcode.begin_conditional_block) {
@@ -812,7 +812,7 @@ namespace ams::dmnt::cheat::impl {
case 2:
case 4:
case 8:
dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, &dst_value, cur_opcode.store_static.bit_width);
dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, std::addressof(dst_value), cur_opcode.store_static.bit_width);
break;
}
}
@@ -827,7 +827,7 @@ namespace ams::dmnt::cheat::impl {
case 2:
case 4:
case 8:
dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, &src_value, cur_opcode.begin_cond.bit_width);
dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, std::addressof(src_value), cur_opcode.begin_cond.bit_width);
break;
}
/* Check against condition. */
@@ -903,7 +903,7 @@ namespace ams::dmnt::cheat::impl {
case 2:
case 4:
case 8:
dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, &this->registers[cur_opcode.ldr_memory.reg_index], cur_opcode.ldr_memory.bit_width);
dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, std::addressof(this->registers[cur_opcode.ldr_memory.reg_index]), cur_opcode.ldr_memory.bit_width);
break;
}
}
@@ -922,7 +922,7 @@ namespace ams::dmnt::cheat::impl {
case 2:
case 4:
case 8:
dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, &dst_value, cur_opcode.str_static.bit_width);
dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, std::addressof(dst_value), cur_opcode.str_static.bit_width);
break;
}
/* Increment register if relevant. */
@@ -1073,7 +1073,7 @@ namespace ams::dmnt::cheat::impl {
case 2:
case 4:
case 8:
dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, &dst_value, cur_opcode.str_register.bit_width);
dmnt::cheat::impl::WriteCheatProcessMemoryUnsafe(dst_address, std::addressof(dst_value), cur_opcode.str_register.bit_width);
break;
}
@@ -1144,7 +1144,7 @@ namespace ams::dmnt::cheat::impl {
case 2:
case 4:
case 8:
dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(cond_address, &cond_value, cur_opcode.begin_reg_cond.bit_width);
dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(cond_address, std::addressof(cond_value), cur_opcode.begin_reg_cond.bit_width);
break;
}
}
@@ -1286,7 +1286,7 @@ namespace ams::dmnt::cheat::impl {
case 2:
case 4:
case 8:
dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(val_address, &log_value, cur_opcode.debug_log.bit_width);
dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(val_address, std::addressof(log_value), cur_opcode.debug_log.bit_width);
break;
}
}

View File

@@ -43,7 +43,7 @@ namespace ams::fatal::srv {
/* Event creator. */
os::NativeHandle GetFatalDirtyEventReadableHandle() {
Event evt;
R_ABORT_UNLESS(setsysAcquireFatalDirtyFlagEventHandle(&evt));
R_ABORT_UNLESS(setsysAcquireFatalDirtyFlagEventHandle(std::addressof(evt)));
return evt.revent;
}
@@ -68,7 +68,7 @@ namespace ams::fatal::srv {
os::ClearSystemEvent(std::addressof(g_fatal_dirty_event));
u64 flags_0, flags_1;
if (R_SUCCEEDED(setsysGetFatalDirtyFlags(&flags_0, &flags_1)) && (flags_0 & 1)) {
if (R_SUCCEEDED(setsysGetFatalDirtyFlags(std::addressof(flags_0), std::addressof(flags_1))) && (flags_0 & 1)) {
GetFatalConfigImpl().UpdateLanguageCode();
}
}
@@ -77,20 +77,20 @@ namespace ams::fatal::srv {
/* Get information from set. */
settings::system::GetSerialNumber(std::addressof(this->serial_number));
settings::system::GetFirmwareVersion(std::addressof(this->firmware_version));
setsysGetQuestFlag(&this->quest_flag);
setsysGetQuestFlag(std::addressof(this->quest_flag));
this->UpdateLanguageCode();
/* Read information from settings. */
settings::fwdbg::GetSettingsItemValue(&this->transition_to_fatal, sizeof(this->transition_to_fatal), "fatal", "transition_to_fatal");
settings::fwdbg::GetSettingsItemValue(&this->show_extra_info, sizeof(this->show_extra_info), "fatal", "show_extra_info");
settings::fwdbg::GetSettingsItemValue(std::addressof(this->transition_to_fatal), sizeof(this->transition_to_fatal), "fatal", "transition_to_fatal");
settings::fwdbg::GetSettingsItemValue(std::addressof(this->show_extra_info), sizeof(this->show_extra_info), "fatal", "show_extra_info");
u64 quest_interval_second;
settings::fwdbg::GetSettingsItemValue(&quest_interval_second, sizeof(quest_interval_second), "fatal", "quest_reboot_interval_second");
settings::fwdbg::GetSettingsItemValue(std::addressof(quest_interval_second), sizeof(quest_interval_second), "fatal", "quest_reboot_interval_second");
this->quest_reboot_interval = TimeSpan::FromSeconds(quest_interval_second);
/* Atmosphere extension for automatic reboot. */
u64 auto_reboot_ms;
if (settings::fwdbg::GetSettingsItemValue(&auto_reboot_ms, sizeof(auto_reboot_ms), "atmosphere", "fatal_auto_reboot_interval") == sizeof(auto_reboot_ms)) {
if (settings::fwdbg::GetSettingsItemValue(std::addressof(auto_reboot_ms), sizeof(auto_reboot_ms), "atmosphere", "fatal_auto_reboot_interval") == sizeof(auto_reboot_ms)) {
this->fatal_auto_reboot_interval = TimeSpan::FromMilliSeconds(auto_reboot_ms);
this->fatal_auto_reboot_enabled = auto_reboot_ms != 0;
}

View File

@@ -160,13 +160,13 @@ namespace ams::fatal::srv {
bool TryGuessBaseAddress(u64 *out_base_address, os::NativeHandle debug_handle, u64 guess) {
svc::MemoryInfo mi;
svc::PageInfo pi;
if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, guess)) || mi.permission != svc::MemoryPermission_ReadExecute) {
if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, guess)) || mi.permission != svc::MemoryPermission_ReadExecute) {
return false;
}
/* Iterate backwards until we find the memory before the code region. */
while (mi.base_address > 0) {
if (R_FAILED(svc::QueryDebugProcessMemory(&mi, &pi, debug_handle, guess))) {
if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, guess))) {
return false;
}
@@ -185,16 +185,16 @@ namespace ams::fatal::srv {
u64 GetBaseAddress(const ThrowContext *throw_ctx, const svc::ThreadContext *thread_ctx, os::NativeHandle debug_handle) {
u64 base_address = 0;
if (TryGuessBaseAddress(&base_address, debug_handle, thread_ctx->pc)) {
if (TryGuessBaseAddress(std::addressof(base_address), debug_handle, thread_ctx->pc)) {
return base_address;
}
if (TryGuessBaseAddress(&base_address, debug_handle, thread_ctx->lr)) {
if (TryGuessBaseAddress(std::addressof(base_address), debug_handle, thread_ctx->lr)) {
return base_address;
}
for (size_t i = 0; i < throw_ctx->cpu_ctx.aarch64_ctx.stack_trace_size; i++) {
if (TryGuessBaseAddress(&base_address, debug_handle, throw_ctx->cpu_ctx.aarch64_ctx.stack_trace[i])) {
if (TryGuessBaseAddress(std::addressof(base_address), debug_handle, throw_ctx->cpu_ctx.aarch64_ctx.stack_trace[i])) {
return base_address;
}
}
@@ -253,7 +253,7 @@ namespace ams::fatal::srv {
/* We start by trying to get a list of threads. */
s32 thread_count;
u64 thread_ids[0x60];
if (R_FAILED(svc::GetThreadList(&thread_count, thread_ids, 0x60, debug_handle))) {
if (R_FAILED(svc::GetThreadList(std::addressof(thread_count), thread_ids, 0x60, debug_handle))) {
return;
}
@@ -265,7 +265,7 @@ namespace ams::fatal::srv {
continue;
}
if (IsThreadFatalCaller(ctx->result, debug_handle, cur_thread_id, cur_thread_tls, &thread_ctx)) {
if (IsThreadFatalCaller(ctx->result, debug_handle, cur_thread_id, cur_thread_tls, std::addressof(thread_ctx))) {
thread_id = cur_thread_id;
thread_tls = cur_thread_tls;
found_fatal_caller = true;
@@ -276,7 +276,7 @@ namespace ams::fatal::srv {
return;
}
}
if (R_FAILED(svc::GetDebugThreadContext(&thread_ctx, debug_handle, thread_id, svc::ThreadContextFlag_All))) {
if (R_FAILED(svc::GetDebugThreadContext(std::addressof(thread_ctx), debug_handle, thread_id, svc::ThreadContextFlag_All))) {
return;
}
@@ -325,7 +325,7 @@ namespace ams::fatal::srv {
}
/* Parse the base address. */
ctx->cpu_ctx.aarch64_ctx.SetBaseAddress(GetBaseAddress(ctx, &thread_ctx, debug_handle));
ctx->cpu_ctx.aarch64_ctx.SetBaseAddress(GetBaseAddress(ctx, std::addressof(thread_ctx), debug_handle));
}
}

View File

@@ -94,7 +94,7 @@ namespace ams::fatal::srv::font {
void DrawCodePoint(u32 codepoint, u32 x, u32 y) {
int width = 0, height = 0;
u8* imageptr = stbtt_GetCodepointBitmap(&g_stb_font, g_font_size, g_font_size, codepoint, &width, &height, 0, 0);
u8* imageptr = stbtt_GetCodepointBitmap(std::addressof(g_stb_font), g_font_size, g_font_size, codepoint, std::addressof(width), std::addressof(height), 0, 0);
ON_SCOPE_EXIT { DeallocateForFont(imageptr); };
for (int tmpy = 0; tmpy < height; tmpy++) {
@@ -114,11 +114,11 @@ namespace ams::fatal::srv::font {
u32 prev_char = 0;
for (u32 i = 0; i < len; ) {
u32 cur_char;
ssize_t unit_count = decode_utf8(&cur_char, reinterpret_cast<const u8 *>(str + i));
ssize_t unit_count = decode_utf8(std::addressof(cur_char), reinterpret_cast<const u8 *>(str + i));
if (unit_count <= 0) break;
if (!g_mono_adv && i > 0) {
cur_x += g_font_size * stbtt_GetCodepointKernAdvance(&g_stb_font, prev_char, cur_char);
cur_x += g_font_size * stbtt_GetCodepointKernAdvance(std::addressof(g_stb_font), prev_char, cur_char);
}
i += unit_count;
@@ -130,11 +130,11 @@ namespace ams::fatal::srv::font {
}
int adv_width, left_side_bearing;
stbtt_GetCodepointHMetrics(&g_stb_font, cur_char, &adv_width, &left_side_bearing);
stbtt_GetCodepointHMetrics(std::addressof(g_stb_font), cur_char, std::addressof(adv_width), std::addressof(left_side_bearing));
const u32 cur_width = static_cast<u32>(adv_width) * g_font_size;
int x0, y0, x1, y1;
stbtt_GetCodepointBitmapBoxSubpixel(&g_stb_font, cur_char, g_font_size, g_font_size, 0, 0, &x0, &y0, &x1, &y1);
stbtt_GetCodepointBitmapBoxSubpixel(std::addressof(g_stb_font), cur_char, g_font_size, g_font_size, 0, 0, std::addressof(x0), std::addressof(y0), std::addressof(x1), std::addressof(y1));
DrawCodePoint(cur_char, cur_x + x0 + ((mono && g_mono_adv > cur_width) ? ((g_mono_adv - cur_width) / 2) : 0), cur_y + y0);
@@ -225,14 +225,14 @@ namespace ams::fatal::srv::font {
}
void SetFontSize(float fsz) {
g_font_size = stbtt_ScaleForPixelHeight(&g_stb_font, fsz * 1.375);
g_font_size = stbtt_ScaleForPixelHeight(std::addressof(g_stb_font), fsz * 1.375);
int ascent;
stbtt_GetFontVMetrics(&g_stb_font, &ascent,0,0);
stbtt_GetFontVMetrics(std::addressof(g_stb_font), std::addressof(ascent),0,0);
g_font_line_pixels = ascent * g_font_size * 1.125;
int adv_width, left_side_bearing;
stbtt_GetCodepointHMetrics(&g_stb_font, 'A', &adv_width, &left_side_bearing);
stbtt_GetCodepointHMetrics(std::addressof(g_stb_font), 'A', std::addressof(adv_width), std::addressof(left_side_bearing));
g_mono_adv = adv_width * g_font_size;
}
@@ -248,10 +248,10 @@ namespace ams::fatal::srv::font {
}
Result InitializeSharedFont() {
R_TRY(plGetSharedFontByType(&g_font, PlSharedFontType_Standard));
R_TRY(plGetSharedFontByType(std::addressof(g_font), PlSharedFontType_Standard));
u8 *font_buffer = reinterpret_cast<u8 *>(g_font.address);
stbtt_InitFont(&g_stb_font, font_buffer, stbtt_GetFontOffsetForIndex(font_buffer, 0));
stbtt_InitFont(std::addressof(g_stb_font), font_buffer, stbtt_GetFontOffsetForIndex(font_buffer, 0));
SetFontSize(16.0f);
return ResultSuccess();

View File

@@ -28,7 +28,7 @@ namespace ams::fatal::srv {
}
bool in_repair;
return R_SUCCEEDED(setsysGetInRepairProcessEnableFlag(&in_repair)) && in_repair;
return R_SUCCEEDED(setsysGetInRepairProcessEnableFlag(std::addressof(in_repair))) && in_repair;
}
bool IsInRepairWithoutVolHeld() {
@@ -66,7 +66,7 @@ namespace ams::fatal::srv {
}
bool requires_time_reviser;
return R_SUCCEEDED(setsysGetRequiresRunRepairTimeReviser(&requires_time_reviser)) && requires_time_reviser;
return R_SUCCEEDED(setsysGetRequiresRunRepairTimeReviser(std::addressof(requires_time_reviser))) && requires_time_reviser;
}
bool IsTimeReviserCartridgeInserted() {
@@ -74,21 +74,21 @@ namespace ams::fatal::srv {
u8 gc_attr;
{
FsDeviceOperator devop;
if (R_FAILED(fsOpenDeviceOperator(&devop))) {
if (R_FAILED(fsOpenDeviceOperator(std::addressof(devop)))) {
return false;
}
/* Ensure we close even on early return. */
ON_SCOPE_EXIT { fsDeviceOperatorClose(&devop); };
ON_SCOPE_EXIT { fsDeviceOperatorClose(std::addressof(devop)); };
/* Check that a gamecard is inserted. */
bool inserted;
if (R_FAILED(fsDeviceOperatorIsGameCardInserted(&devop, &inserted)) || !inserted) {
if (R_FAILED(fsDeviceOperatorIsGameCardInserted(std::addressof(devop), std::addressof(inserted))) || !inserted) {
return false;
}
/* Check that we can retrieve the gamecard's attributes. */
if (R_FAILED(fsDeviceOperatorGetGameCardHandle(&devop, &gc_hnd)) || R_FAILED(fsDeviceOperatorGetGameCardAttribute(&devop, &gc_hnd, &gc_attr))) {
if (R_FAILED(fsDeviceOperatorGetGameCardHandle(std::addressof(devop), std::addressof(gc_hnd))) || R_FAILED(fsDeviceOperatorGetGameCardAttribute(std::addressof(devop), std::addressof(gc_hnd), std::addressof(gc_attr)))) {
return false;
}
}

View File

@@ -85,13 +85,13 @@ namespace ams::fatal::srv {
}
/* Get program id. */
pm::info::GetProgramId(&this->context.program_id, process_id);
pm::info::GetProgramId(std::addressof(this->context.program_id), process_id);
this->context.is_creport = (this->context.program_id == ncm::SystemProgramId::Creport);
if (!this->context.is_creport) {
/* On firmware version 2.0.0, use debugging SVCs to collect information. */
if (hos::GetVersion() >= hos::Version_2_0_0) {
fatal::srv::TryCollectDebugInformation(&this->context, process_id);
fatal::srv::TryCollectDebugInformation(std::addressof(this->context), process_id);
}
} else {
/* We received info from creport. Parse program id from afsr0. */
@@ -117,7 +117,7 @@ namespace ams::fatal::srv {
this->event_manager.SignalEvents();
if (GetFatalConfig().ShouldTransitionToFatal()) {
RunTasks(&this->context);
RunTasks(std::addressof(this->context));
}
break;
/* N aborts here. Should we just return an error code? */

View File

@@ -41,13 +41,13 @@ namespace ams::fatal::srv {
if (hos::GetVersion() >= hos::Version_8_0_0) {
/* On 8.0.0+, convert to module id + use clkrst API. */
PcvModuleId module_id;
R_TRY(pcvGetModuleId(&module_id, module));
R_TRY(pcvGetModuleId(std::addressof(module_id), module));
ClkrstSession session;
R_TRY(clkrstOpenSession(&session, module_id, 3));
ON_SCOPE_EXIT { clkrstCloseSession(&session); };
R_TRY(clkrstOpenSession(std::addressof(session), module_id, 3));
ON_SCOPE_EXIT { clkrstCloseSession(std::addressof(session)); };
R_TRY(clkrstSetClockRate(&session, hz));
R_TRY(clkrstSetClockRate(std::addressof(session), hz));
} else {
/* On 1.0.0-7.0.1, use pcv API. */
R_TRY(pcvSetClockRate(module, hz));
@@ -77,7 +77,7 @@ namespace ams::fatal::srv {
ITask *GetAdjustClockTask(const ThrowContext *ctx) {
g_adjust_clock_task.Initialize(ctx);
return &g_adjust_clock_task;
return std::addressof(g_adjust_clock_task);
}
}

View File

@@ -34,7 +34,7 @@ namespace ams::fatal::srv {
/* Check if we have time service. */
{
bool has_time_service = false;
if (R_FAILED(sm::HasService(&has_time_service, sm::ServiceName::Encode("time:s"))) || !has_time_service) {
if (R_FAILED(sm::HasService(std::addressof(has_time_service), sm::ServiceName::Encode("time:s"))) || !has_time_service) {
return false;
}
}
@@ -73,7 +73,7 @@ namespace ams::fatal::srv {
/* Get a timestamp. */
u64 timestamp;
if (!TryGetCurrentTimestamp(&timestamp)) {
if (!TryGetCurrentTimestamp(std::addressof(timestamp))) {
timestamp = os::GetSystemTick().GetInt64Value();
}
@@ -172,7 +172,7 @@ namespace ams::fatal::srv {
ITask *GetErrorReportTask(const ThrowContext *ctx) {
g_error_report_task.Initialize(ctx);
return &g_error_report_task;
return std::addressof(g_error_report_task);
}
}

View File

@@ -88,7 +88,7 @@ namespace ams::fatal::srv {
break;
}
if (R_FAILED(psmGetBatteryVoltageState(&bv_state)) || bv_state == PsmBatteryVoltageState_NeedsShutdown) {
if (R_FAILED(psmGetBatteryVoltageState(std::addressof(bv_state))) || bv_state == PsmBatteryVoltageState_NeedsShutdown) {
break;
}
@@ -112,7 +112,7 @@ namespace ams::fatal::srv {
PsmBatteryVoltageState bv_state = PsmBatteryVoltageState_Normal;
/* Check the battery state, and shutdown on low voltage. */
if (R_FAILED(psmGetBatteryVoltageState(&bv_state)) || bv_state == PsmBatteryVoltageState_NeedsShutdown) {
if (R_FAILED(psmGetBatteryVoltageState(std::addressof(bv_state))) || bv_state == PsmBatteryVoltageState_NeedsShutdown) {
/* Wait a second for the error report task to finish. */
this->context->erpt_event->TimedWait(TimeSpan::FromSeconds(1));
this->TryShutdown();
@@ -124,7 +124,7 @@ namespace ams::fatal::srv {
/* Loop querying voltage state every 5 seconds. */
while (true) {
if (R_FAILED(psmGetBatteryVoltageState(&bv_state))) {
if (R_FAILED(psmGetBatteryVoltageState(std::addressof(bv_state)))) {
bv_state = PsmBatteryVoltageState_NeedsShutdown;
}
@@ -181,7 +181,7 @@ namespace ams::fatal::srv {
if (fatal_reboot_helper.IsRebootTiming() || (quest_reboot_helper.IsRebootTiming()) ||
(check_vol_up && gpio::GetValue(std::addressof(vol_up_btn)) == gpio::GpioValue_Low) ||
(check_vol_down && gpio::GetValue(std::addressof(vol_down_btn)) == gpio::GpioValue_Low) ||
(R_SUCCEEDED(bpcGetSleepButtonState(&state)) && state == BpcSleepButtonState_Held))
(R_SUCCEEDED(bpcGetSleepButtonState(std::addressof(state))) && state == BpcSleepButtonState_Held))
{
/* If any of the above conditions succeeded, we should reboot. */
bpcRebootSystem();
@@ -214,17 +214,17 @@ namespace ams::fatal::srv {
ITask *GetPowerControlTask(const ThrowContext *ctx) {
g_power_control_task.Initialize(ctx);
return &g_power_control_task;
return std::addressof(g_power_control_task);
}
ITask *GetPowerButtonObserveTask(const ThrowContext *ctx) {
g_power_button_observe_task.Initialize(ctx);
return &g_power_button_observe_task;
return std::addressof(g_power_button_observe_task);
}
ITask *GetStateTransitionStopTask(const ThrowContext *ctx) {
g_state_transition_stop_task.Initialize(ctx);
return &g_state_transition_stop_task;
return std::addressof(g_state_transition_stop_task);
}
}

View File

@@ -107,23 +107,23 @@ namespace ams::fatal::srv {
Result ShowFatalTask::SetupDisplayInternal() {
ViDisplay temp_display;
/* Try to open the display. */
R_TRY_CATCH(viOpenDisplay("Internal", &temp_display)) {
R_TRY_CATCH(viOpenDisplay("Internal", std::addressof(temp_display))) {
R_CONVERT(vi::ResultNotFound, ResultSuccess());
} R_END_TRY_CATCH;
/* Guarantee we close the display. */
ON_SCOPE_EXIT { viCloseDisplay(&temp_display); };
ON_SCOPE_EXIT { viCloseDisplay(std::addressof(temp_display)); };
/* Turn on the screen. */
if (hos::GetVersion() >= hos::Version_3_0_0) {
R_TRY(viSetDisplayPowerState(&temp_display, ViPowerState_On));
R_TRY(viSetDisplayPowerState(std::addressof(temp_display), ViPowerState_On));
} else {
/* Prior to 3.0.0, the ViPowerState enum was different (0 = Off, 1 = On). */
R_TRY(viSetDisplayPowerState(&temp_display, ViPowerState_On_Deprecated));
R_TRY(viSetDisplayPowerState(std::addressof(temp_display), ViPowerState_On_Deprecated));
}
/* Set alpha to 1.0f. */
R_TRY(viSetDisplayAlpha(&temp_display, 1.0f));
R_TRY(viSetDisplayAlpha(std::addressof(temp_display), 1.0f));
return ResultSuccess();
}
@@ -131,15 +131,15 @@ namespace ams::fatal::srv {
Result ShowFatalTask::SetupDisplayExternal() {
ViDisplay temp_display;
/* Try to open the display. */
R_TRY_CATCH(viOpenDisplay("External", &temp_display)) {
R_TRY_CATCH(viOpenDisplay("External", std::addressof(temp_display))) {
R_CONVERT(vi::ResultNotFound, ResultSuccess());
} R_END_TRY_CATCH;
/* Guarantee we close the display. */
ON_SCOPE_EXIT { viCloseDisplay(&temp_display); };
ON_SCOPE_EXIT { viCloseDisplay(std::addressof(temp_display)); };
/* Set alpha to 1.0f. */
R_TRY(viSetDisplayAlpha(&temp_display, 1.0f));
R_TRY(viSetDisplayAlpha(std::addressof(temp_display), 1.0f));
return ResultSuccess();
}
@@ -156,19 +156,19 @@ namespace ams::fatal::srv {
R_TRY(SetupDisplayExternal());
/* Open the default display. */
R_TRY(viOpenDefaultDisplay(&this->display));
R_TRY(viOpenDefaultDisplay(std::addressof(this->display)));
/* Reset the display magnification to its default value. */
s32 display_width, display_height;
R_TRY(viGetDisplayLogicalResolution(&this->display, &display_width, &display_height));
R_TRY(viGetDisplayLogicalResolution(std::addressof(this->display), std::addressof(display_width), std::addressof(display_height)));
/* viSetDisplayMagnification was added in 3.0.0. */
if (hos::GetVersion() >= hos::Version_3_0_0) {
R_TRY(viSetDisplayMagnification(&this->display, 0, 0, display_width, display_height));
R_TRY(viSetDisplayMagnification(std::addressof(this->display), 0, 0, display_width, display_height));
}
/* Create layer to draw to. */
R_TRY(viCreateLayer(&this->display, &this->layer));
R_TRY(viCreateLayer(std::addressof(this->display), std::addressof(this->layer)));
/* Setup the layer. */
{
@@ -183,16 +183,16 @@ namespace ams::fatal::srv {
const float layer_x = static_cast<float>((display_width - LayerWidth) / 2);
const float layer_y = static_cast<float>((display_height - LayerHeight) / 2);
R_TRY(viSetLayerSize(&this->layer, LayerWidth, LayerHeight));
R_TRY(viSetLayerSize(std::addressof(this->layer), LayerWidth, LayerHeight));
/* Set the layer's Z at display maximum, to be above everything else .*/
R_TRY(viSetLayerZ(&this->layer, FatalLayerZ));
R_TRY(viSetLayerZ(std::addressof(this->layer), FatalLayerZ));
/* Center the layer in the screen. */
R_TRY(viSetLayerPosition(&this->layer, layer_x, layer_y));
R_TRY(viSetLayerPosition(std::addressof(this->layer), layer_x, layer_y));
/* Create framebuffer. */
R_TRY(nwindowCreateFromLayer(&this->win, &this->layer));
R_TRY(nwindowCreateFromLayer(std::addressof(this->win), std::addressof(this->layer)));
R_TRY(this->InitializeNativeWindow());
}
@@ -439,7 +439,7 @@ namespace ams::fatal::srv {
R_TRY(nvFenceInit());
/* Create nvmap. */
R_TRY(nvMapCreate(&this->map, g_framebuffer_memory, sizeof(g_framebuffer_memory), 0x20000, NvKind_Pitch, true));
R_TRY(nvMapCreate(std::addressof(this->map), g_framebuffer_memory, sizeof(g_framebuffer_memory), 0x20000, NvKind_Pitch, true));
/* Setup graphics buffer. */
{
@@ -458,14 +458,14 @@ namespace ams::fatal::srv {
grbuf.planes[0].layout = NvLayout_BlockLinear;
grbuf.planes[0].kind = NvKind_Generic_16BX2;
grbuf.planes[0].block_height_log2 = 4;
grbuf.nvmap_id = nvMapGetId(&this->map);
grbuf.nvmap_id = nvMapGetId(std::addressof(this->map));
grbuf.stride = FatalScreenWidthAligned;
grbuf.total_size = sizeof(g_framebuffer_memory);
grbuf.planes[0].pitch = FatalScreenWidthAlignedBytes;
grbuf.planes[0].size = sizeof(g_framebuffer_memory);
grbuf.planes[0].offset = 0;
R_TRY(nwindowConfigureBuffer(&this->win, 0, &grbuf));
R_TRY(nwindowConfigureBuffer(std::addressof(this->win), 0, std::addressof(grbuf)));
}
return ResultSuccess();
@@ -473,9 +473,9 @@ namespace ams::fatal::srv {
void ShowFatalTask::DisplayPreRenderedFrame() {
s32 slot;
R_ABORT_UNLESS(nwindowDequeueBuffer(&this->win, &slot, nullptr));
R_ABORT_UNLESS(nwindowDequeueBuffer(std::addressof(this->win), std::addressof(slot), nullptr));
dd::FlushDataCache(g_framebuffer_memory, sizeof(g_framebuffer_memory));
R_ABORT_UNLESS(nwindowQueueBuffer(&this->win, this->win.cur_slot, NULL));
R_ABORT_UNLESS(nwindowQueueBuffer(std::addressof(this->win), this->win.cur_slot, NULL));
}
Result ShowFatalTask::ShowFatal() {
@@ -511,12 +511,12 @@ namespace ams::fatal::srv {
ITask *GetShowFatalTask(const ThrowContext *ctx) {
g_show_fatal_task.Initialize(ctx);
return &g_show_fatal_task;
return std::addressof(g_show_fatal_task);
}
ITask *GetBacklightControlTask(const ThrowContext *ctx) {
g_backlight_control_task.Initialize(ctx);
return &g_backlight_control_task;
return std::addressof(g_backlight_control_task);
}
}

View File

@@ -39,8 +39,8 @@ namespace ams::fatal::srv {
/* Talk to the ALC5639 over I2C, and disable audio output. */
{
I2cSession audio;
if (R_SUCCEEDED(i2cOpenSession(&audio, I2cDevice_Alc5639))) {
ON_SCOPE_EXIT { i2csessionClose(&audio); };
if (R_SUCCEEDED(i2cOpenSession(std::addressof(audio), I2cDevice_Alc5639))) {
ON_SCOPE_EXIT { i2csessionClose(std::addressof(audio)); };
struct {
u8 reg;
@@ -50,16 +50,16 @@ namespace ams::fatal::srv {
cmd.reg = 0x01;
cmd.val = 0xC8C8;
i2csessionSendAuto(&audio, &cmd, sizeof(cmd), I2cTransactionOption_All);
i2csessionSendAuto(std::addressof(audio), std::addressof(cmd), sizeof(cmd), I2cTransactionOption_All);
cmd.reg = 0x02;
cmd.val = 0xC8C8;
i2csessionSendAuto(&audio, &cmd, sizeof(cmd), I2cTransactionOption_All);
i2csessionSendAuto(std::addressof(audio), std::addressof(cmd), sizeof(cmd), I2cTransactionOption_All);
for (u8 reg = 97; reg <= 102; reg++) {
cmd.reg = reg;
cmd.val = 0;
i2csessionSendAuto(&audio, &cmd, sizeof(cmd), I2cTransactionOption_All);
i2csessionSendAuto(std::addressof(audio), std::addressof(cmd), sizeof(cmd), I2cTransactionOption_All);
}
}
}
@@ -89,7 +89,7 @@ namespace ams::fatal::srv {
ITask *GetStopSoundTask(const ThrowContext *ctx) {
g_stop_sound_task.Initialize(ctx);
return &g_stop_sound_task;
return std::addressof(g_stop_sound_task);
}
}

View File

@@ -31,7 +31,7 @@ namespace ams::ldr {
std::memset(out, 0, sizeof(*out));
cfg::OverrideStatus status = {};
R_TRY(ldr::GetProgramInfo(out, &status, loc));
R_TRY(ldr::GetProgramInfo(out, std::addressof(status), loc));
if (loc.storage_id != static_cast<u8>(ncm::StorageId::None) && loc.program_id != out->program_id) {
char path[fs::EntryNameLengthMax];
@@ -64,7 +64,7 @@ namespace ams::ldr {
char path[fs::EntryNameLengthMax];
/* Get location and override status. */
R_TRY(ldr::ro::GetProgramLocationAndStatus(&loc, &override_status, id));
R_TRY(ldr::ro::GetProgramLocationAndStatus(std::addressof(loc), std::addressof(override_status), id));
if (loc.storage_id != static_cast<u8>(ncm::StorageId::None)) {
R_TRY(ResolveContentPath(path, loc));

View File

@@ -156,7 +156,7 @@ namespace ams::ldr {
/* Validate the meta. */
{
Meta *meta = &cache->meta;
Meta *meta = std::addressof(cache->meta);
Npdm *npdm = reinterpret_cast<Npdm *>(cache->buffer);
R_TRY(ValidateNpdm(npdm, npdm_size));
@@ -194,11 +194,11 @@ namespace ams::ldr {
R_TRY(fs::OpenFile(std::addressof(file), AtmosphereMetaPath, fs::OpenMode_Read));
{
ON_SCOPE_EXIT { fs::CloseFile(file); };
R_TRY(LoadMetaFromFile(file, &g_meta_cache));
R_TRY(LoadMetaFromFile(file, std::addressof(g_meta_cache)));
}
/* Patch meta. Start by setting all program ids to the current program id. */
Meta *meta = &g_meta_cache.meta;
Meta *meta = std::addressof(g_meta_cache.meta);
meta->acid->program_id_min = loc.program_id;
meta->acid->program_id_max = loc.program_id;
meta->aci->program_id = loc.program_id;
@@ -209,8 +209,8 @@ namespace ams::ldr {
ON_SCOPE_EXIT { fs::CloseFile(file); };
if (R_SUCCEEDED(LoadMetaFromFile(file, &g_original_meta_cache))) {
Meta *o_meta = &g_original_meta_cache.meta;
if (R_SUCCEEDED(LoadMetaFromFile(file, std::addressof(g_original_meta_cache)))) {
Meta *o_meta = std::addressof(g_original_meta_cache.meta);
/* Fix pool partition. */
if (hos::GetVersion() >= hos::Version_5_0_0) {
@@ -253,8 +253,8 @@ namespace ams::ldr {
if (static_cast<ncm::StorageId>(loc.storage_id) != ncm::StorageId::None || ncm::IsApplicationId(loc.program_id)) {
R_TRY(fs::OpenFile(std::addressof(file), BaseMetaPath, fs::OpenMode_Read));
ON_SCOPE_EXIT { fs::CloseFile(file); };
R_TRY(LoadMetaFromFile(file, &g_original_meta_cache));
R_TRY(ValidateAcidSignature(&g_original_meta_cache.meta));
R_TRY(LoadMetaFromFile(file, std::addressof(g_original_meta_cache)));
R_TRY(ValidateAcidSignature(std::addressof(g_original_meta_cache.meta)));
meta->modulus = g_original_meta_cache.meta.modulus;
meta->check_verification_data = g_original_meta_cache.meta.check_verification_data;
}

View File

@@ -118,15 +118,15 @@ namespace ams::ldr {
}
ro::ModuleId module_id;
std::memcpy(&module_id.build_id, build_id, sizeof(module_id.build_id));
ams::patcher::LocateAndApplyIpsPatchesToModule(LoaderSdMountName, NsoPatchesDirectory, NsoPatchesProtectedSize, NsoPatchesProtectedOffset, &module_id, reinterpret_cast<u8 *>(mapped_nso), mapped_size);
std::memcpy(std::addressof(module_id.build_id), build_id, sizeof(module_id.build_id));
ams::patcher::LocateAndApplyIpsPatchesToModule(LoaderSdMountName, NsoPatchesDirectory, NsoPatchesProtectedSize, NsoPatchesProtectedOffset, std::addressof(module_id), reinterpret_cast<u8 *>(mapped_nso), mapped_size);
}
/* Apply embedded patches. */
void ApplyEmbeddedPatchesToModule(const u8 *build_id, uintptr_t mapped_nso, size_t mapped_size) {
/* Make module id. */
ro::ModuleId module_id;
std::memcpy(&module_id.build_id, build_id, sizeof(module_id.build_id));
std::memcpy(std::addressof(module_id.build_id), build_id, sizeof(module_id.build_id));
if (IsUsb30ForceEnabled()) {
for (const auto &patch : Usb30ForceEnablePatches) {

View File

@@ -346,7 +346,7 @@ namespace ams::ldr {
out->reslimit = reslimit_h;
/* Set flags. */
R_TRY(GetCreateProcessFlags(&out->flags, meta, flags));
R_TRY(GetCreateProcessFlags(std::addressof(out->flags), meta, flags));
/* 3.0.0+ System Resource Size. */
if (hos::GetVersion() >= hos::Version_3_0_0) {
@@ -574,11 +574,11 @@ namespace ams::ldr {
R_TRY(map.GetResult());
/* Load NSO segments. */
R_TRY(LoadNsoSegment(file, &nso_header->segments[NsoHeader::Segment_Text], nso_header->text_compressed_size, nso_header->text_hash, (nso_header->flags & NsoHeader::Flag_CompressedText) != 0,
R_TRY(LoadNsoSegment(file, std::addressof(nso_header->segments[NsoHeader::Segment_Text]), nso_header->text_compressed_size, nso_header->text_hash, (nso_header->flags & NsoHeader::Flag_CompressedText) != 0,
(nso_header->flags & NsoHeader::Flag_CheckHashText) != 0, map_address + nso_header->text_dst_offset, map_address + nso_size));
R_TRY(LoadNsoSegment(file, &nso_header->segments[NsoHeader::Segment_Ro], nso_header->ro_compressed_size, nso_header->ro_hash, (nso_header->flags & NsoHeader::Flag_CompressedRo) != 0,
R_TRY(LoadNsoSegment(file, std::addressof(nso_header->segments[NsoHeader::Segment_Ro]), nso_header->ro_compressed_size, nso_header->ro_hash, (nso_header->flags & NsoHeader::Flag_CompressedRo) != 0,
(nso_header->flags & NsoHeader::Flag_CheckHashRo) != 0, map_address + nso_header->ro_dst_offset, map_address + nso_size));
R_TRY(LoadNsoSegment(file, &nso_header->segments[NsoHeader::Segment_Rw], nso_header->rw_compressed_size, nso_header->rw_hash, (nso_header->flags & NsoHeader::Flag_CompressedRw) != 0,
R_TRY(LoadNsoSegment(file, std::addressof(nso_header->segments[NsoHeader::Segment_Rw]), nso_header->rw_compressed_size, nso_header->rw_hash, (nso_header->flags & NsoHeader::Flag_CompressedRw) != 0,
(nso_header->flags & NsoHeader::Flag_CheckHashRw) != 0, map_address + nso_header->rw_dst_offset, map_address + nso_size));
/* Clear unused space to zero. */
@@ -670,10 +670,10 @@ namespace ams::ldr {
/* Load meta, possibly from cache. */
Meta meta;
R_TRY(LoadMetaFromCache(&meta, loc, override_status));
R_TRY(LoadMetaFromCache(std::addressof(meta), loc, override_status));
/* Validate meta. */
R_TRY(ValidateMeta(&meta, loc, mount.GetCodeVerificationData()));
R_TRY(ValidateMeta(std::addressof(meta), loc, mount.GetCodeVerificationData()));
/* Load, validate NSOs. */
R_TRY(LoadNsoHeaders(nso_headers, has_nso));
@@ -681,13 +681,13 @@ namespace ams::ldr {
/* Actually create process. */
ProcessInfo info;
R_TRY(CreateProcessImpl(&info, &meta, nso_headers, has_nso, arg_info, flags, reslimit_h));
R_TRY(CreateProcessImpl(std::addressof(info), std::addressof(meta), nso_headers, has_nso, arg_info, flags, reslimit_h));
/* Ensure we close the process handle, if we fail. */
ON_SCOPE_EXIT { os::CloseNativeHandle(info.process_handle); };
/* Load NSOs into process memory. */
R_TRY(LoadNsosIntoProcessMemory(&info, nso_headers, has_nso, arg_info));
R_TRY(LoadNsosIntoProcessMemory(std::addressof(info), nso_headers, has_nso, arg_info));
/* Register NSOs with ro manager. */
{
@@ -732,13 +732,13 @@ namespace ams::ldr {
{
ScopedCodeMount mount(loc);
R_TRY(mount.GetResult());
R_TRY(LoadMeta(&meta, loc, mount.GetOverrideStatus()));
R_TRY(LoadMeta(std::addressof(meta), loc, mount.GetOverrideStatus()));
if (out_status != nullptr) {
*out_status = mount.GetOverrideStatus();
}
}
return GetProgramInfoFromMeta(out, &meta);
return GetProgramInfoFromMeta(out, std::addressof(meta));
}
}

View File

@@ -30,7 +30,7 @@ namespace ams::pm::impl {
void ProcessInfo::Cleanup() {
if (this->handle != os::InvalidNativeHandle) {
/* Unregister the process. */
fsprUnregisterProgram(static_cast<u64>(this->process_id));
fsprUnregisterProgram(this->process_id.value);
sm::manager::UnregisterProcess(this->process_id);
ldr::pm::UnpinProgram(this->pin_id);

View File

@@ -186,7 +186,7 @@ namespace ams::pm::impl {
ProcessInfo *Find(os::ProcessId process_id) {
for (auto it = this->begin(); it != this->end(); it++) {
if ((*it).GetProcessId() == process_id) {
return &*it;
return std::addressof(*it);
}
}
return nullptr;
@@ -195,7 +195,7 @@ namespace ams::pm::impl {
ProcessInfo *Find(ncm::ProgramId program_id) {
for (auto it = this->begin(); it != this->end(); it++) {
if ((*it).GetProgramLocation().program_id == program_id) {
return &*it;
return std::addressof(*it);
}
}
return nullptr;
@@ -216,11 +216,11 @@ namespace ams::pm::impl {
}
ProcessList *operator->() {
return &this->list;
return std::addressof(this->list);
}
const ProcessList *operator->() const {
return &this->list;
return std::addressof(this->list);
}
ProcessList &operator*() {

View File

@@ -166,7 +166,7 @@ namespace ams::pm::impl {
while (true) {
auto signaled_holder = os::WaitAny(std::addressof(process_multi_wait));
if (signaled_holder == &start_event_holder) {
if (signaled_holder == std::addressof(start_event_holder)) {
/* Launch start event signaled. */
/* TryWait will clear signaled, preventing duplicate notifications. */
if (g_process_launch_start_event.TryWait()) {
@@ -224,7 +224,7 @@ namespace ams::pm::impl {
/* Get Program Info. */
ldr::ProgramInfo program_info;
cfg::OverrideStatus override_status;
R_TRY(ldr::pm::AtmosphereGetProgramInfo(&program_info, &override_status, args.location));
R_TRY(ldr::pm::AtmosphereGetProgramInfo(std::addressof(program_info), std::addressof(override_status), args.location));
const bool is_application = (program_info.flags & ldr::ProgramInfoFlag_ApplicationTypeMask) == ldr::ProgramInfoFlag_Application;
const bool allow_debug = (program_info.flags & ldr::ProgramInfoFlag_AllowDebug) || hos::GetVersion() < hos::Version_2_0_0;
@@ -236,16 +236,16 @@ namespace ams::pm::impl {
/* Pin the program with loader. */
ldr::PinId pin_id;
R_TRY(ldr::pm::AtmospherePinProgram(&pin_id, location, override_status));
R_TRY(ldr::pm::AtmospherePinProgram(std::addressof(pin_id), location, override_status));
/* Ensure resources are available. */
resource::WaitResourceAvailable(&program_info);
resource::WaitResourceAvailable(std::addressof(program_info));
/* Actually create the process. */
os::NativeHandle process_handle;
{
auto pin_guard = SCOPE_GUARD { ldr::pm::UnpinProgram(pin_id); };
R_TRY(ldr::pm::CreateProcess(&process_handle, pin_id, GetLoaderCreateProcessFlags(args.flags), resource::GetResourceLimitHandle(&program_info)));
R_TRY(ldr::pm::CreateProcess(std::addressof(process_handle), pin_id, GetLoaderCreateProcessFlags(args.flags), resource::GetResourceLimitHandle(std::addressof(program_info))));
pin_guard.Cancel();
}
@@ -301,7 +301,7 @@ namespace ams::pm::impl {
os::SignalSystemEvent(std::addressof(g_hook_to_create_application_process_event));
g_application_hook = false;
} else if (!ShouldStartSuspended(args.flags)) {
R_TRY(StartProcess(process_info, &program_info));
R_TRY(StartProcess(process_info, std::addressof(program_info)));
}
/* We succeeded, so we can cancel our cleanup. */
@@ -319,7 +319,7 @@ namespace ams::pm::impl {
const svc::ProcessState old_state = process_info->GetState();
{
s64 tmp = 0;
R_ABORT_UNLESS(svc::GetProcessInfo(&tmp, process_info->GetHandle(), svc::ProcessInfoType_ProcessState));
R_ABORT_UNLESS(svc::GetProcessInfo(std::addressof(tmp), process_info->GetHandle(), svc::ProcessInfoType_ProcessState));
process_info->SetState(static_cast<svc::ProcessState>(tmp));
}
const svc::ProcessState new_state = process_info->GetState();
@@ -445,8 +445,8 @@ namespace ams::pm::impl {
R_UNLESS(!process_info->HasStarted(), pm::ResultAlreadyStarted());
ldr::ProgramInfo program_info;
R_TRY(ldr::pm::GetProgramInfo(&program_info, process_info->GetProgramLocation()));
return StartProcess(process_info, &program_info);
R_TRY(ldr::pm::GetProgramInfo(std::addressof(program_info), process_info->GetProgramLocation()));
return StartProcess(process_info, std::addressof(program_info));
}
Result TerminateProcess(os::ProcessId process_id) {
@@ -518,7 +518,7 @@ namespace ams::pm::impl {
out->event = GetProcessEventValue(ProcessEvent::Exited);
out->process_id = process_info.GetProcessId();
CleanupProcessInfo(dead_list, &process_info);
CleanupProcessInfo(dead_list, std::addressof(process_info));
return ResultSuccess();
}
}

View File

@@ -61,7 +61,7 @@ namespace ams {
void RegisterPrivilegedProcesses() {
/* Get privileged process range. */
os::ProcessId min_priv_process_id = os::InvalidProcessId, max_priv_process_id = os::InvalidProcessId;
cfg::GetInitialProcessRange(&min_priv_process_id, &max_priv_process_id);
cfg::GetInitialProcessRange(std::addressof(min_priv_process_id), std::addressof(max_priv_process_id));
/* Get current process id/program id. */
const auto cur_process_id = os::GetCurrentProcessId();
@@ -70,7 +70,7 @@ namespace ams {
/* Get list of processes, register all privileged ones. */
s32 num_pids;
os::ProcessId pids[ProcessCountMax];
R_ABORT_UNLESS(svc::GetProcessList(&num_pids, reinterpret_cast<u64 *>(pids), ProcessCountMax));
R_ABORT_UNLESS(svc::GetProcessList(std::addressof(num_pids), reinterpret_cast<u64 *>(pids), ProcessCountMax));
for (s32 i = 0; i < num_pids; i++) {
if (min_priv_process_id <= pids[i] && pids[i] <= max_priv_process_id) {
RegisterPrivilegedProcess(pids[i], pids[i] == cur_process_id ? cur_program_id : GetProcessProgramId(pids[i]));

View File

@@ -364,7 +364,7 @@ namespace ams::ro::impl {
bool ShouldEaseNroRestriction() {
/* Retrieve whether we should ease restrictions from set:sys. */
u8 should_ease = 0;
if (settings::fwdbg::GetSettingsItemValue(&should_ease, sizeof(should_ease), "ro", "ease_nro_restriction") != sizeof(should_ease)) {
if (settings::fwdbg::GetSettingsItemValue(std::addressof(should_ease), sizeof(should_ease), "ro", "ease_nro_restriction") != sizeof(should_ease)) {
return false;
}
@@ -379,7 +379,7 @@ namespace ams::ro::impl {
{
/* Validate handle is a valid process handle. */
os::ProcessId handle_pid;
R_UNLESS(R_SUCCEEDED(os::GetProcessId(&handle_pid, process_handle.GetOsHandle())), ro::ResultInvalidProcess());
R_UNLESS(R_SUCCEEDED(os::GetProcessId(std::addressof(handle_pid), process_handle.GetOsHandle())), ro::ResultInvalidProcess());
/* Validate process id. */
R_UNLESS(handle_pid == process_id, ro::ResultInvalidProcess());
@@ -420,7 +420,7 @@ namespace ams::ro::impl {
/* Check we have space for a new NRR. */
NrrInfo *nrr_info = nullptr;
R_TRY(context->GetFreeNrrInfo(&nrr_info));
R_TRY(context->GetFreeNrrInfo(std::addressof(nrr_info)));
/* Prepare to cache the NRR's signature hash. */
Sha256Hash signed_area_hash;
@@ -429,7 +429,7 @@ namespace ams::ro::impl {
/* Map. */
NrrHeader *header = nullptr;
u64 mapped_code_address = 0;
R_TRY(MapAndValidateNrr(&header, &mapped_code_address, std::addressof(signed_area_hash), sizeof(signed_area_hash), context->process_handle, program_id, nrr_address, nrr_size, nrr_kind, enforce_nrr_kind));
R_TRY(MapAndValidateNrr(std::addressof(header), std::addressof(mapped_code_address), std::addressof(signed_area_hash), sizeof(signed_area_hash), context->process_handle, program_id, nrr_address, nrr_size, nrr_kind, enforce_nrr_kind));
/* Set NRR info. */
context->SetNrrInfoInUse(nrr_info, true);
@@ -458,7 +458,7 @@ namespace ams::ro::impl {
/* Check the NRR is loaded. */
NrrInfo *nrr_info = nullptr;
R_TRY(context->GetNrrInfoByAddress(&nrr_info, nrr_address));
R_TRY(context->GetNrrInfoByAddress(std::addressof(nrr_info), nrr_address));
/* Unmap. */
const NrrInfo nrr_backup = *nrr_info;
@@ -485,20 +485,20 @@ namespace ams::ro::impl {
/* Check we have space for a new NRO. */
NroInfo *nro_info = nullptr;
R_TRY(context->GetFreeNroInfo(&nro_info));
R_TRY(context->GetFreeNroInfo(std::addressof(nro_info)));
nro_info->nro_heap_address = nro_address;
nro_info->nro_heap_size = nro_size;
nro_info->bss_heap_address = bss_address;
nro_info->bss_heap_size = bss_size;
/* Map the NRO. */
R_TRY(MapNro(&nro_info->base_address, context->process_handle, nro_address, nro_size, bss_address, bss_size));
R_TRY(MapNro(std::addressof(nro_info->base_address), context->process_handle, nro_address, nro_size, bss_address, bss_size));
/* Validate the NRO (parsing region extents). */
u64 rx_size = 0, ro_size = 0, rw_size = 0;
{
auto unmap_guard = SCOPE_GUARD { UnmapNro(context->process_handle, nro_info->base_address, nro_address, bss_address, bss_size, nro_size, 0); };
R_TRY(context->ValidateNro(&nro_info->module_id, &rx_size, &ro_size, &rw_size, nro_info->base_address, nro_size, bss_size));
R_TRY(context->ValidateNro(std::addressof(nro_info->module_id), std::addressof(rx_size), std::addressof(ro_size), std::addressof(rw_size), nro_info->base_address, nro_size, bss_size));
unmap_guard.Cancel();
}
@@ -526,7 +526,7 @@ namespace ams::ro::impl {
/* Check the NRO is loaded. */
NroInfo *nro_info = nullptr;
R_TRY(context->GetNroInfoByAddress(&nro_info, nro_address));
R_TRY(context->GetNroInfoByAddress(std::addressof(nro_info), nro_address));
/* Unmap. */
const NroInfo nro_backup = *nro_info;
@@ -552,7 +552,7 @@ namespace ams::ro::impl {
/* Just copy out the info. */
LoaderModuleInfo *out_info = std::addressof(out_infos[count++]);
memcpy(out_info->build_id, &nro_info->module_id, sizeof(nro_info->module_id));
memcpy(out_info->build_id, std::addressof(nro_info->module_id), sizeof(nro_info->module_id));
out_info->base_address = nro_info->base_address;
out_info->size = nro_info->nro_heap_size + nro_info->bss_heap_size;
}

View File

@@ -127,7 +127,7 @@ namespace ams::sm::impl {
public:
InitialProcessIdLimits() {
/* Retrieve process limits. */
cfg::GetInitialProcessRange(&this->min, &this->max);
cfg::GetInitialProcessRange(std::addressof(this->min), std::addressof(this->max));
/* Ensure range is sane. */
AMS_ABORT_UNLESS(this->min <= this->max);
@@ -538,7 +538,7 @@ namespace ams::sm::impl {
/* Check that we have the service. */
bool has_service = false;
R_TRY(impl::HasService(&has_service, service));
R_TRY(impl::HasService(std::addressof(has_service), service));
/* If we do, we can succeed immediately. */
R_SUCCEED_IF(has_service);

View File

@@ -203,7 +203,7 @@ namespace ams::spl::impl {
}
Result Allocate() {
R_TRY(AllocateAesKeySlot(&this->slot, this));
R_TRY(AllocateAesKeySlot(std::addressof(this->slot), this));
this->has_slot = true;
return ResultSuccess();
}
@@ -269,7 +269,7 @@ namespace ams::spl::impl {
void InitializeSeEvents() {
u64 irq_num;
AMS_ABORT_UNLESS(smc::GetConfig(&irq_num, 1, ConfigItem::SecurityEngineInterruptNumber) == smc::Result::Success);
AMS_ABORT_UNLESS(smc::GetConfig(std::addressof(irq_num), 1, ConfigItem::SecurityEngineInterruptNumber) == smc::Result::Success);
os::InitializeInterruptEvent(std::addressof(g_se_event), irq_num, os::EventClearMode_AutoClear);
R_ABORT_UNLESS(os::CreateSystemEvent(std::addressof(g_se_keyslot_available_event), os::EventClearMode_AutoClear, true));
@@ -279,7 +279,7 @@ namespace ams::spl::impl {
void InitializeDeviceAddressSpace() {
/* Create Address Space. */
R_ABORT_UNLESS(svc::CreateDeviceAddressSpace(&g_se_das_hnd, 0, (1ul << 32)));
R_ABORT_UNLESS(svc::CreateDeviceAddressSpace(std::addressof(g_se_das_hnd), 0, (1ul << 32)));
/* Attach it to the SE. */
R_ABORT_UNLESS(svc::AttachDeviceAddressSpace(svc::DeviceName_Se, g_se_das_hnd));
@@ -320,7 +320,7 @@ namespace ams::spl::impl {
WaitSeOperationComplete();
smc::Result op_res;
smc::Result res = smc::GetResult(&op_res, op_key);
smc::Result res = smc::GetResult(std::addressof(op_res), op_key);
if (res != smc::Result::Success) {
return res;
}
@@ -332,7 +332,7 @@ namespace ams::spl::impl {
WaitSeOperationComplete();
smc::Result op_res;
smc::Result res = smc::GetResultData(&op_res, out_buf, out_buf_size, op_key);
smc::Result res = smc::GetResultData(std::addressof(op_res), out_buf, out_buf_size, op_key);
if (res != smc::Result::Success) {
return res;
}
@@ -381,7 +381,7 @@ namespace ams::spl::impl {
const u32 dst_ll_addr = g_se_mapped_work_buffer_addr + offsetof(DecryptAesBlockLayout, crypt_ctx.out);
const u32 src_ll_addr = g_se_mapped_work_buffer_addr + offsetof(DecryptAesBlockLayout, crypt_ctx.in);
smc::Result res = smc::ComputeAes(&op_key, mode, iv_ctr, dst_ll_addr, src_ll_addr, sizeof(layout->in_block));
smc::Result res = smc::ComputeAes(std::addressof(op_key), mode, iv_ctr, dst_ll_addr, src_ll_addr, sizeof(layout->in_block));
if (res != smc::Result::Success) {
return res;
}
@@ -443,7 +443,7 @@ namespace ams::spl::impl {
std::scoped_lock lk(g_async_op_lock);
smc::AsyncOperationKey op_key;
smc::Result res = smc::ModularExponentiateWithStorageKey(&op_key, layout->base, layout->mod, mode);
smc::Result res = smc::ModularExponentiateWithStorageKey(std::addressof(op_key), layout->base, layout->mod, mode);
if (res != smc::Result::Success) {
return smc::ConvertResult(res);
}
@@ -483,7 +483,7 @@ namespace ams::spl::impl {
std::scoped_lock lk(g_async_op_lock);
smc::AsyncOperationKey op_key;
smc::Result res = smc::PrepareEsDeviceUniqueKey(&op_key, layout->base, layout->mod, label_digest, label_digest_size, smc::GetPrepareEsDeviceUniqueKeyOption(type, generation));
smc::Result res = smc::PrepareEsDeviceUniqueKey(std::addressof(op_key), layout->base, layout->mod, label_digest, label_digest_size, smc::GetPrepareEsDeviceUniqueKeyOption(type, generation));
if (res != smc::Result::Success) {
return smc::ConvertResult(res);
}
@@ -571,7 +571,7 @@ namespace ams::spl::impl {
std::scoped_lock lk(g_async_op_lock);
smc::AsyncOperationKey op_key;
smc::Result res = smc::ModularExponentiate(&op_key, layout->base, layout->exp, exp_size, layout->mod);
smc::Result res = smc::ModularExponentiate(std::addressof(op_key), layout->base, layout->exp, exp_size, layout->mod);
if (res != smc::Result::Success) {
return smc::ConvertResult(res);
}
@@ -587,7 +587,7 @@ namespace ams::spl::impl {
}
Result SetConfig(ConfigItem which, u64 value) {
return smc::ConvertResult(smc::SetConfig(which, &value, 1));
return smc::ConvertResult(smc::SetConfig(which, std::addressof(value), 1));
}
Result GenerateRandomBytes(void *out, size_t size) {
@@ -605,7 +605,7 @@ namespace ams::spl::impl {
Result IsDevelopment(bool *out) {
u64 hardware_state;
R_TRY(impl::GetConfig(&hardware_state, ConfigItem::HardwareState));
R_TRY(impl::GetConfig(std::addressof(hardware_state), ConfigItem::HardwareState));
*out = (hardware_state == HardwareState_Development);
return ResultSuccess();
@@ -646,7 +646,7 @@ namespace ams::spl::impl {
R_TRY(LoadVirtualAesKey(keyslot_holder.GetKeySlot(), access_key, s_generate_aes_key_source));
return smc::ConvertResult(DecryptAesBlock(keyslot_holder.GetKeySlot(), out_key, &key_source));
return smc::ConvertResult(DecryptAesBlock(keyslot_holder.GetKeySlot(), out_key, std::addressof(key_source)));
}
Result DecryptAesKey(AesKey *out_key, const KeySource &key_source, u32 generation, u32 option) {
@@ -655,7 +655,7 @@ namespace ams::spl::impl {
};
AccessKey access_key;
R_TRY(GenerateAesKek(&access_key, s_decrypt_aes_key_source, generation, option));
R_TRY(GenerateAesKek(std::addressof(access_key), s_decrypt_aes_key_source, generation, option));
return GenerateAesKey(out_key, access_key, key_source);
}
@@ -711,7 +711,7 @@ namespace ams::spl::impl {
const u32 dst_ll_addr = g_se_mapped_work_buffer_addr + offsetof(SeCryptContext, out);
const u32 src_ll_addr = g_se_mapped_work_buffer_addr + offsetof(SeCryptContext, in);
smc::Result res = smc::ComputeAes(&op_key, mode, iv_ctr, dst_ll_addr, src_ll_addr, src_size);
smc::Result res = smc::ComputeAes(std::addressof(op_key), mode, iv_ctr, dst_ll_addr, src_ll_addr, src_size);
if (res != smc::Result::Success) {
return smc::ConvertResult(res);
}
@@ -791,7 +791,7 @@ namespace ams::spl::impl {
copy_size = std::min(dst_size, src_size - DeviceUniqueDataMetaSize);
smc_res = smc::DecryptDeviceUniqueData(layout->data, src_size, access_key, key_source, static_cast<smc::DeviceUniqueDataMode>(option));
} else {
smc_res = smc::DecryptDeviceUniqueData(&copy_size, layout->data, src_size, access_key, key_source, option);
smc_res = smc::DecryptDeviceUniqueData(std::addressof(copy_size), layout->data, src_size, access_key, key_source, option);
copy_size = std::min(dst_size, copy_size);
}

View File

@@ -19,16 +19,16 @@
namespace ams::spl {
void CtrDrbg::Update(const void *data) {
aes128ContextCreate(&this->aes_ctx, this->key, true);
aes128ContextCreate(std::addressof(this->aes_ctx), this->key, true);
for (size_t offset = 0; offset < sizeof(this->work[1]); offset += BlockSize) {
IncrementCounter(this->counter);
aes128EncryptBlock(&this->aes_ctx, &this->work[1][offset], this->counter);
aes128EncryptBlock(std::addressof(this->aes_ctx), std::addressof(this->work[1][offset]), this->counter);
}
Xor(this->work[1], data, sizeof(this->work[1]));
std::memcpy(this->key, &this->work[1][0], sizeof(this->key));
std::memcpy(this->counter, &this->work[1][BlockSize], sizeof(this->key));
std::memcpy(this->key, std::addressof(this->work[1][0]), sizeof(this->key));
std::memcpy(this->counter, std::addressof(this->work[1][BlockSize]), sizeof(this->key));
}
void CtrDrbg::Initialize(const void *seed) {
@@ -54,19 +54,19 @@ namespace ams::spl {
return false;
}
aes128ContextCreate(&this->aes_ctx, this->key, true);
aes128ContextCreate(std::addressof(this->aes_ctx), this->key, true);
u8 *cur_dst = reinterpret_cast<u8 *>(out);
size_t aligned_size = (size & ~(BlockSize - 1));
for (size_t offset = 0; offset < aligned_size; offset += BlockSize) {
IncrementCounter(this->counter);
aes128EncryptBlock(&this->aes_ctx, cur_dst, this->counter);
aes128EncryptBlock(std::addressof(this->aes_ctx), cur_dst, this->counter);
cur_dst += BlockSize;
}
if (size > aligned_size) {
IncrementCounter(this->counter);
aes128EncryptBlock(&this->aes_ctx, this->work[1], this->counter);
aes128EncryptBlock(std::addressof(this->aes_ctx), this->work[1], this->counter);
std::memcpy(cur_dst, this->work[1], size - aligned_size);
}