Ejemplo n.º 1
0
        /// <summary>
        /// 获取设备分区
        /// </summary>
        public override void LoadDevicePartitions()
        {
            if (this.Device.Parts.Count != 0)
            {
                return;
            }
            var    link         = new DSK_PART_TABLE();
            UInt64 totalSectors = 0;
            var    result1      = FileServiceCoreDll.DeviceTotalSectors(this.Device.Handle_Flsh, ref totalSectors);
            var    handle       = FileServiceCoreDll.MountDisk(this.Device.Handle_Flsh, -1, totalSectors, 0x1B);
            var    result2      = FileServiceCoreDll.GetPhysicalPartitions(handle, ref link);

            if (result2 != 0)
            {
                //LogHelper.Error(LanguageHelper.Get("LANGKEY_HuoQuSaiBanJingXiangWenJianFen_04946") + result2);
                return;
            }
            var parts = this.CreatePartition(link);

            foreach (var part in parts)
            {
                part.DevType  = 0x12;
                part.PartType = 0;
                this.Device.Parts.Add(part);
            }
            FileServiceCoreDll.FreePartitionTableHandle(ref link);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 创建磁盘分区
        /// </summary>
        /// <param name="link"></param>
        /// <returns></returns>
        protected List <FileSystemPartition> CreatePartition(DSK_PART_TABLE link)
        {
            var parts = new List <FileSystemPartition>();
            var index = 0;

            while (link.next != IntPtr.Zero)
            {
                link = link.next.ToStruct <DSK_PART_TABLE>();
                if (link.disk_part_info.file_system != 0x00)
                {
                    var partition = new FileSystemPartition();
                    partition.Name         = LanguageHelperSingle.Instance.GetLanguageByKey(Languagekeys.FileServiceLanguage_File_FenQu) + ++index;
                    partition.VolName      = link.disk_part_info.vol_name == "userdata" ? "data" : link.disk_part_info.vol_name;
                    partition.FileSystem   = link.disk_part_info.file_system;
                    partition.SerialNumber = String.Format("{0:X}", link.disk_part_info.serial_num);
                    partition.Size         = link.disk_part_info.sectors * 512;
                    partition.SectorOffset = link.disk_part_info.start_lba;
                    partition.TotalSectors = link.disk_part_info.sectors;
                    //partition.PartType = link.disk_part_info.vol_type;
                    parts.Add(partition);
                }
            }
            return(parts);
        }
Ejemplo n.º 4
0
 public static extern void FreePartitionTableHandle(ref DSK_PART_TABLE partTable);
Ejemplo n.º 5
0
 public static extern int GetPhysicalPartitionsByScall(IntPtr mountDevHandle, FindVolumeCallBack lp, UInt64 offset, UInt32 intervalSec, ref DSK_PART_TABLE partTable);
Ejemplo n.º 6
0
 public static extern int GetMirrorFilePartitions(ref DSK_PART_TABLE partTable, string mirrorFilePath);
Ejemplo n.º 7
0
 public static extern int GetPhysicalPartitions(IntPtr devHandle, ref DSK_PART_TABLE partTable);
Ejemplo n.º 8
0
 public static extern void FreePartitionHanlder(IntPtr mountDevHandle, ref DSK_PART_TABLE partTable);
Ejemplo n.º 9
0
 /// <summary>
 /// 卸载(释放)分区链表资源。
 /// </summary>
 /// <param name="partTable">链表对象。</param>
 public void FreePartitionTableHandleEx(ref DSK_PART_TABLE partTable)
 {
     FreePartitionTableHandle(ref partTable);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 获取镜像文件的分区信息
 /// </summary>
 /// <param name="partTable">分区表</param>
 /// <param name="mirrorFilePath">镜像文件</param>
 /// <returns>返回0,代表解析成功。</returns>
 public int GetMirrorFilePartitionsEx(ref DSK_PART_TABLE partTable, string mirrorFilePath)
 {
     return(GetMirrorFilePartitionsEx(ref partTable, mirrorFilePath));
 }
Ejemplo n.º 11
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));
 }
Ejemplo n.º 12
0
 public void FreePartitionHanlderEx(IntPtr mountDevHandle, ref DSK_PART_TABLE partTable)
 {
     FreePartitionHanlder(mountDevHandle, ref partTable);
 }
Ejemplo n.º 13
0
 public int GetPhysicalPartitionsEx(IntPtr devHandle, ref DSK_PART_TABLE partTable)
 {
     return(GetPhysicalPartitions(devHandle, ref partTable));
 }