public static unsafe int ReadTrack(IntPtr driverHandle, IntPtr memoryHandle, int track, int sector) { uint dwRet; //tagFD_READ_WRITE_PARAMS readParams = new tagFD_READ_WRITE_PARAMS() //{ // flags = FD_OPTION_MFM, // phead = (byte)(track & 1), // cyl = (byte)(track >> 1), // head = upperSideHead == UpperSideHead.Head1 ? (byte)(track & 1) : (byte)0, // //sector = 1, // //size = 1, // //eot = 1 + 16, // gap = 0x0a, // datalen = 0xff, //}; tagFD_READ_WRITE_PARAMS readParams = new tagFD_READ_WRITE_PARAMS() { flags = FD_OPTION_MFM, phead = (byte)(track & 1), cyl = (byte)(track / 2), head = 0, sector = 0, size = 7, eot = 0, gap = 0, datalen = 0, }; bool r = DeviceIoControl(driverHandle, IOCTL_FDCMD_READ_TRACK, (IntPtr)(&readParams), (uint)sizeof(tagFD_READ_WRITE_PARAMS), memoryHandle, 65536, out dwRet, IntPtr.Zero); int error = !r?Marshal.GetLastWin32Error() : 0; Log.Trace?.Out($"Track: {track} | Error: {error} | Bytes Read: {dwRet}"); return(error); }
public static unsafe int ReadSectorF(IntPtr driverHandle, IntPtr memoryHandle, int cyl, int sector, int sizeCode, int phead, int head, int gap, int datalen) { uint dwRet; tagFD_READ_WRITE_PARAMS readParams = new tagFD_READ_WRITE_PARAMS() { flags = FD_OPTION_MFM, phead = (byte)phead, cyl = (byte)cyl, head = (byte)head, sector = (byte)sector, size = (byte)sizeCode, eot = (byte)(sector + 1), gap = (byte)gap, datalen = (byte)datalen, }; bool r = DeviceIoControl(driverHandle, IOCTL_FDCMD_READ_DATA, (IntPtr)(&readParams), (uint)sizeof(tagFD_READ_WRITE_PARAMS), memoryHandle, (uint)SectorInfo.GetSizeBytes(sizeCode), out dwRet, IntPtr.Zero); int error = !r?Marshal.GetLastWin32Error() : 0; Log.Trace?.Out($"Cyl: {cyl} | PHead: {phead} | Head: {head} | Sector: {sector} | Gap: {gap} | DataLen: {datalen} | Error: {error} | Bytes Read: {dwRet}"); return(error); }
public static unsafe int ReadSector(IntPtr driverHandle, IntPtr memoryHandle, int track, int sector, UpperSideHead head, int sizeCode) { uint dwRet; tagFD_READ_WRITE_PARAMS readParams = new tagFD_READ_WRITE_PARAMS() { flags = FD_OPTION_MFM, phead = (byte)(track & 1), cyl = (byte)(track >> 1), head = head == UpperSideHead.Head1 ? (byte)(track & 1) : (byte)0, sector = (byte)sector, size = (byte)sizeCode, eot = (byte)(sector + 1), gap = 0x0a, datalen = 0xff, }; bool r = DeviceIoControl(driverHandle, IOCTL_FDCMD_READ_DATA, (IntPtr)(&readParams), (uint)sizeof(tagFD_READ_WRITE_PARAMS), memoryHandle, (uint)SectorInfo.GetSizeBytes(sizeCode), out dwRet, IntPtr.Zero); int error = !r?Marshal.GetLastWin32Error() : 0; Log.Trace?.Out($"Track: {track} | Sector: {sector} | Error: {error} | Bytes Read: {dwRet}"); return(error); }