1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2025-02-21 09:40:01 +00:00

cellSaveData: Avoid passing vm pointer to native API

This commit is contained in:
Eladash 2020-02-27 17:24:47 +02:00 committed by Ivan
parent 556aba46b5
commit 42a0512c66
3 changed files with 18 additions and 7 deletions
rpcs3/Emu/Cell

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "Emu/VFS.h"
#include "Emu/Cell/lv2/sys_fs.h"
#include "Emu/Cell/lv2/sys_sync.h"
#include "Emu/Cell/lv2/sys_process.h"
#include "Emu/Cell/PPUModule.h"
@ -1458,7 +1459,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
// Read from memory file to vm
const u64 sr = file.seek(fileSet->fileOffset);
const u64 rr = file.read(fileSet->fileBuf.get_ptr(), access_size);
const u64 rr = lv2_file::op_read(file, fileSet->fileBuf, access_size);
fileGet->excSize = ::narrow<u32>(rr);
break;
}
@ -1474,7 +1475,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
// Write to memory file and truncate
const u64 sr = file.seek(fileSet->fileOffset);
const u64 wr = file.write(fileSet->fileBuf.get_ptr(), access_size);
const u64 wr = lv2_file::op_write(file, fileSet->fileBuf, access_size);
file.trunc(sr + wr);
fileGet->excSize = ::narrow<u32>(wr);
all_times.erase(file_path);
@ -1506,7 +1507,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
// Write to memory file normally
const u64 sr = file.seek(fileSet->fileOffset);
const u64 wr = file.write(fileSet->fileBuf.get_ptr(), access_size);
const u64 wr = lv2_file::op_write(file, fileSet->fileBuf, access_size);
fileGet->excSize = ::narrow<u32>(wr);
all_times.erase(file_path);
add_to_blist(file_path);

@ -86,7 +86,7 @@ lv2_fs_mount_point* lv2_fs_object::get_mp(std::string_view filename)
return &g_mp_sys_dev_hdd0;
}
u64 lv2_file::op_read(vm::ptr<void> buf, u64 size)
u64 lv2_file::op_read(const fs::file& file, vm::ptr<void> buf, u64 size)
{
// Copy data from intermediate buffer (avoid passing vm pointer to a native API)
uchar local_buf[65536];
@ -110,7 +110,7 @@ u64 lv2_file::op_read(vm::ptr<void> buf, u64 size)
return result;
}
u64 lv2_file::op_write(vm::cptr<void> buf, u64 size)
u64 lv2_file::op_write(const fs::file& file, vm::cptr<void> buf, u64 size)
{
// Copy data to intermediate buffer (avoid passing vm pointer to a native API)
uchar local_buf[65536];

@ -193,10 +193,20 @@ struct lv2_file final : lv2_fs_object
}
// File reading with intermediate buffer
u64 op_read(vm::ptr<void> buf, u64 size);
static u64 op_read(const fs::file& file, vm::ptr<void> buf, u64 size);
u64 op_read(vm::ptr<void> buf, u64 size)
{
return op_read(file, buf, size);
}
// File writing with intermediate buffer
u64 op_write(vm::cptr<void> buf, u64 size);
static u64 op_write(const fs::file& file, vm::cptr<void> buf, u64 size);
u64 op_write(vm::cptr<void> buf, u64 size)
{
return op_write(file, buf, size);
}
// For MSELF support
struct file_view;