public static KernelUpdateLogPage ReadFromDisk(Disk disk, PrivateHeader privateHeader, TOCBlock tocBlock, int kLogIndex)
        {
            ulong sectorIndex = privateHeader.PrivateRegionStartLBA + tocBlock.LogStart + (uint)kLogIndex;

            byte[] sector = disk.ReadSector((long)sectorIndex);
            KernelUpdateLogPage result = new KernelUpdateLogPage(sector);

            return(result);
        }
        public static KernelUpdateLog ReadFromDisk(Disk disk, PrivateHeader privateHeader, TOCBlock tocBlock)
        {
            List <KernelUpdateLogPage> pages     = new List <KernelUpdateLogPage>();
            KernelUpdateLogPage        firstPage = KernelUpdateLogPage.ReadFromDisk(disk, privateHeader, tocBlock, 0);

            pages.Add(firstPage);
            for (int index = 2; index < firstPage.NumberOfPages; index++)
            {
                KernelUpdateLogPage page = KernelUpdateLogPage.ReadFromDisk(disk, privateHeader, tocBlock, index);
                pages.Add(page);
            }
            return(new KernelUpdateLog(pages));
        }
Esempio n. 3
0
        public static KernelUpdateLogPage ReadFromDisk(Disk disk, PrivateHeader privateHeader, TOCBlock tocBlock, int pageIndex)
        {
            ulong sectorIndex = privateHeader.PrivateRegionStartLBA + tocBlock.LogStart + (uint)(pageIndex * Length / disk.BytesPerSector);
            int   pageOffset  = (pageIndex * Length) % disk.BytesPerSector;

            byte[] sector = disk.ReadSector((long)sectorIndex);
            if (pageOffset > 0)
            {
                sector = ByteReader.ReadBytes(sector, pageOffset, Length);
            }
            KernelUpdateLogPage result = new KernelUpdateLogPage(sector);

            return(result);
        }
 public void SetLastEntry(Disk disk, PrivateHeader privateHeader, TOCBlock tocBlock, ulong committedTransactionID, ulong pendingTransactionID)
 {
     if (m_pages.Count > 0)
     {
         m_pages[0].SetLastEntry(committedTransactionID, pendingTransactionID);
         // Windows kernel stores the last committedTransactionID / pendingTransactionID in memory,
         // and it will overwrite the values we write as soon as dmadmin is started,
         // However, it doesn't seem to cause any issues
         KernelUpdateLogPage.WriteToDisk(disk, privateHeader, tocBlock, m_pages[0]);
     }
     else
     {
         throw new InvalidOperationException("KLog records have not been previously read from disk");
     }
 }
Esempio n. 5
0
        public static void WriteToDisk(Disk disk, PrivateHeader privateHeader, TOCBlock tocBlock, KernelUpdateLogPage page)
        {
            ulong sectorIndex = privateHeader.PrivateRegionStartLBA + tocBlock.LogStart + (uint)(page.PageIndex * Length / disk.BytesPerSector);
            int   pageOffset  = ((int)page.PageIndex * Length) % disk.BytesPerSector;

            byte[] pageBytes = page.GetBytes();
            if (disk.BytesPerSector > Length)
            {
                byte[] sectorBytes = disk.ReadSector((long)sectorIndex);
                ByteWriter.WriteBytes(sectorBytes, pageOffset, pageBytes);
                disk.WriteSectors((long)sectorIndex, sectorBytes);
            }
            else
            {
                disk.WriteSectors((long)sectorIndex, pageBytes);
            }
        }
        public static void WriteToDisk(Disk disk, PrivateHeader privateHeader, TOCBlock tocBlock, KernelUpdateLogPage record)
        {
            ulong sectorIndex = privateHeader.PrivateRegionStartLBA + tocBlock.LogStart + record.PageIndex;

            byte[] sector = record.GetBytes();
            disk.WriteSectors((long)sectorIndex, sector);
        }