[Kernel] Implemented: KeSetPriorityThread

This commit is contained in:
Gliniak 2025-05-12 21:10:19 +02:00
parent 2c8acf7b96
commit e85c2392ba
2 changed files with 31 additions and 1 deletions

View File

@ -1782,6 +1782,36 @@ pointer_result_t InterlockedFlushSList_entry(
}
DECLARE_XBOXKRNL_EXPORT1(InterlockedFlushSList, kThreading, kImplemented);
dword_result_t KeSetPriorityThread_entry(pointer_t<X_KTHREAD> thread_ptr,
dword_t new_priority,
const ppc_context_t& context) {
if (!thread_ptr) {
XELOGE("{}: Invalid thread_ptr.", __func__);
return 0;
}
if (thread_ptr->header.type != 6) {
XELOGW("{}: Invalid object type: {}", __func__, thread_ptr->header.type);
}
X_KPRCB* prcb = context->TranslateVirtual(thread_ptr->a_prcb_ptr);
const uint32_t old_irql = xeKeKfAcquireSpinLock(context, &prcb->spin_lock);
const uint8_t old_priority = thread_ptr->priority;
auto thread_ref =
XObject::GetNativeObject<XThread>(kernel_state(), thread_ptr);
if (!thread_ref) {
XELOGW("{}: Missing native thread: {}", __func__, thread_ptr->header.type);
} else {
thread_ref->SetPriority(new_priority);
}
xeKeKfReleaseSpinLock(context, &prcb->spin_lock, old_irql);
return old_priority;
}
DECLARE_XBOXKRNL_EXPORT1(KeSetPriorityThread, kThreading, kImplemented);
} // namespace xboxkrnl
} // namespace kernel
} // namespace xe

View File

@ -107,7 +107,7 @@ struct X_KPRCB {
xe::be<uint32_t> dpc_lock; // 0x44
X_LIST_ENTRY queued_dpcs_list_head; // 0x48
xe::be<uint32_t> dpc_active; // 0x50
xe::be<uint32_t> unk_54; // 0x54
X_KSPINLOCK spin_lock; // 0x54
xe::be<uint32_t> unk_58; // 0x58
// definitely scheduler related
X_SINGLE_LIST_ENTRY unk_5C; // 0x5C