elfviewer : don't display section header if they don't exist (seems like commercial games doesn't have section headers)

This commit is contained in:
georgemoralis 2023-05-14 17:43:45 +03:00
parent 98068809aa
commit 08f8da2fea
1 changed files with 7 additions and 4 deletions

View File

@ -47,6 +47,7 @@ void ElfViewer::display(bool enabled)
} }
if (ImGui::TreeNode("Elf")) if (ImGui::TreeNode("Elf"))
{ {
const auto* elf_header = elf->GetElfHeader();
if (ImGui::TreeNodeEx("Elf Header", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen, "Elf Header")) if (ImGui::TreeNodeEx("Elf Header", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen, "Elf Header"))
{ {
if (ImGui::IsItemClicked()) if (ImGui::IsItemClicked())
@ -54,7 +55,6 @@ void ElfViewer::display(bool enabled)
} }
if (ImGui::TreeNode("Elf Program Headers")) if (ImGui::TreeNode("Elf Program Headers"))
{ {
const auto* elf_header = elf->GetElfHeader();
for (u16 i = 0; i < elf_header->e_phnum; i++) for (u16 i = 0; i < elf_header->e_phnum; i++)
{ {
const auto* pheader = elf->GetProgramHeader(); const auto* pheader = elf->GetProgramHeader();
@ -67,9 +67,12 @@ void ElfViewer::display(bool enabled)
} }
ImGui::TreePop(); ImGui::TreePop();
} }
if (ImGui::TreeNode("Elf Section Headers")) if (elf_header->e_shnum != 0)
{ {
ImGui::TreePop(); if (ImGui::TreeNode("Elf Section Headers"))
{
ImGui::TreePop();
}
} }
ImGui::TreePop(); ImGui::TreePop();
} }