Fix incorrect endianness with variable data

This commit is contained in:
Kyler Eastridge
2025-06-18 08:09:32 -04:00
parent d20417da28
commit e6eed6e4f8

View File

@@ -82,8 +82,8 @@ class Block:
# LL couldn't decide which endianness to use. The different endianness # LL couldn't decide which endianness to use. The different endianness
# is intentional. # is intentional.
sVariable1 = struct.Struct(">B") sVariable1 = struct.Struct("<B")
sVariable2 = struct.Struct(">H") sVariable2 = struct.Struct("<H")
sU8 = struct.Struct("<B") sU8 = struct.Struct("<B")
sU16 = struct.Struct("<H") sU16 = struct.Struct("<H")
sU32 = struct.Struct("<I") sU32 = struct.Struct("<I")
@@ -221,10 +221,12 @@ class Block:
elif type == self.TYPE.VARIABLE: elif type == self.TYPE.VARIABLE:
if size == 1: if size == 1:
data = handle.read(self.sVariable1.unpack(handle.read(self.sVariable1.size))[0]) dataSize, = self.sVariable1.unpack(handle.read(self.sVariable1.size))
data = handle.read(dataSize)
elif size == 2: elif size == 2:
data = handle.read(self.sVariable2.unpack(handle.read(self.sVariable2.size))[0]) dataSize, = self.sVariable2.unpack(handle.read(self.sVariable2.size))
data = handle.read(dataSize)
else: else:
raise Exception("Invalid variable size {}".format(size)) raise Exception("Invalid variable size {}".format(size))