diff --git a/tools/cxbe/Xbe.cpp b/tools/cxbe/Xbe.cpp index daec0c027..1ff7b80e8 100644 --- a/tools/cxbe/Xbe.cpp +++ b/tools/cxbe/Xbe.cpp @@ -17,8 +17,6 @@ #include #include -#define MAX(x, y) (((x) > (y)) ? (x) : (y)) - static const char kKernelImageName[] = "xboxkrnl.exe"; static uint32 CountNonKernelImportTableEntries(class Exe *x_Exe, uint32_t *extra_bytes); @@ -410,11 +408,14 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, bool x_bRetail, const std::vec m_SectionHeader[v].dwVirtualSize = x_Exe->m_SectionHeader[v + 1].m_virtual_addr - x_Exe->m_SectionHeader[v].m_virtual_addr; - else - m_SectionHeader[v].dwVirtualSize = MAX( - RoundUp(x_Exe->m_SectionHeader[v].m_virtual_size, 4), - m_SectionHeader[v].dwSizeofRaw - ); + else { + m_SectionHeader[v].dwVirtualSize = + RoundUp(x_Exe->m_SectionHeader[v].m_virtual_size, 4); + + // force virtual size to be at least as large as the raw size + m_SectionHeader[v].dwVirtualSize = std::max(m_SectionHeader[v].dwSizeofRaw, + m_SectionHeader[v].dwVirtualSize); + } SectionCursor += RoundUp(m_SectionHeader[v].dwSizeofRaw, 0x1000);