Refactor code to improve performance and readability

This commit is contained in:
EnderIce2 2024-02-04 04:29:17 +02:00
parent 69c61037ed
commit 11221b205a
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD

View File

@ -446,8 +446,12 @@ namespace CrashHandler
Address = strtol(arg, NULL, 16);
debug("Converted %s to %#lx", arg, Address);
Memory::PageTable *BasePageTable = (Memory::PageTable *)Address;
if (Memory::Virtual().Check(BasePageTable))
if (!Memory::Virtual().Check(BasePageTable))
{
EHPrint("\eFF4400Address %#lx is not valid!\eFAFAFA\n", Address);
goto DrawBottom;
}
for (int PMLIndex = 0; PMLIndex < 512; PMLIndex++)
{
#if defined(a64)
@ -463,11 +467,13 @@ namespace CrashHandler
PML4.ExecuteDisable ? "\e00FF001\e4500F5" : "\eFF00000\e4500F5",
PML4.GetAddress() << 12);
Display->SetBuffer(SBIdx);
if (PML4.Present)
{
if (!PML4.Present)
continue;
Memory::PageDirectoryPointerTableEntryPtr *PDPTE = (Memory::PageDirectoryPointerTableEntryPtr *)((uintptr_t)PML4.GetAddress() << 12);
if (PDPTE)
{
if (!PDPTE)
continue;
for (int PDPTEIndex = 0; PDPTEIndex < 512; PDPTEIndex++)
{
EHPrint("\e888888# \eAABBCC%03d-%03d-%03d-%03d\e4500F5: P:%s RW:%s US:%s PWT:%s PCB:%s A:%s NX:%s Address:\e888888%#lx\n",
@ -481,11 +487,13 @@ namespace CrashHandler
PDPTE->Entries[PDPTEIndex].ExecuteDisable ? "\e00FF001\e4500F5" : "\eFF00000\e4500F5",
PDPTE->Entries[PDPTEIndex].GetAddress() << 12);
Display->SetBuffer(SBIdx);
if ((PDPTE->Entries[PDPTEIndex].Present))
{
if (!PDPTE->Entries[PDPTEIndex].Present)
continue;
Memory::PageDirectoryEntryPtr *PDE = (Memory::PageDirectoryEntryPtr *)((uintptr_t)PDPTE->Entries[PDPTEIndex].GetAddress() << 12);
if (PDE)
{
if (!PDE)
continue;
for (int PDEIndex = 0; PDEIndex < 512; PDEIndex++)
{
EHPrint("\e888888# \eAABBCC%03d-%03d-%03d-%03d\e4500F5: P:%s RW:%s US:%s PWT:%s PCB:%s A:%s NX:%s Address:\e888888%#lx\n",
@ -499,11 +507,13 @@ namespace CrashHandler
PDE->Entries[PDEIndex].ExecuteDisable ? "\e00FF001\e4500F5" : "\eFF00000\e4500F5",
PDE->Entries[PDEIndex].GetAddress() << 12);
Display->SetBuffer(SBIdx);
if ((PDE->Entries[PDEIndex].Present))
{
if (!PDE->Entries[PDEIndex].Present)
continue;
Memory::PageTableEntryPtr *PTE = (Memory::PageTableEntryPtr *)((uintptr_t)PDE->Entries[PDEIndex].GetAddress() << 12);
if (PTE)
{
if (!PTE)
continue;
for (int PTEIndex = 0; PTEIndex < 512; PTEIndex++)
{
EHPrint("\e888888# \eAABBCC%03d-%03d-%03d-%03d\e4500F5: P:%s RW:%s US:%s PWT:%s PCB:%s A:%s D:%s PAT:%s G:%s PK:%d NX:%s Address:\e888888%#lx\n",
@ -524,16 +534,9 @@ namespace CrashHandler
}
}
}
}
}
}
}
}
}
#endif
}
}
}
else if (strncmp(Input, "bitmap", 6) == 0)
{
Bitmap bm = KernelAllocator.GetPageBitmap();
@ -808,6 +811,7 @@ namespace CrashHandler
else if (strlen(Input) > 0)
EHPrint("Unknown command: %s", Input);
DrawBottom:
DisplayBottomOverlay();
Display->SetBuffer(SBIdx);
}