Skip to content

Commit a41ccc2

Browse files
committed
Pak file fixes
- FPakVFS::LoadPakIndex now handling "unused" pak values - FPakVFS::DecryptDataBlock crashes with "FString[0/0] error when AES was not provided, now displaying more informative error
1 parent e8ae1c0 commit a41ccc2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Unreal/FileSystem/UnArchivePak.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ void FPakVFS::DecryptDataBlock(byte* Data, int DataSize)
684684
guard(FPakVFS::DecryptDataBlock);
685685

686686
const FString& Key = GetPakEncryptionKey();
687+
if (Key.Len() == 0) appError("Empty AES key");
687688
appDecryptAES(Data, DataSize, &Key[0], Key.Len());
688689

689690
unguard;
@@ -967,19 +968,25 @@ bool FPakVFS::LoadPakIndex(FArchive* reader, const FPakInfo& info, FString& erro
967968
FolderIndex = RegisterGameFolder(*DirectoryPath);
968969
}
969970

970-
for (int DirectoryFileIndex = 0; DirectoryFileIndex < NumFilesInDirectory; DirectoryFileIndex++)
971+
for (int DirectoryFileIndex = 0; DirectoryFileIndex < NumFilesInDirectory; DirectoryFileIndex++, FileIndex++)
971972
{
972973
guard(File);
973974
// Read FPakDirectory entry Key
974975
FStaticString<MAX_PACKAGE_PATH> DirectoryFileName;
975976
InfoReader << DirectoryFileName;
977+
976978
// Read FPakDirectory entry Value
979+
// PakEntryLocation is positive (offset in 'EncodedPakEntries') or negative (index in 'Files').
977980
int32 PakEntryLocation;
978981
InfoReader << PakEntryLocation;
982+
if (PakEntryLocation == 0x7fffffff || PakEntryLocation == 0x80000000)
983+
{
984+
// 0x7fffffff and 0x80000000 are special values, "Invalid" or "Unused"
985+
continue;
986+
}
979987

980988
FPakEntry& E = FileInfos[FileIndex];
981989

982-
// PakEntryLocation is positive (offset in 'EncodedPakEntries') or negative (index in 'Files')
983990
// References in UE4:
984991
// FPakFile::DecodePakEntry <- FPakFile::GetPakEntry (decode or pick from 'Files') <- FPakFile::Find (name to index/location)
985992
if (PakEntryLocation < 0)
@@ -1012,7 +1019,6 @@ bool FPakVFS::LoadPakIndex(FArchive* reader, const FPakInfo& info, FString& erro
10121019
reg.IndexInArchive = FileIndex;
10131020
E.FileInfo = RegisterFile(reg);
10141021

1015-
FileIndex++;
10161022
unguard;
10171023
}
10181024
unguard;

0 commit comments

Comments
 (0)