DirectoryBlob: Restructure SetApploader

This commit is contained in:
JosJuice
2017-06-10 10:27:46 +02:00
parent 8747b1b6ab
commit 1258d18f21

View File

@ -329,37 +329,44 @@ void DirectoryBlobReader::SetWiiRegionData()
bool DirectoryBlobReader::SetApploader(const std::string& apploader) bool DirectoryBlobReader::SetApploader(const std::string& apploader)
{ {
if (!apploader.empty()) bool success = false;
if (apploader.empty())
{
m_apploader.resize(0x20);
// Make sure BS2 HLE doesn't try to run the apploader
Write32(static_cast<u32>(-1), 0x10, &m_apploader);
}
else
{ {
std::string data; std::string data;
if (!File::ReadFileToString(apploader, data)) if (!File::ReadFileToString(apploader, data))
{ {
PanicAlertT("Apploader unable to load from file"); PanicAlertT("Apploader unable to load from file");
return false;
} }
size_t apploader_size = 0x20 + Common::swap32(*(u32*)&data.data()[0x14]) + else
{
const size_t apploader_size = 0x20 + Common::swap32(*(u32*)&data.data()[0x14]) +
Common::swap32(*(u32*)&data.data()[0x18]); Common::swap32(*(u32*)&data.data()[0x18]);
if (apploader_size != data.size()) if (apploader_size != data.size())
{ {
PanicAlertT("Apploader is the wrong size...is it really an apploader?"); PanicAlertT("Apploader is the wrong size...is it really an apploader?");
return false;
} }
else
{
m_apploader.resize(apploader_size); m_apploader.resize(apploader_size);
std::copy(data.begin(), data.end(), m_apploader.begin()); std::copy(data.begin(), data.end(), m_apploader.begin());
// 32byte aligned (plus 0x20 padding) // 32byte aligned (plus 0x20 padding)
m_dol_address = Common::AlignUp(APPLOADER_ADDRESS + m_apploader.size() + 0x20, 0x20ull); m_dol_address = Common::AlignUp(APPLOADER_ADDRESS + m_apploader.size() + 0x20, 0x20ull);
return true; success = true;
} }
else
{
m_apploader.resize(0x20);
// Make sure BS2 HLE doesn't try to run the apploader
Write32(static_cast<u32>(-1), 0x10, &m_apploader);
return false;
} }
} }
return success;
}
void DirectoryBlobReader::SetDOL() void DirectoryBlobReader::SetDOL()
{ {
const DiscContent& dol = const DiscContent& dol =