mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-02 23:59:49 -04:00
stratosphere: more result cleanup
This commit is contained in:
parent
7b6050a0cb
commit
cead8a36ea
38 changed files with 158 additions and 448 deletions
|
@ -92,9 +92,7 @@ Result ContentManagement::MountCode(u64 tid, FsStorageId sid) {
|
|||
|
||||
/* Always re-initialize fsp-ldr, in case it's closed */
|
||||
DoWithSmSession([&]() {
|
||||
if (R_FAILED(fsldrInitialize())) {
|
||||
std::abort();
|
||||
}
|
||||
R_ASSERT(fsldrInitialize());
|
||||
});
|
||||
ON_SCOPE_EXIT { fsldrExit(); };
|
||||
|
||||
|
|
|
@ -26,11 +26,13 @@ Result HidManagement::GetKeysHeld(u64 *keys) {
|
|||
}
|
||||
|
||||
if (!serviceIsActive(hidGetSessionService())) {
|
||||
Result rc;
|
||||
bool initialized = false;
|
||||
DoWithSmSession([&]() {
|
||||
rc = hidInitialize();
|
||||
if (R_SUCCEEDED(hidInitialize())) {
|
||||
initialized = true;
|
||||
}
|
||||
});
|
||||
if (R_FAILED(rc)) {
|
||||
if (!initialized) {
|
||||
return MAKERESULT(Module_Libnx, LibnxError_InitFail_HID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,26 +66,13 @@ void __libnx_initheap(void) {
|
|||
}
|
||||
|
||||
void __appInit(void) {
|
||||
Result rc;
|
||||
|
||||
SetFirmwareVersionForLibnx();
|
||||
|
||||
/* Initialize services we need (TODO: SPL) */
|
||||
DoWithSmSession([&]() {
|
||||
rc = fsInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
rc = lrInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
rc = fsldrInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
std::abort();
|
||||
}
|
||||
R_ASSERT(fsInitialize());
|
||||
R_ASSERT(lrInitialize());
|
||||
R_ASSERT(fsldrInitialize());
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -56,9 +56,7 @@ Result MapUtils::LocateSpaceForMapModern(u64 *out, u64 out_size) {
|
|||
}
|
||||
cur_base = address_space.map_end;
|
||||
} else {
|
||||
if (R_FAILED(svcQueryMemory(&mem_info, &page_info, cur_base))) {
|
||||
std::abort();
|
||||
}
|
||||
R_ASSERT(svcQueryMemory(&mem_info, &page_info, cur_base));
|
||||
if (mem_info.type == 0 && mem_info.addr - cur_base + mem_info.size >= out_size) {
|
||||
*out = cur_base;
|
||||
return ResultSuccess;
|
||||
|
|
|
@ -71,9 +71,7 @@ class AutoCloseMap {
|
|||
|
||||
void Close() {
|
||||
if (this->mapped_address) {
|
||||
if (R_FAILED(svcUnmapProcessMemory(this->mapped_address, this->process_handle, this->base_address, this->size))) {
|
||||
std::abort();
|
||||
}
|
||||
R_ASSERT(svcUnmapProcessMemory(this->mapped_address, this->process_handle, this->base_address, this->size));
|
||||
this->mapped_address = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,8 +165,9 @@ Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nc
|
|||
}
|
||||
ON_SCOPE_EXIT {
|
||||
if (mounted_code) {
|
||||
if (R_FAILED(ContentManagement::UnmountCode()) && target_process->tid_sid.storage_id != FsStorageId_None) {
|
||||
std::abort();
|
||||
const Result unmount_res = ContentManagement::UnmountCode();
|
||||
if (target_process->tid_sid.storage_id != FsStorageId_None) {
|
||||
R_ASSERT(unmount_res);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -139,8 +139,9 @@ void Registration::AssociatePidTidForMitM(u64 index) {
|
|||
}
|
||||
|
||||
Handle sm_hnd;
|
||||
Result rc = svcConnectToNamedPort(&sm_hnd, "sm:");
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (R_SUCCEEDED(svcConnectToNamedPort(&sm_hnd, "sm:"))) {
|
||||
ON_SCOPE_EXIT { svcCloseHandle(sm_hnd); };
|
||||
|
||||
/* Initialize. */
|
||||
{
|
||||
IpcCommand c;
|
||||
|
@ -158,22 +159,25 @@ void Registration::AssociatePidTidForMitM(u64 index) {
|
|||
raw->cmd_id = 0;
|
||||
raw->zero = 0;
|
||||
|
||||
rc = ipcDispatch(sm_hnd);
|
||||
if (R_FAILED(ipcDispatch(sm_hnd))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = (decltype(resp))r.Raw;
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = (decltype(resp))r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
if (R_FAILED(resp->result)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Associate. */
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
{
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
struct {
|
||||
|
@ -190,6 +194,5 @@ void Registration::AssociatePidTidForMitM(u64 index) {
|
|||
|
||||
ipcDispatch(sm_hnd);
|
||||
}
|
||||
svcCloseHandle(sm_hnd);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue