From 4d4ff5c8f534f1373a0427950f0686a4f3a73216 Mon Sep 17 00:00:00 2001 From: bushing Date: Sun, 11 Jan 2009 10:00:59 +0000 Subject: [PATCH] properly identify Wii-mode DOL files git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1848 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/Boot/Boot_DOL.cpp | 16 ++++++++++++++++ Source/Core/Core/Src/Boot/Boot_DOL.h | 1 + Source/Core/Core/Src/CoreParameter.cpp | 4 +++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/Src/Boot/Boot_DOL.cpp b/Source/Core/Core/Src/Boot/Boot_DOL.cpp index c3910912c8..c864c787c3 100644 --- a/Source/Core/Core/Src/Boot/Boot_DOL.cpp +++ b/Source/Core/Core/Src/Boot/Boot_DOL.cpp @@ -78,3 +78,19 @@ u32 CDolLoader::GetEntryPoint() { return m_dolheader.entryPoint; } + +bool CDolLoader::IsDolWii(const char* filename) +{ + // try to open file + FILE* pStream = fopen(filename, "rb"); + if (pStream) + { + fseek(pStream, 0xe0, SEEK_SET); + u32 entrypt = fgetc(pStream) << 24 | fgetc(pStream) << 16 | + fgetc(pStream) << 8 | fgetc(pStream); + + fclose(pStream); + return entrypt >= 0x80004000; + } + return 0; +} diff --git a/Source/Core/Core/Src/Boot/Boot_DOL.h b/Source/Core/Core/Src/Boot/Boot_DOL.h index cbec73186e..730d65506c 100644 --- a/Source/Core/Core/Src/Boot/Boot_DOL.h +++ b/Source/Core/Core/Src/Boot/Boot_DOL.h @@ -26,6 +26,7 @@ public: CDolLoader(const char* _szFilename); u32 GetEntryPoint(); + static bool IsDolWii(const char* filename); private: enum { diff --git a/Source/Core/Core/Src/CoreParameter.cpp b/Source/Core/Core/Src/CoreParameter.cpp index 0fb6678e18..937bc4ab72 100644 --- a/Source/Core/Core/Src/CoreParameter.cpp +++ b/Source/Core/Core/Src/CoreParameter.cpp @@ -22,6 +22,7 @@ #include "VolumeCreator.h" // DiscIO #include "Boot/Boot.h" // Core +#include "Boot/Boot_DOL.h" #include "CoreParameter.h" #include "Core.h" // for bWii @@ -114,13 +115,14 @@ bool SCoreStartupParameter::AutoSetup(EBootBios _BootBios) } else if (!strcasecmp(Extension.c_str(), ".elf")) { - bWii = CBoot::IsElfWii(m_strFilename.c_str()); + bWii = CBoot::IsElfWii(m_strFilename.c_str()); Region = USA_DIR; m_BootType = BOOT_ELF; bNTSC = true; } else if (!strcasecmp(Extension.c_str(), ".dol")) { + bWii = CDolLoader::IsDolWii(m_strFilename.c_str()); Region = USA_DIR; m_BootType = BOOT_DOL; bNTSC = true;