mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use new little endian marshaller on filesystems.
This commit is contained in:
@@ -71,10 +71,8 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
|
||||
for(int off = 0; off < directory.Length; off += 32)
|
||||
{
|
||||
IntPtr dirPtr = Marshal.AllocHGlobal(32);
|
||||
Marshal.Copy(directory, off, dirPtr, 32);
|
||||
DirectoryEntry entry = (DirectoryEntry)Marshal.PtrToStructure(dirPtr, typeof(DirectoryEntry));
|
||||
Marshal.FreeHGlobal(dirPtr);
|
||||
DirectoryEntry entry =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<DirectoryEntry>(directory, off, 32);
|
||||
|
||||
if((entry.statusUser & 0x7F) < 0x20)
|
||||
{
|
||||
|
||||
@@ -180,11 +180,8 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
if(sig1 == 0x4D2F5043 && sig2 == 0x004B5344 && sig3 == sig1) amsSbOffset = 0x80;
|
||||
|
||||
// Read the superblock
|
||||
IntPtr amsPtr = Marshal.AllocHGlobal(16);
|
||||
Marshal.Copy(sector, amsSbOffset, amsPtr, 16);
|
||||
AmstradSuperBlock amsSb =
|
||||
(AmstradSuperBlock)Marshal.PtrToStructure(amsPtr, typeof(AmstradSuperBlock));
|
||||
Marshal.FreeHGlobal(amsPtr);
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<AmstradSuperBlock>(sector, amsSbOffset, 16);
|
||||
|
||||
// Check that format byte and sidedness indicate the same number of sizes
|
||||
if(amsSb.format == 0 && (amsSb.sidedness & 0x02) == 0 ||
|
||||
@@ -300,11 +297,8 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
if(sum == 0)
|
||||
{
|
||||
// Read the superblock
|
||||
HardDiskSuperBlock hddSb = new HardDiskSuperBlock();
|
||||
IntPtr hddPtr = Marshal.AllocHGlobal(Marshal.SizeOf(hddSb));
|
||||
Marshal.Copy(sector, 0, hddPtr, Marshal.SizeOf(hddSb));
|
||||
hddSb = (HardDiskSuperBlock)Marshal.PtrToStructure(hddPtr, typeof(HardDiskSuperBlock));
|
||||
Marshal.FreeHGlobal(hddPtr);
|
||||
HardDiskSuperBlock hddSb =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<HardDiskSuperBlock>(sector);
|
||||
|
||||
// Calculate volume size
|
||||
sectorSize = (ulong)(hddSb.recordsPerSector * 128);
|
||||
|
||||
@@ -216,7 +216,6 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
passwordCache = new Dictionary<string, byte[]>();
|
||||
|
||||
DicConsole.DebugWriteLine("CP/M Plugin", "Traversing directory.");
|
||||
IntPtr dirPtr;
|
||||
|
||||
// For each directory entry
|
||||
for(int dOff = 0; dOff < directory.Length; dOff += 32)
|
||||
@@ -224,11 +223,8 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
if((directory[dOff] & 0x7F) < 0x10)
|
||||
if(allocationBlocks.Count > 256)
|
||||
{
|
||||
dirPtr = Marshal.AllocHGlobal(32);
|
||||
Marshal.Copy(directory, dOff, dirPtr, 32);
|
||||
DirectoryEntry16 entry =
|
||||
(DirectoryEntry16)Marshal.PtrToStructure(dirPtr, typeof(DirectoryEntry16));
|
||||
Marshal.FreeHGlobal(dirPtr);
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<DirectoryEntry16>(directory, dOff, 32);
|
||||
|
||||
bool hidden = (entry.statusUser & 0x80) == 0x80;
|
||||
bool rdOnly = (entry.filename[0] & 0x80) == 0x80 || (entry.extension[0] & 0x80) == 0x80;
|
||||
@@ -314,10 +310,8 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
}
|
||||
else
|
||||
{
|
||||
dirPtr = Marshal.AllocHGlobal(32);
|
||||
Marshal.Copy(directory, dOff, dirPtr, 32);
|
||||
DirectoryEntry entry = (DirectoryEntry)Marshal.PtrToStructure(dirPtr, typeof(DirectoryEntry));
|
||||
Marshal.FreeHGlobal(dirPtr);
|
||||
DirectoryEntry entry =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<DirectoryEntry>(directory, dOff, 32);
|
||||
|
||||
bool hidden = (entry.statusUser & 0x80) == 0x80;
|
||||
bool rdOnly = (entry.filename[0] & 0x80) == 0x80 || (entry.extension[0] & 0x80) == 0x80;
|
||||
@@ -404,10 +398,8 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
// A password entry (or a file entry in PDOS, but this does not handle that case)
|
||||
else if((directory[dOff] & 0x7F) >= 0x10 && (directory[dOff] & 0x7F) < 0x20)
|
||||
{
|
||||
dirPtr = Marshal.AllocHGlobal(32);
|
||||
Marshal.Copy(directory, dOff, dirPtr, 32);
|
||||
PasswordEntry entry = (PasswordEntry)Marshal.PtrToStructure(dirPtr, typeof(PasswordEntry));
|
||||
Marshal.FreeHGlobal(dirPtr);
|
||||
PasswordEntry entry =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<PasswordEntry>(directory, dOff, 32);
|
||||
|
||||
int user = entry.userNumber & 0x0F;
|
||||
|
||||
@@ -450,11 +442,8 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
switch(directory[dOff] & 0x7F)
|
||||
{
|
||||
case 0x20:
|
||||
LabelEntry labelEntry;
|
||||
dirPtr = Marshal.AllocHGlobal(32);
|
||||
Marshal.Copy(directory, dOff, dirPtr, 32);
|
||||
labelEntry = (LabelEntry)Marshal.PtrToStructure(dirPtr, typeof(LabelEntry));
|
||||
Marshal.FreeHGlobal(dirPtr);
|
||||
LabelEntry labelEntry =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<LabelEntry>(directory, dOff, 32);
|
||||
|
||||
// The volume label defines if one of the fields in CP/M 3 timestamp is a creation or an
|
||||
// access time
|
||||
@@ -486,10 +475,8 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
if(directory[dOff + 10] == 0x00 && directory[dOff + 20] == 0x00 &&
|
||||
directory[dOff + 30] == 0x00 && directory[dOff + 31] == 0x00)
|
||||
{
|
||||
dirPtr = Marshal.AllocHGlobal(32);
|
||||
Marshal.Copy(directory, dOff, dirPtr, 32);
|
||||
DateEntry dateEntry = (DateEntry)Marshal.PtrToStructure(dirPtr, typeof(DateEntry));
|
||||
Marshal.FreeHGlobal(dirPtr);
|
||||
DateEntry dateEntry =
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<DateEntry>(directory, dOff, 32);
|
||||
|
||||
FileEntryInfo fInfo;
|
||||
|
||||
@@ -541,11 +528,9 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
// However, if this byte is 0, timestamp is in Z80DOS or DOS+ format
|
||||
else if(directory[dOff + 1] == 0x00)
|
||||
{
|
||||
dirPtr = Marshal.AllocHGlobal(32);
|
||||
Marshal.Copy(directory, dOff, dirPtr, 32);
|
||||
TrdPartyDateEntry trdPartyDateEntry =
|
||||
(TrdPartyDateEntry)Marshal.PtrToStructure(dirPtr, typeof(TrdPartyDateEntry));
|
||||
Marshal.FreeHGlobal(dirPtr);
|
||||
Helpers.Marshal.ByteArrayToStructureLittleEndian<TrdPartyDateEntry>(directory, dOff,
|
||||
32);
|
||||
|
||||
FileEntryInfo fInfo;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user