From 22a27098a4f95639f0729d5ad4f7c51c888193fc Mon Sep 17 00:00:00 2001 From: Gliniak Date: Thu, 9 Nov 2023 17:54:33 +0100 Subject: [PATCH 1/2] [Patcher] Make hash mandatory. This is to prevent further frustration. "I added custom patch, removed hash and NOW MY GAME DOESN'T WORK! PLZ FIX" --- src/xenia/patcher/patch_db.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/xenia/patcher/patch_db.cc b/src/xenia/patcher/patch_db.cc index e3acb573dd..2f8f6bfad9 100644 --- a/src/xenia/patcher/patch_db.cc +++ b/src/xenia/patcher/patch_db.cc @@ -201,8 +201,7 @@ std::vector PatchDB::GetTitlePatches( bool hash_exist = std::find(entry.hashes.cbegin(), entry.hashes.cend(), hash) != entry.hashes.cend(); - return entry.title_id == title_id && - (entry.hashes.empty() || hash_exist); + return entry.title_id == title_id && hash_exist; }); return title_patches; From 355e25461e44b85ce6f9d8e6cbf4be1014d9c13f Mon Sep 17 00:00:00 2001 From: Gliniak Date: Fri, 10 Nov 2023 09:15:12 +0100 Subject: [PATCH 2/2] [Kernel] Fixed ptr oopsie in XObject destructor - Removed unnecessary goto statement from XObject::GetNativeObject - Removed unnecessary comments (obsolete) - Removed unused code --- src/xenia/kernel/xobject.cc | 40 +++++++++++-------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/src/xenia/kernel/xobject.cc b/src/xenia/kernel/xobject.cc index 74177d7742..9f896258a7 100644 --- a/src/xenia/kernel/xobject.cc +++ b/src/xenia/kernel/xobject.cc @@ -55,10 +55,10 @@ XObject::~XObject() { assert_zero(pointer_ref_count_); if (allocated_guest_object_) { - uint32_t ptr = guest_object_ptr_ - sizeof(X_OBJECT_HEADER); - auto header = memory()->TranslateVirtual(ptr); + kernel_state()->object_table()->UnmapGuestObjectHostHandle( + guest_object_ptr_); - kernel_state()->object_table()->UnmapGuestObjectHostHandle(ptr); + const uint32_t ptr = guest_object_ptr_ - sizeof(X_OBJECT_HEADER); memory()->SystemHeapFree(ptr); } } @@ -338,9 +338,6 @@ void XObject::SetNativePointer(uint32_t native_ptr, bool uninitialized) { // If hit: We've already setup the native ptr with CreateNative! assert_zero(guest_object_ptr_); - // Stash pointer in struct. - // FIXME: This assumes the object has a dispatch header (some don't!) - //StashHandle(header, handle()); kernel_state()->object_table()->MapGuestObjectToHostHandle(native_ptr, handle()); @@ -372,23 +369,15 @@ object_ref XObject::GetNativeObject(KernelState* kernel_state, if (as_type == -1) { as_type = header->type; } - auto true_object_header = - kernel_state->memory()->TranslateVirtual(guest_ptr-sizeof(X_OBJECT_HEADER)); X_HANDLE host_handle; - if (kernel_state->object_table()->HostHandleForGuestObject(guest_ptr, host_handle)) { // Already initialized. // TODO: assert if the type of the object != as_type - - result = kernel_state->object_table() ->LookupObject(host_handle, true) .release(); - goto return_result; - // TODO(benvanik): assert nothing has been changed in the struct. - // return object; } else { // First use, create new. // https://www.nirsoft.net/kernel_struct/vista/KOBJECTS.html @@ -431,24 +420,19 @@ object_ref XObject::GetNativeObject(KernelState* kernel_state, default: assert_always(); result = nullptr; - goto return_result; - - // return NULL; } - // Stash pointer in struct. - // FIXME: This assumes the object contains a dispatch header (some don't!) - // StashHandle(header, object->handle()); - kernel_state->object_table()->MapGuestObjectToHostHandle(guest_ptr, - object->handle()); - result = object; - - return_result: - if (!already_locked) { - global_critical_region::mutex().unlock(); + if (object) { + kernel_state->object_table()->MapGuestObjectToHostHandle( + guest_ptr, object->handle()); + result = object; } - return object_ref(result); } + + if (!already_locked) { + global_critical_region::mutex().unlock(); + } + return object_ref(result); } } // namespace kernel