mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-25 10:17:18 +02:00
process: Make MirrorMemory take state to map new memory as
Credits to Subv
This commit is contained in:
parent
8aa17f0480
commit
0276761a1e
@ -259,7 +259,8 @@ public:
|
|||||||
ResultVal<VAddr> HeapAllocate(VAddr target, u64 size, VMAPermission perms);
|
ResultVal<VAddr> HeapAllocate(VAddr target, u64 size, VMAPermission perms);
|
||||||
ResultCode HeapFree(VAddr target, u32 size);
|
ResultCode HeapFree(VAddr target, u32 size);
|
||||||
|
|
||||||
ResultCode MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size);
|
ResultCode MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size,
|
||||||
|
MemoryState state = MemoryState::Mapped);
|
||||||
|
|
||||||
ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size);
|
ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size);
|
||||||
|
|
||||||
|
@ -170,17 +170,20 @@ static constexpr u32 PageAlignSize(u32 size) {
|
|||||||
arg_data.size());
|
arg_data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read MOD header
|
|
||||||
ModHeader mod_header{};
|
|
||||||
// Default .bss to NRO header bss size if MOD0 section doesn't exist
|
// Default .bss to NRO header bss size if MOD0 section doesn't exist
|
||||||
u32 bss_size{PageAlignSize(nro_header.bss_size)};
|
u32 bss_size{PageAlignSize(nro_header.bss_size)};
|
||||||
|
|
||||||
|
// Read MOD header
|
||||||
|
ModHeader mod_header{};
|
||||||
std::memcpy(&mod_header, program_image.data() + nro_header.module_header_offset,
|
std::memcpy(&mod_header, program_image.data() + nro_header.module_header_offset,
|
||||||
sizeof(ModHeader));
|
sizeof(ModHeader));
|
||||||
|
|
||||||
const bool has_mod_header{mod_header.magic == Common::MakeMagic('M', 'O', 'D', '0')};
|
const bool has_mod_header{mod_header.magic == Common::MakeMagic('M', 'O', 'D', '0')};
|
||||||
if (has_mod_header) {
|
if (has_mod_header) {
|
||||||
// Resize program image to include .bss section and page align each section
|
// Resize program image to include .bss section and page align each section
|
||||||
bss_size = PageAlignSize(mod_header.bss_end_offset - mod_header.bss_start_offset);
|
bss_size = PageAlignSize(mod_header.bss_end_offset - mod_header.bss_start_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
codeset.DataSegment().size += bss_size;
|
codeset.DataSegment().size += bss_size;
|
||||||
program_image.resize(static_cast<u32>(program_image.size()) + bss_size);
|
program_image.resize(static_cast<u32>(program_image.size()) + bss_size);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user