private static void SetInitialWriteProtection() { if (!KConfig.UseKernelMemoryProtection) { return; } //KernelMessage.WriteLine("Unset CR0.WP"); PageTable.KernelTable.DisableKernelWriteProtection(); PageTable.KernelTable.SetKernelWriteProtectionForAllInitialPages(); PageTable.KernelTable.SetWritable(BootInfoMemoryType.GDT); PageTable.KernelTable.SetWritable(BootInfoMemoryType.PageTable); PageTable.KernelTable.SetWritable(BootInfoMemoryType.InitialStack); //PageTable.KernelTable.InitialKernelProtect_MakeWritable_ByMapType(BootInfoMemoryType.KernelElfVirt); PageTable.KernelTable.SetWritable(BootInfoMemoryType.KernelBssSegment); PageTable.KernelTable.SetWritable(BootInfoMemoryType.KernelDataSegment); //PageTable.KernelTable.InitialKernelProtect_MakeWritable_ByMapType(BootInfoMemoryType.KernelROdataSegment); PageTableExtensions.SetWritable(PageTable.KernelTable, Address.GCInitialMemory, Address.GCInitialMemorySize); //KernelMessage.WriteLine("Reload CR3 to {0:X8}", PageTable.AddrPageDirectory); PageTable.KernelTable.Flush(); //KernelMessage.WriteLine("Set CR0.WP"); PageTable.KernelTable.EnableKernelWriteProtection(); }
private static void SetInitialWriteProtection() { if (!KConfig.UseKernelMemoryProtection) { return; } //KernelMessage.WriteLine("Unset CR0.WP"); PageTable.KernelTable.DisableKernelWriteProtection(); PageTable.KernelTable.SetKernelWriteProtectionForAllInitialPages(); PageTable.KernelTable.SetWritable(BootInfoMemoryType.GDT); PageTable.KernelTable.SetWritable(BootInfoMemoryType.PageTable); PageTable.KernelTable.SetWritable(BootInfoMemoryType.InitialStack); PageTable.KernelTable.SetWritable(BootInfoMemoryType.KernelBssSegment); PageTable.KernelTable.SetWritable(BootInfoMemoryType.KernelDataSegment); PageTableExtensions.SetWritable(PageTable.KernelTable, Address.GCInitialMemory, Address.GCInitialMemorySize); PageTable.KernelTable.Flush(); PageTable.KernelTable.EnableKernelWriteProtection(); }