public void Serialize(BitWriter writer) { writer.Write(magicNumber); writer.Write(version); writer.Write(reserved); macOsX = macOsX.SetLength(16); writer.Write(Encoding.ASCII.GetBytes(macOsX)); writer.Write(numEntries); int forkOffset = writer.Length + entries.Length * Entry.SIZE; BitWriter entriesFork = new BitWriter(forkOffset); for (int i = 0; i < entries.Length; i++) { entries[i].Serialize(writer, entriesFork); } writer.Write(entriesFork.GetBytes()); BitWriter footer = new BitWriter(0); // Filllllll ! footer.Write(0x00000000); footer.Write(0x01000000); footer.Write(0x01000000); footer.Write(0x00000000); footer.Write(0x001E5468); footer.Write(0x69732072); footer.Write(0x65736F75); footer.Write(0x72636520); footer.Write(0x666F726B); footer.Write(0x20696E74); footer.Write(0x656E7469); footer.Write(0x6F6E616C); footer.Write(0x6C79206C); footer.Write(0x65667420); footer.Write(0x626C616E); footer.Write(0x6B202020); for (int i = 0; i < 12; i++) { footer.Write(0x00000000); footer.Write(0x00000000); footer.Write(0x00000000); footer.Write(0x00000000); } footer.Write(0x00000000); footer.Write(0x01000000); footer.Write(0x01000000); footer.Write(0x00000000); footer.Write(0x001E0000); footer.Write(0x00000000); footer.Write(0x0000001C); footer.Write(0x001EFFFF); int size = 4096 - writer.Length - footer.Length; writer.Write(new byte[size]); writer.Write(footer.GetBytes()); }
public void Serialize(BitWriter writer) { unknown0 = new byte[34]; unknown0[10] = 4; // ¯\_(ツ)_/¯ numAttributes = (uint)attributes.Count; valuesOffset = 0; for (int i = 0; i < numAttributes; i++) { int size = attributes[i].nameLen + 11; size += Extensions.GetPadding(size); valuesOffset += (uint)size; } valuesOffset += (uint)SIZE; valuesOffset += (uint)writer.offset; BitWriter fork = new BitWriter((int)valuesOffset); for (int i = 0; i < numAttributes; i++) { attributes[i].SerializeFork(fork); } valuesLen = (uint)fork.Length; writer.Write(unknown0); writer.Write(Encoding.ASCII.GetBytes(signature)); writer.Write(unknown1); writer.Write(logicalFileSize); writer.Write(valuesOffset); writer.Write(valuesLen); writer.Write(unknown3); writer.Write(unknown4); writer.Write(unknown5); writer.Write(numAttributes); for (int i = 0; i < numAttributes; i++) { attributes[i].SerializeHead(writer); } writer.Write(fork.GetBytes()); }