public bool GetInformation(IMediaImage imagePlugin, out List <Partition> partitions, ulong sectorOffset) { partitions = null; byte[] sector = imagePlugin.ReadSector(sectorOffset); if (sector.Length < 512) { return(false); } RioKarmaTable table = Marshal.ByteArrayToStructureLittleEndian <RioKarmaTable>(sector); if (table.magic != KARMA_MAGIC) { return(false); } ulong counter = 0; partitions = (from entry in table.entries let part = new Partition { Start = entry.offset, Offset = (ulong)(entry.offset * sector.Length), Size = entry.size, Length = (ulong)(entry.size * sector.Length), Type = "Rio Karma", Sequence = counter++, Scheme = Name } where entry.type == ENTRY_MAGIC select part).ToList(); return(true); }
public bool GetInformation(IMediaImage imagePlugin, out List <Partition> partitions, ulong sectorOffset) { partitions = new List <Partition>(); byte[] sector = imagePlugin.ReadSector(sectorOffset); if (sector.Length < 512) { return(false); } IntPtr tablePtr = Marshal.AllocHGlobal(512); Marshal.Copy(sector, 0, tablePtr, 512); RioKarmaTable table = (RioKarmaTable)Marshal.PtrToStructure(tablePtr, typeof(RioKarmaTable)); Marshal.FreeHGlobal(tablePtr); if (table.magic != KARMA_MAGIC) { return(false); } ulong counter = 0; foreach (Partition part in from entry in table.entries let part = new Partition { Start = entry.offset, Offset = (ulong)(entry.offset * sector.Length), Size = entry.size, Length = (ulong)(entry.size * sector.Length), Type = "Rio Karma", Sequence = counter, Scheme = Name } where entry.type == ENTRY_MAGIC select part) { partitions.Add(part); counter++; } return(true); }