Support ObReferenceObjectByHandle for XEvents.

This commit is contained in:
Ben Vanik 2015-09-01 17:42:07 -07:00
parent b9debbaa63
commit f3c75b8d87
3 changed files with 25 additions and 15 deletions

View File

@ -20,6 +20,8 @@ XEvent::~XEvent() = default;
void XEvent::Initialize(bool manual_reset, bool initial_state) {
assert_false(event_);
this->CreateNative<X_KEVENT>();
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) {

View File

@ -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<X_KTHREAD>();
if (!guest_thread) {

View File

@ -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<XThread>();
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<XSemaphore>();
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<XThread>();
native_ptr = thread->guest_object();
native_ptr = object->guest_object();
assert_not_zero(native_ptr);
} break;
default: {
assert_unhandled_case(object_type_ptr);