From a0fd824f786c9953d8abae38c3bcdb1d7f79f266 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 30 May 2013 23:47:33 -0700 Subject: [PATCH] Read in the PARAMS.SFO secure file list. --- Core/Dialog/SavedataParam.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 0399ba56f9..78f034ea29 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -875,6 +875,39 @@ int SavedataParam::GetFilesList(SceUtilitySavedataParam *param) fileList->resultNumNormalEntries = 0; fileList->resultNumSystemEntries = 0; + // We need PARAMS.SFO's SAVEDATA_FILE_LIST to determine which entries are secure. + PSPFileInfo sfoFileInfo = pspFileSystem.GetFileInfo(dirPath + "/" + sfoName); + std::vector secureFilenames; + // TODO: Error code if not? + if (sfoFileInfo.exists) { + ParamSFOData sfoFile; + size_t sfoSize = (size_t)sfoFileInfo.size; + u8 *sfoData = new u8[sfoSize]; + if (ReadPSPFile(dirPath + "/" + sfoName, &sfoData, sfoSize, NULL)){ + sfoFile.ReadSFO(sfoData, sfoSize); + } + delete[] sfoData; + + u32 sfoFileListSize = 0; + char *sfoFileList = (char *)sfoFile.GetValueData("SAVEDATA_FILE_LIST", &sfoFileListSize); + const int FILE_LIST_ITEM_SIZE = 13 + 16 + 3; + const int FILE_LIST_COUNT_MAX = 99; + + // Filenames are 13 bytes long at most. Add a NULL so there's no surprises. + char temp[14]; + temp[13] = '\0'; + + for (int i = 0; i < FILE_LIST_COUNT_MAX; ++i) { + // Ends at a NULL filename. + if (sfoFileList[i * FILE_LIST_ITEM_SIZE] == '\0') { + break; + } + + strncpy(temp, &sfoFileList[i * FILE_LIST_ITEM_SIZE], 13); + secureFilenames.push_back(temp); + } + } + // TODO: Does not list directories, nor recurse into them, and ignores files not ALL UPPERCASE. u32 dataAddr = param->fileListAddr;