1
0
mirror of synced 2024-11-30 18:24:39 +01:00

TPL : Add support for little endian

This commit is contained in:
KillzXGaming 2020-09-18 17:20:36 -04:00
parent 9a0f6ebddd
commit 2f6605761a
2 changed files with 7 additions and 3 deletions

View File

@ -28,7 +28,8 @@ namespace FirstPlugin
using (var reader = new FileReader(stream, true))
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
return reader.ReadUInt32() == 0x0020AF30 || Utils.GetExtension(FileName) == ".tpl";
uint magic = reader.ReadUInt32();
return magic == 0x0020AF30 || magic == 0x30AF2000 || Utils.GetExtension(FileName) == ".tpl";
}
}

View File

@ -17,12 +17,13 @@ namespace FirstPlugin
public List<ImageEntry> Images = new List<ImageEntry>();
public bool IsV1 = false;
public bool IsBigEndian = true;
public void Read(FileReader reader)
{
reader.SetByteOrder(true);
uint Identifier = reader.ReadUInt32();
if (Identifier != 0x0020AF30) {
if (Identifier != 0x0020AF30 && Identifier != 0x30AF2000) {
IsV1 = true;
reader.Position = 0;
@ -36,6 +37,8 @@ namespace FirstPlugin
}
}
else {
IsBigEndian = Identifier == 0x0020AF30;
reader.SetByteOrder(IsBigEndian);
uint ImageCount = reader.ReadUInt32();
uint ImageOffsetTable = reader.ReadUInt32();
for (int i = 0; i < ImageCount; i++) {
@ -61,7 +64,7 @@ namespace FirstPlugin
public void Write(FileWriter writer)
{
writer.SetByteOrder(true);
writer.SetByteOrder(IsBigEndian);
if (IsV1) {
writer.Write(Images.Count);
for (int i = 0; i < Images.Count; i++)