Beispiel #1
0
        // f**k windows
        public static IEnumerable <PartitionInfo> ToDiskPartitions(LogicalDiskInfo disk)
        {
            ObjectQuery query = new ObjectQuery($"associators of {{Win32_LogicalDisk.DeviceID='{disk.DeviceID}'}} where AssocClass = Win32_LogicalDiskToPartition");
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

            return(searcher.Get().Cast <ManagementObject>().Select(x => new PartitionInfo(x)));
        }
Beispiel #2
0
 void DeviceRemove(LogicalDiskInfo param)
 {
     try
     {
         Messenger.Default.Send <LogicalDiskInfo>(param, ViewModelMessages.DeviceRemoved);
     }
     catch (Exception err)
     {
         LogHelper.Manage("MainViewModel:DeviceAdd", err);
     }
 }
        internal void HandleDeviceAdd(LogicalDiskInfo disk)
        {
            if (!Data.Exists(p => p.Name == disk.Path))
            {
                Data.Add(disk);

                SysDriveViewModel sysDrive = new SysDriveViewModel(disk.Path);
                sysDrive.Name = string.Format("{0} - {1}", disk.Name, disk.Model);
                _Drives.Add(sysDrive);

                RaisePropertyChanged("Drives");
            }
        }
        public override bool CollectReportData()
        {
            Boolean result = false;

            try
            {
                // productInfoItems.Clear();



                //List<String> test = InputConnectionInfo.DatabaseFields;

                foreach (ManagementObject mo in searcher.Get().AsParallel())
                {
                    LogicalDiskInfo productInfo = new LogicalDiskInfo()
                    {
                    };
                    foreach (String itemProp in InputConnectionInfo.WMIFields)
                    {
                        productInfo.GetType().GetProperty(itemProp).SetValue(productInfo, (WMIQueryBuilder.GetValue(mo, itemProp)), null);
                    }
                    productInfo.TimeStamp  = InputConnectionInfo.TimeStamp;
                    productInfo.SystemName = MachineDetails.ServerName;
                    UpdateStatus(productInfo.Name);
                    productInfoItems.Add(productInfo);
                    if (IsCancelRequested)
                    {
                        break;
                    }
                }

                result = true;
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }

            return(result);
        }
Beispiel #5
0
        private static bool FindEmuMMC(DriveInfo drive)
        {
            DirectoryInfo root      = drive.RootDirectory;
            FileInfo      emummcIni = root.GetFile("emuMMC/emummc.ini");

            if (emummcIni.Exists)
            {
                // find the DiskDrive associated with this drive letter
                VolumeInfo volume = AllVolumes
                                    .Where(x => x.Caption == drive.Name).FirstOrDefault();

                LogicalDiskInfo logicalDisk = AllLogicalDisks
                                              .Where(x => x.DeviceID == volume.DriveLetter).FirstOrDefault();

                IEnumerable <PartitionInfo> partitionsFromLogicalDisk = ToDiskPartitions(logicalDisk);
                if (!partitionsFromLogicalDisk.Any())
                {
                    return(false);
                }

                DiskInfo disk = AllDisks.Where(x => x.Index == partitionsFromLogicalDisk.First().DiskIndex).FirstOrDefault();

                IEnumerable <PartitionInfo> partitions = AllPartitions.Where(x => x.DiskIndex == disk.Index);

                // parse ini
                FileIniDataParser parser = new FileIniDataParser();

                IniData ini = parser.ReadFile(emummcIni.FullName);
                ini.SectionKeySeparator = '/';

                if (!ini.TryGetKey("emummc/sector", out string sectorStr))
                {
                    return(false);
                }

                ulong sector = ulong.Parse(sectorStr.Replace("0x", ""), System.Globalization.NumberStyles.HexNumber);

                PartitionInfo partition = partitions.Where(x =>
                                                           (sector * x.BlockSize)
                                                           - 0x1000000 /* hekate's 16MB padding to protect the emuMMC */

                                                           == x.StartingOffset).FirstOrDefault();

                bool usingEmummc = partition != null;
                if (usingEmummc)
                {
                    MessageBoxResult r = MessageBox.Show("emuMMC was detected on this SD card. Do you want to open that instead of sysMMC content?", "emuMMC", MessageBoxButton.YesNo);
                    if (r == MessageBoxResult.No)
                    {
                        usingEmummc = false;
                    }
                }

                if (usingEmummc)
                {
                    DeviceStream stream      = new DeviceStream(disk.PhysicalName, disk.Length);
                    IStorage     diskStorage = new CachedStorage(stream.AsStorage().AsReadOnly(), disk.SectorSize * 100, 4, true);
                    long         offset      = (long)partition.StartingOffset;
                    offset += 0x1000000; // account for hekate's padding
                    offset += 0x400000;  // BOOT0
                    offset += 0x400000;  // BOOT1


                    NANDService.InsertNAND(diskStorage.Slice(offset, (long)partition.Size), false);
                }

                return(usingEmummc);
            }

            return(false);
        }
 internal void HandleDeviceRemove(LogicalDiskInfo disk)
 {
     Data.Remove(disk);
     _Drives.Remove(_Drives.Where(p => p.FullPath == disk.Path).First());
     RaisePropertyChanged("Drives");
 }