public void IntLSBMSB(int i, int start, int end) { BeginField(start); this.generator.Bytes(ConvertTo.Int2LSB(i)); this.generator.Bytes(ConvertTo.Int2MSB(i)); EndField(end); }
private void susp_base_ce(MemoryStream m) // IEEE P1282 SUSP ( 5.1 ) { int start = (int)m.Length; m.WriteByte((byte)'C'); m.WriteByte((byte)'E'); m.WriteByte(28); // LEN_CE m.WriteByte(1); // version m.Write(ConvertTo.Int2LSB(ContinuationBlock), 0, 4); m.Write(ConvertTo.Int2MSB(ContinuationBlock), 0, 4); m.Write(ConvertTo.Int2LSB(0), 0, 4); // Continuation Offset m.Write(ConvertTo.Int2MSB(0), 0, 4); // Continuation Offset m.Write(ConvertTo.Int2LSB(ContinuationLength), 0, 4); m.Write(ConvertTo.Int2MSB(ContinuationLength), 0, 4); System.Diagnostics.Debug.Assert((m.Length - start) == 28); }
/// <summary> /// writes a file out to cd. Generate the Boot Info Table if necessary /// </summary> /// <param Name="f">the file to write</param> /// <param Name="primaryVolumeDescriptor">the PVD block, passed in case we need to generate the Boot Info Table</param> public void WriteFile(IsoFile f, int primaryVolumeDescriptor) { if (f.fileInfo.Length > 0xffffffff) { throw new NotImplementedException(">4G files not implemented"); } int bytes = (int)f.fileInfo.Length; if (this.fs == null) { this.Index += bytes; return; } // TODO FIXME - create smaller reusable buffer and read fixed-size chunks at a time... byte[] b = new byte[bytes]; using (FileStream stream = f.fileInfo.OpenRead()) { if (bytes != stream.Read(b, 0, bytes)) { throw new Exception("number of bytes read from file != reported length of file: " + f.fileInfo.Name); } } if (f.BootInfoTable) { // TODO FIXME - this is TERRIBLE. This should be implemented at a higher level, and // doing it here requires passing the primaryVolumeDescriptor to every call of WriteFile() // The reason it is here is because this is the only place where the file actually gets // pulled into memory and I didn't want to modify the boot image on-disk like mkisofs does. Bytes(b, 0, 8); Bytes(ConvertTo.Int2LSB(primaryVolumeDescriptor)); Bytes(ConvertTo.Int2LSB(f.DataBlock)); Bytes(ConvertTo.Int2LSB((int)f.fileInfo.Length)); Bytes(ConvertTo.Int2LSB(0)); // TODO FIXME - checksum DupByte(0, 40); // reserved Bytes(b, 64, bytes - 64); } else { Bytes(b); } }