From 55f5b956709ccd7244f0cd7837d7b3fd8c54718a Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Fri, 17 Jul 2015 19:58:56 -0500 Subject: [PATCH] These are implemented (and formatting) --- src/xenia/kernel/xboxkrnl_ob.cc | 57 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/src/xenia/kernel/xboxkrnl_ob.cc b/src/xenia/kernel/xboxkrnl_ob.cc index df6b1f858..7bf99bdb5 100644 --- a/src/xenia/kernel/xboxkrnl_ob.cc +++ b/src/xenia/kernel/xboxkrnl_ob.cc @@ -49,6 +49,34 @@ SHIM_CALL ObOpenObjectByName_shim(PPCContext* ppc_context, SHIM_SET_RETURN_32(result); } +dword_result_t ObOpenObjectByPointer(lpvoid_t object_ptr, + lpdword_t out_handle_ptr) { + auto object = XObject::GetNativeObject(kernel_state(), object_ptr); + if (!object) { + return X_STATUS_UNSUCCESSFUL; + } + + // Retain the handle. Will be released in NtClose. + object->RetainHandle(); + *out_handle_ptr = object->handle(); + return X_STATUS_SUCCESS; +} +DECLARE_XBOXKRNL_EXPORT(ObOpenObjectByPointer, ExportTag::kImplemented); + +dword_result_t ObLookupThreadByThreadId(dword_t thread_id, + lpdword_t out_object_ptr) { + auto thread = kernel_state()->GetThreadByID(thread_id); + if (!thread) { + return X_STATUS_NOT_FOUND; + } + + // Retain the object. Will be released in ObDereferenceObject. + thread->Retain(); + *out_object_ptr = thread->guest_object(); + return X_STATUS_SUCCESS; +} +DECLARE_XBOXKRNL_EXPORT(ObLookupThreadByThreadId, ExportTag::kImplemented); + SHIM_CALL ObReferenceObjectByHandle_shim(PPCContext* ppc_context, KernelState* kernel_state) { uint32_t handle = SHIM_GET_ARG_32(0); @@ -136,35 +164,6 @@ SHIM_CALL ObDereferenceObject_shim(PPCContext* ppc_context, SHIM_SET_RETURN_32(0); } -dword_result_t ObLookupThreadByThreadId(dword_t thread_id, lpdword_t out_object_ptr) { - auto thread = kernel_state()->GetThreadByID(thread_id); - if (!thread) { - return X_STATUS_NOT_FOUND; - } - - // Retain the object. Will be released in ObDereferenceObject. - thread->Retain(); - *out_object_ptr = thread->guest_object(); - auto hdr = kernel_memory()->TranslateVirtual(thread->guest_object()); - assert_true(hdr->type == 6); - - return X_STATUS_SUCCESS; -} -DECLARE_XBOXKRNL_EXPORT(ObLookupThreadByThreadId, ExportTag::kStub); - -dword_result_t ObOpenObjectByPointer(lpvoid_t object_ptr, lpdword_t out_handle_ptr) { - auto object = XObject::GetNativeObject(kernel_state(), object_ptr); - if (!object) { - return X_STATUS_UNSUCCESSFUL; - } - - // Retain the handle. Will be released in NtClose. - object->RetainHandle(); - *out_handle_ptr = object->handle(); - return X_STATUS_SUCCESS; -} -DECLARE_XBOXKRNL_EXPORT(ObOpenObjectByPointer, ExportTag::kStub); - dword_result_t NtDuplicateObject(dword_t handle, lpdword_t new_handle_ptr, dword_t options) { // NOTE: new_handle_ptr can be zero to just close a handle.