mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-14 15:14:23 -04:00
kern: SvcGetDebugThreadParam
This commit is contained in:
parent
e1f3bb10a5
commit
3afd723b92
6 changed files with 140 additions and 3 deletions
|
@ -1190,6 +1190,41 @@ namespace ams::kern {
|
|||
return std::addressof(this->GetContext());
|
||||
}
|
||||
|
||||
KThread *KThread::GetThreadFromId(u64 thread_id) {
|
||||
/* Lock the list. */
|
||||
KThread::ListAccessor accessor;
|
||||
const auto end = accessor.end();
|
||||
|
||||
/* Define helper object to find the thread. */
|
||||
class IdObjectHelper : public KAutoObjectWithListContainer::ListType::value_type {
|
||||
private:
|
||||
u64 id;
|
||||
public:
|
||||
constexpr explicit IdObjectHelper(u64 id) : id(id) { /* ... */ }
|
||||
virtual u64 GetId() const override { return this->id; }
|
||||
};
|
||||
|
||||
/* Find the object with the right id. */
|
||||
const auto it = accessor.find(IdObjectHelper(thread_id));
|
||||
|
||||
/* Check to make sure we found the thread. */
|
||||
if (it == end) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Get the thread. */
|
||||
KThread *thread = static_cast<KThread *>(std::addressof(*it));
|
||||
|
||||
/* Open the thread. */
|
||||
if (AMS_LIKELY(thread->Open())) {
|
||||
MESOSPHERE_ASSERT(thread->GetId() == thread_id);
|
||||
return thread;
|
||||
}
|
||||
|
||||
/* We failed to find the thread. */
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Result KThread::GetThreadList(s32 *out_num_threads, ams::kern::svc::KUserPointer<u64 *> out_thread_ids, s32 max_out_count) {
|
||||
/* Lock the list. */
|
||||
KThread::ListAccessor accessor;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue