From 98e14fcb1bba4959e6d418d32b10668bec5dc078 Mon Sep 17 00:00:00 2001 From: gibbed Date: Sun, 7 Jun 2015 21:08:16 -0500 Subject: [PATCH] Hack for KeWaitForSingleObject when games pass in object handles. --- src/xenia/kernel/xboxkrnl_threading.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/xenia/kernel/xboxkrnl_threading.cc b/src/xenia/kernel/xboxkrnl_threading.cc index 7a4fb63d9..424fd394d 100644 --- a/src/xenia/kernel/xboxkrnl_threading.cc +++ b/src/xenia/kernel/xboxkrnl_threading.cc @@ -858,8 +858,19 @@ SHIM_CALL KeWaitForSingleObject_shim(PPCContext* ppc_context, XELOGD("KeWaitForSingleObject(%.8X, %.8X, %.8X, %.1X, %.8X)", object_ptr, wait_reason, processor_mode, alertable, timeout_ptr); - auto object = XObject::GetNativeObject(kernel_state, - SHIM_MEM_ADDR(object_ptr)); + object_ref object; + if (object_ptr < 0x1000) { + // They passed in a handle (for some reason) + object = kernel_state->object_table()->LookupObject(object_ptr); + + // Log it in case this is the source of any problems in the future + XELOGD("KeWaitForSingleObject - Interpreting object ptr as handle!"); + } + else { + object = XObject::GetNativeObject(kernel_state, + SHIM_MEM_ADDR(object_ptr)); + } + if (!object) { // The only kind-of failure code. SHIM_SET_RETURN_32(X_STATUS_ABANDONED_WAIT_0);