public void readLogicalSector(int cyl, int side, int sec, byte[] buffer) { for (int i = 0; i < buffer.Length; i++) { buffer[i] = 0; } if (cyl < 0 || cyl >= this._cylynderList.Count) { return; } Track[] array = (Track[])this._cylynderList[cyl]; if (side < 0 || side >= this._sideCount) { return; } Track track = array[side]; for (int j = 0; j < track.HeaderList.Count; j++) { SECHDR sechdr = (SECHDR)track.HeaderList[j]; if ((int)sechdr.n == sec && (int)sechdr.c == cyl && sechdr.dataOffset > 0) { int num = sechdr.datlen; if (num > buffer.Length) { num = buffer.Length; } for (int k = 0; k < num; k++) { buffer[k] = track.RawRead(sechdr.dataOffset + k); } return; } } }
public void RefreshHeaders() { this._headerList.Clear(); if (this._trackImage == null) { return; } for (int i = 0; i < this._trackImage.Length - 8; i++) { if (this._trackImage[i] == 161 && this._trackImage[i + 1] == 254 && this.RawTestClock(i)) { SECHDR sechdr = new SECHDR(); this._headerList.Add(sechdr); sechdr.idOffset = i + 2; sechdr.idTime = (ulong)((long)sechdr.idOffset * (long)this._byteTime); sechdr.c = this._trackImage[sechdr.idOffset]; sechdr.s = this._trackImage[sechdr.idOffset + 1]; sechdr.n = this._trackImage[sechdr.idOffset + 2]; sechdr.l = this._trackImage[sechdr.idOffset + 3]; sechdr.crc1 = (ushort)((int)this._trackImage[i + 6] | (int)this._trackImage[i + 7] << 8); sechdr.c1 = (this.WD1793_CRC(i + 1, 5) == sechdr.crc1); sechdr.dataOffset = -1; sechdr.datlen = 0; if (sechdr.l <= 5) { int num = this._trackImage.Length - 8; int j = i + 8; while (j < num) { if (this._trackImage[j] == 161 && this.RawTestClock(j) && !this.RawTestClock(j + 1)) { if (this._trackImage[j + 1] != 248 && this._trackImage[j + 1] != 251) { break; } sechdr.datlen = 128 << (int)sechdr.l; sechdr.dataOffset = j + 2; sechdr.dataTime = (ulong)((long)sechdr.dataOffset * (long)this._byteTime); if (sechdr.dataOffset + sechdr.datlen + 2 > this._trackImage.Length) { sechdr.datlen = this._trackImage.Length - sechdr.dataOffset; sechdr.crc2 = (ushort)((this.WD1793_CRC(sechdr.dataOffset - 1, sechdr.datlen + 1) ^ ushort.MaxValue)); sechdr.c2 = false; break; } sechdr.crc2 = (ushort)((int)this._trackImage[sechdr.dataOffset + sechdr.datlen] | (int)this._trackImage[sechdr.dataOffset + sechdr.datlen + 1] << 8); sechdr.c2 = (this.WD1793_CRC(sechdr.dataOffset - 1, sechdr.datlen + 1) == sechdr.crc2); break; } else { j++; } } } } } }
public void writeLogicalSector(int cyl, int side, int sec, byte[] buffer) { if (cyl < 0 || cyl >= this._cylynderList.Count) { return; } Track[] array = (Track[])this._cylynderList[cyl]; if (side < 0 || side >= this._sideCount) { return; } Track track = array[side]; for (int i = 0; i < track.HeaderList.Count; i++) { SECHDR sechdr = (SECHDR)track.HeaderList[i]; if ((int)sechdr.n == sec && (int)sechdr.c == cyl && sechdr.dataOffset > 0 && sechdr.datlen >= buffer.Length) { int num = buffer.Length; if (num > sechdr.datlen) { num = sechdr.datlen; } for (int j = 0; j < num; j++) { track.RawWrite(sechdr.dataOffset + j, buffer[j], false); } ushort num2 = track.WD1793_CRC(sechdr.dataOffset - 1, sechdr.datlen + 1); track.RawWrite(sechdr.dataOffset + sechdr.datlen, (byte)num2, false); track.RawWrite(sechdr.dataOffset + sechdr.datlen + 1, (byte)(num2 >> 8), false); sechdr.crc2 = num2; sechdr.c2 = true; return; } } }