private static ModuleFileHeaderStruct ReadAndValidateFileHeader(BinaryReader reader) { var header = new ModuleFileHeaderStruct(); header.Read(reader); ValidateHeader(header); return(header); }
private static int[] ReadResourceEntries(BinaryReader reader, ModuleFileHeaderStruct header) { var files = new int[header.ResourceCount]; for (var i = 0; i < header.ResourceCount; i++) { files[i] = reader.ReadInt32(); } return(files); }
private static void ValidateHeader(ModuleFileHeaderStruct header) { if (header.Magic != ModuleFileHeaderStruct.ExpectedMagic) { throw new InvalidDataException($"Invalid module magic {header.Magic}"); } if (header.Version != ModuleFileHeaderStruct.ExpectedVersion) { throw new InvalidDataException($"Unsupported module version {header.Version}"); } }
private static ModuleEntryStruct[] ReadFileEntries(BinaryReader reader, ModuleFileHeaderStruct header) { var entries = new ModuleEntryStruct[header.FileCount]; for (var i = 0; i < header.FileCount; i++) { var entry = new ModuleEntryStruct(); entry.Read(reader); entries[i] = entry; } return(entries); }
private static ModuleCompressedBlockStruct[] ReadCompressedBlocks(BinaryReader reader, ModuleFileHeaderStruct header) { var blocks = new ModuleCompressedBlockStruct[header.CompressedBlockCount]; for (var i = 0; i < header.CompressedBlockCount; i++) { var block = new ModuleCompressedBlockStruct(); block.Read(reader); blocks[i] = block; } return(blocks); }
private static StringBlob ReadStringTable(BinaryReader reader, ModuleFileHeaderStruct header) { var bytes = reader.ReadBytes((int)header.StringTableSize); return(new StringBlob(Encoding.UTF8, bytes)); }