1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 04:02:42 +01:00

Fcntl e0000025 (#10172)

Co-authored-by: Eladash <elad3356p@gmail.com>
This commit is contained in:
clienthax 2021-04-24 19:43:09 +01:00 committed by GitHub
parent 0b9e4ffe54
commit 7197dd751a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 2 deletions

View File

@ -2,6 +2,7 @@
#include "sys_sync.h"
#include "sys_fs.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/Cell/PPUThread.h"
#include "Crypto/unedat.h"
#include "Emu/System.h"
@ -1709,9 +1710,53 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
break;
}
case 0x00000025: // cellFsSdataOpenWithVersion
case 0xe0000025: // cellFsSdataOpenWithVersion
{
break;
const auto arg = vm::static_ptr_cast<lv2_file_e0000025>(_arg);
if (arg->size != 0x30u)
{
sys_fs.error("sys_fs_fcntl(0xe0000025): invalid size (0x%x)", arg->size);
break;
}
if (arg->_x4 != 0x10u || arg->_x8 != 0x28u)
{
sys_fs.error("sys_fs_fcntl(0xe0000025): invalid args (0x%x, 0x%x)", arg->_x4, arg->_x8);
break;
}
std::string_view vpath{ arg->name.get_ptr(), arg->name_size };
vpath = vpath.substr(0, vpath.find_first_of('\0'));
sys_fs.notice("sys_fs_fcntl(0xe0000025): %s", vpath);
be_t<u64> sdata_identifier = 0x18000000010;
lv2_file::open_result_t result = lv2_file::open(vpath, 0, 0, &sdata_identifier, 8);
if (result.error)
{
return result.error;
}
if (const u32 id = idm::import<lv2_fs_object, lv2_file>([&]() -> std::shared_ptr<lv2_file>
{
if (!g_fxo->get<loaded_npdrm_keys>().npdrm_fds.try_inc(16))
{
return nullptr;
}
return std::make_shared<lv2_file>(result.ppath, std::move(result.file), 0, 0, std::move(result.real_path), lv2_file_type::sdata);
}))
{
arg->out_code = CELL_OK;
arg->fd = id;
return CELL_OK;
}
// Out of file descriptors
return CELL_EMFILE;
}
}

View File

@ -382,6 +382,24 @@ struct lv2_file_op_09 : lv2_file_op
CHECK_SIZE(lv2_file_op_09, 0x40);
struct lv2_file_e0000025 : lv2_file_op
{
be_t<u32> size; // 0x30
be_t<u32> _x4; // 0x10
be_t<u32> _x8; // 0x28 - offset of out_code
be_t<u32> name_size;
vm::bcptr<char> name;
be_t<u32> _x14;
be_t<u32> _x18; // 0
be_t<u32> _x1c; // 0
be_t<u32> _x20; // 16
be_t<u32> _x24; // unk, seems to be memory location
be_t<u32> out_code; // out_code
be_t<u32> fd; // 0xffffffff - likely fd out
};
CHECK_SIZE(lv2_file_e0000025, 0x30);
// sys_fs_fnctl: cellFsGetDirectoryEntries
struct lv2_file_op_dir : lv2_file_op
{