Пример #1
0
 public void close()
 {
     if (hDevice != null)
     {
         hDevice.Dispose();
     }
     hDevice = null;
     dev = null;
 }
Пример #2
0
 public bool open(PHYS_DEVICE dev)
 {
     try
     {
         this.dev = dev;
         hDevice = new FileStream(
             dev.filename,
             FileMode.OpenOrCreate,
             FileAccess.ReadWrite,
             FileShare.ReadWrite);
         return true;
     }
     catch (Exception ex)
     {
         LogAgent.Error(ex);
         return false;
     }
 }
Пример #3
0
        public void configure(IdeDiskDescriptor cfg)
        {
            ata_p.close();
            c = cfg.c;
            h = cfg.h;
            s = cfg.s;
            lba = cfg.lba;
            readOnly = cfg.readOnly;

            for (int i = 0; i < regs.Length; i++)	// clear registers
                regs[i] = 0;
            command_ok(); // reset state and transfer position

            phys_dev = -1;
            if (String.IsNullOrEmpty(cfg.image))
                return;

            PHYS_DEVICE filedev = new PHYS_DEVICE();
            filedev.filename = cfg.image;
            filedev.type = cfg.cd ? DEVTYPE.ATA_FILECD : DEVTYPE.ATA_FILEHDD;

            bool success = false;
            if (filedev.type == DEVTYPE.ATA_FILEHDD)
            {
                filedev.usage = DEVUSAGE.ATA_OP_USE;
                success = ata_p.open(filedev);
                atapi = false;
            }
            //if (filedev.type == DEVTYPE.ATA_FILECD)
            //{
            //    filedev.usage = DEVUSAGE.ATA_OP_USE;
            //    errCode = atapi_p.open(filedev);
            //    atapi = 1;
            //}
            if (success)
                return;
            cfg.image = string.Empty;
        }