Skip to content

Commit

Permalink
cxbe: Warn on excessively large image sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
thrimbor authored and mborgerson committed Oct 5, 2020
1 parent 53b0daf commit 6170b5e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tools/cxbe/Xbe.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// ******************************************************************
// *
// * .,-::::: .,:: .::::::::. .,:: .:
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
// * $$$ Y$$$P $$""""Y$$ Y$$$P
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
// * $$$ Y$$$P $$""""Y$$ Y$$$P
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
// *
// * Cxbx->Core->Xbe.cpp
Expand Down Expand Up @@ -538,7 +538,7 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, bool x_bRetail)
}

// for now we'll just allow any media you could want
m_Certificate.dwAllowedMedia = XBEIMAGE_MEDIA_TYPE_HARD_DISK | XBEIMAGE_MEDIA_TYPE_DVD_CD | XBEIMAGE_MEDIA_TYPE_MEDIA_BOARD
m_Certificate.dwAllowedMedia = XBEIMAGE_MEDIA_TYPE_HARD_DISK | XBEIMAGE_MEDIA_TYPE_DVD_CD | XBEIMAGE_MEDIA_TYPE_MEDIA_BOARD
| XBEIMAGE_MEDIA_TYPE_NONSECURE_HARD_DISK | XBEIMAGE_MEDIA_TYPE_NONSECURE_MODE;

// TODO: allow configuration
Expand Down Expand Up @@ -779,6 +779,13 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, bool x_bRetail)
{
m_Header.dwSizeofImage = m_SectionHeader[m_Header.dwSections-1].dwVirtualAddr + m_SectionHeader[m_Header.dwSections-1].dwVirtualSize - m_Header.dwBaseAddr;

if (m_Header.dwSizeofImage >= 64*1024*1024)
{
fprintf(stderr, "Xbe::Xbe: Image size exceeds 64MiB - this xbe will not run on retail systems\n");
} else if (m_Header.dwSizeofImage >= 32*1024*1024) {
fprintf(stderr, "Xbe::Xbe: Image size exceeds 32MiB\n");
}

// relocate to base : 0x00010000
{
printf("Xbe::Xbe: Relocating to Base 0x00010000...");
Expand Down Expand Up @@ -1161,7 +1168,7 @@ void Xbe::DumpInformation(FILE *x_file)
} else {
AsciiFilename[0] = '\0';
}

fprintf(x_file, "Entry Point : 0x%.08X (Retail: 0x%.08X, Debug: 0x%.08X)\n", m_Header.dwEntryAddr, m_Header.dwEntryAddr ^ XOR_EP_RETAIL, m_Header.dwEntryAddr ^ XOR_EP_DEBUG);
fprintf(x_file, "TLS Address : 0x%.08X\n", m_Header.dwTLSAddr);
fprintf(x_file, "(PE) Stack Commit : 0x%.08X\n", m_Header.dwPeStackCommit);
Expand Down Expand Up @@ -1319,7 +1326,7 @@ void Xbe::DumpInformation(FILE *x_file)

fprintf(x_file, "Library Name : %s\n", tmp);
fprintf(x_file, "Version : %d.%d.%d\n", m_LibraryVersion[v].wMajorVersion, m_LibraryVersion[v].wMinorVersion, m_LibraryVersion[v].wBuildVersion);

// print flags
{
fprintf(x_file, "Flags : ");
Expand Down

0 comments on commit 6170b5e

Please sign in to comment.