Beispiel #1
0
        public void  Dispose()
        {
            if (openedSipperFiles != null)
            {
                // Close all SipperDiskFiles that are still opened.
                while (openedSipperFiles.Count > 0)
                {
                    SipperDiskFile sdf = openedSipperFiles[0];
                    sdf.Close(); //The close method will call 'CloseSipperDiskFile' which will remove from 'openedSipperFiles' list.
                    sdf.Dispose();
                    sdf = null;
                }
            }

            BlockStart();

            if (fs != null)
            {
                CloseHandleToPhysicalDisk();
            }

            if (mbr != null)
            {
                mbr.Dispose();
                mbr = null;
            }

            BlockEnd();

            sipperFiles = null;
        } /* Dispose */
Beispiel #2
0
        } /* ReOpen */

        private void  OpenSipperDrive()
        {
            fs  = null;
            mbr = null;

            bool sipperDriveFound = false;

            physicalDriveNumber = (int)0;
            while ((!sipperDriveFound) && (physicalDriveNumber < 32))
            {
                CreateHandleToPhysicalDisk(physicalDriveNumber);

                if (fs != null)
                {
                    byte[] buffer = new byte [MasterBootRecord.BuffSpaceNeeded()];

                    fs.Read(buffer, 0, buffer.Length);

                    int nextIndex = 0;
                    mbr = new MasterBootRecord(buffer, ref nextIndex);

                    sipperDriveFound = false;

                    ReadSipperPartitionSector(); // will read in class global 'sipperPartitionSector'

                    sipperDriveFound = sipperPartitionSector.IsASipperPartion();
                    if (!sipperDriveFound)
                    {
                        CloseHandleToPhysicalDisk();
                        mbr.Dispose();
                        mbr = null;
                    }
                }

                if (!sipperDriveFound)
                {
                    physicalDriveNumber++;
                }
            }


            if (!sipperDriveFound)
            {
                if (fs != null)
                {
                    fs.Close();
                    fs = null;
                }

                if (mbr != null)
                {
                    mbr.Dispose();
                    mbr = null;
                }
            }

            return;
        } /* OpenSipperDrive */