示例#1
0
 public static byte[] ReadSector(long startingsector, int numberofsectors, DISK.streamer iface)
 {
     byte[] numArray;
     byte[] numArray1 = new byte[numberofsectors];
     if (!iface.SH.IsInvalid)
     {
         if (iface.STR.CanRead)
         {
             iface.STR.Seek(startingsector, SeekOrigin.Begin);
             iface.STR.Read(numArray1, 0, numberofsectors);
             numArray = numArray1;
             return(numArray);
         }
     }
     numArray = null;
     return(numArray);
 }
示例#2
0
        public static streamer CreateStream(string drive, FileAccess type)
        {
            DISK.streamer _streamer;
            DISK.streamer _streamer1;
            DISK.streamer _streamer2 = new DISK.streamer();
            int           num        = 0;

            while (true)
            {
                SafeFileHandle safeFileHandle = DISK.CreateFile(string.Concat("\\\\.\\", drive), type, FileShare.None, 0, FileMode.Open, 0, 0);
                if (safeFileHandle.IsInvalid)
                {
                    num++;
                    if (num > 6)
                    {
                        _streamer2.isERROR = true;
                        _streamer1         = _streamer2;
                        break;
                    }
                }
                else
                {
                    if (safeFileHandle.IsInvalid)
                    {
                        _streamer2.isERROR = true;
                        _streamer          = _streamer2;
                    }
                    else
                    {
                        Stream fileStream = new FileStream(safeFileHandle, type);
                        _streamer2.SH      = safeFileHandle;
                        _streamer2.STR     = fileStream;
                        _streamer2.isERROR = false;
                        _streamer          = _streamer2;
                    }
                    _streamer1 = _streamer;
                    break;
                }
            }
            return(_streamer1);
        }
示例#3
0
        public static int WriteSector(long startingsector, int numberofsectors, byte[] data, DISK.streamer iface)
        {
            int num;

            if (!iface.SH.IsInvalid)
            {
                if (iface.STR.CanRead)
                {
                    iface.STR.Seek(startingsector, SeekOrigin.Begin);
                    iface.STR.Write(data, 0, numberofsectors);
                    iface.STR.Flush();
                    num = 0;
                    return(num);
                }
            }
            num = -1;
            return(num);
        }