diff --git a/src/xenia/kernel/objects/xthread.cc b/src/xenia/kernel/objects/xthread.cc index afbec952b..4d5d4cfeb 100644 --- a/src/xenia/kernel/objects/xthread.cc +++ b/src/xenia/kernel/objects/xthread.cc @@ -382,6 +382,14 @@ void XThread::LowerIrql(uint32_t new_irql) { irql_ = new_irql; } +int32_t XThread::QueryPriority() { + return GetThreadPriority(thread_handle_); +} + +void XThread::SetPriority(int32_t increment) { + SetThreadPriority(thread_handle_, increment); +} + X_STATUS XThread::Resume(uint32_t* out_suspend_count) { DWORD result = ResumeThread(thread_handle_); if (result >= 0) { diff --git a/src/xenia/kernel/objects/xthread.h b/src/xenia/kernel/objects/xthread.h index e1171c935..d9f222e47 100644 --- a/src/xenia/kernel/objects/xthread.h +++ b/src/xenia/kernel/objects/xthread.h @@ -59,6 +59,9 @@ public: uint32_t RaiseIrql(uint32_t new_irql); void LowerIrql(uint32_t new_irql); + int32_t QueryPriority(); + void SetPriority(int32_t increment); + X_STATUS Resume(uint32_t* out_suspend_count); X_STATUS Suspend(uint32_t* out_suspend_count); X_STATUS Delay( diff --git a/src/xenia/kernel/xboxkrnl_threading.cc b/src/xenia/kernel/xboxkrnl_threading.cc index 54f0ec9ce..637710450 100644 --- a/src/xenia/kernel/xboxkrnl_threading.cc +++ b/src/xenia/kernel/xboxkrnl_threading.cc @@ -302,6 +302,26 @@ SHIM_CALL KeSetAffinityThread_shim( } +SHIM_CALL KeQueryBasePriorityThread_shim( + PPCContext* ppc_state, KernelState* state) { + uint32_t thread_ptr = SHIM_GET_ARG_32(0); + + XELOGD( + "KeQueryBasePriorityThread(%.8X)", + thread_ptr); + + int32_t priority = 0; + + XThread* thread = (XThread*)XObject::GetObject( + state, SHIM_MEM_ADDR(thread_ptr)); + if (thread) { + priority = thread->QueryPriority(); + } + + SHIM_SET_RETURN(priority); +} + + uint32_t xeKeSetBasePriorityThread(void* thread_ptr, int32_t increment) { KernelState* state = shared_kernel_state_; XEASSERTNOTNULL(state); @@ -310,8 +330,8 @@ uint32_t xeKeSetBasePriorityThread(void* thread_ptr, int32_t increment) { XThread* thread = (XThread*)XObject::GetObject(state, thread_ptr); if (thread) { - // TODO(benvanik): implement. - XELOGW("KeSetBasePriority not implemented"); + prev_priority = thread->QueryPriority(); + thread->SetPriority(increment); } return prev_priority; @@ -1282,6 +1302,7 @@ void xe::kernel::xboxkrnl::RegisterThreadingExports( SHIM_SET_MAPPING("xboxkrnl.exe", KeResumeThread, state); SHIM_SET_MAPPING("xboxkrnl.exe", NtSuspendThread, state); SHIM_SET_MAPPING("xboxkrnl.exe", KeSetAffinityThread, state); + SHIM_SET_MAPPING("xboxkrnl.exe", KeQueryBasePriorityThread, state); SHIM_SET_MAPPING("xboxkrnl.exe", KeSetBasePriorityThread, state); SHIM_SET_MAPPING("xboxkrnl.exe", KeGetCurrentProcessType, state);