Exemple #1
0
        internal static bool IsValidDirectoryEntry(cSector Sector, int SubIndex, ushort SectorIndex, cFAT FAT)
        {
            if (SubIndex > Sector.Memory.Length)
            {
                return(false);
            }
            for (int i = 0; i < 6; i++)
            {
                if (Sector.Memory[SubIndex] == 0x0000)      //Name
                {
                    return(false);
                }
            }
            uint TempSize = (uint)(Sector.Memory[SubIndex + 0xC] + (Sector.Memory[SubIndex + 0xD] << 16));

            if ((TempSize == 0) && ((Sector.Memory[SubIndex + 0x5] & 0x0010) == 0))
            {
                return(false);
            }
            if (FAT.NextSector(SectorIndex) == 0x0000)
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        internal cSector Clone()
        {
            cSector Clone = new cSector();

            for (int i = 0; i < this.Memory.Length; i++)
            {
                Clone.Memory[i] = this.Memory[i];
            }
            Clone.Mode = this.Mode;
            return(Clone);
        }
Exemple #3
0
 internal void ChangeNumKernelSectorsAndRelocateFAT(ushort NewNumber)
 {
     cSector[] Temp = new cSector[NumFatSectors];
     for (int i = 0; i < NumFatSectors; i++)
     {
         Temp[i] = Floppy.Sectors[i + FatIndex];
     }
     FatIndex = (ushort)(NewNumber + 1);
     Floppy.Sectors[0].Memory[8] = FatIndex;
     for (int i = 0; i < NumFatSectors; i++)
     {
         Floppy.Sectors[i + FatIndex] = Temp[i];
     }
 }
        internal List <cSector> GetFile(FileType Type)
        {
            List <cSector> Result         = new List <cSector>();
            cSector        WorkingSector  = new cSector();
            int            ReadoutIndex   = 0;
            int            IntSectorIndex = 0;

            if (Type == FileType.Bootloader || Type == FileType.Kernel || Type == FileType.fullFloppy)
            {
                //atm no special actions required...
            }
            else
            {
                //add file Metadata
                //name is 0 for now
                //extensaion is 0 for now
                //dateTimes 0 for now
                WorkingSector.Memory[0xC] = (ushort)(Readout.Count & 0x0000FFFF);
                WorkingSector.Memory[0xD] = (ushort)(Readout.Count >> 16);
                //First Sector unknown for now
                //reserved is reserved
                IntSectorIndex = 0x0010;
            }
            for (ReadoutIndex = 0; ReadoutIndex < Readout.Count; ReadoutIndex++)
            {
                WorkingSector.Memory[IntSectorIndex] = Readout[ReadoutIndex];
                IntSectorIndex++;
                if (IntSectorIndex == WorkingSector.Memory.Length)    //current sector is full, need new one
                {
                    IntSectorIndex = 0;
                    Result.Add(WorkingSector.Clone());
                    WorkingSector = new cSector();
                }
            }
            if (IntSectorIndex > 0)
            {
                Result.Add(WorkingSector.Clone());
            }
            return(Result);
        }
Exemple #5
0
 static public bool VerifyFHAT16BootSector(cSector Bootloader, ushort KernelSectorSize, ushort FloppyLength, bool IsBootable)
 {
     if (IsBootable && Bootloader.Memory[0] != 0xC382)      //is the Bootable Flag correct?
     {
         MessageBox.Show("Incorrect Bootflag");
         return(false);
     }
     else if (!IsBootable && Bootloader.Memory[0] != 0x0000)
     {
         MessageBox.Show("Incorrect Bootflag");
         return(false);
     }
     //now some checks for consistency to the HA FAT
     if (Bootloader.Memory[8] != KernelSectorSize)
     {
         if (MessageBox.Show("Wrong amount of reserved sectors detected.\r\nCorrect them?", "FAT Inconsistency", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             Bootloader.Memory[8] = KernelSectorSize;
         }
         else
         {
             return(false);
         }
     }
     if (FloppyLength != Bootloader.Memory[0xb])
     {
         if (MessageBox.Show("Wron amount of sectors specified fot the loaded Device.\r\nCorrect them?", "Device size inconsitency", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             Bootloader.Memory[0xb] = FloppyLength;
         }
         else
         {
             return(false);
         }
     }
     //and whatever more can go wrong...
     return(true);
 }
Exemple #6
0
        internal void CreateBootSector(string MediaName, int NumSectors)
        {
            cSector BootSector = new cSector();

            BootSector.Memory[0] = 0;
            BootSector.Memory[1] = 0xFA16;
            ushort[] Temp = cFileSigConverter.ConvertToMediaNameSig(TrimMediaName(MediaName));
            BootSector.Memory[2]  = Temp[0];
            BootSector.Memory[3]  = Temp[1];
            BootSector.Memory[4]  = Temp[2];
            BootSector.Memory[5]  = Temp[3];
            BootSector.Memory[6]  = Temp[4];
            BootSector.Memory[7]  = Temp[5];
            BootSector.Memory[8]  = 1;
            BootSector.Memory[9]  = 1;
            BootSector.Memory[10] = 512;
            BootSector.Memory[11] = (ushort)NumSectors;
            Temp = cFileSigConverter.CreateSerial();
            BootSector.Memory[12] = Temp[0];
            BootSector.Memory[13] = Temp[1];
            BootSector.Memory[14] = Temp[2];
            BootSector.Memory[15] = Temp[3];
            Floppy.Sectors[0]     = BootSector;
        }