Exemple #1
0
        public VMFS1Volume(byte[] data)
        {
            diskData = data;
            byte[] s = new byte[8];

            // Check boot signature and FS label

            // Get file system label
            Array.Copy(diskData, 16, s, 0, 8);
            string fsLabel = Encoding.UTF8.GetString(s);

            if (!((data[510] == 0x66) & (data[511] == 0xBB) & (fsLabel == "VMFS1\0\0\0")))
            {
                throw new Exception("Invalid boot signature or file system label.");
            }

            // Get the jump code
            Array.Copy(diskData, 0, jump, 0, 8);

            // Get the volume label
            Array.Copy(diskData, 8, s, 0, 8);
            volumeLabel = Encoding.UTF8.GetString(s);

            // Get boostrap code
            byte[] a_bootstrap = new byte[486];
            Array.Copy(diskData, 24, a_bootstrap, 0, 486);
            bootstrap.AddRange(a_bootstrap);

            // Get table
            fileTable = new List <VMFS1FileTableRecord>();
            int offset = 512;

            byte[] filename    = new byte[28];
            byte[] startSector = new byte[2];
            byte[] fileLength  = new byte[2];

            for (int i = 0; i < 2880; i++)
            {
                // Get the raw data
                Array.Copy(diskData, offset, filename, 0, 28);
                Array.Copy(diskData, offset + 28, startSector, 0, 2);
                Array.Copy(diskData, offset + 30, fileLength, 0, 2);

                // Convert the values
                ushort sector = BitConverter.ToUInt16(startSector, 0);
                ushort len    = BitConverter.ToUInt16(fileLength, 0);

                // Get the file data
                byte[] fileData = new byte[len];
                if (len > 0)
                {
                    Array.Copy(diskData, sector * 512, fileData, 0, len);
                    VMFS1FileTableRecord record = new VMFS1FileTableRecord(Encoding.UTF8.GetString(filename), sector, fileData);
                    fileTable.Add(record);
                }

                offset = offset + 32;
            }
        }
Exemple #2
0
 public VMFS1FileInfo(VMFS1Volume volume, VMFS1FileTableRecord record)
 {
     this.volume = volume;
     this.file   = record;
 }
Exemple #3
0
 public VMFS1FileInfo(VMFS1Volume volume, string filename)
 {
     this.volume = volume;
     file        = new VMFS1FileTableRecord(filename, 0, new byte[0]);
 }