From 3627418e0ee7b4720dca7194534a206dc626869e Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Tue, 9 Jun 2015 18:58:02 -0500 Subject: [PATCH] Object table handle duplication --- src/xenia/kernel/object_table.cc | 15 +++++++++++++++ src/xenia/kernel/object_table.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/xenia/kernel/object_table.cc b/src/xenia/kernel/object_table.cc index 8defb54c5..50cb6720c 100644 --- a/src/xenia/kernel/object_table.cc +++ b/src/xenia/kernel/object_table.cc @@ -112,6 +112,21 @@ X_STATUS ObjectTable::AddHandle(XObject* object, X_HANDLE* out_handle) { return result; } +X_STATUS ObjectTable::DuplicateHandle(X_HANDLE handle, X_HANDLE* out_handle) { + X_STATUS result = X_STATUS_SUCCESS; + handle = TranslateHandle(handle); + + XObject* object = LookupObject(handle, false); + if (object) { + result = AddHandle(object, out_handle); + object->Release(); // Release the ref that LookupObject took + } else { + result = X_STATUS_INVALID_HANDLE; + } + + return result; +} + X_STATUS ObjectTable::RemoveHandle(X_HANDLE handle) { X_STATUS result = X_STATUS_SUCCESS; diff --git a/src/xenia/kernel/object_table.h b/src/xenia/kernel/object_table.h index e5ba8061e..340a01b9a 100644 --- a/src/xenia/kernel/object_table.h +++ b/src/xenia/kernel/object_table.h @@ -27,6 +27,7 @@ class ObjectTable { ~ObjectTable(); X_STATUS AddHandle(XObject* object, X_HANDLE* out_handle); + X_STATUS DuplicateHandle(X_HANDLE orig, X_HANDLE* out_handle); X_STATUS RemoveHandle(X_HANDLE handle); template object_ref LookupObject(X_HANDLE handle) {