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
|
@ -61,12 +61,7 @@ void DmntCheatDebugEventsManager::ContinueCheatProcess(Handle cheat_dbg_hnd) {
|
|||
if (dbg_event.type == DebugEventType::AttachThread) {
|
||||
u64 out64;
|
||||
u32 out32;
|
||||
Result rc = svcGetDebugThreadParam(&out64, &out32, cheat_dbg_hnd, dbg_event.info.attach_thread.thread_id, DebugThreadParam_CurrentCore);
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
|
||||
|
||||
R_ASSERT(svcGetDebugThreadParam(&out64, &out32, cheat_dbg_hnd, dbg_event.info.attach_thread.thread_id, DebugThreadParam_CurrentCore));
|
||||
target_core = out32;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,15 +54,8 @@ void DmntCheatManager::StartDebugEventsThread() {
|
|||
|
||||
/* Spawn the debug events thread. */
|
||||
if (!g_has_debug_events_thread) {
|
||||
Result rc;
|
||||
|
||||
if (R_FAILED((rc = g_debug_events_thread.Initialize(&DmntCheatManager::DebugEventsThread, nullptr, 0x4000, 48)))) {
|
||||
return fatalSimple(rc);
|
||||
}
|
||||
|
||||
if (R_FAILED((rc = g_debug_events_thread.Start()))) {
|
||||
return fatalSimple(rc);
|
||||
}
|
||||
R_ASSERT(g_debug_events_thread.Initialize(&DmntCheatManager::DebugEventsThread, nullptr, 0x4000, 48));
|
||||
R_ASSERT(g_debug_events_thread.Start());
|
||||
|
||||
g_has_debug_events_thread = true;
|
||||
}
|
||||
|
@ -799,33 +792,22 @@ Result DmntCheatManager::DisableFrozenAddress(u64 address) {
|
|||
}
|
||||
|
||||
Handle DmntCheatManager::PrepareDebugNextApplication() {
|
||||
Result rc;
|
||||
Handle event_h;
|
||||
if (R_FAILED((rc = pmdmntEnableDebugForApplication(&event_h)))) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
R_ASSERT(pmdmntEnableDebugForApplication(&event_h));
|
||||
|
||||
return event_h;
|
||||
}
|
||||
|
||||
static void PopulateMemoryExtents(MemoryRegionExtents *extents, Handle p_h, u64 id_base, u64 id_size) {
|
||||
Result rc;
|
||||
/* Get base extent. */
|
||||
if (R_FAILED((rc = svcGetInfo(&extents->base, id_base, p_h, 0)))) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
R_ASSERT(svcGetInfo(&extents->base, id_base, p_h, 0));
|
||||
|
||||
/* Get size extent. */
|
||||
if (R_FAILED((rc = svcGetInfo(&extents->size, id_size, p_h, 0)))) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
R_ASSERT(svcGetInfo(&extents->size, id_size, p_h, 0));
|
||||
}
|
||||
|
||||
static void StartDebugProcess(u64 pid) {
|
||||
Result rc = pmdmntStartProcess(pid);
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
R_ASSERT(pmdmntStartProcess(pid));
|
||||
}
|
||||
|
||||
Result DmntCheatManager::ForceOpenCheatProcess() {
|
||||
|
@ -921,7 +903,6 @@ Result DmntCheatManager::ForceOpenCheatProcess() {
|
|||
|
||||
void DmntCheatManager::OnNewApplicationLaunch() {
|
||||
std::scoped_lock<HosMutex> attach_lk(g_attach_lock);
|
||||
Result rc;
|
||||
|
||||
{
|
||||
std::scoped_lock<HosMutex> lk(g_cheat_lock);
|
||||
|
@ -937,18 +918,14 @@ void DmntCheatManager::OnNewApplicationLaunch() {
|
|||
std::scoped_lock<HosMutex> lk(g_cheat_lock);
|
||||
|
||||
/* Get the new application's process ID. */
|
||||
if (R_FAILED((rc = pmdmntGetApplicationPid(&g_cheat_process_metadata.process_id)))) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
R_ASSERT(pmdmntGetApplicationPid(&g_cheat_process_metadata.process_id));
|
||||
|
||||
/* Get process handle, use it to learn memory extents. */
|
||||
{
|
||||
Handle proc_h = 0;
|
||||
ON_SCOPE_EXIT { if (proc_h != 0) { svcCloseHandle(proc_h); } };
|
||||
|
||||
if (R_FAILED((rc = pmdmntAtmosphereGetProcessInfo(&proc_h, &g_cheat_process_metadata.title_id, nullptr, g_cheat_process_metadata.process_id)))) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
R_ASSERT(pmdmntAtmosphereGetProcessInfo(&proc_h, &g_cheat_process_metadata.title_id, nullptr, g_cheat_process_metadata.process_id));
|
||||
|
||||
/* Get memory extents. */
|
||||
PopulateMemoryExtents(&g_cheat_process_metadata.heap_extents, proc_h, 4, 5);
|
||||
|
@ -972,9 +949,7 @@ void DmntCheatManager::OnNewApplicationLaunch() {
|
|||
{
|
||||
LoaderModuleInfo proc_modules[2];
|
||||
u32 num_modules;
|
||||
if (R_FAILED((rc = ldrDmntGetModuleInfos(g_cheat_process_metadata.process_id, proc_modules, sizeof(proc_modules)/sizeof(proc_modules[0]), &num_modules)))) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
R_ASSERT(ldrDmntGetModuleInfos(g_cheat_process_metadata.process_id, proc_modules, sizeof(proc_modules)/sizeof(proc_modules[0]), &num_modules));
|
||||
|
||||
/* All applications must have two modules. */
|
||||
/* If we only have one, we must be e.g. mitming HBL. */
|
||||
|
@ -999,9 +974,7 @@ void DmntCheatManager::OnNewApplicationLaunch() {
|
|||
}
|
||||
|
||||
/* Open a debug handle. */
|
||||
if (R_FAILED((rc = svcDebugActiveProcess(&g_cheat_process_debug_hnd, g_cheat_process_metadata.process_id)))) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
R_ASSERT(svcDebugActiveProcess(&g_cheat_process_debug_hnd, g_cheat_process_metadata.process_id));
|
||||
|
||||
/* Start the process. */
|
||||
StartDebugProcess(g_cheat_process_metadata.process_id);
|
||||
|
|
|
@ -59,64 +59,23 @@ void __libnx_initheap(void) {
|
|||
}
|
||||
|
||||
void __appInit(void) {
|
||||
Result rc;
|
||||
|
||||
SetFirmwareVersionForLibnx();
|
||||
|
||||
DoWithSmSession([&]() {
|
||||
rc = pmdmntInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
|
||||
rc = ldrDmntInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
|
||||
R_ASSERT(pmdmntInitialize());
|
||||
R_ASSERT(ldrDmntInitialize());
|
||||
/* TODO: We provide this on every sysver via ro. Do we need a shim? */
|
||||
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_300) {
|
||||
rc = roDmntInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
}
|
||||
|
||||
rc = nsdevInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
|
||||
rc = lrInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
|
||||
rc = setInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
|
||||
rc = setsysInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
|
||||
rc = hidInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
|
||||
rc = fsInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
R_ASSERT(roDmntInitialize());
|
||||
}
|
||||
R_ASSERT(nsdevInitialize());
|
||||
R_ASSERT(lrInitialize());
|
||||
R_ASSERT(setInitialize());
|
||||
R_ASSERT(setsysInitialize());
|
||||
R_ASSERT(fsInitialize());
|
||||
});
|
||||
|
||||
rc = fsdevMountSdmc();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(rc);
|
||||
}
|
||||
R_ASSERT(fsdevMountSdmc());
|
||||
|
||||
CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue