//---------------------------------------------------------------------------------------- // Update //---------------------------------------------------------------------------------------- void CZMEditionPopupObserver::Update( const ClassID& theChange, ISubject* theSubject, const PMIID & protocol, void* changedBy) { inheritClass::Update( theChange, theSubject, protocol, changedBy ); InterfacePtr<IZMDataObjPopupController> popupController( this , UseDefaultIID() ); ASSERT(popupController); if( theChange == kZMEditionListWillChange ) { popupController->SaveSelection(); } else if( theChange == kZMEditionListChanged && protocol == IZMEditionList::kDefaultIID) { if( changedBy ) { //Only Refresh if it is of associated title InterfacePtr<const IZMEditionList> titleEditilList( (const IPMUnknown*)changedBy, UseDefaultIID() ); InterfacePtr<const IStringData> titleID( titleEditilList, IID_IZMDATAID); ASSERT( titleID ); InterfacePtr<const IStringData> selfEditionTitleID( this, IID_IZMTITLEIDSTRINGDATA ); ASSERT(selfEditionTitleID); const PMString & selfTitleID = selfEditionTitleID->Get(); const PMString & msgTitleID = titleID->Get(); if( selfTitleID.IsEmpty() == kFalse && selfTitleID.Compare( kTrue, msgTitleID ) == 0 ) popupController->Refresh(); } //else // popupController->Refresh(); } }
s32 npDrmIsAvailable(u32 k_licensee_addr, vm::cptr<char> drm_path) { if (!Emu.GetVFS().ExistsFile(drm_path.get_ptr())) { sceNp.Warning("npDrmIsAvailable(): '%s' not found", drm_path.get_ptr()); return CELL_ENOENT; } std::string k_licensee_str = "0"; u8 k_licensee[0x10]; if (k_licensee_addr) { for (s32 i = 0; i < 0x10; i++) { k_licensee[i] = vm::read8(k_licensee_addr + i); k_licensee_str += fmt::format("%02x", k_licensee[i]); } } sceNp.Warning("npDrmIsAvailable(): Found DRM license file at %s", drm_path.get_ptr()); sceNp.Warning("npDrmIsAvailable(): Using k_licensee 0x%s", k_licensee_str.c_str()); // Set the necessary file paths. std::string drm_file_name = fmt::AfterLast(drm_path.get_ptr(), '/'); // TODO: Make more explicit what this actually does (currently it copies "XXXXXXXX" from drm_path (== "/dev_hdd0/game/XXXXXXXXX/*" assumed) std::string titleID(&drm_path[15], 9); // TODO: These shouldn't use current dir std::string enc_drm_path = drm_path.get_ptr(); std::string dec_drm_path = "/dev_hdd1/cache/" + drm_file_name; std::string pf_str("00000001"); // TODO: Allow multiple profiles. Use default for now. std::string rap_path("/dev_hdd0/home/" + pf_str + "/exdata/"); // Search dev_usb000 for a compatible RAP file. for (const auto entry : vfsDir(rap_path)) { if (entry->name.find(titleID) != std::string::npos) { rap_path += entry->name; break; } } if (rap_path.back() == '/') { sceNp.Warning("npDrmIsAvailable(): Can't find RAP file for '%s' (titleID='%s')", drm_path.get_ptr(), titleID); } // Decrypt this EDAT using the supplied k_licensee and matching RAP file. std::string enc_drm_path_local, dec_drm_path_local, rap_path_local; Emu.GetVFS().GetDevice(enc_drm_path, enc_drm_path_local); Emu.GetVFS().GetDevice(dec_drm_path, dec_drm_path_local); Emu.GetVFS().GetDevice(rap_path, rap_path_local); if (DecryptEDAT(enc_drm_path_local, dec_drm_path_local, 8, rap_path_local, k_licensee, false) >= 0) { // If decryption succeeds, replace the encrypted file with it. fs::remove_file(enc_drm_path_local); fs::rename(dec_drm_path_local, enc_drm_path_local); } return CELL_OK; }