DRM: Search all user directories for rap files

This commit is contained in:
Megamouse 2021-04-07 22:37:32 +02:00
parent d2b761b7de
commit d10584ac6c
4 changed files with 30 additions and 21 deletions

View file

@ -475,8 +475,6 @@ error_code npDrmIsAvailable(vm::cptr<u8> k_licensee_addr, vm::cptr<char> drm_pat
auto& npdrmkeys = g_fxo->get<loaded_npdrm_keys>();
std::string rap_dir_path = "/dev_hdd0/home/" + Emu.GetUsr() + "/exdata/";
const std::string& enc_drm_path_local = vfs::get(enc_drm_path);
const fs::file enc_file(enc_drm_path_local);
@ -508,7 +506,7 @@ error_code npDrmIsAvailable(vm::cptr<u8> k_licensee_addr, vm::cptr<char> drm_pat
if (VerifyEDATHeaderWithKLicense(enc_file, enc_drm_path_local, reinterpret_cast<u8*>(&k_licensee), &contentID))
{
const std::string rap_file = rap_dir_path + contentID + ".rap";
const std::string rap_file = Emulator::GetRapFilePath(contentID);
npdrmkeys.devKlic = k_licensee;
if (fs::is_file(vfs::get(rap_file)))
@ -554,10 +552,11 @@ error_code sceNpDrmVerifyUpgradeLicense(vm::cptr<char> content_id)
}
const std::string content_str(content_id.get_ptr(), std::find(content_id.get_ptr(), content_id.get_ptr() + 0x2f, '\0'));
const std::string rap_file = Emulator::GetRapFilePath(content_str);
sceNp.warning(u8"sceNpDrmVerifyUpgradeLicense(): content_id=“%s”", content_id);
if (fs::stat_t s{}; !fs::stat(vfs::get("/dev_hdd0/home/" + Emu.GetUsr() + "/exdata/" + content_str + ".rap"), s) || s.is_directory || s.size < 0x10)
if (fs::stat_t s{}; !fs::stat(rap_file, s) || s.is_directory || s.size < 0x10)
{
// Game hasn't been purchased therefore no RAP file present
return SCE_NP_DRM_ERROR_LICENSE_NOT_FOUND;
@ -577,10 +576,11 @@ error_code sceNpDrmVerifyUpgradeLicense2(vm::cptr<char> content_id)
}
const std::string content_str(content_id.get_ptr(), std::find(content_id.get_ptr(), content_id.get_ptr() + 0x2f, '\0'));
const std::string rap_file = Emulator::GetRapFilePath(content_str);
sceNp.warning(u8"sceNpDrmVerifyUpgradeLicense2(): content_id=“%s”", content_id);
if (fs::stat_t s{}; !fs::stat(vfs::get("/dev_hdd0/home/" + Emu.GetUsr() + "/exdata/" + content_str + ".rap"), s) || s.is_directory || s.size < 0x10)
if (fs::stat_t s{}; !fs::stat(rap_file, s) || s.is_directory || s.size < 0x10)
{
// Game hasn't been purchased therefore no RAP file present
return SCE_NP_DRM_ERROR_LICENSE_NOT_FOUND;