public void Handle(IHexDataContext hexDataContext)
        {
            if (hexDataContext == null)
            {
                return;
            }

            var device = hexDataContext.GetInstance <IFile>(Contracts.FileExplorer.Constants.HexDataContextTag_File) as IDevice;

            if (device == null)
            {
                return;
            }

            if (device.PartitionEntries == null)
            {
                return;
            }

            int i = 0;

            foreach (var ti in device.PartitionEntries.OrderBy(p => p.StartLBA))
            {
                hexDataContext.CustomBackgroundBlocks?.Add(
                    BrushBlockFactory.CreateNewBackgroundBlock(
                        ti.StartLBA,
                        ti.Size,
                        i++ % 2 == 0 ? BrushBlockFactory.FirstBrush : BrushBlockFactory.SecondBrush
                        )
                    );
            }

            hexDataContext.UpdateCustomBackgroundBlocks();
        }
Ejemplo n.º 2
0
        public void Handle(IHexDataContext hexDataContext)
        {
            if (hexDataContext == null)
            {
                return;
            }

            var part = hexDataContext.GetInstance <IFile>(Contracts.FileExplorer.Constants.HexDataContextTag_File) as IPartition;

            if (part == null)
            {
                return;
            }

            if (part.TypeGuid != Constants.PartitionType_FAT32)
            {
                return;
            }

            var fatPartInfo = part.GetInstance <FATPartInfo>(Constants.PartitionStokenTag_FATPartInfo);

            if (fatPartInfo == null)
            {
                LoggerService.WriteCallerLine($"{nameof(fatPartInfo)} can't be null.");
                return;
            }

            IEnumerable <(ICustomMemberDescriptor descriptor, long offset, string languagePrefix)> GetDescriptorTuples()
            {
                yield return(fatPartInfo.FatDBR, fatPartInfo.FatDBR?.Offset ?? 0, Constants.FATFieldPrefix_DBR);

                yield return(fatPartInfo.FatDBR_BackUp, fatPartInfo.FatDBR_BackUp?.Offset ?? 0, Constants.FATFieldPrefix_DBR);

                yield return(fatPartInfo.FatInfo, fatPartInfo.FatInfo?.Offset ?? 0, Constants.FATFieldPrefix_Info);

                yield return(fatPartInfo.FatInfo_BackUp, fatPartInfo.FatInfo_BackUp?.Offset ?? 0, Constants.FATFieldPrefix_Info);
            };

            var infoIndex = 0;

            foreach (var tuple in GetDescriptorTuples().OrderBy(p => p.offset))
            {
                if (tuple.descriptor == null)
                {
                    continue;
                }
                hexDataContext.LoadCustomTypeDescriptor(
                    tuple.descriptor,
                    tuple.offset,
                    infoIndex % 2 == 0?BrushBlockFactory.FirstBrush:BrushBlockFactory.SecondBrush,
                    BrushBlockFactory.HighLightBrush
                    );
                infoIndex++;
            }
        }
        public void Handle(IHexDataContext hexDataContext)
        {
            if (hexDataContext == null)
            {
                return;
            }

            if (!(hexDataContext.GetInstance <IFile>(Contracts.FileExplorer.Constants.HexDataContextTag_File) is IPartition part))
            {
                return;
            }

            if (part.TypeGuid != Constants.PartitionType_Ext)
            {
                return;
            }

            var extPartInfo = part.GetInstance <ExtPartInfo>(Constants.PartitionStokenTag_ExtPartInfo);

            if (extPartInfo == null)
            {
                LoggerService.WriteCallerLine($"{nameof(extPartInfo)} can't be null.");
                return;
            }

            if (extPartInfo.SuperBlock != null)
            {
                var stSuperBlock = extPartInfo.SuperBlock.StructInstance;
                hexDataContext.LoadCustomTypeDescriptor(extPartInfo.SuperBlock, Constants.ExtSuperBlockStartIndex, BrushBlockFactory.FirstBrush, BrushBlockFactory.HighLightBrush);

                var descStart = (stSuperBlock.s_first_data_block + 1) * stSuperBlock.BlockSize;

                var descIndex = 0;
                if (extPartInfo.Ext4GroupDescs == null)
                {
                    LoggerService.WriteCallerLine($"{nameof(extPartInfo.Ext4GroupDescs)} can't be null.");
                    return;
                }

                foreach (var desc in extPartInfo.Ext4GroupDescs)
                {
                    hexDataContext.LoadCustomTypeDescriptor(
                        desc,
                        descStart + descIndex * stSuperBlock.s_desc_size,
                        descIndex % 2 == 0?BrushBlockFactory.FirstBrush:BrushBlockFactory.SecondBrush,
                        BrushBlockFactory.HighLightBrush
                        );
                    descIndex++;
                }
                //extPartInfo.StExt4GroupDescs
            }

            Handle(hexDataContext, extPartInfo);
        }
Ejemplo n.º 4
0
        public void Handle(IHexDataContext hexDataContext)
        {
            if (hexDataContext == null)
            {
                return;
            }

            if (!(hexDataContext.GetInstance <IFile>(Contracts.FileExplorer.Constants.HexDataContextTag_File) is IDevice device))
            {
                return;
            }

            if (device.TypeGuid != Constants.DeviceType_DOS)
            {
                return;
            }

            var dosDeviceInfo = device.GetInstance <DOSDeviceInfo>(Constants.DeviceStokenTag_DOSDeviceInfo);

            if (dosDeviceInfo == null)
            {
                LoggerService.WriteCallerLine($"{nameof(dosDeviceInfo)} can't be null.");
                return;
            }

            var pTableIndex = 0;

            foreach (var p in dosDeviceInfo.DosPartInfos.OrderBy(p => p.DosPTable.StDosPTable.nOffset))
            {
                if (p.InfoDisk != null)
                {
                    hexDataContext.LoadCustomTypeDescriptor(
                        p.InfoDisk,
                        (long)p.DosPTable.StDosPTable.nOffset,
                        pTableIndex % 2 == 0 ? BrushBlockFactory.FirstBrush : BrushBlockFactory.SecondBrush,
                        BrushBlockFactory.HighLightBrush
                        );
                }

                pTableIndex++;
            }
        }