From f14a52358ac02e66018a22fc20a64c039ac76a9b Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Sun, 17 May 2015 11:03:02 -0500 Subject: [PATCH] KeSetBasePriorityThread: Some games apparently pass in the thread handle instead --- src/xenia/kernel/xboxkrnl_threading.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/xenia/kernel/xboxkrnl_threading.cc b/src/xenia/kernel/xboxkrnl_threading.cc index 2c4813de7..ca8bc6c12 100644 --- a/src/xenia/kernel/xboxkrnl_threading.cc +++ b/src/xenia/kernel/xboxkrnl_threading.cc @@ -247,8 +247,18 @@ SHIM_CALL KeSetBasePriorityThread_shim(PPCContext* ppc_state, int32_t prev_priority = 0; - XThread* thread = - (XThread*)XObject::GetObject(state, SHIM_MEM_ADDR(thread_ptr)); + XThread* thread = NULL; + if (thread_ptr < 0x1000) { + // They passed in a handle (for some reason) + X_STATUS result = + state->object_table()->GetObject(thread_ptr, (XObject**)&thread); + + // Log it in case this is the source of any problems in the future + XELOGD("KeSetBasePriorityThread - Interpreting thread ptr as handle!"); + } else { + thread = (XThread*)XObject::GetObject(state, SHIM_MEM_ADDR(thread_ptr)); + } + if (thread) { prev_priority = thread->QueryPriority(); thread->SetPriority(increment);