1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-26 13:52:21 +00:00

pm: work around HOS bug

This commit is contained in:
hexkyz 2019-07-23 19:38:14 +01:00 committed by GitHub
parent 00f4e5158f
commit 7e169bc7df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,17 +110,20 @@ namespace {
/* This uses debugging SVCs to retrieve a process's title id. */ /* This uses debugging SVCs to retrieve a process's title id. */
sts::ncm::TitleId GetProcessTitleId(u64 process_id) { sts::ncm::TitleId GetProcessTitleId(u64 process_id) {
/* Get a debug handle, or return our title id. */ /* Check if we should return our title id. */
/* Doing this here works around a bug fixed in 6.0.0. */
/* Not doing so will cause svcDebugActiveProcess to deadlock on lower firmwares if called for it's own process. */
u64 current_process_id = 0;
R_ASSERT(svcGetProcessId(&current_process_id, CUR_PROCESS_HANDLE));
if (current_process_id == process_id) {
return __stratosphere_title_id;
}
/* Get a debug handle. */
AutoHandle debug_handle; AutoHandle debug_handle;
if (R_FAILED(svcDebugActiveProcess(debug_handle.GetPointer(), process_id))) { if (R_FAILED(svcDebugActiveProcess(debug_handle.GetPointer(), process_id))) {
u64 current_process_id = 0; /* If we fail to debug a process other than our own, abort. */
R_ASSERT(svcGetProcessId(&current_process_id, CUR_PROCESS_HANDLE)); std::abort();
if (current_process_id == process_id) {
return __stratosphere_title_id;
} else {
/* If we fail to debug a process other than our own, abort. */
std::abort();
}
} }
/* Loop until we get the event that tells us about the process. */ /* Loop until we get the event that tells us about the process. */