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) {