SavedataParam/ParamSFO: Minor code cleanups

This commit is contained in:
Henrik Rydgård committed 2024-04-07 12:31:45 +02:00
1 parent d75b97ff39
commit 404600faa3
4 files changed
+9 -8

No files matched your search

+3 -5
View File
@@ -145,7 +145,7 @@ namespace
int align16(int address)
{
return ((address + 0xF) >> 4) << 4;
return (address + 15) & ~15;
}
int GetSDKMainVersion(int sdkVersion)
@@ -537,10 +537,8 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
delete[] updatedList;
// Init param with 0. This will be used to detect crypted save or not on loading
u8 *tmpData = new u8[128];
memset(tmpData, 0, 128);
sfoFile->SetValue("SAVEDATA_PARAMS", tmpData, 128, 128);
delete[] tmpData;
u8 zeroes[128]{};
sfoFile->SetValue("SAVEDATA_PARAMS", zeroes, 128, 128);
u8 *sfoData;
size_t sfoSize;
+2
View File
@@ -375,6 +375,8 @@ private:
int DecryptSave(unsigned int mode, unsigned char *data, int *dataLen, int *alignedLen, unsigned char *cryptkey, const u8 *expectedHash);
int EncryptData(unsigned int mode, unsigned char *data, int *dataLen, int *alignedLen, unsigned char *hash, unsigned char *cryptkey);
int UpdateHash(u8* sfoData, int sfoSize, int sfoDataParamsOffset, int encryptmode);
// WARNING: this writes zeroes to data from len to alignedLen. This means that data must have space for the full alignedLen!
int BuildHash(unsigned char *output, unsigned char *data, unsigned int len, unsigned int alignedLen, int mode, unsigned char *cryptkey);
int DetermineCryptMode(const SceUtilitySavedataParam *param) const;
+2 -2
View File
@@ -195,7 +195,7 @@ bool ParamSFOData::ReadSFO(const u8 *paramsfo, size_t size) {
return true;
}
int ParamSFOData::GetDataOffset(const u8 *paramsfo, const std::string &dataName) {
int ParamSFOData::GetDataOffset(const u8 *paramsfo, const char *dataName) {
const Header *header = (const Header *)paramsfo;
if (header->magic != 0x46535000)
return -1;
@@ -210,7 +210,7 @@ int ParamSFOData::GetDataOffset(const u8 *paramsfo, const std::string &dataName)
for (u32 i = 0; i < header->index_table_entries; i++)
{
const char *key = (const char *)(key_start + indexTables[i].key_table_offset);
if (!strcmp(key, dataName.c_str()))
if (!strcmp(key, dataName))
{
return data_start + indexTables[i].data_table_offset;
}
+2 -1
View File
@@ -55,7 +55,8 @@ public:
}
}
int GetDataOffset(const u8 *paramsfo, const std::string &dataName);
// If not found, returns a negative value.
int GetDataOffset(const u8 *paramsfo, const char *dataName);
void Clear();