Click here to Skip to main content
15,891,902 members
Articles / Programming Languages / C#

SCSI Library in C# - Burn CDs and DVDs, Access Hard Disks, etc.

Rate me:
Please Sign up or sign in to vote.
4.77/5 (48 votes)
19 Jun 2017Ms-PL6 min read 145.9K   8.1K   146  
Ever wonder how programs like Nero work? They make their own SCSI libraries... like this!
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Helper;

namespace Scsi.Multimedia
{
	[StructLayout(LayoutKind.Sequential, Pack = 1)]
	public abstract class FormatDescriptorOther : FormatDescriptor
	{
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private const byte FORMAT_TYPE_MASK = 0xFC;
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private const byte FORMAT_SUBTYPE_MASK = 0x03;

		protected FormatDescriptorOther(FormatType formatType) : base() { this.FormatType = formatType; }

		//Descriptor starts here
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private uint _NumberOfBlocks;
		/// <summary>Number of addressable blocks, NOT the block length!</summary>
		[Description("Number of addressable blocks, NOT the block length!")]
		public uint NumberOfBlocks { get { return Bits.BigEndian(this._NumberOfBlocks); } set { this._NumberOfBlocks = Bits.BigEndian(value); } }

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private byte FormatDescriptor_byte4;
		public FormatType FormatType
		{
			get { return (FormatType)Bits.GetValueMask(this.FormatDescriptor_byte4, 2, FORMAT_TYPE_MASK); }
			private set { this.FormatDescriptor_byte4 = Bits.PutValueMask(this.FormatDescriptor_byte4, (byte)value, 2, FORMAT_TYPE_MASK); }
		}
		protected byte FormatSubType
		{
			get { return (byte)Bits.GetValueMask(this.FormatDescriptor_byte4, 0, FORMAT_SUBTYPE_MASK); }
			private set { this.FormatDescriptor_byte4 = Bits.PutValueMask(this.FormatDescriptor_byte4, (byte)value, 0, FORMAT_SUBTYPE_MASK); }
		}
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private byte _byte5; //msb
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private byte _byte6;
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private byte _byte7; //lsb
		protected uint TypeDependentParameter
		{
			get { unchecked { return (uint)this._byte7 | ((uint)this._byte6 << 8) | ((uint)this._byte5 << 16); } }
			set { unchecked { this._byte7 = (byte)(value >> 0); this._byte6 = (byte)(value >> 8); this._byte5 = (byte)(value >> 16); } }
		}

		public override FormatCode FormatCode { get { return FormatCode.Other; } }
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions