From 42a0512c6663b1feee262860cc25549d3b30ea18 Mon Sep 17 00:00:00 2001 From: Eladash Date: Thu, 27 Feb 2020 17:24:47 +0200 Subject: [PATCH] cellSaveData: Avoid passing vm pointer to native API --- rpcs3/Emu/Cell/Modules/cellSaveData.cpp | 7 ++++--- rpcs3/Emu/Cell/lv2/sys_fs.cpp | 4 ++-- rpcs3/Emu/Cell/lv2/sys_fs.h | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 079f215921..ffb0fcbeb6 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -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(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(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(wr); all_times.erase(file_path); add_to_blist(file_path); diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index a02f5d1bfd..0735ca7829 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -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 buf, u64 size) +u64 lv2_file::op_read(const fs::file& file, vm::ptr 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 buf, u64 size) return result; } -u64 lv2_file::op_write(vm::cptr buf, u64 size) +u64 lv2_file::op_write(const fs::file& file, vm::cptr buf, u64 size) { // Copy data to intermediate buffer (avoid passing vm pointer to a native API) uchar local_buf[65536]; diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.h b/rpcs3/Emu/Cell/lv2/sys_fs.h index ceb0826fea..bc81c4b85a 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.h +++ b/rpcs3/Emu/Cell/lv2/sys_fs.h @@ -193,10 +193,20 @@ struct lv2_file final : lv2_fs_object } // File reading with intermediate buffer - u64 op_read(vm::ptr buf, u64 size); + static u64 op_read(const fs::file& file, vm::ptr buf, u64 size); + + u64 op_read(vm::ptr buf, u64 size) + { + return op_read(file, buf, size); + } // File writing with intermediate buffer - u64 op_write(vm::cptr buf, u64 size); + static u64 op_write(const fs::file& file, vm::cptr buf, u64 size); + + u64 op_write(vm::cptr buf, u64 size) + { + return op_write(file, buf, size); + } // For MSELF support struct file_view;