Exemplo n.º 1
0
        /// <summary>
        /// 获取设备分区
        /// </summary>
        public override void LoadDevicePartitions()
        {
            try
            {
                Asyn?.Advance(1, LanguageHelperSingle.Instance.GetLanguageByKey(Languagekeys.FileServiceLanguage_File_JiaZaiXiTongFenQuLieBiao));

                var rootTable = new DSK_PART_TABLE();
                var result    = FileServiceCoreDll.GetMirrorFilePartitions(ref rootTable, Device.Source.ToString());
                if (result != 0)
                {
                    LoggerManagerSingle.Instance.Error("1/123获取镜像文件的分区信息失败并返回");
                    return;
                }
                if (rootTable.next == IntPtr.Zero)  //无法读取分区,需要进行深度分区扫描
                {
                    var handle = FileServiceCoreDll.MountDisk(Device.Handle, -1, (ulong)Device.TotalSectors, 0x12);
                    if (handle == IntPtr.Zero)
                    {
                        LoggerManagerSingle.Instance.Error(string.Format("2/123获取镜像文件的分区信息成功;无法读取分区,需要进行深度分区扫描;加载磁盘句柄失败(句柄:{0}, disNum:{1},扇区数:{2},设备类型:0x12)", Device.Handle, -1, Device.TotalSectors));
                    }

                    FindVolumeCallBack fv = (ref FIND_VOLUME_PROGRESS pdi) => { return(0); };
                    try
                    {
                        result = FileServiceCoreDll.GetPhysicalPartitionsByScall(handle, fv, 0, 1, ref rootTable);
                    }
                    catch (Exception ex)
                    {
                        LoggerManagerSingle.Instance.Error("深度查找分区异常", ex);
                    }

                    if (result != 0)
                    {
                        LoggerManagerSingle.Instance.Error("3/123获取镜像文件的分区信息成功; 无法读取分区,需要进行深度分区扫描; 深度查找分区失败并返回");
                        return;
                    }

                    var parts = CreatePartition(rootTable);
                    Device.Parts.AddRange(parts);
                    FileServiceCoreDll.UnloadDeviceHandle(ref handle);
                }
                else
                {
                    var parts = CreatePartition(rootTable);
                    Device.Parts.AddRange(parts);
                }
            }
            catch (Exception ex)
            {
                LoggerManagerSingle.Instance.Error("获取设备分区异常", ex);
            }
        }
Exemplo n.º 2
0
 public static extern int GetPhysicalPartitionsByScall(IntPtr mountDevHandle, FindVolumeCallBack lp, UInt64 offset, UInt32 intervalSec, ref DSK_PART_TABLE partTable);
Exemplo n.º 3
0
 /// <summary>
 /// 深度查找分区
 /// </summary>
 public int GetPhysicalPartitionsByScallEx(IntPtr mountDevHandle, FindVolumeCallBack lp, UInt64 offset, UInt32 intervalSec, ref DSK_PART_TABLE partTable)
 {
     return(GetPhysicalPartitionsByScall(mountDevHandle, lp, offset, intervalSec, ref partTable));
 }