Support ObReferenceObjectByHandle for XEvents.
This commit is contained in:
parent
b9debbaa63
commit
f3c75b8d87
|
@ -20,6 +20,8 @@ XEvent::~XEvent() = default;
|
||||||
void XEvent::Initialize(bool manual_reset, bool initial_state) {
|
void XEvent::Initialize(bool manual_reset, bool initial_state) {
|
||||||
assert_false(event_);
|
assert_false(event_);
|
||||||
|
|
||||||
|
this->CreateNative<X_KEVENT>();
|
||||||
|
|
||||||
if (manual_reset) {
|
if (manual_reset) {
|
||||||
event_ = xe::threading::Event::CreateManualResetEvent(initial_state);
|
event_ = xe::threading::Event::CreateManualResetEvent(initial_state);
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,7 +46,11 @@ void XEvent::InitializeNative(void* native_ptr, X_DISPATCH_HEADER* header) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool initial_state = header->signal_state ? true : false;
|
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) {
|
int32_t XEvent::Set(uint32_t priority_increment, bool wait) {
|
||||||
|
|
|
@ -146,7 +146,7 @@ uint8_t GetFakeCpuNumber(uint8_t proc_mask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
X_STATUS XThread::Create() {
|
X_STATUS XThread::Create() {
|
||||||
// Thread kernel object
|
// Thread kernel object.
|
||||||
// This call will also setup the native pointer for us.
|
// This call will also setup the native pointer for us.
|
||||||
auto guest_thread = CreateNative<X_KTHREAD>();
|
auto guest_thread = CreateNative<X_KTHREAD>();
|
||||||
if (!guest_thread) {
|
if (!guest_thread) {
|
||||||
|
|
|
@ -97,14 +97,20 @@ SHIM_CALL ObReferenceObjectByHandle_shim(PPCContext* ppc_context,
|
||||||
switch (object_type_ptr) {
|
switch (object_type_ptr) {
|
||||||
case 0x00000000: { // whatever?
|
case 0x00000000: { // whatever?
|
||||||
switch (object->type()) {
|
switch (object->type()) {
|
||||||
// TODO(benvanik): need to track native_ptr in XObject, allocate as
|
case XObject::kTypeEvent: {
|
||||||
// needed?
|
assert(object->type() == XObject::kTypeEvent);
|
||||||
/*case XObject::kTypeEvent: {
|
native_ptr = object->guest_object();
|
||||||
XEvent* ev = (XEvent*)object;
|
assert_not_zero(native_ptr);
|
||||||
} break;*/
|
} break;
|
||||||
|
case XObject::kTypeSemaphore: {
|
||||||
|
assert(object->type() == XObject::kTypeSemaphore);
|
||||||
|
native_ptr = object->guest_object();
|
||||||
|
assert_not_zero(native_ptr);
|
||||||
|
} break;
|
||||||
case XObject::kTypeThread: {
|
case XObject::kTypeThread: {
|
||||||
auto thread = object.get<XThread>();
|
assert(object->type() == XObject::kTypeThread);
|
||||||
native_ptr = thread->guest_object();
|
native_ptr = object->guest_object();
|
||||||
|
assert_not_zero(native_ptr);
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
assert_unhandled_case(object->type());
|
assert_unhandled_case(object->type());
|
||||||
|
@ -114,15 +120,13 @@ SHIM_CALL ObReferenceObjectByHandle_shim(PPCContext* ppc_context,
|
||||||
} break;
|
} break;
|
||||||
case 0xD017BEEF: { // ExSemaphoreObjectType
|
case 0xD017BEEF: { // ExSemaphoreObjectType
|
||||||
assert(object->type() == XObject::kTypeSemaphore);
|
assert(object->type() == XObject::kTypeSemaphore);
|
||||||
auto sem = object.get<XSemaphore>();
|
native_ptr = object->guest_object();
|
||||||
|
assert_not_zero(native_ptr);
|
||||||
native_ptr = sem->guest_object();
|
|
||||||
} break;
|
} break;
|
||||||
case 0xD01BBEEF: { // ExThreadObjectType
|
case 0xD01BBEEF: { // ExThreadObjectType
|
||||||
assert(object->type() == XObject::kTypeThread);
|
assert(object->type() == XObject::kTypeThread);
|
||||||
auto thread = object.get<XThread>();
|
native_ptr = object->guest_object();
|
||||||
|
assert_not_zero(native_ptr);
|
||||||
native_ptr = thread->guest_object();
|
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
assert_unhandled_case(object_type_ptr);
|
assert_unhandled_case(object_type_ptr);
|
||||||
|
|
Loading…
Reference in New Issue