Example #1
0
        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);
        }
Example #2
0
        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);
        }