diff --git a/src/xenia/emulator.cc b/src/xenia/emulator.cc index 91a9d9101..38ffba47c 100644 --- a/src/xenia/emulator.cc +++ b/src/xenia/emulator.cc @@ -535,8 +535,7 @@ const std::filesystem::path Emulator::GetNewDiscPath( {"All Files (*.*)", "*.*"}, }); - if (file_picker->Show( - kernel_state()->emulator()->display_window()->native_handle())) { + if (file_picker->Show()) { auto selected_files = file_picker->selected_files(); if (!selected_files.empty()) { path = selected_files[0]; diff --git a/src/xenia/kernel/xam/xam_content.cc b/src/xenia/kernel/xam/xam_content.cc index ae461b5cc..09777efeb 100644 --- a/src/xenia/kernel/xam/xam_content.cc +++ b/src/xenia/kernel/xam/xam_content.cc @@ -443,9 +443,9 @@ typedef struct { } X_SWAPDISC_ERROR_MESSAGE; static_assert_size(X_SWAPDISC_ERROR_MESSAGE, 12); -dword_result_t XamSwapDisc(dword_t disc_number, - pointer_t completion_handle, - pointer_t error_message) { +dword_result_t XamSwapDisc_entry( + dword_t disc_number, pointer_t completion_handle, + pointer_t error_message) { xex2_opt_execution_info* info = nullptr; kernel_state()->GetExecutableModule()->GetOptHeader(XEX_HEADER_EXECUTION_INFO, diff --git a/src/xenia/memory.cc b/src/xenia/memory.cc index fa24da118..b37418050 100644 --- a/src/xenia/memory.cc +++ b/src/xenia/memory.cc @@ -555,7 +555,7 @@ uint32_t Memory::SystemHeapAlloc(uint32_t size, uint32_t alignment, uint32_t address; if (!heap->AllocSystemHeap( size, alignment, kMemoryAllocationReserve | kMemoryAllocationCommit, - kMemoryProtectRead | kMemoryProtectWrite, false, &address)) { + kMemoryProtectRead | kMemoryProtectWrite, true, &address)) { return 0; } Zero(address, size); @@ -823,10 +823,14 @@ bool BaseHeap::Alloc(uint32_t size, uint32_t alignment, *out_address = 0; size = xe::round_up(size, page_size_); alignment = xe::round_up(alignment, page_size_); + uint32_t heap_virtual_guest_offset = 0; + if (heap_type_ == HeapType::kGuestVirtual) { + heap_virtual_guest_offset = 0x10000000; + } + uint32_t low_address = heap_base_; uint32_t high_address = - heap_base_ + (heap_size_ - 1) - - (heap_type_ == HeapType::kGuestVirtual ? 0x10000000 : 0); + heap_base_ + (heap_size_ - 1) - heap_virtual_guest_offset; return AllocRange(low_address, high_address, size, alignment, allocation_type, protect, top_down, out_address); } @@ -1523,6 +1527,12 @@ bool PhysicalHeap::AllocRange(uint32_t low_address, uint32_t high_address, return true; } +bool PhysicalHeap::AllocSystemHeap(uint32_t size, uint32_t alignment, + uint32_t allocation_type, uint32_t protect, + bool top_down, uint32_t* out_address) { + return Alloc(size, alignment, allocation_type, protect, top_down, out_address); +} + bool PhysicalHeap::Decommit(uint32_t address, uint32_t size) { auto global_lock = global_critical_region_.Acquire(); diff --git a/src/xenia/memory.h b/src/xenia/memory.h index 4975f0030..813eb25bc 100644 --- a/src/xenia/memory.h +++ b/src/xenia/memory.h @@ -165,6 +165,9 @@ class BaseHeap { uint32_t allocation_type, uint32_t protect, bool top_down, uint32_t* out_address); + virtual bool AllocSystemHeap(uint32_t size, uint32_t alignment, + uint32_t allocation_type, uint32_t protect, + bool top_down, uint32_t* out_address); // Decommits pages in the given range. // Partial overlapping pages will also be decommitted. virtual bool Decommit(uint32_t address, uint32_t size); @@ -255,6 +258,9 @@ class PhysicalHeap : public BaseHeap { uint32_t alignment, uint32_t allocation_type, uint32_t protect, bool top_down, uint32_t* out_address) override; + bool AllocSystemHeap(uint32_t size, uint32_t alignment, + uint32_t allocation_type, uint32_t protect, + bool top_down, uint32_t* out_address) override; bool Decommit(uint32_t address, uint32_t size) override; bool Release(uint32_t base_address, uint32_t* out_region_size = nullptr) override;