2012-11-15 00:39:56 +01:00
|
|
|
#include "stdafx.h"
|
2014-06-17 17:44:03 +02:00
|
|
|
#include "Utilities/Log.h"
|
2012-11-15 00:39:56 +01:00
|
|
|
#include "SELF.h"
|
2013-06-30 10:46:29 +02:00
|
|
|
#include "ELF64.h"
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2013-06-30 10:46:29 +02:00
|
|
|
SELFLoader::SELFLoader(vfsStream& f)
|
2012-11-15 00:39:56 +01:00
|
|
|
: self_f(f)
|
|
|
|
|
, LoaderBase()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SELFLoader::LoadInfo()
|
|
|
|
|
{
|
|
|
|
|
if(!self_f.IsOpened()) return false;
|
|
|
|
|
self_f.Seek(0);
|
|
|
|
|
sce_hdr.Load(self_f);
|
|
|
|
|
self_hdr.Load(self_f);
|
|
|
|
|
if(!sce_hdr.CheckMagic()) return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-30 10:46:29 +02:00
|
|
|
bool SELFLoader::LoadData(u64 offset)
|
2012-11-15 00:39:56 +01:00
|
|
|
{
|
|
|
|
|
if(!self_f.IsOpened()) return false;
|
|
|
|
|
|
|
|
|
|
sce_hdr.Show();
|
|
|
|
|
self_hdr.Show();
|
2013-06-30 10:46:29 +02:00
|
|
|
|
|
|
|
|
ELF64Loader l(self_f);
|
|
|
|
|
if( !l.LoadEhdrInfo(self_hdr.se_elfoff) ||
|
|
|
|
|
!l.LoadPhdrInfo(self_hdr.se_phdroff) ||
|
|
|
|
|
!l.LoadShdrInfo(self_hdr.se_shdroff) ||
|
2013-07-08 15:24:46 +02:00
|
|
|
!l.LoadData(self_hdr.se_appinfooff) )
|
2013-06-30 10:46:29 +02:00
|
|
|
{
|
2014-06-17 17:44:03 +02:00
|
|
|
LOG_ERROR(LOADER, "Broken SELF file.");
|
2013-06-30 10:46:29 +02:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-08 15:24:46 +02:00
|
|
|
machine = l.GetMachine();
|
|
|
|
|
entry = l.GetEntry();
|
|
|
|
|
|
2013-06-30 10:46:29 +02:00
|
|
|
return true;
|
|
|
|
|
|
2014-06-17 17:44:03 +02:00
|
|
|
LOG_ERROR(LOADER, "Boot SELF not supported yet!");
|
2012-11-15 00:39:56 +01:00
|
|
|
return false;
|
|
|
|
|
}
|