Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Warning! Experimental! No guarantees on functionality! Use at your own risk!!!!!
- #include "ExtractMorrowindFormLibrary.h"
- #include "Serialization/MemoryReader.h"
- TArray<uint8> UExtractMorrowindFormLibrary::ExtractMorrowindFormData(const TArray<uint8>& MainFileData)
- {
- TArray<uint8> ExtractedData;
- FMemoryReader Ar(MainFileData, true);
- while (!Ar.AtEnd())
- {
- // Read record type (4 bytes)
- FString RecordType;
- Ar << RecordType;
- // Read record size (4 bytes)
- int32 RecordSize;
- Ar << RecordSize;
- int64 RecordEnd = Ar.Tell() + RecordSize;
- while (Ar.Tell() < RecordEnd)
- {
- // Read subrecord type (4 bytes)
- FString SubrecordType;
- Ar << SubrecordType;
- // Read subrecord size (4 bytes)
- int32 SubrecordSize;
- Ar << SubrecordSize;
- // Read subrecord data
- TArray<uint8> SubrecordData;
- SubrecordData.SetNum(SubrecordSize);
- Ar.Serialize(SubrecordData.GetData(), SubrecordSize);
- // Append all subrecord data to the result
- ExtractedData.Append(SubrecordData);
- }
- }
- return ExtractedData;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement