diff --git a/src/xenia/kernel/objects/xevent.cc b/src/xenia/kernel/objects/xevent.cc index 63108ef4c..7da6e7f58 100644 --- a/src/xenia/kernel/objects/xevent.cc +++ b/src/xenia/kernel/objects/xevent.cc @@ -20,6 +20,8 @@ XEvent::~XEvent() = default; void XEvent::Initialize(bool manual_reset, bool initial_state) { assert_false(event_); + this->CreateNative(); + if (manual_reset) { event_ = xe::threading::Event::CreateManualResetEvent(initial_state); } else { @@ -44,7 +46,11 @@ void XEvent::InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header) { } bool initial_state = header->signal_state ? true : false; - Initialize(manual_reset, initial_state); + if (manual_reset) { + event_ = xe::threading::Event::CreateManualResetEvent(initial_state); + } else { + event_ = xe::threading::Event::CreateAutoResetEvent(initial_state); + } } int32_t XEvent::Set(uint32_t priority_increment, bool wait) { diff --git a/src/xenia/kernel/objects/xthread.cc b/src/xenia/kernel/objects/xthread.cc index 01f6825d1..32800df6b 100644 --- a/src/xenia/kernel/objects/xthread.cc +++ b/src/xenia/kernel/objects/xthread.cc @@ -146,7 +146,7 @@ uint8_t GetFakeCpuNumber(uint8_t proc_mask) { } X_STATUS XThread::Create() { - // Thread kernel object + // Thread kernel object. // This call will also setup the native pointer for us. auto guest_thread = CreateNative(); if (!guest_thread) { diff --git a/src/xenia/kernel/xboxkrnl_ob.cc b/src/xenia/kernel/xboxkrnl_ob.cc index 6846dff9f..b71a59f18 100644 --- a/src/xenia/kernel/xboxkrnl_ob.cc +++ b/src/xenia/kernel/xboxkrnl_ob.cc @@ -97,14 +97,20 @@ SHIM_CALL ObReferenceObjectByHandle_shim(PPCContext* ppc_context, switch (object_type_ptr) { case 0x00000000: { // whatever? switch (object->type()) { - // TODO(benvanik): need to track native_ptr in XObject, allocate as - // needed? - /*case XObject::kTypeEvent: { - XEvent* ev = (XEvent*)object; - } break;*/ + case XObject::kTypeEvent: { + assert(object->type() == XObject::kTypeEvent); + native_ptr = object->guest_object(); + assert_not_zero(native_ptr); + } break; + case XObject::kTypeSemaphore: { + assert(object->type() == XObject::kTypeSemaphore); + native_ptr = object->guest_object(); + assert_not_zero(native_ptr); + } break; case XObject::kTypeThread: { - auto thread = object.get(); - native_ptr = thread->guest_object(); + assert(object->type() == XObject::kTypeThread); + native_ptr = object->guest_object(); + assert_not_zero(native_ptr); } break; default: { assert_unhandled_case(object->type()); @@ -114,15 +120,13 @@ SHIM_CALL ObReferenceObjectByHandle_shim(PPCContext* ppc_context, } break; case 0xD017BEEF: { // ExSemaphoreObjectType assert(object->type() == XObject::kTypeSemaphore); - auto sem = object.get(); - - native_ptr = sem->guest_object(); + native_ptr = object->guest_object(); + assert_not_zero(native_ptr); } break; case 0xD01BBEEF: { // ExThreadObjectType assert(object->type() == XObject::kTypeThread); - auto thread = object.get(); - - native_ptr = thread->guest_object(); + native_ptr = object->guest_object(); + assert_not_zero(native_ptr); } break; default: { assert_unhandled_case(object_type_ptr);