mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-09 22:56:35 +00:00
ams: replace most remaining operator & with std::addressof
This commit is contained in:
parent
ce8aacef21
commit
1ab0bd1765
109 changed files with 587 additions and 586 deletions
|
@ -221,7 +221,7 @@ namespace ams::secmon::fatal {
|
|||
const int prefix_len = std::strlen(automatic_backups_prefix);
|
||||
|
||||
for (size_t i = 0; i + prefix_len < f_ctx->stack_dump_size; ++i) {
|
||||
if (std::memcmp(&f_ctx->stack_dump[i], automatic_backups_prefix, prefix_len) == 0) {
|
||||
if (std::memcmp(f_ctx->stack_dump + i, automatic_backups_prefix, prefix_len) == 0) {
|
||||
suggestion = "The atmosphere directory may improperly have archive bits set.\n"
|
||||
"Please try running an archive bit fixer tool (for example, the one in Hekate).\n";
|
||||
break;
|
||||
|
|
|
@ -182,7 +182,7 @@ namespace ams::kern {
|
|||
|
||||
if (m_current_hints[which] + value <= m_limit_values[which] && (timeout < 0 || KHardwareTimer::GetTick() < timeout)) {
|
||||
m_waiter_count++;
|
||||
m_cond_var.Wait(&m_lock, timeout, false);
|
||||
m_cond_var.Wait(std::addressof(m_lock), timeout, false);
|
||||
m_waiter_count--;
|
||||
|
||||
if (GetCurrentThread().IsTerminationRequested()) {
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace ams::kern {
|
|||
const uintptr_t stack_bottom = stack_top - PageSize;
|
||||
|
||||
KPhysicalAddress stack_paddr = Null<KPhysicalAddress>;
|
||||
MESOSPHERE_ABORT_UNLESS(Kernel::GetKernelPageTable().GetPhysicalAddress(&stack_paddr, stack_bottom));
|
||||
MESOSPHERE_ABORT_UNLESS(Kernel::GetKernelPageTable().GetPhysicalAddress(std::addressof(stack_paddr), stack_bottom));
|
||||
|
||||
MESOSPHERE_R_ABORT_UNLESS(Kernel::GetKernelPageTable().UnmapPages(stack_bottom, 1, KMemoryState_Kernel));
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace ams::kern {
|
|||
|
||||
/* Get the physical address of the page. */
|
||||
KPhysicalAddress phys_addr = Null<KPhysicalAddress>;
|
||||
MESOSPHERE_ABORT_UNLESS(m_owner->GetPageTable().GetPhysicalAddress(&phys_addr, this->GetAddress()));
|
||||
MESOSPHERE_ABORT_UNLESS(m_owner->GetPageTable().GetPhysicalAddress(std::addressof(phys_addr), this->GetAddress()));
|
||||
|
||||
/* Unmap the page. */
|
||||
R_TRY(m_owner->GetPageTable().UnmapPages(this->GetAddress(), 1, KMemoryState_ThreadLocal));
|
||||
|
|
|
@ -129,6 +129,10 @@ hos_stratosphere_api.o: CXXFLAGS += -fno-lto
|
|||
init_operator_new.o: CXXFLAGS += -fno-lto
|
||||
init_libnx_shim.os.horizon.o: CXXFLAGS += -fno-lto
|
||||
|
||||
usb_remote_ds_endpoint.o: CXXFLAGS += -Wno-error=deprecated-declarations
|
||||
usb_remote_ds_interface.o: CXXFLAGS += -Wno-error=deprecated-declarations
|
||||
usb_remote_ds_service.o: CXXFLAGS += -Wno-error=deprecated-declarations
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%_bin.h %.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace ams::cfg {
|
|||
static_assert(util::is_pod<OverrideStatus>::value, "util::is_pod<OverrideStatus>::value");
|
||||
|
||||
constexpr inline bool operator==(const OverrideStatus &lhs, const OverrideStatus &rhs) {
|
||||
return std::memcmp(&lhs, &rhs, sizeof(lhs)) == 0;
|
||||
return std::memcmp(std::addressof(lhs), std::addressof(rhs), sizeof(lhs)) == 0;
|
||||
}
|
||||
|
||||
constexpr inline bool operator!=(const OverrideStatus &lhs, const OverrideStatus &rhs) {
|
||||
|
|
|
@ -169,7 +169,7 @@ namespace ams::fs {
|
|||
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
|
||||
|
||||
FsFile f;
|
||||
R_TRY(fsFsOpenFile(std::addressof(this->base_fs), sf_path.str, mode, &f));
|
||||
R_TRY(fsFsOpenFile(std::addressof(this->base_fs), sf_path.str, mode, std::addressof(f)));
|
||||
|
||||
auto file = std::make_unique<RemoteFile>(f);
|
||||
R_UNLESS(file != nullptr, fs::ResultAllocationFailureInNew());
|
||||
|
@ -183,7 +183,7 @@ namespace ams::fs {
|
|||
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
|
||||
|
||||
FsDir d;
|
||||
R_TRY(fsFsOpenDirectory(std::addressof(this->base_fs), sf_path.str, mode, &d));
|
||||
R_TRY(fsFsOpenDirectory(std::addressof(this->base_fs), sf_path.str, mode, std::addressof(d)));
|
||||
|
||||
auto dir = std::make_unique<RemoteDirectory>(d);
|
||||
R_UNLESS(dir != nullptr, fs::ResultAllocationFailureInNew());
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace ams::fssystem {
|
|||
Result IterateDirectoryRecursivelyImpl(fs::fsa::IFileSystem *fs, char *work_path, size_t work_path_size, fs::DirectoryEntry *dir_ent, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) {
|
||||
/* Open the directory. */
|
||||
std::unique_ptr<fs::fsa::IDirectory> dir;
|
||||
R_TRY(fs->OpenDirectory(&dir, work_path, fs::OpenDirectoryMode_All));
|
||||
R_TRY(fs->OpenDirectory(std::addressof(dir), work_path, fs::OpenDirectoryMode_All));
|
||||
|
||||
const size_t parent_len = strnlen(work_path, work_path_size - 1);
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace ams::fssystem {
|
|||
while (true) {
|
||||
/* Read a single entry. */
|
||||
s64 read_count = 0;
|
||||
R_TRY(dir->Read(&read_count, dir_ent, 1));
|
||||
R_TRY(dir->Read(std::addressof(read_count), dir_ent, 1));
|
||||
|
||||
/* If we're out of entries, we're done. */
|
||||
if (read_count == 0) {
|
||||
|
@ -106,7 +106,7 @@ namespace ams::fssystem {
|
|||
Result IterateDirectoryRecursively(fs::fsa::IFileSystem *fs, const char *root_path, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) {
|
||||
fs::DirectoryEntry dir_entry = {};
|
||||
char work_path[fs::EntryNameLengthMax + 1] = {};
|
||||
return IterateDirectoryRecursively(fs, root_path, work_path, sizeof(work_path), &dir_entry, on_enter_dir, on_exit_dir, on_file);
|
||||
return IterateDirectoryRecursively(fs, root_path, work_path, sizeof(work_path), std::addressof(dir_entry), on_enter_dir, on_exit_dir, on_file);
|
||||
}
|
||||
|
||||
template<typename OnEnterDir, typename OnExitDir, typename OnFile>
|
||||
|
|
|
@ -245,8 +245,8 @@ namespace ams::kvdb {
|
|||
static Result ValidateExistingCache(const char *dir) {
|
||||
/* Check for existence. */
|
||||
bool has_lru = false, has_kvs = false;
|
||||
R_TRY(FileExists(&has_lru, GetLeastRecentlyUsedListPath(dir)));
|
||||
R_TRY(DirectoryExists(&has_kvs, GetFileKeyValueStorePath(dir)));
|
||||
R_TRY(FileExists(std::addressof(has_lru), GetLeastRecentlyUsedListPath(dir)));
|
||||
R_TRY(DirectoryExists(std::addressof(has_kvs), GetFileKeyValueStorePath(dir)));
|
||||
|
||||
/* If neither exists, CreateNewCache was never called. */
|
||||
R_UNLESS(has_lru || has_kvs, kvdb::ResultNotCreated());
|
||||
|
|
|
@ -84,38 +84,38 @@ namespace ams::kvdb {
|
|||
template<typename Key>
|
||||
Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) {
|
||||
static_assert(util::is_pod<Key>::value && sizeof(Key) <= MaxKeySize, "Invalid FileKeyValueStore Key!");
|
||||
return this->Get(out_size, out_value, max_out_size, &key, sizeof(Key));
|
||||
return this->Get(out_size, out_value, max_out_size, std::addressof(key), sizeof(Key));
|
||||
}
|
||||
|
||||
template<typename Key, typename Value>
|
||||
Result Get(Value *out_value, const Key &key) {
|
||||
static_assert(util::is_pod<Value>::value && !std::is_pointer<Value>::value, "Invalid FileKeyValueStore Value!");
|
||||
size_t size = 0;
|
||||
R_TRY(this->Get(&size, out_value, sizeof(Value), key));
|
||||
R_TRY(this->Get(std::addressof(size), out_value, sizeof(Value), key));
|
||||
AMS_ABORT_UNLESS(size >= sizeof(Value));
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
template<typename Key>
|
||||
Result GetSize(size_t *out_size, const Key &key) {
|
||||
return this->GetSize(out_size, &key, sizeof(Key));
|
||||
return this->GetSize(out_size, std::addressof(key), sizeof(Key));
|
||||
}
|
||||
|
||||
template<typename Key>
|
||||
Result Set(const Key &key, const void *value, size_t value_size) {
|
||||
static_assert(util::is_pod<Key>::value && sizeof(Key) <= MaxKeySize, "Invalid FileKeyValueStore Key!");
|
||||
return this->Set(&key, sizeof(Key), value, value_size);
|
||||
return this->Set(std::addressof(key), sizeof(Key), value, value_size);
|
||||
}
|
||||
|
||||
template<typename Key, typename Value>
|
||||
Result Set(const Key &key, const Value &value) {
|
||||
static_assert(util::is_pod<Value>::value && !std::is_pointer<Value>::value, "Invalid FileKeyValueStore Value!");
|
||||
return this->Set(key, &value, sizeof(Value));
|
||||
return this->Set(key, std::addressof(value), sizeof(Value));
|
||||
}
|
||||
|
||||
template<typename Key>
|
||||
Result Remove(const Key &key) {
|
||||
return this->Remove(&key, sizeof(Key));
|
||||
return this->Remove(std::addressof(key), sizeof(Key));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ namespace ams::kvdb {
|
|||
/* Try to read the archive -- note, path not found is a success condition. */
|
||||
/* This is because no archive file = no entries, so we're in the right state. */
|
||||
AutoBuffer buffer;
|
||||
R_TRY_CATCH(this->ReadArchiveFile(&buffer)) {
|
||||
R_TRY_CATCH(this->ReadArchiveFile(std::addressof(buffer))) {
|
||||
R_CONVERT(fs::ResultPathNotFound, ResultSuccess());
|
||||
} R_END_TRY_CATCH;
|
||||
|
||||
|
@ -315,12 +315,12 @@ namespace ams::kvdb {
|
|||
ArchiveReader reader(buffer);
|
||||
|
||||
size_t entry_count = 0;
|
||||
R_TRY(reader.ReadEntryCount(&entry_count));
|
||||
R_TRY(reader.ReadEntryCount(std::addressof(entry_count)));
|
||||
|
||||
for (size_t i = 0; i < entry_count; i++) {
|
||||
/* Get size of key/value. */
|
||||
size_t key_size = 0, value_size = 0;
|
||||
R_TRY(reader.GetEntrySize(&key_size, &value_size));
|
||||
R_TRY(reader.GetEntrySize(std::addressof(key_size), std::addressof(value_size)));
|
||||
|
||||
/* Allocate memory for value. */
|
||||
void *new_value = this->memory_resource->Allocate(value_size);
|
||||
|
@ -329,7 +329,7 @@ namespace ams::kvdb {
|
|||
|
||||
/* Read key and value. */
|
||||
Key key;
|
||||
R_TRY(reader.ReadEntry(&key, sizeof(key), new_value, value_size));
|
||||
R_TRY(reader.ReadEntry(std::addressof(key), sizeof(key), new_value, value_size));
|
||||
R_TRY(this->index.AddUnsafe(key, new_value, value_size));
|
||||
|
||||
/* We succeeded, so cancel the value guard to prevent deallocation. */
|
||||
|
@ -351,7 +351,7 @@ namespace ams::kvdb {
|
|||
writer.WriteHeader(this->GetCount());
|
||||
for (const auto &it : this->index) {
|
||||
const auto &key = it.GetKey();
|
||||
writer.WriteEntry(&key, sizeof(Key), it.GetValuePointer(), it.GetValueSize());
|
||||
writer.WriteEntry(std::addressof(key), sizeof(Key), it.GetValuePointer(), it.GetValueSize());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@ namespace ams::kvdb {
|
|||
Result Set(const Key &key, const Value &value) {
|
||||
/* Only allow setting pod. */
|
||||
static_assert(util::is_pod<Value>::value, "KeyValueStore Values must be pod");
|
||||
return this->Set(key, &value, sizeof(Value));
|
||||
return this->Set(key, std::addressof(value), sizeof(Value));
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
|
|
|
@ -50,11 +50,11 @@ namespace ams::ncm {
|
|||
|
||||
void Store(ContentId content_id, ncm::RightsId rights_id) {
|
||||
std::scoped_lock lk(this->mutex);
|
||||
Entry *eviction_candidate = &this->entries[0];
|
||||
Entry *eviction_candidate = std::addressof(this->entries[0]);
|
||||
|
||||
/* Find a suitable existing entry to store our new one at. */
|
||||
for (size_t i = 1; i < MaxEntries; i++) {
|
||||
Entry *entry = &this->entries[i];
|
||||
Entry *entry = std::addressof(this->entries[i]);
|
||||
|
||||
/* Change eviction candidates if the uuid already matches ours, or if the uuid doesn't already match and the last_accessed count is lower */
|
||||
if (content_id == entry->uuid || (content_id != eviction_candidate->uuid && entry->last_accessed < eviction_candidate->last_accessed)) {
|
||||
|
@ -73,7 +73,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Attempt to locate the content id in the cache. */
|
||||
for (size_t i = 0; i < MaxEntries; i++) {
|
||||
Entry *entry = &this->entries[i];
|
||||
Entry *entry = std::addressof(this->entries[i]);
|
||||
|
||||
if (entry->last_accessed != 1 && content_id == entry->uuid) {
|
||||
entry->last_accessed = this->counter;
|
||||
|
|
|
@ -26,4 +26,4 @@
|
|||
|
||||
#include <stratosphere/rapidjson/rapidjson.h>
|
||||
#include <stratosphere/rapidjson/encodings.h>
|
||||
#include <stratosphere/rapidjson/reader.h>
|
||||
#include <stratosphere/rapidjson/reader.h>
|
||||
|
|
|
@ -190,7 +190,7 @@ namespace ams::ro {
|
|||
}
|
||||
|
||||
const ModuleId *GetModuleId() const {
|
||||
return &this->module_id;
|
||||
return std::addressof(this->module_id);
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(NroHeader) == 0x80, "NroHeader definition!");
|
||||
|
|
|
@ -116,7 +116,7 @@ namespace ams::sf::cmif {
|
|||
using DispatchTableType = DomainServiceObjectDispatchTable;
|
||||
static constexpr ProcessHandlerType ProcessHandlerImpl = &impl::ServiceDispatchTableBase::ProcessMessage<DispatchTableType>;
|
||||
|
||||
static constexpr inline ServiceDispatchMeta Meta{&DomainServiceObject::s_CmifServiceDispatchTable, ProcessHandlerImpl};
|
||||
static constexpr inline ServiceDispatchMeta Meta{std::addressof(DomainServiceObject::s_CmifServiceDispatchTable), ProcessHandlerImpl};
|
||||
};
|
||||
|
||||
template<>
|
||||
|
@ -127,7 +127,7 @@ namespace ams::sf::cmif {
|
|||
using DispatchTableType = DomainServiceObjectDispatchTable;
|
||||
static constexpr ProcessHandlerType ProcessHandlerImpl = &impl::ServiceDispatchTableBase::ProcessMessageForMitm<DispatchTableType>;
|
||||
|
||||
static constexpr inline ServiceDispatchMeta Meta{&DomainServiceObject::s_CmifServiceDispatchTable, ProcessHandlerImpl};
|
||||
static constexpr inline ServiceDispatchMeta Meta{std::addressof(DomainServiceObject::s_CmifServiceDispatchTable), ProcessHandlerImpl};
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ namespace ams::sf::cmif {
|
|||
static constexpr ProcessHandlerType ProcessHandlerImpl = sf::IsMitmServiceObject<T> ? (&impl::ServiceDispatchTableBase::ProcessMessageForMitm<DispatchTableType>)
|
||||
: (&impl::ServiceDispatchTableBase::ProcessMessage<DispatchTableType>);
|
||||
|
||||
static constexpr inline ServiceDispatchMeta Meta{&DispatchTable, ProcessHandlerImpl};
|
||||
static constexpr inline ServiceDispatchMeta Meta{std::addressof(DispatchTable), ProcessHandlerImpl};
|
||||
};
|
||||
|
||||
template<>
|
||||
|
@ -151,7 +151,7 @@ namespace ams::sf::cmif {
|
|||
|
||||
template<typename T>
|
||||
constexpr ALWAYS_INLINE const ServiceDispatchMeta *GetServiceDispatchMeta() {
|
||||
return &ServiceDispatchTraits<T>::Meta;
|
||||
return std::addressof(ServiceDispatchTraits<T>::Meta);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -760,7 +760,7 @@ namespace ams::sf::impl {
|
|||
template<size_t Index, typename Interface>
|
||||
Out<SharedPointer<Interface>> GetOutObject() {
|
||||
auto sp = std::construct_at(GetOutObjectSharedPointer<Index, Interface>());
|
||||
return Out<SharedPointer<Interface>>(sp, this->out_object_ids + Index);
|
||||
return Out<SharedPointer<Interface>>(sp, std::addressof(this->out_object_ids[Index]));
|
||||
}
|
||||
|
||||
template<size_t Index, typename Interface>
|
||||
|
@ -869,7 +869,7 @@ namespace ams::sf::impl {
|
|||
return;
|
||||
}
|
||||
os::NativeHandle server_handle, client_handle;
|
||||
R_ABORT_UNLESS(sf::hipc::CreateSession(&server_handle, &client_handle));
|
||||
R_ABORT_UNLESS(sf::hipc::CreateSession(std::addressof(server_handle), std::addressof(client_handle)));
|
||||
R_ABORT_UNLESS(manager->RegisterSession(server_handle, std::move(object)));
|
||||
response.move_handles[Index] = client_handle;
|
||||
}
|
||||
|
@ -1137,10 +1137,10 @@ namespace ams::sf::impl {
|
|||
ImplProcessorType impl_processor;
|
||||
if (ctx.processor == nullptr) {
|
||||
/* In the non-domain case, this is our only processor. */
|
||||
ctx.processor = &impl_processor;
|
||||
ctx.processor = std::addressof(impl_processor);
|
||||
} else {
|
||||
/* In the domain case, we already have a processor, so we should give it a pointer to our template implementation. */
|
||||
ctx.processor->SetImplementationProcessor(&impl_processor);
|
||||
ctx.processor->SetImplementationProcessor(std::addressof(impl_processor));
|
||||
}
|
||||
|
||||
/* Validate the metadata has the expected counts. */
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace ams::sm {
|
|||
static_assert(alignof(ServiceName) == 1, "ServiceName definition!");
|
||||
|
||||
inline bool operator==(const ServiceName &lhs, const ServiceName &rhs) {
|
||||
return std::memcmp(&lhs, &rhs, sizeof(ServiceName)) == 0;
|
||||
return std::memcmp(std::addressof(lhs), std::addressof(rhs), sizeof(ServiceName)) == 0;
|
||||
}
|
||||
|
||||
inline bool operator!=(const ServiceName &lhs, const ServiceName &rhs) {
|
||||
|
|
|
@ -78,10 +78,10 @@ namespace ams::emummc {
|
|||
struct {
|
||||
char file_path[MaxDirLen + 1];
|
||||
char nintendo_path[MaxDirLen + 1];
|
||||
} *paths = reinterpret_cast<decltype(paths)>(&path_storage);
|
||||
} *paths = reinterpret_cast<decltype(paths)>(std::addressof(path_storage));
|
||||
|
||||
/* Retrieve paths from secure monitor. */
|
||||
AMS_ABORT_UNLESS(spl::smc::AtmosphereGetEmummcConfig(&g_exo_config, paths, 0) == spl::smc::Result::Success);
|
||||
AMS_ABORT_UNLESS(spl::smc::AtmosphereGetEmummcConfig(std::addressof(g_exo_config), paths, 0) == spl::smc::Result::Success);
|
||||
|
||||
const Storage storage = static_cast<Storage>(g_exo_config.base_cfg.type);
|
||||
g_is_emummc = g_exo_config.base_cfg.magic == StorageMagic && storage != Storage_Emmc;
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace ams {
|
|||
svc::lp64::MemoryInfo mem_info;
|
||||
svc::PageInfo page_info;
|
||||
if (R_SUCCEEDED(svc::QueryMemory(std::addressof(mem_info), std::addressof(page_info), cur_fp)) && (mem_info.permission & svc::MemoryPermission_Read) == svc::MemoryPermission_Read) {
|
||||
std::memcpy(&cur_frame, reinterpret_cast<void *>(cur_fp), sizeof(cur_frame));
|
||||
std::memcpy(std::addressof(cur_frame), reinterpret_cast<void *>(cur_fp), sizeof(cur_frame));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ namespace ams {
|
|||
}
|
||||
|
||||
/* Just call the user exception handler. */
|
||||
::ams::ExceptionHandler(&ams_ctx);
|
||||
::ams::ExceptionHandler(std::addressof(ams_ctx));
|
||||
}
|
||||
|
||||
NORETURN void AbortImpl();
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace ams::exosphere {
|
|||
|
||||
ApiInfo GetApiInfo() {
|
||||
u64 exosphere_cfg;
|
||||
if (spl::smc::GetConfig(&exosphere_cfg, 1, spl::ConfigItem::ExosphereApiVersion) != spl::smc::Result::Success) {
|
||||
if (spl::smc::GetConfig(std::addressof(exosphere_cfg), 1, spl::ConfigItem::ExosphereApiVersion) != spl::smc::Result::Success) {
|
||||
R_ABORT_UNLESS(ResultNotPresent());
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ namespace ams::boot2 {
|
|||
if (IsAllowedLaunchProgram(loc)) {
|
||||
/* Launch, lightly validate result. */
|
||||
{
|
||||
const auto launch_result = pm::shell::LaunchProgram(&process_id, loc, launch_flags);
|
||||
const auto launch_result = pm::shell::LaunchProgram(std::addressof(process_id), loc, launch_flags);
|
||||
AMS_ABORT_UNLESS(!(svc::ResultOutOfResource::Includes(launch_result)));
|
||||
AMS_ABORT_UNLESS(!(svc::ResultOutOfMemory::Includes(launch_result)));
|
||||
AMS_ABORT_UNLESS(!(svc::ResultLimitReached::Includes(launch_result)));
|
||||
|
@ -178,13 +178,13 @@ namespace ams::boot2 {
|
|||
|
||||
bool IsForceMaintenance() {
|
||||
u8 force_maintenance = 1;
|
||||
settings::fwdbg::GetSettingsItemValue(&force_maintenance, sizeof(force_maintenance), "boot", "force_maintenance");
|
||||
settings::fwdbg::GetSettingsItemValue(std::addressof(force_maintenance), sizeof(force_maintenance), "boot", "force_maintenance");
|
||||
return force_maintenance != 0;
|
||||
}
|
||||
|
||||
bool IsHtcEnabled() {
|
||||
u8 enable_htc = 0;
|
||||
settings::fwdbg::GetSettingsItemValue(&enable_htc, sizeof(enable_htc), "atmosphere", "enable_htc");
|
||||
settings::fwdbg::GetSettingsItemValue(std::addressof(enable_htc), sizeof(enable_htc), "atmosphere", "enable_htc");
|
||||
return enable_htc != 0;
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ namespace ams::boot2 {
|
|||
}
|
||||
|
||||
u8 enable_ams_lm = 0;
|
||||
settings::fwdbg::GetSettingsItemValue(&enable_ams_lm, sizeof(enable_ams_lm), "atmosphere", "enable_log_manager");
|
||||
settings::fwdbg::GetSettingsItemValue(std::addressof(enable_ams_lm), sizeof(enable_ams_lm), "atmosphere", "enable_log_manager");
|
||||
return enable_ams_lm != 0;
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ namespace ams::boot2 {
|
|||
void IterateOverFlaggedProgramsOnSdCard(F f) {
|
||||
/* Validate that the contents directory exists. */
|
||||
fs::DirectoryHandle contents_dir;
|
||||
if (R_FAILED(fs::OpenDirectory(&contents_dir, "sdmc:/atmosphere/contents", fs::OpenDirectoryMode_Directory))) {
|
||||
if (R_FAILED(fs::OpenDirectory(std::addressof(contents_dir), "sdmc:/atmosphere/contents", fs::OpenDirectoryMode_Directory))) {
|
||||
return;
|
||||
}
|
||||
ON_SCOPE_EXIT { fs::CloseDirectory(contents_dir); };
|
||||
|
@ -223,7 +223,7 @@ namespace ams::boot2 {
|
|||
/* Iterate over entries in the contents directory */
|
||||
fs::DirectoryEntry entry;
|
||||
s64 count;
|
||||
while (R_SUCCEEDED(fs::ReadDirectory(&count, &entry, contents_dir, 1)) && count == 1) {
|
||||
while (R_SUCCEEDED(fs::ReadDirectory(std::addressof(count), std::addressof(entry), contents_dir, 1)) && count == 1) {
|
||||
/* Check that the subdirectory can be converted to a program id. */
|
||||
if (std::strlen(entry.name) == 2 * sizeof(ncm::ProgramId) && IsHexadecimal(entry.name)) {
|
||||
/* Check if we've already launched the program. */
|
||||
|
@ -252,12 +252,12 @@ namespace ams::boot2 {
|
|||
util::SNPrintf(path, sizeof(path), "sdmc:/atmosphere/contents/%016lx/mitm.lst", static_cast<u64>(program_id));
|
||||
|
||||
fs::FileHandle f;
|
||||
if (R_FAILED(fs::OpenFile(&f, path, fs::OpenMode_Read))) {
|
||||
if (R_FAILED(fs::OpenFile(std::addressof(f), path, fs::OpenMode_Read))) {
|
||||
return;
|
||||
}
|
||||
ON_SCOPE_EXIT { fs::CloseFile(f); };
|
||||
|
||||
R_ABORT_UNLESS(fs::ReadFile(&mitm_list_size, f, 0, mitm_list, sizeof(mitm_list)));
|
||||
R_ABORT_UNLESS(fs::ReadFile(std::addressof(mitm_list_size), f, 0, mitm_list, sizeof(mitm_list)));
|
||||
}
|
||||
|
||||
/* Validate read size. */
|
||||
|
@ -352,7 +352,7 @@ namespace ams::boot2 {
|
|||
|
||||
/* Retrieve setting from the database. */
|
||||
u8 force_maintenance = 0;
|
||||
settings::fwdbg::GetSettingsItemValue(&force_maintenance, sizeof(force_maintenance), "boot", "force_maintenance");
|
||||
settings::fwdbg::GetSettingsItemValue(std::addressof(force_maintenance), sizeof(force_maintenance), "boot", "force_maintenance");
|
||||
}
|
||||
|
||||
/* Launch pcv. */
|
||||
|
|
|
@ -121,7 +121,7 @@ namespace ams::capsrv::server::jpeg {
|
|||
cinfo.do_block_smoothing = input.block_smoothing;
|
||||
|
||||
/* Start decompression. */
|
||||
R_UNLESS(jpeg_start_decompress(&cinfo) == TRUE, capsrv::ResultAlbumInvalidFileData());
|
||||
R_UNLESS(jpeg_start_decompress(std::addressof(cinfo)) == TRUE, capsrv::ResultAlbumInvalidFileData());
|
||||
|
||||
/* Check the parameters. */
|
||||
CAPSRV_ASSERT(cinfo.output_width == input.width);
|
||||
|
@ -169,7 +169,7 @@ namespace ams::capsrv::server::jpeg {
|
|||
}
|
||||
|
||||
/* Finish the decompression. */
|
||||
R_UNLESS(jpeg_finish_decompress(&cinfo) == TRUE, capsrv::ResultAlbumInvalidFileData());
|
||||
R_UNLESS(jpeg_finish_decompress(std::addressof(cinfo)) == TRUE, capsrv::ResultAlbumInvalidFileData());
|
||||
} else {
|
||||
/* Some unknown error was caught by our handler. */
|
||||
return capsrv::ResultAlbumInvalidFileData();
|
||||
|
|
|
@ -373,9 +373,9 @@ namespace ams::cfg {
|
|||
.override_key = g_default_override_key,
|
||||
.cheat_enable_key = g_default_cheat_enable_key,
|
||||
};
|
||||
std::memset(&config.locale, 0xCC, sizeof(config.locale));
|
||||
std::memset(std::addressof(config.locale), 0xCC, sizeof(config.locale));
|
||||
|
||||
ParseIniFile(ContentSpecificIniHandler, path, &config);
|
||||
ParseIniFile(ContentSpecificIniHandler, path, std::addressof(config));
|
||||
return config;
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ namespace ams::cfg {
|
|||
RefreshOverrideConfiguration();
|
||||
|
||||
/* If we can't read the key state, don't override anything. */
|
||||
if (R_FAILED(hid::GetKeysHeld(&status.keys_held))) {
|
||||
if (R_FAILED(hid::GetKeysHeld(std::addressof(status.keys_held)))) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace ams::cfg {
|
|||
Result CheckSdCardServicesReady() {
|
||||
for (size_t i = 0; i < NumRequiredServicesForSdCardAccess; i++) {
|
||||
bool service_present = false;
|
||||
R_TRY(sm::HasService(&service_present, RequiredServicesForSdCardAccess[i]));
|
||||
R_TRY(sm::HasService(std::addressof(service_present), RequiredServicesForSdCardAccess[i]));
|
||||
if (!service_present) {
|
||||
return fs::ResultSdCardNotPresent();
|
||||
}
|
||||
|
@ -54,14 +54,14 @@ namespace ams::cfg {
|
|||
|
||||
Result TryInitializeSdCard() {
|
||||
R_TRY(CheckSdCardServicesReady());
|
||||
R_ABORT_UNLESS(fsOpenSdCardFileSystem(&g_sd_card_filesystem));
|
||||
R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(g_sd_card_filesystem)));
|
||||
g_sd_card_initialized = true;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
void InitializeSdCard() {
|
||||
WaitSdCardServicesReadyImpl();
|
||||
R_ABORT_UNLESS(fsOpenSdCardFileSystem(&g_sd_card_filesystem));
|
||||
R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(g_sd_card_filesystem)));
|
||||
g_sd_card_initialized = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace ams::fssrv::impl {
|
|||
R_UNLESS(size >= 0, fs::ResultInvalidSize());
|
||||
|
||||
size_t read_size = 0;
|
||||
R_TRY(this->base_file->Read(&read_size, offset, buffer.GetPointer(), static_cast<size_t>(size), option));
|
||||
R_TRY(this->base_file->Read(std::addressof(read_size), offset, buffer.GetPointer(), static_cast<size_t>(size), option));
|
||||
|
||||
out.SetValue(read_size);
|
||||
return ResultSuccess();
|
||||
|
@ -82,7 +82,7 @@ namespace ams::fssrv::impl {
|
|||
auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
|
||||
fs::FileQueryRangeInfo info;
|
||||
R_TRY(this->base_file->OperateRange(&info, sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0));
|
||||
R_TRY(this->base_file->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0));
|
||||
out->Merge(info);
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ namespace ams::fssrv::impl {
|
|||
|
||||
/* TODO: N retries on fs::ResultDataCorrupted, we may want to eventually. */
|
||||
std::unique_ptr<fs::fsa::IFile> file;
|
||||
R_TRY(this->base_fs->OpenFile(&file, normalizer.GetPath(), static_cast<fs::OpenMode>(mode)));
|
||||
R_TRY(this->base_fs->OpenFile(std::addressof(file), normalizer.GetPath(), static_cast<fs::OpenMode>(mode)));
|
||||
|
||||
/* TODO: This is a hack to get the mitm API to work. Better solution? */
|
||||
const auto target_object_id = file->GetDomainObjectId();
|
||||
|
@ -296,7 +296,7 @@ namespace ams::fssrv::impl {
|
|||
|
||||
/* TODO: N retries on fs::ResultDataCorrupted, we may want to eventually. */
|
||||
std::unique_ptr<fs::fsa::IDirectory> dir;
|
||||
R_TRY(this->base_fs->OpenDirectory(&dir, normalizer.GetPath(), static_cast<fs::OpenDirectoryMode>(mode)));
|
||||
R_TRY(this->base_fs->OpenDirectory(std::addressof(dir), normalizer.GetPath(), static_cast<fs::OpenDirectoryMode>(mode)));
|
||||
|
||||
/* TODO: This is a hack to get the mitm API to work. Better solution? */
|
||||
const auto target_object_id = dir->GetDomainObjectId();
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace ams::fssrv::impl {
|
|||
auto read_lock = this->AcquireCacheInvalidationReadLock();
|
||||
|
||||
fs::StorageQueryRangeInfo info;
|
||||
R_TRY(this->base_storage->OperateRange(&info, sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0));
|
||||
R_TRY(this->base_storage->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0));
|
||||
out->Merge(info);
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace ams::fssystem {
|
|||
fs::DirectoryEntryType type;
|
||||
|
||||
/* Check that the working directory exists. */
|
||||
R_TRY_CATCH(this->base_fs->GetEntryType(&type, WorkingDirectoryPath)) {
|
||||
R_TRY_CATCH(this->base_fs->GetEntryType(std::addressof(type), WorkingDirectoryPath)) {
|
||||
/* If path isn't found, create working directory and committed directory. */
|
||||
R_CATCH(fs::ResultPathNotFound) {
|
||||
R_TRY(this->base_fs->CreateDirectory(WorkingDirectoryPath));
|
||||
|
@ -105,7 +105,7 @@ namespace ams::fssystem {
|
|||
} R_END_TRY_CATCH;
|
||||
|
||||
/* Now check for the committed directory. */
|
||||
R_TRY_CATCH(this->base_fs->GetEntryType(&type, CommittedDirectoryPath)) {
|
||||
R_TRY_CATCH(this->base_fs->GetEntryType(std::addressof(type), CommittedDirectoryPath)) {
|
||||
/* Committed doesn't exist, so synchronize and rename. */
|
||||
R_CATCH(fs::ResultPathNotFound) {
|
||||
R_TRY(this->SynchronizeDirectory(SynchronizingDirectoryPath, WorkingDirectoryPath));
|
||||
|
@ -148,7 +148,7 @@ namespace ams::fssystem {
|
|||
/* Get a work buffer to work with. */
|
||||
std::unique_ptr<u8[]> work_buf;
|
||||
size_t work_buf_size;
|
||||
R_TRY(this->AllocateWorkBuffer(&work_buf, &work_buf_size, IdealWorkBufferSize));
|
||||
R_TRY(this->AllocateWorkBuffer(std::addressof(work_buf), std::addressof(work_buf_size), IdealWorkBufferSize));
|
||||
|
||||
/* Copy the directory recursively. */
|
||||
return fssystem::CopyDirectoryRecursively(this->base_fs, dst, src, work_buf.get(), work_buf_size);
|
||||
|
@ -165,7 +165,7 @@ namespace ams::fssystem {
|
|||
/* Normalize it. */
|
||||
constexpr size_t WorkingDirectoryPathLength = sizeof(WorkingDirectoryPath) - 1;
|
||||
size_t normalized_length;
|
||||
return fs::PathNormalizer::Normalize(out + WorkingDirectoryPathLength - 1, &normalized_length, relative_path, out_size - (WorkingDirectoryPathLength - 1));
|
||||
return fs::PathNormalizer::Normalize(out + WorkingDirectoryPathLength - 1, std::addressof(normalized_length), relative_path, out_size - (WorkingDirectoryPathLength - 1));
|
||||
}
|
||||
|
||||
void DirectorySaveDataFileSystem::OnWritableFileClose() {
|
||||
|
@ -183,7 +183,7 @@ namespace ams::fssystem {
|
|||
/* Get a work buffer to work with. */
|
||||
std::unique_ptr<u8[]> work_buf;
|
||||
size_t work_buf_size;
|
||||
R_TRY(this->AllocateWorkBuffer(&work_buf, &work_buf_size, IdealWorkBufferSize));
|
||||
R_TRY(this->AllocateWorkBuffer(std::addressof(work_buf), std::addressof(work_buf_size), IdealWorkBufferSize));
|
||||
|
||||
/* Copy the directory recursively. */
|
||||
R_TRY(fssystem::CopyDirectoryRecursively(this->base_fs, save_fs, fs::PathNormalizer::RootPath, fs::PathNormalizer::RootPath, work_buf.get(), work_buf_size));
|
||||
|
@ -198,7 +198,7 @@ namespace ams::fssystem {
|
|||
|
||||
std::scoped_lock lk(this->accessor_mutex);
|
||||
std::unique_ptr<fs::fsa::IFile> base_file;
|
||||
R_TRY(this->base_fs->OpenFile(&base_file, full_path, mode));
|
||||
R_TRY(this->base_fs->OpenFile(std::addressof(base_file), full_path, mode));
|
||||
|
||||
std::unique_ptr<DirectorySaveDataFile> file(new (std::nothrow) DirectorySaveDataFile(std::move(base_file), this, mode));
|
||||
R_UNLESS(file != nullptr, fs::ResultAllocationFailureInDirectorySaveDataFileSystem());
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace ams::fssystem {
|
|||
Result CopyFile(fs::fsa::IFileSystem *dst_fs, fs::fsa::IFileSystem *src_fs, const char *dst_parent_path, const char *src_path, const fs::DirectoryEntry *entry, void *work_buf, size_t work_buf_size) {
|
||||
/* Open source file. */
|
||||
std::unique_ptr<fs::fsa::IFile> src_file;
|
||||
R_TRY(src_fs->OpenFile(&src_file, src_path, fs::OpenMode_Read));
|
||||
R_TRY(src_fs->OpenFile(std::addressof(src_file), src_path, fs::OpenMode_Read));
|
||||
|
||||
/* Open dst file. */
|
||||
std::unique_ptr<fs::fsa::IFile> dst_file;
|
||||
|
@ -83,7 +83,7 @@ namespace ams::fssystem {
|
|||
AMS_ABORT_UNLESS(original_size < sizeof(dst_path));
|
||||
|
||||
R_TRY(dst_fs->CreateFile(dst_path, entry->file_size));
|
||||
R_TRY(dst_fs->OpenFile(&dst_file, dst_path, fs::OpenMode_Write));
|
||||
R_TRY(dst_fs->OpenFile(std::addressof(dst_file), dst_path, fs::OpenMode_Write));
|
||||
}
|
||||
|
||||
/* Read/Write file in work buffer sized chunks. */
|
||||
|
@ -91,7 +91,7 @@ namespace ams::fssystem {
|
|||
s64 offset = 0;
|
||||
while (remaining > 0) {
|
||||
size_t read_size;
|
||||
R_TRY(src_file->Read(&read_size, offset, work_buf, work_buf_size, fs::ReadOption()));
|
||||
R_TRY(src_file->Read(std::addressof(read_size), offset, work_buf, work_buf_size, fs::ReadOption()));
|
||||
R_TRY(dst_file->Write(offset, work_buf, read_size, fs::WriteOption()));
|
||||
|
||||
remaining -= read_size;
|
||||
|
@ -132,7 +132,7 @@ namespace ams::fssystem {
|
|||
return ResultSuccess();
|
||||
},
|
||||
[&](const char *path, const fs::DirectoryEntry &entry) -> Result { /* On File */
|
||||
return CopyFile(dst_fs, src_fs, dst_path_buf, path, &entry, work_buf, work_buf_size);
|
||||
return CopyFile(dst_fs, src_fs, dst_path_buf, path, std::addressof(entry), work_buf, work_buf_size);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace ams::kvdb {
|
|||
|
||||
/* Read and validate header. */
|
||||
ArchiveHeader header;
|
||||
R_TRY(this->Read(&header, sizeof(header)));
|
||||
R_TRY(this->Read(std::addressof(header), sizeof(header)));
|
||||
R_TRY(header.Validate());
|
||||
|
||||
*out = header.entry_count;
|
||||
|
@ -100,7 +100,7 @@ namespace ams::kvdb {
|
|||
|
||||
/* Peek the next entry header. */
|
||||
ArchiveEntryHeader header;
|
||||
R_TRY(this->Peek(&header, sizeof(header)));
|
||||
R_TRY(this->Peek(std::addressof(header), sizeof(header)));
|
||||
R_TRY(header.Validate());
|
||||
|
||||
*out_key_size = header.key_size;
|
||||
|
@ -114,7 +114,7 @@ namespace ams::kvdb {
|
|||
|
||||
/* Read the next entry header. */
|
||||
ArchiveEntryHeader header;
|
||||
R_TRY(this->Read(&header, sizeof(header)));
|
||||
R_TRY(this->Read(std::addressof(header), sizeof(header)));
|
||||
R_TRY(header.Validate());
|
||||
|
||||
/* Key size and Value size must be correct. */
|
||||
|
@ -142,7 +142,7 @@ namespace ams::kvdb {
|
|||
AMS_ABORT_UNLESS(this->offset == 0);
|
||||
|
||||
ArchiveHeader header = ArchiveHeader::Make(entry_count);
|
||||
R_ABORT_UNLESS(this->Write(&header, sizeof(header)));
|
||||
R_ABORT_UNLESS(this->Write(std::addressof(header), sizeof(header)));
|
||||
}
|
||||
|
||||
void ArchiveWriter::WriteEntry(const void *key, size_t key_size, const void *value, size_t value_size) {
|
||||
|
@ -150,7 +150,7 @@ namespace ams::kvdb {
|
|||
AMS_ABORT_UNLESS(this->offset != 0);
|
||||
|
||||
ArchiveEntryHeader header = ArchiveEntryHeader::Make(key_size, value_size);
|
||||
R_ABORT_UNLESS(this->Write(&header, sizeof(header)));
|
||||
R_ABORT_UNLESS(this->Write(std::addressof(header), sizeof(header)));
|
||||
R_ABORT_UNLESS(this->Write(key, key_size));
|
||||
R_ABORT_UNLESS(this->Write(value, value_size));
|
||||
}
|
||||
|
|
|
@ -24,12 +24,12 @@ namespace ams::ldr::pm {
|
|||
}
|
||||
|
||||
Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc) {
|
||||
return ldrPmGetProgramInfo(reinterpret_cast<const NcmProgramLocation *>(&loc), reinterpret_cast<LoaderProgramInfo *>(out));
|
||||
return ldrPmGetProgramInfo(reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)), reinterpret_cast<LoaderProgramInfo *>(out));
|
||||
}
|
||||
|
||||
Result PinProgram(PinId *out, const ncm::ProgramLocation &loc) {
|
||||
static_assert(sizeof(*out) == sizeof(u64), "PinId definition!");
|
||||
return ldrPmPinProgram(reinterpret_cast<const NcmProgramLocation *>(&loc), reinterpret_cast<u64 *>(out));
|
||||
return ldrPmPinProgram(reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)), reinterpret_cast<u64 *>(out));
|
||||
}
|
||||
|
||||
Result UnpinProgram(PinId pin_id) {
|
||||
|
@ -42,7 +42,7 @@ namespace ams::ldr::pm {
|
|||
|
||||
Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) {
|
||||
static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!");
|
||||
return ldrPmAtmosphereGetProgramInfo(reinterpret_cast<LoaderProgramInfo *>(out), reinterpret_cast<CfgOverrideStatus *>(out_status), reinterpret_cast<const NcmProgramLocation *>(&loc));
|
||||
return ldrPmAtmosphereGetProgramInfo(reinterpret_cast<LoaderProgramInfo *>(out), reinterpret_cast<CfgOverrideStatus *>(out_status), reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)));
|
||||
}
|
||||
|
||||
Result SetEnabledProgramVerification(bool enabled) {
|
||||
|
@ -52,7 +52,7 @@ namespace ams::ldr::pm {
|
|||
Result AtmospherePinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status) {
|
||||
static_assert(sizeof(*out) == sizeof(u64), "PinId definition!");
|
||||
static_assert(sizeof(status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!");
|
||||
return ldrPmAtmospherePinProgram(reinterpret_cast<u64 *>(out), reinterpret_cast<const NcmProgramLocation *>(&loc), reinterpret_cast<const CfgOverrideStatus *>(&status));
|
||||
return ldrPmAtmospherePinProgram(reinterpret_cast<u64 *>(out), reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)), reinterpret_cast<const CfgOverrideStatus *>(std::addressof(status)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,10 +43,10 @@ namespace ams::lm {
|
|||
u64 pid_placeholder = 0;
|
||||
|
||||
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||
R_TRY(serviceDispatchIn(&m_srv, 0, pid_placeholder,
|
||||
R_TRY(serviceDispatchIn(std::addressof(m_srv), 0, pid_placeholder,
|
||||
.in_send_pid = true,
|
||||
.out_num_objects = 1,
|
||||
.out_objects = &logger_srv,
|
||||
.out_objects = std::addressof(logger_srv),
|
||||
));
|
||||
#undef NX_SERVICE_ASSUME_NON_DOMAIN
|
||||
}
|
||||
|
|
|
@ -32,14 +32,14 @@ namespace ams::lm {
|
|||
public:
|
||||
/* Actual commands. */
|
||||
Result Log(const sf::InAutoSelectBuffer &message) {
|
||||
return serviceDispatch(&m_srv, 0,
|
||||
return serviceDispatch(std::addressof(m_srv), 0,
|
||||
.buffer_attrs = { SfBufferAttr_In | SfBufferAttr_HipcAutoSelect },
|
||||
.buffers = { { message.GetPointer(), message.GetSize() } },
|
||||
);
|
||||
}
|
||||
|
||||
Result SetDestination(u32 destination) {
|
||||
return serviceDispatchIn(&m_srv, 1, destination);
|
||||
return serviceDispatchIn(std::addressof(m_srv), 1, destination);
|
||||
}
|
||||
};
|
||||
static_assert(lm::IsILogger<RemoteLogger>);
|
||||
|
|
|
@ -43,11 +43,11 @@ namespace ams::lmem::impl {
|
|||
}
|
||||
|
||||
constexpr inline ExpHeapHead *GetExpHeapHead(HeapHead *heap_head) {
|
||||
return &heap_head->impl_head.exp_heap_head;
|
||||
return std::addressof(heap_head->impl_head.exp_heap_head);
|
||||
}
|
||||
|
||||
constexpr inline const ExpHeapHead *GetExpHeapHead(const HeapHead *heap_head) {
|
||||
return &heap_head->impl_head.exp_heap_head;
|
||||
return std::addressof(heap_head->impl_head.exp_heap_head);
|
||||
}
|
||||
|
||||
constexpr inline HeapHead *GetHeapHead(ExpHeapHead *exp_heap_head) {
|
||||
|
@ -197,7 +197,7 @@ namespace ams::lmem::impl {
|
|||
|
||||
/* Locate the block. */
|
||||
for (auto it = head->free_list.begin(); it != head->free_list.end(); it++) {
|
||||
ExpHeapMemoryBlockHead *cur_free_block = &*it;
|
||||
ExpHeapMemoryBlockHead *cur_free_block = std::addressof(*it);
|
||||
|
||||
if (cur_free_block < region->start) {
|
||||
prev_free_block_it = it;
|
||||
|
@ -220,9 +220,9 @@ namespace ams::lmem::impl {
|
|||
auto insertion_it = head->free_list.begin();
|
||||
if (prev_free_block_it != head->free_list.end()) {
|
||||
/* There's a previous free block, so we want to insert as the next iterator. */
|
||||
if (GetMemoryBlockEnd(&*prev_free_block_it) == region->start) {
|
||||
if (GetMemoryBlockEnd(std::addressof(*prev_free_block_it)) == region->start) {
|
||||
/* We can coalesce, so do so. */
|
||||
free_region.start = &*prev_free_block_it;
|
||||
free_region.start = std::addressof(*prev_free_block_it);
|
||||
insertion_it = head->free_list.erase(prev_free_block_it);
|
||||
} else {
|
||||
/* We can't coalesce, so just select the next iterator. */
|
||||
|
@ -249,7 +249,7 @@ namespace ams::lmem::impl {
|
|||
void *ConvertFreeBlockToUsedBlock(ExpHeapHead *head, ExpHeapMemoryBlockHead *block_head, void *block, size_t size, AllocationDirection direction) {
|
||||
/* Calculate freed memory regions. */
|
||||
MemoryRegion free_region_front;
|
||||
GetMemoryBlockRegion(&free_region_front, block_head);
|
||||
GetMemoryBlockRegion(std::addressof(free_region_front), block_head);
|
||||
MemoryRegion free_region_back{ .start = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(block) + size), .end = free_region_front.end, };
|
||||
|
||||
/* Adjust end of head region. */
|
||||
|
@ -308,12 +308,12 @@ namespace ams::lmem::impl {
|
|||
size_t best_size = std::numeric_limits<size_t>::max();
|
||||
|
||||
for (auto it = exp_heap_head->free_list.begin(); it != exp_heap_head->free_list.end(); it++) {
|
||||
const uintptr_t absolute_block_start = reinterpret_cast<uintptr_t>(GetMemoryBlockStart(&*it));
|
||||
const uintptr_t absolute_block_start = reinterpret_cast<uintptr_t>(GetMemoryBlockStart(std::addressof(*it)));
|
||||
const uintptr_t block_start = util::AlignUp(absolute_block_start, alignment);
|
||||
const size_t block_offset = block_start - absolute_block_start;
|
||||
|
||||
if (it->block_size >= size + block_offset && best_size > it->block_size) {
|
||||
found_block_head = &*it;
|
||||
found_block_head = std::addressof(*it);
|
||||
found_block = reinterpret_cast<void *>(block_start);
|
||||
best_size = it->block_size;
|
||||
|
||||
|
@ -342,12 +342,12 @@ namespace ams::lmem::impl {
|
|||
size_t best_size = std::numeric_limits<size_t>::max();
|
||||
|
||||
for (auto it = exp_heap_head->free_list.rbegin(); it != exp_heap_head->free_list.rend(); it++) {
|
||||
const uintptr_t absolute_block_start = reinterpret_cast<uintptr_t>(GetMemoryBlockStart(&*it));
|
||||
const uintptr_t absolute_block_start = reinterpret_cast<uintptr_t>(GetMemoryBlockStart(std::addressof(*it)));
|
||||
const uintptr_t block_start = util::AlignUp(absolute_block_start, alignment);
|
||||
const size_t block_offset = block_start - absolute_block_start;
|
||||
|
||||
if (it->block_size >= size + block_offset && best_size > it->block_size) {
|
||||
found_block_head = &*it;
|
||||
found_block_head = std::addressof(*it);
|
||||
found_block = reinterpret_cast<void *>(block_start);
|
||||
best_size = it->block_size;
|
||||
|
||||
|
@ -396,7 +396,7 @@ namespace ams::lmem::impl {
|
|||
}
|
||||
|
||||
/* Get the memory block end, make sure it really is the last block. */
|
||||
ExpHeapMemoryBlockHead *block = &exp_heap_head->free_list.back();
|
||||
ExpHeapMemoryBlockHead *block = std::addressof(exp_heap_head->free_list.back());
|
||||
void * const block_start = GetMemoryBlockStart(block);
|
||||
const size_t block_size = block->block_size;
|
||||
void * const block_end = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(block_start) + block_size);
|
||||
|
@ -460,11 +460,11 @@ namespace ams::lmem::impl {
|
|||
MemoryRegion region;
|
||||
|
||||
/* Erase the heap from the used list, and coalesce it with adjacent blocks. */
|
||||
GetMemoryBlockRegion(®ion, block);
|
||||
GetMemoryBlockRegion(std::addressof(region), block);
|
||||
exp_heap_head->used_list.erase(exp_heap_head->used_list.iterator_to(*block));
|
||||
|
||||
/* Coalesce with adjacent blocks. */
|
||||
const bool coalesced = CoalesceFreedRegion(exp_heap_head, ®ion);
|
||||
const bool coalesced = CoalesceFreedRegion(exp_heap_head, std::addressof(region));
|
||||
AMS_ASSERT(coalesced);
|
||||
AMS_UNUSED(coalesced);
|
||||
}
|
||||
|
@ -493,8 +493,8 @@ namespace ams::lmem::impl {
|
|||
ExpHeapMemoryBlockHead *next_block_head = nullptr;
|
||||
|
||||
for (auto it = exp_heap_head->free_list.begin(); it != exp_heap_head->free_list.end(); it++) {
|
||||
if (&*it == cur_block_end) {
|
||||
next_block_head = &*it;
|
||||
if (std::addressof(*it) == cur_block_end) {
|
||||
next_block_head = std::addressof(*it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ namespace ams::lmem::impl {
|
|||
{
|
||||
/* Get block region. */
|
||||
MemoryRegion new_free_region;
|
||||
GetMemoryBlockRegion(&new_free_region, next_block_head);
|
||||
GetMemoryBlockRegion(std::addressof(new_free_region), next_block_head);
|
||||
|
||||
/* Remove the next block from the free list. */
|
||||
auto insertion_it = exp_heap_head->free_list.erase(exp_heap_head->free_list.iterator_to(*next_block_head));
|
||||
|
@ -539,7 +539,7 @@ namespace ams::lmem::impl {
|
|||
|
||||
/* Try to free the new memory. */
|
||||
block_head->block_size = size;
|
||||
if (!CoalesceFreedRegion(exp_heap_head, &new_free_region)) {
|
||||
if (!CoalesceFreedRegion(exp_heap_head, std::addressof(new_free_region))) {
|
||||
/* We didn't shrink the block successfully, so restore the size. */
|
||||
block_head->block_size = original_block_size;
|
||||
}
|
||||
|
@ -567,9 +567,9 @@ namespace ams::lmem::impl {
|
|||
size_t max_size = std::numeric_limits<size_t>::min();
|
||||
size_t min_offset = std::numeric_limits<size_t>::max();
|
||||
for (const auto &it : GetExpHeapHead(handle)->free_list) {
|
||||
const uintptr_t absolute_block_start = reinterpret_cast<uintptr_t>(GetMemoryBlockStart(&it));
|
||||
const uintptr_t absolute_block_start = reinterpret_cast<uintptr_t>(GetMemoryBlockStart(std::addressof(it)));
|
||||
const uintptr_t block_start = util::AlignUp(absolute_block_start, alignment);
|
||||
const uintptr_t block_end = reinterpret_cast<uintptr_t>(GetMemoryBlockEnd(&it));
|
||||
const uintptr_t block_end = reinterpret_cast<uintptr_t>(GetMemoryBlockEnd(std::addressof(it)));
|
||||
|
||||
if (block_start < block_end) {
|
||||
const size_t block_size = GetPointerDifference(block_start, block_end);
|
||||
|
@ -620,7 +620,7 @@ namespace ams::lmem::impl {
|
|||
AMS_ASSERT(IsValidHeapHandle(handle));
|
||||
|
||||
for (auto &it : GetExpHeapHead(handle)->used_list) {
|
||||
(*visitor)(GetMemoryBlockStart(&it), handle, user_data);
|
||||
(*visitor)(GetMemoryBlockStart(std::addressof(it)), handle, user_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@ namespace ams::lmem::impl {
|
|||
}
|
||||
|
||||
constexpr inline UnitHeapHead *GetUnitHeapHead(HeapHead *heap_head) {
|
||||
return &heap_head->impl_head.unit_heap_head;
|
||||
return std::addressof(heap_head->impl_head.unit_heap_head);
|
||||
}
|
||||
|
||||
constexpr inline const UnitHeapHead *GetUnitHeapHead(const HeapHead *heap_head) {
|
||||
return &heap_head->impl_head.unit_heap_head;
|
||||
return std::addressof(heap_head->impl_head.unit_heap_head);
|
||||
}
|
||||
|
||||
inline UnitHead *PopUnit(UnitHeapList *list) {
|
||||
|
@ -190,7 +190,7 @@ namespace ams::lmem::impl {
|
|||
|
||||
/* Allocate a unit. */
|
||||
UnitHeapHead *unit_heap = GetUnitHeapHead(handle);
|
||||
UnitHead *unit = PopUnit(&unit_heap->free_list);
|
||||
UnitHead *unit = PopUnit(std::addressof(unit_heap->free_list));
|
||||
if (unit != nullptr) {
|
||||
/* Fill memory with pattern for debug, if needed. */
|
||||
FillAllocatedMemory(handle, unit, unit_heap->unit_size);
|
||||
|
@ -215,7 +215,7 @@ namespace ams::lmem::impl {
|
|||
FillFreedMemory(handle, block, unit_heap->unit_size);
|
||||
|
||||
/* Push the unit onto the free list. */
|
||||
PushUnit(&unit_heap->free_list, reinterpret_cast<UnitHead *>(block));
|
||||
PushUnit(std::addressof(unit_heap->free_list), static_cast<UnitHead *>(block));
|
||||
|
||||
/* Note that we freed a unit. */
|
||||
unit_heap->num_units--;
|
||||
|
|
|
@ -21,19 +21,19 @@ namespace ams::lr {
|
|||
Result AddOnContentLocationResolverImpl::ResolveAddOnContentPath(sf::Out<Path> out, ncm::DataId id) {
|
||||
/* Find a storage that contains the given program id. */
|
||||
ncm::StorageId storage_id = ncm::StorageId::None;
|
||||
R_UNLESS(this->registered_storages.Find(&storage_id, id), lr::ResultAddOnContentNotFound());
|
||||
R_UNLESS(this->registered_storages.Find(std::addressof(storage_id), id), lr::ResultAddOnContentNotFound());
|
||||
|
||||
/* Obtain a content meta database for the storage id. */
|
||||
ncm::ContentMetaDatabase content_meta_database;
|
||||
R_TRY(ncm::OpenContentMetaDatabase(&content_meta_database, storage_id));
|
||||
R_TRY(ncm::OpenContentMetaDatabase(std::addressof(content_meta_database), storage_id));
|
||||
|
||||
/* Find the latest data content id for the given program id. */
|
||||
ncm::ContentId data_content_id;
|
||||
R_TRY(content_meta_database.GetLatestData(&data_content_id, id));
|
||||
R_TRY(content_meta_database.GetLatestData(std::addressof(data_content_id), id));
|
||||
|
||||
/* Obtain a content storage for the storage id. */
|
||||
ncm::ContentStorage content_storage;
|
||||
R_TRY(ncm::OpenContentStorage(&content_storage, storage_id));
|
||||
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), storage_id));
|
||||
|
||||
/* Get the path of the data content. */
|
||||
static_assert(sizeof(lr::Path) == sizeof(ncm::Path));
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace ams::lr {
|
|||
|
||||
/* Find the latest program content for the program id. */
|
||||
ncm::ContentId program_content_id;
|
||||
R_TRY_CATCH(this->content_meta_database.GetLatestProgram(&program_content_id, id)) {
|
||||
R_TRY_CATCH(this->content_meta_database.GetLatestProgram(std::addressof(program_content_id), id)) {
|
||||
R_CONVERT(ncm::ResultContentMetaNotFound, lr::ResultProgramNotFound())
|
||||
} R_END_TRY_CATCH;
|
||||
|
||||
|
@ -62,7 +62,7 @@ namespace ams::lr {
|
|||
Result ContentLocationResolverImpl::ResolveDataPath(sf::Out<Path> out, ncm::DataId id) {
|
||||
/* Find the latest data content for the program id. */
|
||||
ncm::ContentId data_content_id;
|
||||
R_TRY(this->content_meta_database.GetLatestData(&data_content_id, id));
|
||||
R_TRY(this->content_meta_database.GetLatestData(std::addressof(data_content_id), id));
|
||||
|
||||
/* Obtain the content path. */
|
||||
this->GetContentStoragePath(out.GetPointer(), data_content_id);
|
||||
|
@ -109,8 +109,8 @@ namespace ams::lr {
|
|||
/* Obtain content meta database and content storage objects for this resolver's storage. */
|
||||
ncm::ContentMetaDatabase meta_db;
|
||||
ncm::ContentStorage storage;
|
||||
R_TRY(ncm::OpenContentMetaDatabase(&meta_db, this->storage_id));
|
||||
R_TRY(ncm::OpenContentStorage(&storage, this->storage_id));
|
||||
R_TRY(ncm::OpenContentMetaDatabase(std::addressof(meta_db), this->storage_id));
|
||||
R_TRY(ncm::OpenContentStorage(std::addressof(storage), this->storage_id));
|
||||
|
||||
/* Store the acquired objects. */
|
||||
this->content_meta_database = std::move(meta_db);
|
||||
|
|
|
@ -84,13 +84,13 @@ namespace ams::lr {
|
|||
}
|
||||
}
|
||||
|
||||
void LocationRedirector::EraseRedirection(ncm::ProgramId program_id)
|
||||
{
|
||||
void LocationRedirector::EraseRedirection(ncm::ProgramId program_id) {
|
||||
/* Remove any redirections with a matching program id. */
|
||||
for (auto &redirection : this->redirection_list) {
|
||||
if (redirection.GetProgramId() == program_id) {
|
||||
this->redirection_list.erase(this->redirection_list.iterator_to(redirection));
|
||||
delete &redirection;
|
||||
for (auto it = this->redirection_list.begin(); it != this->redirection_list.end();) {
|
||||
if (it->GetProgramId() == program_id) {
|
||||
auto *redirection = std::addressof(*it);
|
||||
this->redirection_list.erase(it);
|
||||
delete redirection;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -100,9 +100,9 @@ namespace ams::lr {
|
|||
/* Remove any redirections with matching flags. */
|
||||
for (auto it = this->redirection_list.begin(); it != this->redirection_list.end();) {
|
||||
if ((it->GetFlags() & flags) == flags) {
|
||||
auto old = it;
|
||||
auto *redirection = std::addressof(*it);
|
||||
it = this->redirection_list.erase(it);
|
||||
delete std::addressof(*old);
|
||||
delete redirection;
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
|
@ -118,9 +118,9 @@ namespace ams::lr {
|
|||
}
|
||||
|
||||
/* Remove the redirection. */
|
||||
auto old = it;
|
||||
auto *redirection = std::addressof(*it);
|
||||
it = this->redirection_list.erase(it);
|
||||
delete std::addressof(*old);
|
||||
delete redirection;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace ams::lr {
|
|||
public:
|
||||
RemoteLocationResolverImpl(::LrLocationResolver &l) : srv(l) { /* ... */ }
|
||||
|
||||
~RemoteLocationResolverImpl() { ::serviceClose(&srv.s); }
|
||||
~RemoteLocationResolverImpl() { ::serviceClose(std::addressof(srv.s)); }
|
||||
public:
|
||||
/* Actual commands. */
|
||||
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace ams::lr {
|
|||
public:
|
||||
RemoteRegisteredLocationResolverImpl(::LrRegisteredLocationResolver &l) : srv(l) { /* ... */ }
|
||||
|
||||
~RemoteRegisteredLocationResolverImpl() { ::serviceClose(&srv.s); }
|
||||
~RemoteRegisteredLocationResolverImpl() { ::serviceClose(std::addressof(srv.s)); }
|
||||
public:
|
||||
/* Actual commands. */
|
||||
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {
|
||||
|
|
|
@ -251,7 +251,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Obtain the content meta database root. */
|
||||
ContentMetaDatabaseRoot *root;
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
|
||||
|
||||
/* Print the savedata path. */
|
||||
PathString savedata_db_path;
|
||||
|
@ -331,14 +331,14 @@ namespace ams::ncm {
|
|||
}
|
||||
|
||||
/* First, setup the BuiltInSystem storage entry. */
|
||||
R_TRY(this->InitializeContentStorageRoot(&this->content_storage_roots[this->num_content_storage_entries++], StorageId::BuiltInSystem, fs::ContentStorageId::System));
|
||||
R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[this->num_content_storage_entries++]), StorageId::BuiltInSystem, fs::ContentStorageId::System));
|
||||
if (R_FAILED(this->VerifyContentStorage(StorageId::BuiltInSystem))) {
|
||||
R_TRY(this->CreateContentStorage(StorageId::BuiltInSystem));
|
||||
}
|
||||
R_TRY(this->ActivateContentStorage(StorageId::BuiltInSystem));
|
||||
|
||||
/* Next, the BuiltInSystem content meta entry. */
|
||||
R_TRY(this->InitializeContentMetaDatabaseRoot(&this->content_meta_database_roots[this->num_content_meta_entries++], StorageId::BuiltInSystem, BuiltInSystemSystemSaveDataInfo, SystemMaxContentMetaCount, std::addressof(g_system_content_meta_memory_resource)));
|
||||
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[this->num_content_meta_entries++]), StorageId::BuiltInSystem, BuiltInSystemSystemSaveDataInfo, SystemMaxContentMetaCount, std::addressof(g_system_content_meta_memory_resource)));
|
||||
|
||||
if (R_FAILED(this->VerifyContentMetaDatabase(StorageId::BuiltInSystem))) {
|
||||
R_TRY(this->CreateContentMetaDatabase(StorageId::BuiltInSystem));
|
||||
|
@ -365,19 +365,19 @@ namespace ams::ncm {
|
|||
R_TRY(this->ActivateContentMetaDatabase(StorageId::BuiltInSystem));
|
||||
|
||||
/* Now for BuiltInUser's content storage and content meta entries. */
|
||||
R_TRY(this->InitializeContentStorageRoot(&this->content_storage_roots[this->num_content_storage_entries++], StorageId::BuiltInUser, fs::ContentStorageId::User));
|
||||
R_TRY(this->InitializeContentMetaDatabaseRoot(&this->content_meta_database_roots[this->num_content_meta_entries++], StorageId::BuiltInUser, BuiltInUserSystemSaveDataInfo, UserMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
|
||||
R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[this->num_content_storage_entries++]), StorageId::BuiltInUser, fs::ContentStorageId::User));
|
||||
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[this->num_content_meta_entries++]), StorageId::BuiltInUser, BuiltInUserSystemSaveDataInfo, UserMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
|
||||
|
||||
/* Beyond this point, N uses hardcoded indices. */
|
||||
|
||||
/* Next SdCard's content storage and content meta entries. */
|
||||
R_TRY(this->InitializeContentStorageRoot(&this->content_storage_roots[2], StorageId::SdCard, fs::ContentStorageId::SdCard));
|
||||
R_TRY(this->InitializeContentMetaDatabaseRoot(&this->content_meta_database_roots[2], StorageId::SdCard, SdCardSystemSaveDataInfo, SdCardMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
|
||||
R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[2]), StorageId::SdCard, fs::ContentStorageId::SdCard));
|
||||
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[2]), StorageId::SdCard, SdCardSystemSaveDataInfo, SdCardMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
|
||||
|
||||
/* GameCard's content storage and content meta entries. */
|
||||
/* N doesn't set a content storage id for game cards, so we'll just use 0 (System). */
|
||||
R_TRY(this->InitializeGameCardContentStorageRoot(&this->content_storage_roots[3]));
|
||||
R_TRY(this->InitializeGameCardContentMetaDatabaseRoot(&this->content_meta_database_roots[3], GameCardMaxContentMetaCount, std::addressof(g_gamecard_content_meta_memory_resource)));
|
||||
R_TRY(this->InitializeGameCardContentStorageRoot(std::addressof(this->content_storage_roots[3])));
|
||||
R_TRY(this->InitializeGameCardContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[3]), GameCardMaxContentMetaCount, std::addressof(g_gamecard_content_meta_memory_resource)));
|
||||
|
||||
this->initialized = true;
|
||||
return ResultSuccess();
|
||||
|
@ -408,7 +408,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Obtain the content meta database root. */
|
||||
ContentMetaDatabaseRoot *root;
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
|
||||
|
||||
/* Mount (and optionally create) save data for the root. */
|
||||
R_TRY(this->EnsureAndMountSystemSaveData(root->mount_name, root->info));
|
||||
|
@ -449,7 +449,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Obtain the content meta database root. */
|
||||
ContentMetaDatabaseRoot *root;
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
|
||||
|
||||
/* Mount save data for non-existing content meta databases. */
|
||||
const bool mount = !root->content_meta_database;
|
||||
|
@ -460,7 +460,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Ensure the root path exists. */
|
||||
bool has_dir = false;
|
||||
R_TRY(fs::HasDirectory(&has_dir, root->path));
|
||||
R_TRY(fs::HasDirectory(std::addressof(has_dir), root->path));
|
||||
R_UNLESS(has_dir, ncm::ResultInvalidContentMetaDatabase());
|
||||
|
||||
return ResultSuccess();
|
||||
|
@ -492,7 +492,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Obtain the content meta database root. */
|
||||
ContentMetaDatabaseRoot *root;
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
|
||||
|
||||
if (hos::GetVersion() >= hos::Version_2_0_0) {
|
||||
/* Obtain the content meta database if already active. */
|
||||
|
@ -524,7 +524,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Obtain the content meta database root. */
|
||||
ContentMetaDatabaseRoot *root;
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
|
||||
|
||||
/* Delete save data for the content meta database root. */
|
||||
return fs::DeleteSaveData(root->info.space_id, root->info.id);
|
||||
|
@ -614,7 +614,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Obtain the content meta database root. */
|
||||
ContentMetaDatabaseRoot *root;
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
|
||||
|
||||
/* Already activated. */
|
||||
R_SUCCEED_IF(root->content_meta_database != nullptr);
|
||||
|
@ -652,7 +652,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Obtain the content meta database root. */
|
||||
ContentMetaDatabaseRoot *root;
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
|
||||
R_TRY(this->GetContentMetaDatabaseRoot(std::addressof(root), storage_id));
|
||||
|
||||
/* Disable the content meta database, if present. */
|
||||
if (root->content_meta_database != nullptr) {
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace ams::ncm {
|
|||
/* Call the process function. */
|
||||
bool should_continue = true;
|
||||
bool should_retry_dir_read = false;
|
||||
R_TRY(f(&should_continue, &should_retry_dir_read, current_path, entry));
|
||||
R_TRY(f(std::addressof(should_continue), std::addressof(should_retry_dir_read), current_path, entry));
|
||||
|
||||
/* If the provided function wishes to terminate immediately, we should respect it. */
|
||||
if (!should_continue) {
|
||||
|
@ -368,7 +368,7 @@ namespace ams::ncm {
|
|||
MakeContentPath(std::addressof(path), content_id, this->make_content_path_func, this->root_path);
|
||||
|
||||
/* Open the content file and store to the cache. */
|
||||
R_TRY_CATCH(fs::OpenFile(&this->cached_file_handle, path, fs::OpenMode_Read)) {
|
||||
R_TRY_CATCH(fs::OpenFile(std::addressof(this->cached_file_handle), path, fs::OpenMode_Read)) {
|
||||
R_CONVERT(ams::fs::ResultPathNotFound, ncm::ResultContentNotFound())
|
||||
} R_END_TRY_CATCH;
|
||||
|
||||
|
@ -416,7 +416,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Check if placeholder file exists. */
|
||||
bool has = false;
|
||||
R_TRY(fs::HasFile(&has, placeholder_path));
|
||||
R_TRY(fs::HasFile(std::addressof(has), placeholder_path));
|
||||
out.SetValue(has);
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Check if the content file exists. */
|
||||
bool has = false;
|
||||
R_TRY(fs::HasFile(&has, content_path));
|
||||
R_TRY(fs::HasFile(std::addressof(has), content_path));
|
||||
out.SetValue(has);
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -714,7 +714,7 @@ namespace ams::ncm {
|
|||
Result ContentStorageImpl::GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
|
||||
/* Obtain the regular rights id for the placeholder id. */
|
||||
ncm::RightsId rights_id;
|
||||
R_TRY(this->GetRightsIdFromPlaceHolderId(&rights_id, placeholder_id));
|
||||
R_TRY(this->GetRightsIdFromPlaceHolderId(std::addressof(rights_id), placeholder_id));
|
||||
|
||||
/* Output the fs rights id. */
|
||||
out_rights_id.SetValue(rights_id.id);
|
||||
|
@ -735,7 +735,7 @@ namespace ams::ncm {
|
|||
Result ContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) {
|
||||
/* Obtain the regular rights id for the content id. */
|
||||
ncm::RightsId rights_id;
|
||||
R_TRY(this->GetRightsIdFromContentId(&rights_id, content_id));
|
||||
R_TRY(this->GetRightsIdFromContentId(std::addressof(rights_id), content_id));
|
||||
|
||||
/* Output the fs rights id. */
|
||||
out_rights_id.SetValue(rights_id.id);
|
||||
|
@ -893,7 +893,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Get the rights id. */
|
||||
ncm::RightsId rights_id;
|
||||
R_TRY(GetRightsId(&rights_id, common_path));
|
||||
R_TRY(GetRightsId(std::addressof(rights_id), common_path));
|
||||
this->rights_id_cache->Store(cache_content_id, rights_id);
|
||||
|
||||
/* Set output. */
|
||||
|
|
|
@ -137,7 +137,7 @@ namespace ams::ncm {
|
|||
Result HostContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) {
|
||||
/* Obtain the regular rights id for the content id. */
|
||||
ncm::RightsId rights_id;
|
||||
R_TRY(this->GetRightsIdFromContentId(&rights_id, content_id));
|
||||
R_TRY(this->GetRightsIdFromContentId(std::addressof(rights_id), content_id));
|
||||
|
||||
/* Output the fs rights id. */
|
||||
out_rights_id.SetValue(rights_id.id);
|
||||
|
|
|
@ -206,7 +206,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Open the relevant content storage. */
|
||||
ContentStorage content_storage;
|
||||
R_TRY(ncm::OpenContentStorage(&content_storage, storage_id));
|
||||
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), storage_id));
|
||||
|
||||
/* Iterate over content infos. */
|
||||
for (size_t i = 0; i < reader.GetContentCount(); i++) {
|
||||
|
@ -464,7 +464,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Open the content storage for this meta. */
|
||||
ContentStorage content_storage;
|
||||
R_TRY(OpenContentStorage(&content_storage, storage_id));
|
||||
R_TRY(OpenContentStorage(std::addressof(content_storage), storage_id));
|
||||
|
||||
/* Open the content meta database for this meta. */
|
||||
ContentMetaDatabase meta_db;
|
||||
|
@ -546,7 +546,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Open the content storage for the content info. */
|
||||
ContentStorage content_storage;
|
||||
R_TRY(OpenContentStorage(&content_storage, content_info->storage_id));
|
||||
R_TRY(OpenContentStorage(std::addressof(content_storage), content_info->storage_id));
|
||||
|
||||
/* Write data to the placeholder. */
|
||||
R_TRY(content_storage.WritePlaceHolder(content_info->placeholder_id, content_info->written, data, data_size));
|
||||
|
@ -658,7 +658,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Open the relevant content storage. */
|
||||
ContentStorage content_storage;
|
||||
R_TRY(ncm::OpenContentStorage(&content_storage, storage_id));
|
||||
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), storage_id));
|
||||
|
||||
/* Update the storage id in the header. */
|
||||
auto writer = content_meta.GetWriter();
|
||||
|
@ -670,7 +670,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Check if we have the content already exists. */
|
||||
bool has_content;
|
||||
R_TRY(content_storage.Has(&has_content, content_info->GetId()));
|
||||
R_TRY(content_storage.Has(std::addressof(has_content), content_info->GetId()));
|
||||
|
||||
if (has_content) {
|
||||
/* Add the size of installed content infos to the total size. */
|
||||
|
@ -739,7 +739,7 @@ namespace ams::ncm {
|
|||
Result InstallTaskBase::PrepareContentMeta(const InstallContentMetaInfo &meta_info, util::optional<ContentMetaKey> expected_key, util::optional<u32> source_version) {
|
||||
/* Open the BuiltInSystem content storage. */
|
||||
ContentStorage content_storage;
|
||||
R_TRY(OpenContentStorage(&content_storage, StorageId::BuiltInSystem));
|
||||
R_TRY(OpenContentStorage(std::addressof(content_storage), StorageId::BuiltInSystem));
|
||||
|
||||
/* Write content meta to a placeholder. */
|
||||
InstallContentInfo content_info;
|
||||
|
@ -1104,7 +1104,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Open the content storage. */
|
||||
ContentStorage content_storage;
|
||||
R_TRY(ncm::OpenContentStorage(&content_storage, storage_id));
|
||||
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), storage_id));
|
||||
|
||||
/* Iterate over content meta. */
|
||||
for (s32 i = 0; i < count; i++) {
|
||||
|
@ -1162,7 +1162,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Open the BuiltInSystem content storage. */
|
||||
ContentStorage content_storage;
|
||||
R_TRY(ncm::OpenContentStorage(&content_storage, StorageId::BuiltInSystem));
|
||||
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), StorageId::BuiltInSystem));
|
||||
|
||||
/* Write content meta to a placeholder. */
|
||||
InstallContentInfo content_info;
|
||||
|
@ -1375,7 +1375,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Open the relevant content storage. */
|
||||
ContentStorage content_storage;
|
||||
R_TRY(ncm::OpenContentStorage(&content_storage, content_info->storage_id));
|
||||
R_TRY(ncm::OpenContentStorage(std::addressof(content_storage), content_info->storage_id));
|
||||
|
||||
/* Get the rights id. */
|
||||
RightsId rights_id;
|
||||
|
|
|
@ -137,7 +137,7 @@ namespace ams::ncm {
|
|||
/* Attempt to find a cache entry with the same placeholder id. */
|
||||
for (size_t i = 0; i < MaxCacheEntries; i++) {
|
||||
if (placeholder_id == this->caches[i].id) {
|
||||
return &this->caches[i];
|
||||
return std::addressof(this->caches[i]);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
|
|
@ -224,7 +224,7 @@ namespace ams::ncm {
|
|||
Result ReadOnlyContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) {
|
||||
/* Obtain the regular rights id for the content id. */
|
||||
ncm::RightsId rights_id;
|
||||
R_TRY(this->GetRightsIdFromContentId(&rights_id, content_id));
|
||||
R_TRY(this->GetRightsIdFromContentId(std::addressof(rights_id), content_id));
|
||||
|
||||
/* Output the fs rights id. */
|
||||
out_rights_id.SetValue(rights_id.id);
|
||||
|
@ -240,7 +240,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Get the rights id. */
|
||||
ncm::RightsId rights_id;
|
||||
R_TRY(GetRightsId(&rights_id, path));
|
||||
R_TRY(GetRightsId(std::addressof(rights_id), path));
|
||||
out_rights_id.SetValue(rights_id);
|
||||
|
||||
return ResultSuccess();
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace ams::os::impl {
|
|||
this->current_time = GetCurrentTick().ToTimeSpan();
|
||||
|
||||
TimeSpan min_timeout = 0;
|
||||
MultiWaitHolderBase *min_timeout_object = this->RecalculateNextTimeout(&min_timeout, end_time);
|
||||
MultiWaitHolderBase *min_timeout_object = this->RecalculateNextTimeout(std::addressof(min_timeout), end_time);
|
||||
|
||||
s32 index = WaitInvalid;
|
||||
Result wait_result = ResultSuccess();
|
||||
|
@ -141,11 +141,10 @@ namespace ams::os::impl {
|
|||
|
||||
for (MultiWaitHolderBase &holder_base : this->multi_wait_list) {
|
||||
if (auto handle = holder_base.GetHandle(); handle != os::InvalidNativeHandle) {
|
||||
AMS_ASSERT(count < num);
|
||||
AMS_UNUSED(num);
|
||||
AMS_ABORT_UNLESS(count < num);
|
||||
|
||||
out_handles[count] = handle;
|
||||
out_objects[count] = &holder_base;
|
||||
out_objects[count] = std::addressof(holder_base);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +159,7 @@ namespace ams::os::impl {
|
|||
TriBool is_signaled = holder_base.LinkToObjectList();
|
||||
|
||||
if (signaled_holder == nullptr && is_signaled == TriBool::True) {
|
||||
signaled_holder = &holder_base;
|
||||
signaled_holder = std::addressof(holder_base);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,7 +178,7 @@ namespace ams::os::impl {
|
|||
|
||||
for (MultiWaitHolderBase &holder_base : this->multi_wait_list) {
|
||||
if (const TimeSpan cur_time = holder_base.GetAbsoluteWakeupTime(); cur_time < min_time) {
|
||||
min_timeout_holder = &holder_base;
|
||||
min_timeout_holder = std::addressof(holder_base);
|
||||
min_time = cur_time;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace ams::os::impl {
|
|||
public:
|
||||
void SignalAllThreads() {
|
||||
for (MultiWaitHolderBase &holder_base : this->object_list) {
|
||||
holder_base.GetMultiWait()->SignalAndWakeupThread(&holder_base);
|
||||
holder_base.GetMultiWait()->SignalAndWakeupThread(std::addressof(holder_base));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace ams::os::impl {
|
||||
|
||||
#define ATOMIC_COMPARE_EXCHANGE_LOCK_COUNT(dst_ref, expected_ref, desired_ref, success, fail) \
|
||||
(__atomic_compare_exchange(reinterpret_cast<u64 *>(&dst_ref), reinterpret_cast<u64 *>(&expected_ref), reinterpret_cast<u64 *>(&desired_ref), true, success, fail))
|
||||
(__atomic_compare_exchange(reinterpret_cast<u64 *>(std::addressof(dst_ref)), reinterpret_cast<u64 *>(std::addressof(expected_ref)), reinterpret_cast<u64 *>(std::addressof(desired_ref)), true, success, fail))
|
||||
|
||||
|
||||
void ReaderWriterLockHorizonImpl::AcquireReadLockWriteLocked(os::ReaderWriterLockType *rw_lock) {
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace ams::os {
|
|||
AMS_ASSERT(!holder_base->IsLinked());
|
||||
|
||||
impl.LinkMultiWaitHolder(*holder_base);
|
||||
holder_base->SetMultiWait(&impl);
|
||||
holder_base->SetMultiWait(std::addressof(impl));
|
||||
}
|
||||
|
||||
void UnlinkMultiWaitHolder(MultiWaitHolderType *holder) {
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace ams::os {
|
|||
const T EffectiveMax = (std::numeric_limits<T>::max() / max) * max;
|
||||
T cur_rnd;
|
||||
while (true) {
|
||||
os::GenerateRandomBytes(&cur_rnd, sizeof(T));
|
||||
os::GenerateRandomBytes(std::addressof(cur_rnd), sizeof(T));
|
||||
if (cur_rnd < EffectiveMax) {
|
||||
return cur_rnd % max;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace ams::os {
|
|||
std::scoped_lock lk(g_random_mutex);
|
||||
|
||||
if (AMS_UNLIKELY(!g_initialized_random)) {
|
||||
impl::InitializeRandomImpl(&g_random);
|
||||
impl::InitializeRandomImpl(std::addressof(g_random));
|
||||
g_initialized_random = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,11 +66,11 @@ namespace ams::patcher {
|
|||
bool MatchesModuleId(const char *name, size_t name_len, size_t extension_len, const ro::ModuleId *module_id) {
|
||||
/* Get module id. */
|
||||
ro::ModuleId module_id_from_name;
|
||||
if (!ParseModuleIdFromPath(&module_id_from_name, name, name_len, extension_len)) {
|
||||
if (!ParseModuleIdFromPath(std::addressof(module_id_from_name), name, name_len, extension_len)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return std::memcmp(&module_id_from_name, module_id, sizeof(*module_id)) == 0;
|
||||
return std::memcmp(std::addressof(module_id_from_name), module_id, sizeof(*module_id)) == 0;
|
||||
}
|
||||
|
||||
bool IsIpsFileForModule(const char *name, const ro::ModuleId *module_id) {
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace ams::pm::bm {
|
|||
/* Both functions should be weakly linked, so that they can be overridden by ams::boot2 as needed. */
|
||||
BootMode WEAK_SYMBOL GetBootMode() {
|
||||
PmBootMode boot_mode = PmBootMode_Normal;
|
||||
R_ABORT_UNLESS(pmbmGetBootMode(&boot_mode));
|
||||
R_ABORT_UNLESS(pmbmGetBootMode(std::addressof(boot_mode)));
|
||||
return static_cast<BootMode>(boot_mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace ams::pm::dmnt {
|
|||
|
||||
Result HookToCreateApplicationProcess(os::NativeHandle *out_handle) {
|
||||
Event evt;
|
||||
R_TRY(pmdmntHookToCreateApplicationProcess(&evt));
|
||||
R_TRY(pmdmntHookToCreateApplicationProcess(std::addressof(evt)));
|
||||
*out_handle = evt.revent;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace ams::pm::info {
|
|||
|
||||
bool HasLaunchedBootProgram(ncm::ProgramId program_id) {
|
||||
bool has_launched = false;
|
||||
R_ABORT_UNLESS(HasLaunchedBootProgram(&has_launched, program_id));
|
||||
R_ABORT_UNLESS(HasLaunchedBootProgram(std::addressof(has_launched), program_id));
|
||||
return has_launched;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace ams::pm::info {
|
|||
Result IsHblProcessId(bool *out, os::ProcessId process_id) {
|
||||
ncm::ProgramLocation loc;
|
||||
cfg::OverrideStatus override_status;
|
||||
R_TRY(GetProcessInfo(&loc, &override_status, process_id));
|
||||
R_TRY(GetProcessInfo(std::addressof(loc), std::addressof(override_status), process_id));
|
||||
|
||||
*out = override_status.IsHbl();
|
||||
return ResultSuccess();
|
||||
|
@ -52,7 +52,7 @@ namespace ams::pm::info {
|
|||
|
||||
Result IsHblProgramId(bool *out, ncm::ProgramId program_id) {
|
||||
os::ProcessId process_id;
|
||||
R_TRY(GetProcessId(&process_id, program_id));
|
||||
R_TRY(GetProcessId(std::addressof(process_id), program_id));
|
||||
|
||||
return IsHblProcessId(out, process_id);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace ams::pm::info {
|
|||
/* Information API. */
|
||||
Result WEAK_SYMBOL HasLaunchedBootProgram(bool *out, ncm::ProgramId program_id) {
|
||||
bool has_launched = false;
|
||||
R_TRY(pminfoAtmosphereHasLaunchedBootProgram(&has_launched, static_cast<u64>(program_id)));
|
||||
R_TRY(pminfoAtmosphereHasLaunchedBootProgram(std::addressof(has_launched), static_cast<u64>(program_id)));
|
||||
*out = has_launched;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace ams::pm::shell {
|
|||
Result WEAK_SYMBOL LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 launch_flags) {
|
||||
static_assert(sizeof(ncm::ProgramLocation) == sizeof(NcmProgramLocation));
|
||||
static_assert(alignof(ncm::ProgramLocation) == alignof(NcmProgramLocation));
|
||||
return pmshellLaunchProgram(launch_flags, reinterpret_cast<const NcmProgramLocation *>(&loc), reinterpret_cast<u64 *>(out));
|
||||
return pmshellLaunchProgram(launch_flags, reinterpret_cast<const NcmProgramLocation *>(std::addressof(loc)), reinterpret_cast<u64 *>(out));
|
||||
}
|
||||
|
||||
Result TerminateProcess(os::ProcessId process_id) {
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace ams::sf::cmif {
|
|||
|
||||
ServerDomainManager::Domain::~Domain() {
|
||||
while (!this->entries.empty()) {
|
||||
Entry *entry = &this->entries.front();
|
||||
Entry *entry = std::addressof(this->entries.front());
|
||||
{
|
||||
std::scoped_lock lk(this->manager->entry_owner_lock);
|
||||
AMS_ABORT_UNLESS(entry->owner == this);
|
||||
|
@ -127,7 +127,7 @@ namespace ams::sf::cmif {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Entry *e = &this->free_list.front();
|
||||
Entry *e = std::addressof(this->free_list.front());
|
||||
this->free_list.pop_front();
|
||||
return e;
|
||||
}
|
||||
|
|
|
@ -43,9 +43,9 @@ namespace ams::sf::cmif {
|
|||
std::memcpy(in_object_ids, reinterpret_cast<DomainObjectId *>(in_message_raw_data.GetAddress() + in_message_raw_data.GetSize()), sizeof(DomainObjectId) * in_header->num_in_objects);
|
||||
DomainServiceObjectProcessor domain_processor(domain, in_object_ids, in_header->num_in_objects);
|
||||
if (ctx.processor == nullptr) {
|
||||
ctx.processor = &domain_processor;
|
||||
ctx.processor = std::addressof(domain_processor);
|
||||
} else {
|
||||
ctx.processor->SetImplementationProcessor(&domain_processor);
|
||||
ctx.processor->SetImplementationProcessor(std::addressof(domain_processor));
|
||||
}
|
||||
ctx.srv_obj = target_object.GetServiceObjectUnsafe();
|
||||
return target_object.ProcessMessage(ctx, in_message_raw_data);
|
||||
|
@ -82,9 +82,9 @@ namespace ams::sf::cmif {
|
|||
std::memcpy(in_object_ids, reinterpret_cast<DomainObjectId *>(in_message_raw_data.GetAddress() + in_message_raw_data.GetSize()), sizeof(DomainObjectId) * in_header->num_in_objects);
|
||||
DomainServiceObjectProcessor domain_processor(domain, in_object_ids, in_header->num_in_objects);
|
||||
if (ctx.processor == nullptr) {
|
||||
ctx.processor = &domain_processor;
|
||||
ctx.processor = std::addressof(domain_processor);
|
||||
} else {
|
||||
ctx.processor->SetImplementationProcessor(&domain_processor);
|
||||
ctx.processor->SetImplementationProcessor(std::addressof(domain_processor));
|
||||
}
|
||||
ctx.srv_obj = target_object.GetServiceObjectUnsafe();
|
||||
return target_object.ProcessMessage(ctx, in_message_raw_data);
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace ams::sf::hipc {
|
|||
|
||||
/* The object ID reservation cannot fail here, as that would cause desynchronization from target domain. */
|
||||
object_id = cmif::DomainObjectId{session->forward_service->object_id};
|
||||
domain->ReserveSpecificIds(&object_id, 1);
|
||||
domain->ReserveSpecificIds(std::addressof(object_id), 1);
|
||||
|
||||
/* Register the object. */
|
||||
domain->RegisterObject(object_id, std::move(session->srv_obj_holder));
|
||||
|
@ -91,7 +91,7 @@ namespace ams::sf::hipc {
|
|||
SharedPointer<cmif::DomainServiceObject> cmif_domain(domain, false);
|
||||
|
||||
/* Reserve a new object in the domain. */
|
||||
R_TRY(domain->ReserveIds(&object_id, 1));
|
||||
R_TRY(domain->ReserveIds(std::addressof(object_id), 1));
|
||||
|
||||
/* Register the object. */
|
||||
domain->RegisterObject(object_id, std::move(session->srv_obj_holder));
|
||||
|
@ -136,7 +136,7 @@ namespace ams::sf::hipc {
|
|||
} else {
|
||||
/* Copy from the target domain. */
|
||||
os::NativeHandle new_forward_target;
|
||||
R_TRY(cmifCopyFromCurrentDomain(this->session->forward_service->session, object_id.value, &new_forward_target));
|
||||
R_TRY(cmifCopyFromCurrentDomain(this->session->forward_service->session, object_id.value, std::addressof(new_forward_target)));
|
||||
|
||||
/* Create new session handles. */
|
||||
os::NativeHandle server_handle, client_handle;
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace ams::sf::hipc {
|
|||
Result ServerManagerBase::InstallMitmServerImpl(os::NativeHandle *out_port_handle, sm::ServiceName service_name, ServerManagerBase::MitmQueryFunction query_func) {
|
||||
/* Install the Mitm. */
|
||||
os::NativeHandle query_handle;
|
||||
R_TRY(sm::mitm::InstallMitm(out_port_handle, &query_handle, service_name));
|
||||
R_TRY(sm::mitm::InstallMitm(out_port_handle, std::addressof(query_handle), service_name));
|
||||
|
||||
/* Register the query handle. */
|
||||
impl::RegisterMitmQueryHandle(query_handle, query_func);
|
||||
|
@ -57,9 +57,9 @@ namespace ams::sf::hipc {
|
|||
while (true) {
|
||||
this->LinkDeferred();
|
||||
auto selected = os::WaitAny(std::addressof(this->multi_wait));
|
||||
if (selected == &this->request_stop_event_holder) {
|
||||
if (selected == std::addressof(this->request_stop_event_holder)) {
|
||||
return nullptr;
|
||||
} else if (selected == &this->notify_event_holder) {
|
||||
} else if (selected == std::addressof(this->notify_event_holder)) {
|
||||
this->notify_event.Clear();
|
||||
} else {
|
||||
os::UnlinkMultiWaitHolder(selected);
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace ams::sf::hipc {
|
|||
Result ServerSessionManager::AcceptSessionImpl(ServerSession *session_memory, os::NativeHandle port_handle, cmif::ServiceObjectHolder &&obj) {
|
||||
/* Create session handle. */
|
||||
os::NativeHandle session_handle;
|
||||
R_TRY(svc::AcceptSession(&session_handle, port_handle));
|
||||
R_TRY(svc::AcceptSession(std::addressof(session_handle), port_handle));
|
||||
|
||||
auto session_guard = SCOPE_GUARD { os::CloseNativeHandle(session_handle); };
|
||||
|
||||
|
@ -133,7 +133,7 @@ namespace ams::sf::hipc {
|
|||
Result ServerSessionManager::AcceptMitmSessionImpl(ServerSession *session_memory, os::NativeHandle mitm_port_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) {
|
||||
/* Create session handle. */
|
||||
os::NativeHandle mitm_session_handle;
|
||||
R_TRY(svc::AcceptSession(&mitm_session_handle, mitm_port_handle));
|
||||
R_TRY(svc::AcceptSession(std::addressof(mitm_session_handle), mitm_port_handle));
|
||||
|
||||
auto session_guard = SCOPE_GUARD { os::CloseNativeHandle(mitm_session_handle); };
|
||||
|
||||
|
@ -147,25 +147,25 @@ namespace ams::sf::hipc {
|
|||
Result ServerSessionManager::RegisterSession(os::NativeHandle session_handle, cmif::ServiceObjectHolder &&obj) {
|
||||
/* We don't actually care about what happens to the session. It'll get linked. */
|
||||
ServerSession *session_ptr = nullptr;
|
||||
return this->RegisterSession(&session_ptr, session_handle, std::forward<cmif::ServiceObjectHolder>(obj));
|
||||
return this->RegisterSession(std::addressof(session_ptr), session_handle, std::forward<cmif::ServiceObjectHolder>(obj));
|
||||
}
|
||||
|
||||
Result ServerSessionManager::AcceptSession(os::NativeHandle port_handle, cmif::ServiceObjectHolder &&obj) {
|
||||
/* We don't actually care about what happens to the session. It'll get linked. */
|
||||
ServerSession *session_ptr = nullptr;
|
||||
return this->AcceptSession(&session_ptr, port_handle, std::forward<cmif::ServiceObjectHolder>(obj));
|
||||
return this->AcceptSession(std::addressof(session_ptr), port_handle, std::forward<cmif::ServiceObjectHolder>(obj));
|
||||
}
|
||||
|
||||
Result ServerSessionManager::RegisterMitmSession(os::NativeHandle mitm_session_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) {
|
||||
/* We don't actually care about what happens to the session. It'll get linked. */
|
||||
ServerSession *session_ptr = nullptr;
|
||||
return this->RegisterMitmSession(&session_ptr, mitm_session_handle, std::forward<cmif::ServiceObjectHolder>(obj), std::forward<std::shared_ptr<::Service>>(fsrv));
|
||||
return this->RegisterMitmSession(std::addressof(session_ptr), mitm_session_handle, std::forward<cmif::ServiceObjectHolder>(obj), std::forward<std::shared_ptr<::Service>>(fsrv));
|
||||
}
|
||||
|
||||
Result ServerSessionManager::AcceptMitmSession(os::NativeHandle mitm_port_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) {
|
||||
/* We don't actually care about what happens to the session. It'll get linked. */
|
||||
ServerSession *session_ptr = nullptr;
|
||||
return this->AcceptMitmSession(&session_ptr, mitm_port_handle, std::forward<cmif::ServiceObjectHolder>(obj), std::forward<std::shared_ptr<::Service>>(fsrv));
|
||||
return this->AcceptMitmSession(std::addressof(session_ptr), mitm_port_handle, std::forward<cmif::ServiceObjectHolder>(obj), std::forward<std::shared_ptr<::Service>>(fsrv));
|
||||
}
|
||||
|
||||
Result ServerSessionManager::ReceiveRequestImpl(ServerSession *session, const cmif::PointerAndSize &message) {
|
||||
|
@ -184,7 +184,7 @@ namespace ams::sf::hipc {
|
|||
);
|
||||
}
|
||||
hipc::ReceiveResult recv_result;
|
||||
R_TRY(hipc::Receive(&recv_result, session->session_handle, message));
|
||||
R_TRY(hipc::Receive(std::addressof(recv_result), session->session_handle, message));
|
||||
switch (recv_result) {
|
||||
case hipc::ReceiveResult::Success:
|
||||
session->is_closed = false;
|
||||
|
@ -203,7 +203,7 @@ namespace ams::sf::hipc {
|
|||
|
||||
NX_CONSTEXPR u32 GetCmifCommandType(const cmif::PointerAndSize &message) {
|
||||
HipcHeader hdr = {};
|
||||
__builtin_memcpy(&hdr, message.GetPointer(), sizeof(hdr));
|
||||
__builtin_memcpy(std::addressof(hdr), message.GetPointer(), sizeof(hdr));
|
||||
return hdr.type;
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ namespace ams::sf::hipc {
|
|||
.manager = this,
|
||||
.session = session,
|
||||
.processor = nullptr, /* Filled in by template implementations. */
|
||||
.handles_to_close = &handles_to_close,
|
||||
.handles_to_close = std::addressof(handles_to_close),
|
||||
.pointer_buffer = session->pointer_buffer,
|
||||
.in_message_buffer = in_message,
|
||||
.out_message_buffer = out_message,
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace ams::sm::manager {
|
|||
/* Manager API. */
|
||||
Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus status, const void *acid, size_t acid_size, const void *aci, size_t aci_size) {
|
||||
static_assert(sizeof(status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition");
|
||||
return smManagerAtmosphereRegisterProcess(static_cast<u64>(process_id), static_cast<u64>(program_id), reinterpret_cast<const CfgOverrideStatus *>(&status), acid, acid_size, aci, aci_size);
|
||||
return smManagerAtmosphereRegisterProcess(static_cast<u64>(process_id), static_cast<u64>(program_id), reinterpret_cast<const CfgOverrideStatus *>(std::addressof(status)), acid, acid_size, aci, aci_size);
|
||||
}
|
||||
|
||||
Result UnregisterProcess(os::ProcessId process_id) {
|
||||
|
|
|
@ -40,19 +40,17 @@ namespace ams::sm::impl {
|
|||
TipcService srv;
|
||||
{
|
||||
std::scoped_lock lk(GetPerThreadSessionMutex());
|
||||
R_ABORT_UNLESS(smAtmosphereOpenSession(&srv));
|
||||
R_ABORT_UNLESS(smAtmosphereOpenSession(std::addressof(srv)));
|
||||
}
|
||||
{
|
||||
ON_SCOPE_EXIT { smAtmosphereCloseSession(&srv); };
|
||||
return f(&srv);
|
||||
ON_SCOPE_EXIT { smAtmosphereCloseSession(std::addressof(srv)); };
|
||||
return f(std::addressof(srv));
|
||||
}
|
||||
}
|
||||
|
||||
NX_CONSTEXPR SmServiceName ConvertName(sm::ServiceName name) {
|
||||
constexpr ALWAYS_INLINE SmServiceName ConvertName(sm::ServiceName name) {
|
||||
static_assert(sizeof(SmServiceName) == sizeof(sm::ServiceName));
|
||||
SmServiceName ret = {};
|
||||
__builtin_memcpy(&ret, &name, sizeof(sm::ServiceName));
|
||||
return ret;
|
||||
return std::bit_cast<SmServiceName>(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -173,13 +173,13 @@ namespace ams::spl::smc {
|
|||
svc::SecureMonitorArguments args;
|
||||
|
||||
args.r[0] = static_cast<u64>(FunctionId::ReencryptDeviceUniqueData);
|
||||
args.r[1] = reinterpret_cast<u64>(&access_key_dec);
|
||||
args.r[2] = reinterpret_cast<u64>(&access_key_enc);
|
||||
args.r[1] = reinterpret_cast<u64>(std::addressof(access_key_dec));
|
||||
args.r[2] = reinterpret_cast<u64>(std::addressof(access_key_enc));
|
||||
args.r[3] = option;
|
||||
args.r[4] = reinterpret_cast<u64>(data);
|
||||
args.r[5] = size;
|
||||
args.r[6] = reinterpret_cast<u64>(&source_dec);
|
||||
args.r[7] = reinterpret_cast<u64>(&source_enc);
|
||||
args.r[6] = reinterpret_cast<u64>(std::addressof(source_dec));
|
||||
args.r[7] = reinterpret_cast<u64>(std::addressof(source_enc));
|
||||
svc::CallSecureMonitor(std::addressof(args));
|
||||
|
||||
return static_cast<Result>(args.r[0]);
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace ams::updater {
|
|||
Result VerifyBootImagesAndRepairIfNeeded(bool *out_repaired, BootModeType mode, void *work_buffer, size_t work_buffer_size, BootImageUpdateType boot_image_update_type) {
|
||||
/* Get system data id for boot images (819/81A/81B/81C). */
|
||||
ncm::SystemDataId bip_data_id = {};
|
||||
R_TRY(GetBootImagePackageId(&bip_data_id, mode, work_buffer, work_buffer_size));
|
||||
R_TRY(GetBootImagePackageId(std::addressof(bip_data_id), mode, work_buffer, work_buffer_size));
|
||||
|
||||
/* Verify the boot images in NAND. */
|
||||
R_TRY_CATCH(VerifyBootImages(bip_data_id, mode, work_buffer, work_buffer_size, boot_image_update_type)) {
|
||||
|
@ -174,7 +174,7 @@ namespace ams::updater {
|
|||
R_TRY(ValidateBctFileHash(boot0_accessor, Boot0Partition::BctNormalSub, nand_hash, work_buffer, work_buffer_size, boot_image_update_type));
|
||||
|
||||
/* Compare Package1 Normal/Sub hashes. */
|
||||
R_TRY(GetFileHash(&size, file_hash, GetPackage1Path(boot_image_update_type), work_buffer, work_buffer_size));
|
||||
R_TRY(GetFileHash(std::addressof(size), file_hash, GetPackage1Path(boot_image_update_type), work_buffer, work_buffer_size));
|
||||
|
||||
R_TRY(boot0_accessor.GetHash(nand_hash, size, work_buffer, work_buffer_size, Boot0Partition::Package1NormalMain));
|
||||
R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash)));
|
||||
|
@ -183,7 +183,7 @@ namespace ams::updater {
|
|||
R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash)));
|
||||
|
||||
/* Compare Package2 Normal/Sub hashes. */
|
||||
R_TRY(GetFileHash(&size, file_hash, GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size));
|
||||
R_TRY(GetFileHash(std::addressof(size), file_hash, GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size));
|
||||
|
||||
R_TRY(GetPackage2Hash(nand_hash, size, work_buffer, work_buffer_size, Package2Type::NormalMain));
|
||||
R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash)));
|
||||
|
@ -236,7 +236,7 @@ namespace ams::updater {
|
|||
R_TRY(ValidateBctFileHash(boot0_accessor, Boot0Partition::BctSafeSub, nand_hash, work_buffer, work_buffer_size, boot_image_update_type));
|
||||
|
||||
/* Compare Package1 Normal/Sub hashes. */
|
||||
R_TRY(GetFileHash(&size, file_hash, GetPackage1Path(boot_image_update_type), work_buffer, work_buffer_size));
|
||||
R_TRY(GetFileHash(std::addressof(size), file_hash, GetPackage1Path(boot_image_update_type), work_buffer, work_buffer_size));
|
||||
|
||||
R_TRY(boot1_accessor.GetHash(nand_hash, size, work_buffer, work_buffer_size, Boot1Partition::Package1SafeMain));
|
||||
R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash)));
|
||||
|
@ -245,7 +245,7 @@ namespace ams::updater {
|
|||
R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash)));
|
||||
|
||||
/* Compare Package2 Normal/Sub hashes. */
|
||||
R_TRY(GetFileHash(&size, file_hash, GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size));
|
||||
R_TRY(GetFileHash(std::addressof(size), file_hash, GetPackage2Path(boot_image_update_type), work_buffer, work_buffer_size));
|
||||
|
||||
R_TRY(GetPackage2Hash(nand_hash, size, work_buffer, work_buffer_size, Package2Type::SafeMain));
|
||||
R_TRY(CompareHash(file_hash, nand_hash, sizeof(file_hash)));
|
||||
|
@ -291,7 +291,7 @@ namespace ams::updater {
|
|||
void *work = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(work_buffer) + BctSize);
|
||||
|
||||
size_t size;
|
||||
R_TRY(ReadFile(&size, bct, BctSize, GetBctPath(boot_image_update_type)));
|
||||
R_TRY(ReadFile(std::addressof(size), bct, BctSize, GetBctPath(boot_image_update_type)));
|
||||
if (HasEks(boot_image_update_type)) {
|
||||
R_TRY(boot0_accessor.UpdateEks(bct, work));
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ namespace ams::updater {
|
|||
void *work = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(work_buffer) + BctSize);
|
||||
|
||||
size_t size;
|
||||
R_TRY(ReadFile(&size, bct, BctSize, GetBctPath(boot_image_update_type)));
|
||||
R_TRY(ReadFile(std::addressof(size), bct, BctSize, GetBctPath(boot_image_update_type)));
|
||||
if (HasEks(boot_image_update_type)) {
|
||||
R_TRY(boot0_accessor.UpdateEks(bct, work));
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ namespace ams::updater {
|
|||
void *work = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(work_buffer) + BctSize);
|
||||
|
||||
size_t size;
|
||||
R_TRY(ReadFile(&size, bct, BctSize, GetBctPath(boot_image_update_type)));
|
||||
R_TRY(ReadFile(std::addressof(size), bct, BctSize, GetBctPath(boot_image_update_type)));
|
||||
if (HasEks(boot_image_update_type)) {
|
||||
R_TRY(accessor.UpdateEks(bct, work));
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ namespace ams::updater {
|
|||
|
||||
/* Get verification state from NAND. */
|
||||
VerificationState verification_state;
|
||||
R_TRY(GetVerificationState(&verification_state, work_buffer, work_buffer_size));
|
||||
R_TRY(GetVerificationState(std::addressof(verification_state), work_buffer, work_buffer_size));
|
||||
|
||||
/* If we don't need to verify anything, we're done. */
|
||||
if (!verification_state.needs_verify_normal && !verification_state.needs_verify_safe) {
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace ams::updater {
|
|||
const OffsetSizeType *entry = nullptr;
|
||||
for (size_t i = 0; i < Meta::NumEntries; i++) {
|
||||
if (Meta::Entries[i].which == which) {
|
||||
entry = &Meta::Entries[i];
|
||||
entry = std::addressof(Meta::Entries[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,12 +115,12 @@ namespace ams::util::ini {
|
|||
|
||||
int ParseFile(fs::FileHandle file, void *user_ctx, Handler h) {
|
||||
FileContext ctx(file);
|
||||
return ini_parse_stream(ini_reader_file_handle, &ctx, h, user_ctx);
|
||||
return ini_parse_stream(ini_reader_file_handle, std::addressof(ctx), h, user_ctx);
|
||||
}
|
||||
|
||||
int ParseFile(fs::fsa::IFile *file, void *user_ctx, Handler h) {
|
||||
IFileContext ctx(file);
|
||||
return ini_parse_stream(ini_reader_ifile, &ctx, h, user_ctx);
|
||||
return ini_parse_stream(ini_reader_ifile, std::addressof(ctx), h, user_ctx);
|
||||
}
|
||||
|
||||
}
|
|
@ -200,23 +200,23 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
ALWAYS_INLINE iterator end() {
|
||||
return iterator(&this->root_node);
|
||||
return iterator(std::addressof(this->root_node));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const_iterator end() const {
|
||||
return const_iterator(&this->root_node);
|
||||
return const_iterator(std::addressof(this->root_node));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE iterator iterator_to(reference v) {
|
||||
/* Only allow iterator_to for values in lists. */
|
||||
AMS_ASSERT(v.IsLinked());
|
||||
return iterator(&v);
|
||||
return iterator(std::addressof(v));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const_iterator iterator_to(const_reference v) const {
|
||||
/* Only allow iterator_to for values in lists. */
|
||||
AMS_ASSERT(v.IsLinked());
|
||||
return const_iterator(&v);
|
||||
return const_iterator(std::addressof(v));
|
||||
}
|
||||
|
||||
/* Content management. */
|
||||
|
@ -245,11 +245,11 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
ALWAYS_INLINE void push_back(reference node) {
|
||||
this->root_node.LinkPrev(&node);
|
||||
this->root_node.LinkPrev(std::addressof(node));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void push_front(reference node) {
|
||||
this->root_node.LinkNext(&node);
|
||||
this->root_node.LinkNext(std::addressof(node));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void pop_back() {
|
||||
|
@ -261,8 +261,8 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
ALWAYS_INLINE iterator insert(const_iterator pos, reference node) {
|
||||
pos.GetNonConstIterator()->LinkPrev(&node);
|
||||
return iterator(&node);
|
||||
pos.GetNonConstIterator()->LinkPrev(std::addressof(node));
|
||||
return iterator(std::addressof(node));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void splice(const_iterator pos, IntrusiveListImpl &o) {
|
||||
|
@ -303,8 +303,8 @@ namespace ams::util {
|
|||
iterator pos(_pos.GetNonConstIterator());
|
||||
iterator first(_first.GetNonConstIterator());
|
||||
iterator last(_last.GetNonConstIterator());
|
||||
first->Unlink(&*last);
|
||||
pos->SplicePrev(&*first, &*first);
|
||||
first->Unlink(std::addressof(*last));
|
||||
pos->SplicePrev(std::addressof(*first), std::addressof(*first));
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -362,7 +362,7 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
ALWAYS_INLINE pointer operator->() const {
|
||||
return &Traits::GetParent(*this->iterator);
|
||||
return std::addressof(Traits::GetParent(*this->iterator));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE reference operator*() const {
|
||||
|
@ -562,11 +562,11 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
static constexpr ALWAYS_INLINE Derived &GetParent(IntrusiveListNode &node) {
|
||||
return util::GetParentReference<Member, Derived>(&node);
|
||||
return util::GetParentReference<Member, Derived>(std::addressof(node));
|
||||
}
|
||||
|
||||
static constexpr ALWAYS_INLINE Derived const &GetParent(IntrusiveListNode const &node) {
|
||||
return util::GetParentReference<Member, Derived>(&node);
|
||||
return util::GetParentReference<Member, Derived>(std::addressof(node));
|
||||
}
|
||||
private:
|
||||
static constexpr TypedStorage<Derived> DerivedStorage = {};
|
||||
|
@ -597,11 +597,11 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
static constexpr ALWAYS_INLINE Derived &GetParent(IntrusiveListNode &node) {
|
||||
return util::GetParentReference<Member, Derived>(&node);
|
||||
return util::GetParentReference<Member, Derived>(std::addressof(node));
|
||||
}
|
||||
|
||||
static constexpr ALWAYS_INLINE Derived const &GetParent(IntrusiveListNode const &node) {
|
||||
return util::GetParentReference<Member, Derived>(&node);
|
||||
return util::GetParentReference<Member, Derived>(std::addressof(node));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -130,14 +130,14 @@ namespace ams::util {
|
|||
{
|
||||
const int num_init_iterations = std::max(seed_count + 1, MinimumInitIterations) - 1;
|
||||
|
||||
GenerateInitialValuePlus(&this->state, 0, seed_count);
|
||||
GenerateInitialValuePlus(std::addressof(this->state), 0, seed_count);
|
||||
|
||||
for (int i = 0; i < num_init_iterations; i++) {
|
||||
GenerateInitialValuePlus(&this->state, (i + 1) % NumStateWords, (i < seed_count) ? seed[i] : 0);
|
||||
GenerateInitialValuePlus(std::addressof(this->state), (i + 1) % NumStateWords, (i < seed_count) ? seed[i] : 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < static_cast<int>(NumStateWords); i++) {
|
||||
GenerateInitialValueXor(&this->state, (i + 1 + num_init_iterations) % NumStateWords);
|
||||
GenerateInitialValueXor(std::addressof(this->state), (i + 1 + num_init_iterations) % NumStateWords);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ namespace ams::util {
|
|||
/* Make sure we're aligned. */
|
||||
if (start < aligned_start) {
|
||||
const u32 rnd = this->GenerateRandomU32();
|
||||
std::memcpy(dst, &rnd, aligned_start - start);
|
||||
std::memcpy(dst, std::addressof(rnd), aligned_start - start);
|
||||
}
|
||||
|
||||
/* Write as many aligned u32s as we can. */
|
||||
|
@ -179,7 +179,7 @@ namespace ams::util {
|
|||
/* Handle any leftover unaligned data. */
|
||||
if (aligned_end < end) {
|
||||
const u32 rnd = this->GenerateRandomU32();
|
||||
std::memcpy(reinterpret_cast<void *>(aligned_end), &rnd, end - aligned_end);
|
||||
std::memcpy(reinterpret_cast<void *>(aligned_end), std::addressof(rnd), end - aligned_end);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ namespace ams::crypto::impl {
|
|||
if (!(power_1.IsValid() && power_2.IsValid() && power_3.IsValid())) {
|
||||
return false;
|
||||
}
|
||||
decltype(power_1)* powers[3] = { &power_1, &power_2, &power_3 };
|
||||
decltype(power_1)* powers[3] = { std::addressof(power_1), std::addressof(power_2), std::addressof(power_3) };
|
||||
|
||||
/* Set the powers of src. */
|
||||
Copy(power_1.GetBuffer(), src, mod_words);
|
||||
|
|
|
@ -68,13 +68,13 @@ namespace ams::dd {
|
|||
|
||||
if (hos::GetVersion() >= hos::Version_10_0_0) {
|
||||
svc::Size region_size = 0;
|
||||
R_TRY_CATCH(svc::QueryIoMapping(&virt_addr, ®ion_size, aligned_addr, aligned_size)) {
|
||||
R_TRY_CATCH(svc::QueryIoMapping(std::addressof(virt_addr), std::addressof(region_size), aligned_addr, aligned_size)) {
|
||||
/* Official software handles this by returning 0. */
|
||||
R_CATCH(svc::ResultNotFound) { return 0; }
|
||||
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
|
||||
AMS_ASSERT(region_size >= aligned_size);
|
||||
} else {
|
||||
R_TRY_CATCH(svc::LegacyQueryIoMapping(&virt_addr, aligned_addr, aligned_size)) {
|
||||
R_TRY_CATCH(svc::LegacyQueryIoMapping(std::addressof(virt_addr), aligned_addr, aligned_size)) {
|
||||
/* Official software handles this by returning 0. */
|
||||
R_CATCH(svc::ResultNotFound) { return 0; }
|
||||
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
|
||||
|
@ -102,7 +102,7 @@ namespace ams::dd {
|
|||
|
||||
u32 ReadWritePmcRegisterImpl(dd::PhysicalAddress phys_addr, u32 value, u32 mask) {
|
||||
u32 out_value;
|
||||
R_ABORT_UNLESS(spl::smc::ConvertResult(spl::smc::AtmosphereReadWriteRegister(phys_addr, mask, value, &out_value)));
|
||||
R_ABORT_UNLESS(spl::smc::ConvertResult(spl::smc::AtmosphereReadWriteRegister(phys_addr, mask, value, std::addressof(out_value))));
|
||||
return out_value;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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? */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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(×tamp)) {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue