Skip to content

Commit

Permalink
Merge branch 'xenia-canary:canary_experimental' into Custom
Browse files Browse the repository at this point in the history
  • Loading branch information
backgamon authored Nov 11, 2023
2 parents c26ce92 + 355e254 commit e58949c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 30 deletions.
40 changes: 12 additions & 28 deletions src/xenia/kernel/xobject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<X_OBJECT_HEADER*>(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);
}
}
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -372,23 +369,15 @@ object_ref<XObject> XObject::GetNativeObject(KernelState* kernel_state,
if (as_type == -1) {
as_type = header->type;
}
auto true_object_header =
kernel_state->memory()->TranslateVirtual<X_OBJECT_HEADER*>(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<XObject>(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
Expand Down Expand Up @@ -431,24 +420,19 @@ object_ref<XObject> 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<XObject>(result);
}

if (!already_locked) {
global_critical_region::mutex().unlock();
}
return object_ref<XObject>(result);
}

} // namespace kernel
Expand Down
3 changes: 1 addition & 2 deletions src/xenia/patcher/patch_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ std::vector<PatchFileEntry> 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;
Expand Down

0 comments on commit e58949c

Please sign in to comment.