/// <summary> /// 编辑Dos设备的Stoken; /// </summary> /// <param name="deviceStoken"></param> /// <param name="xElem">案件文件相关Xml元素</param> private static void EditStokenOnDos( DeviceStoken deviceStoken, IUnmanagedBasicDeviceManager entity) { if (deviceStoken == null) { throw new ArgumentNullException(nameof(deviceStoken)); } var dosDeviceInfo = new DOSDeviceInfo(); try { deviceStoken.TypeGuid = Constants.DeviceType_DOS; deviceStoken.PartsType = Constants.PartsType_DOS; //获取Dos链表; var partPtr = Partition_Get_DosPTable(entity.BasicDevicePtr); var partNode = partPtr; var infoDiskIndex = 0; while (partNode != IntPtr.Zero) { var dosPTable = partNode.GetStructure <StDosPTable>(); var dosPartInfo = new DOSPartInfo { DosPTable = new DosPTable(dosPTable) }; if (dosPTable.Info != IntPtr.Zero) { var stInfoDisk = dosPTable.Info.GetStructure <StInFoDisk>(); dosPartInfo.InfoDisk = new InfoDisk(stInfoDisk) { InternalDisplayName = $"{LanguageService.FindResourceString(Constants.DisplayName_InfoDisk)}{++infoDiskIndex}" }; } dosDeviceInfo.DosPartInfos.Add(dosPartInfo); partNode = dosPTable.next; } EditDosPartEntries(dosDeviceInfo, deviceStoken); //编辑拓展; deviceStoken.SetInstance(dosDeviceInfo, Constants.DeviceStokenTag_DOSDeviceInfo); } catch (Exception ex) { LoggerService.WriteCallerLine(ex.Message); } }
/// <summary> /// 根据Dos分区表项编辑Dos分区项; /// </summary> /// <param name="dosDeviceInfo"></param> private static void EditDosPartEntries(DOSDeviceInfo dosDeviceInfo, DeviceStoken deviceStoken) { if (dosDeviceInfo == null) { throw new ArgumentNullException(nameof(dosDeviceInfo)); } if (deviceStoken == null) { throw new ArgumentNullException(nameof(deviceStoken)); } //拓展分区偏移; long extendPartLBA = 0; dosDeviceInfo.DosPartInfos.ForEach(dosPartInfo => { //确定起始绝对位移; long startLBA = 0; long?partStartLBA = null; long?partSize = dosPartInfo.InfoDisk.StructInstance.AllSector * SECSIZE; switch (dosPartInfo.DosPTable.StDosPTable.DosPartType) { case DosPartType.Error: return; case DosPartType.Main: startLBA = (long)dosPartInfo.DosPTable.StDosPTable.nOffset; partStartLBA = dosPartInfo.InfoDisk.StructInstance.HeadSector * SECSIZE; break; case DosPartType.Extend: extendPartLBA += dosPartInfo.InfoDisk.StructInstance.HeadSector * SECSIZE; startLBA = (long)dosPartInfo.DosPTable.StDosPTable.nOffset; partSize = null; partStartLBA = null; break; case DosPartType.Logic: startLBA = (long)dosPartInfo.DosPTable.StDosPTable.nOffset; partStartLBA = extendPartLBA + dosPartInfo.InfoDisk.StructInstance.HeadSector * SECSIZE; break; default: break; } var entry = PartitionEntryFactory.CreatePartitionEntry(Constants.PartEntryKey_DOS); var entryStoken = entry.GetStoken(Constants.PartEntryKey_DOS); entryStoken.TypeGUID = FromDosPartTypeToCons(dosPartInfo.DosPTable.StDosPTable.DosPartType); entryStoken.StartLBA = startLBA; entryStoken.Size = Marshal.SizeOf(typeof(StInFoDisk)); entryStoken.PartStartLBA = partStartLBA; entryStoken.PartSize = partSize; entryStoken.SetInstance(dosPartInfo, Constants.PartitionEntryStokenTag_DOS); deviceStoken.PartitionEntries.Add(entry); }); }