Ejemplo n.º 1
0
        /// <summary>
        ///     Gets a list of Devices that can be selected
        /// </summary>
        /// <param name="onlyRemoveable"> If set to false also Fixed devices will be included in the list (most likely useless) </param>
        /// <returns> List of devices used for the MMC Flasher </returns>
        internal static IList <MMCDevice> GetDevices(bool onlyRemoveable = true)
        {
            var tmp = new Dictionary <int, MMCDevice>();

            foreach (var drive in DriveInfo.GetDrives())
            {
                if (drive.DriveType == DriveType.Fixed && onlyRemoveable)
                {
                    continue;
                }
                if (drive.DriveType != DriveType.Removable && drive.DriveType != DriveType.Fixed)
                {
                    continue;
                }
                try {
                    var devnum = NativeWin32.GetDeviceNumber(drive.Name);
                    if (!tmp.ContainsKey(devnum))
                    {
                        var path = NativeWin32.GetDevicePath(drive.Name);
                        tmp.Add(devnum, new MMCDevice(drive.Name, path, NativeWin32.GetGeometryEX(path)));
                    }
                    else
                    {
                        tmp[devnum].DisplayName = string.Format("{0}, {1}", tmp[devnum].DisplayName, drive.Name);
                        tmp[devnum].AddVolume(drive.Name);
                    }
                }
                catch (Exception ex) {
                    var dex = ex as X360NANDManagerException;
                    if (dex != null && (dex.Win32ErrorNumber == 32 || dex.Win32ErrorNumber == 0 /* Success, not an error?! */ || dex.Win32ErrorNumber == 21 /* Device not ready... ignore it... */))
                    {
                        continue;
                    }
                    var wex = ex as Win32Exception;
                    if (wex != null && wex.NativeErrorCode == 21) //Device not ready, Win32 Error outside of my own error handling...
                    {
                        continue;
                    }
                    throw;
                }
            }
            Main.SendDebug("Copying data to returnable object");
            var ret = new MMCDevice[tmp.Values.Count];

            tmp.Values.CopyTo(ret, 0);
            return(ret);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   Gets a list of Devices that can be selected
        /// </summary>
        /// <param name="onlyRemoveable"> If set to false also Fixed devices will be included in the list (most likely useless) </param>
        /// <returns> List of devices used for the MMC Flasher </returns>
        internal static IList <MMCDevice> GetDevices(bool onlyRemoveable = true)
        {
            var tmp = new Dictionary <int, MMCDevice>();

            foreach (var drive in DriveInfo.GetDrives())
            {
                if (drive.DriveType == DriveType.Fixed && onlyRemoveable)
                {
                    continue;
                }
                if (drive.DriveType != DriveType.Removable && drive.DriveType != DriveType.Fixed)
                {
                    continue;
                }
                try {
                    Main.SendDebug(string.Format("Getting Drive number for Device: {0}", drive.Name));
                    var devnum = NativeWin32.GetDeviceNumber(drive.Name);
                    if (!tmp.ContainsKey(devnum))
                    {
                        Main.SendDebug(string.Format("Getting Drive path for Device: {0}", drive.Name));
                        var path = NativeWin32.GetDevicePath(drive.Name);
                        Main.SendDebug(string.Format("Getting Drive Geometry for Device: {0}", drive.Name));
                        tmp.Add(devnum, new MMCDevice(drive.Name, path, NativeWin32.GetGeometry(path)));
                    }
                    else
                    {
                        tmp[devnum].DisplayName = string.Format("{0}, {1}", tmp[devnum].DisplayName, drive.Name);
                    }
                }
                catch (Exception ex) {
                    var dex = ex as DeviceError;
                    if (dex != null && dex.Win32ErrorNumber == 32)
                    {
                        continue;
                    }
                    throw;
                }
            }
            Main.SendDebug("Copying data to returnable object");
            var ret = new MMCDevice[tmp.Values.Count];

            tmp.Values.CopyTo(ret, 0);
            return(ret);
        }
Ejemplo n.º 3
0
 public BWArgs(Operations op)
 {
     Operation = op;
     foreach(var ctrl in Program.MainForm.devices.Controls) {
         if(!(ctrl is RadioButton))
             continue;
         var rb = ctrl as RadioButton;
         if(rb.Checked) {
             Device = (Devices) Enum.Parse(typeof(Devices), rb.Name, true);
             break;
         }
         Device = Devices.None;
     }
     if (Program.MainForm.mmcdevice.SelectedItem != null)
         MMCDevice = Program.MainForm.mmcdevice.SelectedItem as MMCDevice;
     Verify = Program.MainForm.verifyBox.Checked;
     EraseFirst = Program.MainForm.eraseBox.Checked;
     AddSpare = Program.MainForm.addSpareBox.Checked;
     CorrectSpare = Program.MainForm.correctSpareBox.Checked;
 }
Ejemplo n.º 4
0
 /// <summary>
 ///   Gets a list of Devices that can be selected
 /// </summary>
 /// <param name="onlyRemoveable"> If set to false also Fixed devices will be included in the list (most likely useless) </param>
 /// <returns> List of devices used for the MMC Flasher </returns>
 internal static IList<MMCDevice> GetDevices(bool onlyRemoveable = true)
 {
     var tmp = new Dictionary<int, MMCDevice>();
     foreach(var drive in DriveInfo.GetDrives()) {
         if(drive.DriveType == DriveType.Fixed && onlyRemoveable)
             continue;
         if(drive.DriveType != DriveType.Removable && drive.DriveType != DriveType.Fixed)
             continue;
         try {
             var devnum = NativeWin32.GetDeviceNumber(drive.Name);
             if(!tmp.ContainsKey(devnum)) {
                 var path = NativeWin32.GetDevicePath(drive.Name);
                 tmp.Add(devnum, new MMCDevice(drive.Name, path, NativeWin32.GetGeometryEX(path)));
             }
             else
                 tmp[devnum].DisplayName = string.Format("{0}, {1}", tmp[devnum].DisplayName, drive.Name);
         }
         catch(Exception ex) {
             var dex = ex as X360NANDManagerException;
             if(dex != null && (dex.Win32ErrorNumber == 32 || dex.Win32ErrorNumber == 0 /* Success, not an error?! */|| dex.Win32ErrorNumber == 21 /* Device not ready... ignore it... */))
                 continue;
             var wex = ex as Win32Exception;
             if(wex != null && wex.NativeErrorCode == 21) //Device not ready, Win32 Error outside of my own error handling...
                 continue;
             throw;
         }
     }
     Main.SendDebug("Copying data to returnable object");
     var ret = new MMCDevice[tmp.Values.Count];
     tmp.Values.CopyTo(ret, 0);
     return ret;
 }
Ejemplo n.º 5
0
 public MMCFlasher(MMCDevice device)
 {
     _device = device;
     _sectorSize = (int) _device.DiskGeometryEX.Geometry.BytesPerSector;
 }
Ejemplo n.º 6
0
 public static IMMCFlasher GetMMCFlasher(MMCDevice device)
 {
     return new MMCFlasher(device);
 }
Ejemplo n.º 7
0
 public static IMMCFlasher GetMMCFlasher(MMCDevice device)
 {
     if(!IsUserAnAdmin())
         throw new Exception("You must be admin to use this function...");
     return new MMCFlasher(device);
 }
Ejemplo n.º 8
0
 public MMCFlasher(MMCDevice device)
 {
     _device     = device;
     _sectorSize = (int)_device.DiskGeometryEX.Geometry.BytesPerSector;
 }
Ejemplo n.º 9
0
 /// <summary>
 ///   Gets a list of Devices that can be selected
 /// </summary>
 /// <param name="onlyRemoveable"> If set to false also Fixed devices will be included in the list (most likely useless) </param>
 /// <returns> List of devices used for the MMC Flasher </returns>
 internal static IList<MMCDevice> GetDevices(bool onlyRemoveable = true)
 {
     var tmp = new Dictionary<int, MMCDevice>();
     foreach(var drive in DriveInfo.GetDrives()) {
         if(drive.DriveType == DriveType.Fixed && onlyRemoveable)
             continue;
         if(drive.DriveType != DriveType.Removable && drive.DriveType != DriveType.Fixed)
             continue;
         try {
             Main.SendDebug(string.Format("Getting Drive number for Device: {0}", drive.Name));
             var devnum = NativeWin32.GetDeviceNumber(drive.Name);
             if(!tmp.ContainsKey(devnum)) {
                 Main.SendDebug(string.Format("Getting Drive path for Device: {0}", drive.Name));
                 var path = NativeWin32.GetDevicePath(drive.Name);
                 Main.SendDebug(string.Format("Getting Drive Geometry for Device: {0}", drive.Name));
                 tmp.Add(devnum, new MMCDevice(drive.Name, path, NativeWin32.GetGeometry(path)));
             }
             else
                 tmp[devnum].DisplayName = string.Format("{0}, {1}", tmp[devnum].DisplayName, drive.Name);
         }
         catch(Exception ex) {
             var dex = ex as DeviceError;
             if(dex != null && dex.Win32ErrorNumber == 32)
                 continue;
             throw;
         }
     }
     Main.SendDebug("Copying data to returnable object");
     var ret = new MMCDevice[tmp.Values.Count];
     tmp.Values.CopyTo(ret, 0);
     return ret;
 }