mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
NANDアプリバナー読み込みの処理をbanner.cに移動
NANDアプリバナー読み込み時にバナー検証処理を行うよう追加 git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@771 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
parent
325d939d0b
commit
14aa4dcb7f
@ -76,6 +76,82 @@ BOOL SYSMi_ReadCardBannerFile( u32 bannerOffset, TWLBannerFile *pBanner )
|
||||
*/
|
||||
}
|
||||
|
||||
// NANDアプリバナーリード
|
||||
BOOL SYSMi_ReadBanner_NAND( NAMTitleId titleID, TWLBannerFile *pDst )
|
||||
{
|
||||
#define PATH_LENGTH 1024
|
||||
OSTick start;
|
||||
FSFile file[1];
|
||||
BOOL bSuccess;
|
||||
char path[PATH_LENGTH];
|
||||
s32 readLen;
|
||||
s32 offset;
|
||||
|
||||
//[TODO:]サブバナーが保存されている場合、そちらを使う
|
||||
|
||||
start = OS_GetTick();
|
||||
readLen = NAM_GetTitleBootContentPathFast( path, titleID );
|
||||
OS_TPrintf( "NAM_GetTitleBootContentPath : %dus\n", OS_TicksToMicroSeconds( OS_GetTick() - start ) );
|
||||
|
||||
// ファイルパスを取得
|
||||
if(readLen != NAM_OK){
|
||||
OS_TPrintf("NAM_GetTitleBootContentPath failed %lld,%d\n", titleID, readLen );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ファイルオープン
|
||||
bSuccess = FS_OpenFileEx(file, path, FS_FILEMODE_R);
|
||||
if( ! bSuccess )
|
||||
{
|
||||
OS_TPrintf("SYSM_GetNandTitleList failed: cant open file %s\n",path);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ROMヘッダのバナーデータオフセットを読み込む
|
||||
bSuccess = FS_SeekFile(file, 0x68, FS_SEEK_SET);
|
||||
if( ! bSuccess )
|
||||
{
|
||||
OS_TPrintf("SYSM_GetNandTitleList failed: cant seek file(0)\n");
|
||||
FS_CloseFile(file);
|
||||
return FALSE;
|
||||
}
|
||||
readLen = FS_ReadFile(file, &offset, sizeof(offset));
|
||||
if( readLen != sizeof(offset) )
|
||||
{
|
||||
OS_TPrintf("SYSM_GetNandTitleList failed: cant read file\n");
|
||||
FS_CloseFile(file);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// バナーが存在する場合のみリード
|
||||
if( offset ) {
|
||||
bSuccess = FS_SeekFile(file, offset, FS_SEEK_SET);
|
||||
if( ! bSuccess )
|
||||
{
|
||||
OS_TPrintf("SYSM_GetNandTitleList failed: cant seek file(offset)\n");
|
||||
FS_CloseFile(file);
|
||||
return FALSE;
|
||||
}
|
||||
readLen = FS_ReadFile( file, pDst, (s32)sizeof(TWLBannerFile) );
|
||||
if( readLen != (s32)sizeof(TWLBannerFile) )
|
||||
{
|
||||
OS_TPrintf("SYSM_GetNandTitleList failed: cant read file2\n");
|
||||
FS_CloseFile(file);
|
||||
return FALSE;
|
||||
}
|
||||
if( !SYSMi_CheckBannerFile( pDst ) )
|
||||
{
|
||||
// 正当性チェック失敗の場合はバッファクリア
|
||||
MI_CpuClearFast( pDst, sizeof(TWLBannerFile) );
|
||||
}
|
||||
}else {
|
||||
// バナーが存在しない場合はバッファクリア
|
||||
MI_CpuClearFast( pDst, sizeof(TWLBannerFile) );
|
||||
}
|
||||
|
||||
FS_CloseFile(file);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// バナーデータの正誤チェック
|
||||
static BOOL SYSMi_CheckBannerFile( TWLBannerFile *pBanner )
|
||||
|
||||
@ -51,7 +51,6 @@ typedef struct MbAuthCode
|
||||
extern const u8 g_devPubKey[ 3 ][ 0x80 ];
|
||||
|
||||
// function's prototype-------------------------------------------------------
|
||||
static BOOL SYSMi_ReadBanner_NAND( NAMTitleId titleID, u8 *pDst );
|
||||
static s32 ReadFile( FSFile* pf, void* buffer, s32 size );
|
||||
static void SYSMi_EnableHotSW( BOOL enable );
|
||||
static void SYSMi_LoadTitleThreadFunc( TitleProperty *pBootTitle );
|
||||
@ -218,7 +217,7 @@ int SYSM_GetNandTitleList( TitleProperty *pTitleList_Nand, int listNum )
|
||||
// "Not Launch"でない かつ "Data Only"でない なら有効なタイトルとしてリストに追加
|
||||
if( ( pTitleIDList[ l ] & ( TITLE_ID_NOT_LAUNCH_FLAG_MASK | TITLE_ID_DATA_ONLY_FLAG_MASK ) ) == 0 ) {
|
||||
titleIDArray[ validNum ] = pTitleIDList[ l ];
|
||||
SYSMi_ReadBanner_NAND( pTitleIDList[ l ], (u8 *)&s_bannerBuf[ validNum ] );
|
||||
SYSMi_ReadBanner_NAND( pTitleIDList[ l ], &s_bannerBuf[ validNum ] );
|
||||
validNum++;
|
||||
}
|
||||
}
|
||||
@ -247,76 +246,6 @@ int SYSM_GetNandTitleList( TitleProperty *pTitleList_Nand, int listNum )
|
||||
return listNum;
|
||||
}
|
||||
|
||||
static BOOL SYSMi_ReadBanner_NAND( NAMTitleId titleID, u8 *pDst )
|
||||
{
|
||||
#define PATH_LENGTH 1024
|
||||
OSTick start;
|
||||
FSFile file[1];
|
||||
BOOL bSuccess;
|
||||
char path[PATH_LENGTH];
|
||||
s32 readLen;
|
||||
s32 offset;
|
||||
|
||||
start = OS_GetTick();
|
||||
readLen = NAM_GetTitleBootContentPathFast( path, titleID );
|
||||
OS_TPrintf( "NAM_GetTitleBootContentPath : %dus\n", OS_TicksToMicroSeconds( OS_GetTick() - start ) );
|
||||
|
||||
// ファイルパスを取得
|
||||
if(readLen != NAM_OK){
|
||||
OS_TPrintf("NAM_GetTitleBootContentPath failed %lld,%d\n", titleID, readLen );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ファイルオープン
|
||||
bSuccess = FS_OpenFileEx(file, path, FS_FILEMODE_R);
|
||||
if( ! bSuccess )
|
||||
{
|
||||
OS_TPrintf("SYSM_GetNandTitleList failed: cant open file %s\n",path);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ROMヘッダのバナーデータオフセットを読み込む
|
||||
bSuccess = FS_SeekFile(file, 0x68, FS_SEEK_SET);
|
||||
if( ! bSuccess )
|
||||
{
|
||||
OS_TPrintf("SYSM_GetNandTitleList failed: cant seek file(0)\n");
|
||||
FS_CloseFile(file);
|
||||
return FALSE;
|
||||
}
|
||||
readLen = FS_ReadFile(file, &offset, sizeof(offset));
|
||||
if( readLen != sizeof(offset) )
|
||||
{
|
||||
OS_TPrintf("SYSM_GetNandTitleList failed: cant read file\n");
|
||||
FS_CloseFile(file);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// バナーが存在する場合のみリード
|
||||
if( offset ) {
|
||||
bSuccess = FS_SeekFile(file, offset, FS_SEEK_SET);
|
||||
if( ! bSuccess )
|
||||
{
|
||||
OS_TPrintf("SYSM_GetNandTitleList failed: cant seek file(offset)\n");
|
||||
FS_CloseFile(file);
|
||||
return FALSE;
|
||||
}
|
||||
readLen = ReadFile( file, pDst, (s32)sizeof(TWLBannerFile) );
|
||||
if( readLen != (s32)sizeof(TWLBannerFile) )
|
||||
{
|
||||
OS_TPrintf("SYSM_GetNandTitleList failed: cant read file2\n");
|
||||
FS_CloseFile(file);
|
||||
return FALSE;
|
||||
}
|
||||
}else {
|
||||
// バナーが存在しない場合はバッファクリア
|
||||
MI_CpuClearFast( pDst, sizeof(TWLBannerFile) );
|
||||
}
|
||||
|
||||
FS_CloseFile(file);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
// 指定ファイルリード
|
||||
static s32 ReadFile(FSFile* pf, void* buffer, s32 size)
|
||||
{
|
||||
|
||||
@ -63,6 +63,9 @@ void SYSMi_CheckRTC( void );
|
||||
// カードバナーリード(※NTR-IPL2仕様)
|
||||
BOOL SYSMi_ReadCardBannerFile( u32 bannerOffset, TWLBannerFile *pBanner );
|
||||
|
||||
// NANDアプリバナーリード
|
||||
BOOL SYSMi_ReadBanner_NAND( NAMTitleId titleID, TWLBannerFile *pDst );
|
||||
|
||||
//-------------------------------------------------------
|
||||
// 活線挿抜
|
||||
//-------------------------------------------------------
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user