NandInitializer では内部的に HWInfoWriter とまったく同様のコードを実行していましたが、

両方をメンテナンスすることが手間であるため、HWInfoWriterのコードの一部をライブラリ化し、
一元管理できるようにしました。ただ、Makefileの記述も合わせる必要があることに注意が必要です。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@652 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
kamikawa 2008-02-14 03:06:18 +00:00
parent 17a021d92e
commit 4d072fd20a
9 changed files with 517 additions and 612 deletions

View File

@ -36,7 +36,7 @@ ROM_SPEC = main.rsf
MISC_DIR = ../../misc
SRCS = main.c HWInfoWriter.c \
SRCS = main.c HWInfoWriter.c hwi.c \
$(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c
LINCLUDES = $(MISC_DIR)/include \

View File

@ -21,6 +21,7 @@
#include "TWLSettings_api.h"
#include "misc.h"
#include "HWInfoWriter.h"
#include "hwi.h"
// define data------------------------------------------
#define WRITER_ELEMENT_NUM 7
@ -28,22 +29,10 @@
#define MSG_Y 19
// extern data------------------------------------------
const LCFGTWLHWNormalInfo *LCFG_THW_GetDefaultNormalInfo( void );
const LCFGTWLHWSecureInfo *LCFG_THW_GetDefaultSecureInfo( void );
const LCFGTWLHWNormalInfo *LCFG_THW_GetNormalInfo( void );
const LCFGTWLHWSecureInfo *LCFG_THW_GetSecureInfo( void );
// function's prototype declaration---------------------
static void ReadTWLSettings( void );
static void ModifyLanguage( u8 region );
static void ReadPrivateKey( void );
static void ReadHWInfoFile( void );
static void WriteHWInfoFile( u8 region );
static BOOL WriteHWNormalInfoFile( void );
static BOOL WriteHWSecureInfoFile( u8 region );
static void DeleteHWInfoFile( void );
static void VerifyHWInfo( void );
static BOOL VerifyData( const u8 *pTgt, const u8 *pOrg, u32 len );
static void DispMessage( int x, int y, u16 color, const u16 *pMsg );
// global variable -------------------------------------
@ -89,26 +78,6 @@ static const MenuParam s_writerParam = {
(const u16 **)&s_pStrWriter,
};
static const u32 s_langBitmapList[ LCFG_TWL_REGION_MAX ] = {
LCFG_TWL_LANG_BITMAP_JAPAN,
LCFG_TWL_LANG_BITMAP_AMERICA,
LCFG_TWL_LANG_BITMAP_EUROPE,
LCFG_TWL_LANG_BITMAP_AUSTRALIA,
LCFG_TWL_LANG_BITMAP_CHINA,
LCFG_TWL_LANG_BITMAP_KOREA,
};
static char *strLanguage[] = {
(char *)"LANG_JAPANESE",
(char *)"LANG_ENGLISH",
(char *)"LANG_FRENCH",
(char *)"LANG_GERMAN",
(char *)"LANG_ITALIAN",
(char *)"LANG_SPANISH",
(char *)"LANG_CHINESE",
(char *)"LANG_KOREAN",
};
static const char *strRegion[] = {
"JAPAN",
"AMERICA",
@ -118,14 +87,6 @@ static const char *strRegion[] = {
"KOREA",
};
static const char *strLauncherGameCode[] = {
"LNCJ",
"LNCE",
"LNCP",
"LNCO",
"LNCC",
"LNCK",
};
//======================================================
// HW情報ライター
@ -144,12 +105,12 @@ void HWInfoWriterInit( void )
PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"HW Info Writer");
GetAndDrawRTCData( &g_rtcDraw, TRUE );
ACSign_SetAllocFunc( Alloc, Free );
ReadTWLSettings();
ReadPrivateKey();
ReadHWInfoFile();
// VerifyHWInfo();
if (HWI_Init( Alloc, Free ) == HWI_INIT_SUCCESS_NO_SIGNATRUE_MODE)
{
PutStringUTF16( 14 * 8, 0 * 8, TXT_COLOR_RED, (const u16 *)L"[No Signature MODE]" );
}
OS_TPrintf( "region = %d\n", LCFG_THW_GetRegion() );
PrintfSJISSub( 2 * 8, 16 * 8, TXT_COLOR_BLACK, "Region = %s", strRegion[ LCFG_THW_GetRegion() ] );
PrintfSJISSub( 2 * 8, 18 * 8, TXT_COLOR_BLACK, "SerialNo = %s", LCFG_THW_GetSerialNoPtr() );
@ -203,116 +164,6 @@ void HWInfoWriterMain( void )
}
// TWL設定データのリード
static void ReadTWLSettings( void )
{
s_isReadTSD = LCFGi_TSD_ReadSettings();
if( s_isReadTSD ) {
OS_TPrintf( "TSD read succeeded.\n" );
}else {
OS_TPrintf( "TSD read failed.\n" );
}
}
// 言語コードをリージョン値に合わせて修正する。
static void ModifyLanguage( u8 region )
{
u32 langBitmap = s_langBitmapList[ region ];
u8 nowLanguage = LCFG_TSD_GetLanguage();
// TSDが読み込めていないなら、何もせずリターン
if( !s_isReadTSD ) {
return;
}
if( langBitmap & ( 0x0001 << nowLanguage ) ) {
OS_TPrintf( "Language no change.\n" );
}else {
int i;
for( i = 0; i < LCFG_TWL_LANG_CODE_MAX; i++ ) {
if( langBitmap & ( 0x0001 << i ) ) {
break;
}
}
LCFG_TSD_SetLanguage( (LCFGTWLLangCode)i );
LCFG_TSD_SetFlagCountry( FALSE ); // ※ついでに国コードもクリアしておく。
LCFG_TSD_SetCountry( LCFG_TWL_COUNTRY_UNDEFINED );
LCFGi_TSD_WriteSettings();
OS_TPrintf( "Language Change \"%s\" -> \"%s\"\n",
strLanguage[ nowLanguage ], strLanguage[ LCFG_TSD_GetLanguage() ] );
}
}
// 秘密鍵のリード
static void ReadPrivateKey( void )
{
BOOL result = FALSE;
u32 keyLength;
FSFile file;
OSTick start = OS_GetTick();
FS_InitFile( &file );
if( !FS_OpenFileEx( &file, "rom:key/private_HWInfo.der", FS_FILEMODE_R ) ) {
OS_TPrintf( "PrivateKey read failed.\n" );
}else {
keyLength = FS_GetFileLength( &file );
if( keyLength > 0 ) {
s_pPrivKeyBuffer = Alloc( keyLength );
if( FS_ReadFile( &file, s_pPrivKeyBuffer, (s32)keyLength ) == keyLength ) {
OS_TPrintf( "PrivateKey read succeeded.\n" );
result = TRUE;
}else {
OS_TPrintf( "PrivateKey read failed.\n" );
}
}
FS_CloseFile( &file );
}
if( !result && s_pPrivKeyBuffer ) {
Free( s_pPrivKeyBuffer );
s_pPrivKeyBuffer = NULL;
}
OS_TPrintf( "PrivKey read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
#ifdef USE_PRODUCT_KEY
// 製品用秘密鍵が有効なら、署名ありのアクセス
s_pReadSecureInfoFunc = LCFGi_THW_ReadSecureInfo;
#else
// そうでないなら、署名なしのアクセス
s_pReadSecureInfoFunc = LCFGi_THW_ReadSecureInfo_NoCheck;
PutStringUTF16( 14 * 8, 0 * 8, TXT_COLOR_RED, (const u16 *)L"[No Signature MODE]" );
#endif
}
// HW情報全体のリード
static void ReadHWInfoFile( void )
{
LCFGReadResult retval;
OSTick start = OS_GetTick();
retval = LCFGi_THW_ReadNormalInfo();
if( retval == LCFG_TSF_READ_RESULT_SUCCEEDED ) {
OS_TPrintf( "HW Normal Info read succeeded.\n" );
}else {
OS_TPrintf( "HW Normal Info read failed.\n" );
}
OS_TPrintf( "HW Normal Info read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
start = OS_GetTick();
retval = s_pReadSecureInfoFunc();
if( retval == LCFG_TSF_READ_RESULT_SUCCEEDED ) {
OS_TPrintf( "HW Secure Info read succeeded.\n" );
}else {
OS_TPrintf( "HW Secure Info read failed.\n" );
}
OS_TPrintf( "HW Secure Info read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
}
// HW情報全体のライト
static void WriteHWInfoFile( u8 region )
{
@ -324,7 +175,7 @@ static void WriteHWInfoFile( u8 region )
// ノーマルファイルのライト
(void)PutStringUTF16( MSG_X * 8, MSG_Y * 8, TXT_COLOR_BLACK, pMsgNormalWriting );
if( WriteHWNormalInfoFile() ) {
if( HWI_WriteHWNormalInfoFile() ) {
(void)PutStringUTF16( ( MSG_X + 18 ) * 8, MSG_Y * 8, TXT_COLOR_BLUE, pMsgSucceeded );
}else {
(void)PutStringUTF16( ( MSG_X + 18 ) * 8, MSG_Y * 8, TXT_COLOR_RED, pMsgFailed );
@ -333,13 +184,13 @@ static void WriteHWInfoFile( u8 region )
// セキュアファイルのライト
(void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLACK, pMsgSecureWriting );
if( WriteHWSecureInfoFile( region ) ) {
if( HWI_WriteHWSecureInfoFile( region ) ) {
(void)PutStringUTF16( ( MSG_X + 18 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded );
}else {
(void)PutStringUTF16( ( MSG_X + 18 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_RED, pMsgFailed );
}
ModifyLanguage( region );
HWI_ModifyLanguage( region );
// メッセージを一定時間表示して消去
DispMessage( 0, 0, TXT_COLOR_NULL, NULL );
@ -351,90 +202,6 @@ static void WriteHWInfoFile( u8 region )
s_region_old = LCFG_THW_GetRegion();
}
// HWーマルInfoファイルのライト
static BOOL WriteHWNormalInfoFile( void )
{
BOOL isWrite = TRUE;
LCFGReadResult result;
result = LCFGi_THW_ReadNormalInfo();
if( result != LCFG_TSF_READ_RESULT_SUCCEEDED ) {
if( !LCFGi_THW_RecoveryNormalInfo( result ) ) {
OS_TPrintf( "HW Normal Info Recovery failed.\n" );
isWrite = FALSE;
}
}
if( isWrite &&
!LCFGi_THW_WriteNormalInfo() ) {
OS_TPrintf( "HW Normal Info Write failed.\n" );
}
return isWrite;
}
// HWセキュアInfoファイルのライト
static BOOL WriteHWSecureInfoFile( u8 region )
{
BOOL isWrite = TRUE;
LCFGReadResult result;
// ファイルのリード
result = s_pReadSecureInfoFunc();
// リードに失敗したらリカバリ
if( result != LCFG_TSF_READ_RESULT_SUCCEEDED ) {
if( !LCFGi_THW_RecoverySecureInfo( result ) ) {
OS_TPrintf( "HW Secure Info Recovery failed.\n" );
isWrite = FALSE;
}
}
// リージョンのセット
LCFG_THW_SetRegion( region );
// 対応言語ビットマップのセット
LCFG_THW_SetValidLanguageBitmap( s_langBitmapList[ region ] );
// [TODO:]量産工程でないとシリアルNo.は用意できないので、ここではMACアドレスをもとに適当な値をセットする。
// シリアルNo.のセット
{
u8 buffer[ 12 ] = "SERIAL"; // 適当な文字列をMACアドレスと結合してSHA1を取り、仮SerialNoとする。
u8 serialNo[ SVC_SHA1_DIGEST_SIZE ];
int i;
int len = ( LCFG_THW_GetRegion() == LCFG_TWL_REGION_AMERICA ) ?
LCFG_TWL_HWINFO_SERIALNO_LEN_AMERICA : LCFG_TWL_HWINFO_SERIALNO_LEN_OTHERS;
OS_GetMacAddress( buffer + 6 );
SVC_CalcSHA1( serialNo, buffer, sizeof(buffer) );
for( i = 3; i < SVC_SHA1_DIGEST_SIZE; i++ ) {
serialNo[ i ] = (u8)( ( serialNo[ i ] % 10 ) + 0x30 );
}
MI_CpuCopy8( "SRN", serialNo, 3 );
MI_CpuClear8( &serialNo[ len ], sizeof(serialNo) - len );
OS_TPrintf( "serialNo : %s\n", serialNo );
LCFG_THW_SetSerialNo( serialNo );
}
// ランチャーTitleID_Loのセット
{
int i;
u8 titleID_Lo[4];
for( i = 0; i < 4; i++ ) titleID_Lo[ i ] = (u8)strLauncherGameCode[ region ][ 4 - i - 1 ];
LCFG_THW_SetLauncherTitleID_Lo( (const u8 *)titleID_Lo );
}
// ライト
if( isWrite &&
!LCFGi_THW_WriteSecureInfo( s_pPrivKeyBuffer ) ) {
isWrite = FALSE;
OS_TPrintf( "HW Secure Info Write failed.\n" );
}
return isWrite;
}
// HWInfoファイルの削除
static void DeleteHWInfoFile( void )
{
@ -445,21 +212,17 @@ static void DeleteHWInfoFile( void )
// ノーマルファイル
(void)PutStringUTF16( MSG_X * 8, MSG_Y * 8, TXT_COLOR_BLACK, pMsgNormalDeleting );
if( FS_DeleteFile( (char *)LCFG_TWL_HWINFO_NORMAL_PATH ) ) {
OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH );
if( HWI_DeleteHWNormalInfoFile() ) {
(void)PutStringUTF16( ( MSG_X + 19 ) * 8, MSG_Y * 8, TXT_COLOR_BLUE, pMsgSucceeded );
}else {
OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH );
(void)PutStringUTF16( ( MSG_X + 19 ) * 8, MSG_Y * 8, TXT_COLOR_RED, pMsgFailed );
}
// セキュアファイル
(void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLACK, pMsgSecureDeleting );
if( FS_DeleteFile( (char *)LCFG_TWL_HWINFO_SECURE_PATH ) ) {
OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH );
if( HWI_DeleteHWSecureInfoFile() ) {
(void)PutStringUTF16( ( MSG_X + 19 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded );
}else {
OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH );
(void)PutStringUTF16( ( MSG_X + 19 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_RED, pMsgFailed );
}
DispMessage( 0, 0, TXT_COLOR_NULL, NULL );
@ -467,36 +230,6 @@ static void DeleteHWInfoFile( void )
MSG_X * 8 , MSG_Y * 8, ( 32 - MSG_X ) * 8, ( MSG_Y + 4 ) * 8 );
}
// HWInfoファイルのベリファイ
static void VerifyHWInfo( void )
{
if( VerifyData( (const u8 *)LCFG_THW_GetNormalInfo(), (const u8 *)LCFG_THW_GetDefaultNormalInfo(), sizeof(LCFGTWLHWNormalInfo) ) ) {
OS_TPrintf( "HW normal Info verify succeeded.\n" );
}else {
OS_TPrintf( "HW normal Info verify failed.\n" );
}
if( VerifyData( (const u8 *)LCFG_THW_GetSecureInfo(), (const u8 *)LCFG_THW_GetDefaultSecureInfo(), sizeof(LCFGTWLHWSecureInfo) ) ) {
OS_TPrintf( "HW secure Info verify succeeded.\n" );
}else {
OS_TPrintf( "HW secure Info verify failed.\n" );
}
}
// メモリ上のデータベリファイ
static BOOL VerifyData( const u8 *pTgt, const u8 *pOrg, u32 len )
{
while( len-- ) {
if( *pTgt++ != *pOrg++ ) {
return FALSE;
}
}
return TRUE;
}
// メッセージ表示
static void DispMessage( int x, int y, u16 color, const u16 *pMsg )
{

View File

@ -15,8 +15,8 @@
$Author$
*---------------------------------------------------------------------------*/
#ifndef __DS_CHAT_H__
#define __DS_CHAT_H__
#ifndef __HW_INFO_WRITER__
#define __HW_INFO_WRITER__
#ifdef __cplusplus
extern "C" {
@ -34,4 +34,4 @@ void HWInfoWriterMain( void );
}
#endif
#endif // __DS_CHAT_H__
#endif // __HW_INFO_WRITER__

View File

@ -0,0 +1,399 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File: HWInfoWriterLib.c
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <sysmenu.h>
#include "TWLHWInfo_api.h"
#include "TWLSettings_api.h"
#include "hwi.h"
// define data------------------------------------------
// extern data------------------------------------------
const LCFGTWLHWNormalInfo *LCFG_THW_GetDefaultNormalInfo( void );
const LCFGTWLHWSecureInfo *LCFG_THW_GetDefaultSecureInfo( void );
const LCFGTWLHWNormalInfo *LCFG_THW_GetNormalInfo( void );
const LCFGTWLHWSecureInfo *LCFG_THW_GetSecureInfo( void );
// function's prototype declaration---------------------
static void ReadTWLSettings( void );
static HwiInitResult ReadPrivateKey( void );
static void ReadHWInfoFile( void );
static void VerifyHWInfo( void );
static BOOL VerifyData( const u8 *pTgt, const u8 *pOrg, u32 len );
// global variable -------------------------------------
// static variable -------------------------------------
static u8 *s_pPrivKeyBuffer = NULL;
static LCFGReadResult (*s_pReadSecureInfoFunc)( void );
static BOOL s_isReadTSD;
static void *(*spAlloc)( u32 length );
static void (*spFree)( void *ptr );
// const data -----------------------------------------
static const u32 s_langBitmapList[ LCFG_TWL_REGION_MAX ] = {
LCFG_TWL_LANG_BITMAP_JAPAN,
LCFG_TWL_LANG_BITMAP_AMERICA,
LCFG_TWL_LANG_BITMAP_EUROPE,
LCFG_TWL_LANG_BITMAP_AUSTRALIA,
LCFG_TWL_LANG_BITMAP_CHINA,
LCFG_TWL_LANG_BITMAP_KOREA,
};
static char *strLanguage[] = {
(char *)"LANG_JAPANESE",
(char *)"LANG_ENGLISH",
(char *)"LANG_FRENCH",
(char *)"LANG_GERMAN",
(char *)"LANG_ITALIAN",
(char *)"LANG_SPANISH",
(char *)"LANG_CHINESE",
(char *)"LANG_KOREAN",
};
static const char *strLauncherGameCode[] = {
"LNCJ",
"LNCE",
"LNCP",
"LNCO",
"LNCC",
"LNCK",
};
//======================================================
// HW情報ライター
//======================================================
/*---------------------------------------------------------------------------*
Name: HWI_Init
Description: HW情報ライターの初期化
Arguments:
Returns: None.
*---------------------------------------------------------------------------*/
HwiInitResult HWI_Init( void *(*pAlloc)( u32 ), void (*pFree)( void * ) )
{
HwiInitResult result;
spAlloc = pAlloc;
spFree = pFree;
ACSign_SetAllocFunc( pAlloc, pFree );
ReadTWLSettings();
result = ReadPrivateKey();
ReadHWInfoFile();
// VerifyHWInfo();
return result;
}
// TWL設定データのリード
static void ReadTWLSettings( void )
{
s_isReadTSD = LCFGi_TSD_ReadSettings();
if( s_isReadTSD ) {
OS_TPrintf( "TSD read succeeded.\n" );
}else {
OS_TPrintf( "TSD read failed.\n" );
}
}
// 秘密鍵のリード
HwiInitResult ReadPrivateKey( void )
{
BOOL result = FALSE;
u32 keyLength;
FSFile file;
OSTick start = OS_GetTick();
FS_InitFile( &file );
if( !FS_OpenFileEx( &file, "rom:key/private_HWInfo.der", FS_FILEMODE_R ) )
{
OS_TPrintf( "PrivateKey read failed.\n" );
}
else
{
keyLength = FS_GetFileLength( &file );
if( keyLength > 0 ) {
s_pPrivKeyBuffer = spAlloc( keyLength );
if( FS_ReadFile( &file, s_pPrivKeyBuffer, (s32)keyLength ) == keyLength ) {
OS_TPrintf( "PrivateKey read succeeded.\n" );
result = TRUE;
}else {
OS_TPrintf( "PrivateKey read failed.\n" );
}
}
FS_CloseFile( &file );
}
if( !result && s_pPrivKeyBuffer ) {
spFree( s_pPrivKeyBuffer );
s_pPrivKeyBuffer = NULL;
}
OS_TPrintf( "PrivKey read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
#ifdef USE_PRODUCT_KEY
// 製品用秘密鍵が有効なら、署名ありのアクセス
s_pReadSecureInfoFunc = LCFGi_THW_ReadSecureInfo;
if (result) { return HWI_INIT_SUCCESS_SIGNATURE_MODE; }
else { return HWI_INIT_FAILURE; }
#else
// そうでないなら、署名なしのアクセス
s_pReadSecureInfoFunc = LCFGi_THW_ReadSecureInfo_NoCheck;
if (result) { return HWI_INIT_SUCCESS_NO_SIGNATRUE_MODE; }
else { return HWI_INIT_FAILURE; }
#endif
}
// HW情報全体のリード
static void ReadHWInfoFile( void )
{
LCFGReadResult retval;
OSTick start = OS_GetTick();
retval = LCFGi_THW_ReadNormalInfo();
if( retval == LCFG_TSF_READ_RESULT_SUCCEEDED ) {
OS_TPrintf( "HW Normal Info read succeeded.\n" );
}else {
OS_TPrintf( "HW Normal Info read failed.\n" );
}
OS_TPrintf( "HW Normal Info read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
start = OS_GetTick();
retval = s_pReadSecureInfoFunc();
if( retval == LCFG_TSF_READ_RESULT_SUCCEEDED ) {
OS_TPrintf( "HW Secure Info read succeeded.\n" );
}else {
OS_TPrintf( "HW Secure Info read failed.\n" );
}
OS_TPrintf( "HW Secure Info read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
}
// HWInfoファイルのベリファイ
static void VerifyHWInfo( void )
{
if( VerifyData( (const u8 *)LCFG_THW_GetNormalInfo(), (const u8 *)LCFG_THW_GetDefaultNormalInfo(), sizeof(LCFGTWLHWNormalInfo) ) ) {
OS_TPrintf( "HW normal Info verify succeeded.\n" );
}else {
OS_TPrintf( "HW normal Info verify failed.\n" );
}
if( VerifyData( (const u8 *)LCFG_THW_GetSecureInfo(), (const u8 *)LCFG_THW_GetDefaultSecureInfo(), sizeof(LCFGTWLHWSecureInfo) ) ) {
OS_TPrintf( "HW secure Info verify succeeded.\n" );
}else {
OS_TPrintf( "HW secure Info verify failed.\n" );
}
}
// メモリ上のデータベリファイ
static BOOL VerifyData( const u8 *pTgt, const u8 *pOrg, u32 len )
{
while( len-- ) {
if( *pTgt++ != *pOrg++ ) {
return FALSE;
}
}
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: HWI_ModifyLanguage
Description:
Arguments:
Returns: None.
*---------------------------------------------------------------------------*/
void HWI_ModifyLanguage( u8 region )
{
u32 langBitmap = s_langBitmapList[ region ];
u8 nowLanguage = LCFG_TSD_GetLanguage();
// TSDが読み込めていないなら、何もせずリターン
if( !s_isReadTSD ) {
return;
}
if( langBitmap & ( 0x0001 << nowLanguage ) ) {
OS_TPrintf( "Language no change.\n" );
}else {
int i;
for( i = 0; i < LCFG_TWL_LANG_CODE_MAX; i++ ) {
if( langBitmap & ( 0x0001 << i ) ) {
break;
}
}
LCFG_TSD_SetLanguage( (LCFGTWLLangCode)i );
LCFG_TSD_SetFlagCountry( FALSE ); // ※ついでに国コードもクリアしておく。
LCFG_TSD_SetCountry( LCFG_TWL_COUNTRY_UNDEFINED );
LCFGi_TSD_WriteSettings();
OS_TPrintf( "Language Change \"%s\" -> \"%s\"\n",
strLanguage[ nowLanguage ], strLanguage[ LCFG_TSD_GetLanguage() ] );
}
}
/*---------------------------------------------------------------------------*
Name: HWI_WriteHWNormalInfoFile
Description: HWーマルInfoファイルのライト
Arguments:
Returns: None.
*---------------------------------------------------------------------------*/
BOOL HWI_WriteHWNormalInfoFile( void )
{
BOOL isWrite = TRUE;
LCFGReadResult result;
result = LCFGi_THW_ReadNormalInfo();
if( result != LCFG_TSF_READ_RESULT_SUCCEEDED ) {
if( !LCFGi_THW_RecoveryNormalInfo( result ) ) {
OS_TPrintf( "HW Normal Info Recovery failed.\n" );
isWrite = FALSE;
}
}
if( isWrite &&
!LCFGi_THW_WriteNormalInfo() ) {
OS_TPrintf( "HW Normal Info Write failed.\n" );
}
return isWrite;
}
/*---------------------------------------------------------------------------*
Name: HWI_WriteHWSecureInfoFile
Description: HWセキュアInfoファイルのライト
Arguments:
Returns: None.
*---------------------------------------------------------------------------*/
BOOL HWI_WriteHWSecureInfoFile( u8 region )
{
BOOL isWrite = TRUE;
LCFGReadResult result;
// ファイルのリード
result = s_pReadSecureInfoFunc();
// リードに失敗したらリカバリ
if( result != LCFG_TSF_READ_RESULT_SUCCEEDED ) {
if( !LCFGi_THW_RecoverySecureInfo( result ) ) {
OS_TPrintf( "HW Secure Info Recovery failed.\n" );
isWrite = FALSE;
}
}
// リージョンのセット
LCFG_THW_SetRegion( region );
// 対応言語ビットマップのセット
LCFG_THW_SetValidLanguageBitmap( s_langBitmapList[ region ] );
// [TODO:]量産工程でないとシリアルNo.は用意できないので、ここではMACアドレスをもとに適当な値をセットする。
// シリアルNo.のセット
{
u8 buffer[ 12 ] = "SERIAL"; // 適当な文字列をMACアドレスと結合してSHA1を取り、仮SerialNoとする。
u8 serialNo[ SVC_SHA1_DIGEST_SIZE ];
int i;
int len = ( LCFG_THW_GetRegion() == LCFG_TWL_REGION_AMERICA ) ?
LCFG_TWL_HWINFO_SERIALNO_LEN_AMERICA : LCFG_TWL_HWINFO_SERIALNO_LEN_OTHERS;
OS_GetMacAddress( buffer + 6 );
SVC_CalcSHA1( serialNo, buffer, sizeof(buffer) );
for( i = 3; i < SVC_SHA1_DIGEST_SIZE; i++ ) {
serialNo[ i ] = (u8)( ( serialNo[ i ] % 10 ) + 0x30 );
}
MI_CpuCopy8( "SRN", serialNo, 3 );
MI_CpuClear8( &serialNo[ len ], sizeof(serialNo) - len );
OS_TPrintf( "serialNo : %s\n", serialNo );
LCFG_THW_SetSerialNo( serialNo );
}
// ランチャーTitleID_Loのセット
{
int i;
u8 titleID_Lo[4];
for( i = 0; i < 4; i++ ) titleID_Lo[ i ] = (u8)strLauncherGameCode[ region ][ 4 - i - 1 ];
LCFG_THW_SetLauncherTitleID_Lo( (const u8 *)titleID_Lo );
}
// ライト
if( isWrite &&
!LCFGi_THW_WriteSecureInfo( s_pPrivKeyBuffer ) ) {
isWrite = FALSE;
OS_TPrintf( "HW Secure Info Write failed.\n" );
}
return isWrite;
}
/*---------------------------------------------------------------------------*
Name: HWI_DeleteHWNormalInfoFile
Description: HWーマルInfoファイルの消去
Arguments: None
Returns: BOOL
*---------------------------------------------------------------------------*/
BOOL HWI_DeleteHWNormalInfoFile( void )
{
if (FS_DeleteFile( (char *)LCFG_TWL_HWINFO_NORMAL_PATH ))
{
OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH );
return TRUE;
}
else
{
OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH );
return FALSE;
}
}
/*---------------------------------------------------------------------------*
Name: HWI_DeleteHWSecureInfoFile
Description: HWセキュアInfoファイルの消去
Arguments: None
Returns: BOOL
*---------------------------------------------------------------------------*/
BOOL HWI_DeleteHWSecureInfoFile( void )
{
if (FS_DeleteFile( (char *)LCFG_TWL_HWINFO_SECURE_PATH ))
{
OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH );
return TRUE;
}
else
{
OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH );
return FALSE;
}
}

View File

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File: DS_Chat.h
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#ifndef __HWI_LIB__
#define __HWI_LIB__
#ifdef __cplusplus
extern "C" {
#endif
#include <twl.h>
// define data----------------------------------------------------------
typedef enum
{
HWI_INIT_FAILURE,
HWI_INIT_SUCCESS_SIGNATURE_MODE,
HWI_INIT_SUCCESS_NO_SIGNATRUE_MODE
}
HwiInitResult;
HwiInitResult HWI_Init( void *(*pAlloc)( u32 ), void (*pFree)( void * ) );
void HWI_ModifyLanguage( u8 region );
BOOL HWI_WriteHWNormalInfoFile( void );
BOOL HWI_WriteHWSecureInfoFile( u8 region );
BOOL HWI_DeleteHWNormalInfoFile( void );
BOOL HWI_DeleteHWSecureInfoFile( void );
#ifdef __cplusplus
}
#endif
#endif // __HWI_LIB__

View File

@ -23,9 +23,6 @@ SUBDIRS =
USE_PRODUCT_KEY = TRUE
# if USE_PRODUCT_KEY is set, set USE_SDBOOT_KEY to boot from SDMC, otherwise to boot from CARD/NAND
#USE_SDBOOT_KEY = TRUE
KEYS_DIR = $(shell $(CYGPATH) -m $(TWL_KEYSDIR))
TARGET_FIRM = SYSTEMMENU
@ -60,13 +57,16 @@ SRCS = main.c \
process_norfirm.c \
process_auto.c \
process_fade.c \
sd_event.c
sd_event.c \
hwi.c
LINCLUDES = ../common/include \
$(ROOT)/build/libraries/lcfg/ARM9.TWL/include
SRCDIR = src \
$(ROOT)/build/demos.TWL/camera/saveShoot-1/src
$(ROOT)/build/demos.TWL/camera/saveShoot-1/src \
../../HWInfoWriter/ARM9/src
#LCFILE = # using default
MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' \
@ -76,11 +76,6 @@ MAKETAD_FLAGS += -s
ifdef USE_PRODUCT_KEY
MAKEROM_FLAGS += -DPRIVKEY_PATH='$(KEYS_DIR)/rsa'
MACRO_FLAGS += -DUSE_PRODUCT_KEY
ifdef USE_SDBOOT_KEY
MAKEROM_FLAGS += -s -DSYS_PRIV_KEY='$(KEYS_DIR)/rsa/private_sdboot.der' \
-DSYS_PUB_KEY='$(KEYS_DIR)/rsa/pubkey_sdboot.der'
TARGET_TAD=
endif
else
MAKEROM_FLAGS += -DPRIVKEY_PATH='../../../../keys/dummy/rsa'
endif
@ -91,8 +86,6 @@ LLIBRARIES += libes$(TWL_LIBSUFFIX).a \
libacsign_enc$(TWL_LIBSUFFIX).a \
libnamut$(TWL_LIBSUFFIX).a
#include $(TWLSDK_ROOT)/build/buildtools/commondefs
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
include $(TWLSDK_ROOT)/build/buildtools/commondefs.gx.demolib

View File

@ -11,8 +11,8 @@
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev:$
$Author:$
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#ifndef KAMI_FONT_H_
@ -48,8 +48,8 @@ void kamiFontPrintfMain(s16 x, s16 y, u8 color, char *text, ...);
void kamiFontFill(s16 x, s16 y, u8 color, s16 value, s32 length);
void kamiFontFillChar(int lineNo, u8 color1, u8 color2);
void kamiFontLoadScreenData(void);
void kamiFontPrintfConsole(u8 color, char *text, ...);
void kamiFontPrintfConsoleEx(u8 color, char *text, ...);
void kamiFontPrintfConsole(u8 color, const char *text, ...);
void kamiFontPrintfConsoleEx(u8 color, const char *text, ...);
// 上画面コンソール文字列用パレット
#define CONSOLE_ORANGE 0

View File

@ -11,8 +11,8 @@
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev:$
$Author:$
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include <twl.h>
@ -303,7 +303,7 @@ kamiFontFillChar(int lineNo, u8 color1, u8 color2)
Returns: None.
*---------------------------------------------------------------------------*/
void
kamiFontPrintfConsole(u8 color, char *text, ...)
kamiFontPrintfConsole(u8 color, const char *text, ...)
{
va_list vlist;
char temp[256 + 2];
@ -351,7 +351,7 @@ kamiFontPrintfConsole(u8 color, char *text, ...)
Returns: None.
*---------------------------------------------------------------------------*/
void
kamiFontPrintfConsoleEx(u8 color, char *text, ...)
kamiFontPrintfConsoleEx(u8 color, const char *text, ...)
{
va_list vlist;
char temp[256 + 2];

View File

@ -28,10 +28,7 @@
#include "process_fade.h"
#include "cursor.h"
#include "keypad.h"
#include <sysmenu/acsign.h>
//#include <sysmenu/settings/common/TWLHWInfo.h>
//#include <sysmenu/settings/common/TWLSettings.h>
#include "hwi.h"
//
#include "TWLHWInfo_api.h"
@ -135,6 +132,7 @@ const LCFGTWLHWSecureInfo *LCFG_THW_GetSecureInfo( void );
void* HWInfoProcess0(void)
{
HwiInitResult initResult;
int i;
// 文字列全クリア
@ -178,7 +176,19 @@ void* HWInfoProcess0(void)
SetCursorPos((u16)200, (u16)200);
// 前準備
HWInfoWriterInit();
initResult = HWI_Init( OS_AllocFromMain, OS_FreeToMain );
switch (initResult)
{
case HWI_INIT_FAILURE:
kamiFontPrintfConsoleEx(CONSOLE_RED, "HWI_INIT() Failure!\n" );
break;
case HWI_INIT_SUCCESS_SIGNATURE_MODE:
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, "[Signature MODE]\n" );
break;
case HWI_INIT_SUCCESS_NO_SIGNATRUE_MODE:
kamiFontPrintfConsoleEx(CONSOLE_RED, "[No Signature MODE]\n" );
break;
}
FADE_IN_RETURN( HWInfoProcess1 );
}
@ -292,178 +302,6 @@ void* HWInfoProcess2(void)
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: HW情報ライターの初期化
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void HWInfoWriterInit( void )
{
// PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"HW Info Writer");
// GetAndDrawRTCData( &g_rtcDraw, TRUE );
ACSign_SetAllocFunc( OS_AllocFromMain, OS_FreeToMain );
ReadTWLSettings();
ReadPrivateKey();
ReadHWInfoFile();
// VerifyHWInfo();
OS_Printf("region = %d\n", LCFG_THW_GetRegion() );
// s_csr = 0;
// DrawMenu( s_csr, &s_writerParam );
// GXS_SetVisiblePlane( GX_PLANEMASK_BG0 );
// GX_DispOn();
// GXS_DispOn();
}
/*---------------------------------------------------------------------------*
Name: TWL設定データのリード
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void ReadTWLSettings( void )
{
s_isReadTSD = LCFGi_TSD_ReadSettings();
if( s_isReadTSD ) {
OS_TPrintf( "TSD read succeeded.\n" );
}else {
OS_TPrintf( "TSD read failed.\n" );
}
}
/*---------------------------------------------------------------------------*
Name:
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void ModifyLanguage( u8 region )
{
u32 langBitmap = s_langBitmapList[ region ];
u8 nowLanguage = LCFG_TSD_GetLanguage();
// TSDが読み込めていないなら、何もせずリターン
if( !s_isReadTSD ) {
return;
}
if( langBitmap & ( 0x0001 << nowLanguage ) ) {
OS_TPrintf( "Language no change.\n" );
}else {
int i;
for( i = 0; i < LCFG_TWL_LANG_CODE_MAX; i++ ) {
if( langBitmap & ( 0x0001 << i ) ) {
break;
}
}
LCFG_TSD_SetLanguage( (LCFGTWLLangCode)i );
LCFG_TSD_SetFlagCountry( FALSE ); // ※ついでに国コードもクリアしておく。
LCFG_TSD_SetCountry( LCFG_TWL_COUNTRY_UNDEFINED );
LCFGi_TSD_WriteSettings();
OS_TPrintf( "Language Change \"%s\" -> \"%s\"\n",
strLanguage[ nowLanguage ], strLanguage[ LCFG_TSD_GetLanguage() ] );
}
}
/*---------------------------------------------------------------------------*
Name:
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void ReadPrivateKey( void )
{
BOOL result = FALSE;
u32 keyLength;
FSFile file;
OSTick start = OS_GetTick();
FS_InitFile( &file );
if( !FS_OpenFileEx( &file, "rom:key/private_HWInfo.der", FS_FILEMODE_R ) ) {
kamiFontPrintfConsoleEx(CONSOLE_RED, "PrivateKey read failed.\n" );
}else {
keyLength = FS_GetFileLength( &file );
if( keyLength > 0 ) {
s_pPrivKeyBuffer = OS_Alloc( keyLength );
if( FS_ReadFile( &file, s_pPrivKeyBuffer, (s32)keyLength ) == keyLength ) {
OS_TPrintf( "PrivateKey read succeeded.\n" );
result = TRUE;
}else {
kamiFontPrintfConsoleEx(CONSOLE_RED, "PrivateKey read failed.\n" );
}
}
FS_CloseFile( &file );
}
if( !result && s_pPrivKeyBuffer ) {
OS_Free( s_pPrivKeyBuffer );
s_pPrivKeyBuffer = NULL;
}
OS_TPrintf( "PrivKey read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
#ifdef USE_PRODUCT_KEY
// 製品用秘密鍵が有効なら、署名ありのアクセス
s_pReadSecureInfoFunc = LCFGi_THW_ReadSecureInfo;
#else
// そうでないなら、署名なしのアクセス
s_pReadSecureInfoFunc = LCFGi_THW_ReadSecureInfo_NoCheck;
// PutStringUTF16( 14 * 8, 0 * 8, TXT_COLOR_RED, (const u16 *)L"[No Signature MODE]" );
#endif
}
/*---------------------------------------------------------------------------*
Name: HW情報全体のリード
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void ReadHWInfoFile( void )
{
LCFGReadResult retval;
OSTick start = OS_GetTick();
retval = LCFGi_THW_ReadNormalInfo();
if( retval == LCFG_TSF_READ_RESULT_SUCCEEDED ) {
OS_Printf("HW Normal Info read succeeded.\n" );
}else {
kamiFontPrintfConsoleEx(0, "HW Normal Info read failed.\n" );
}
OS_TPrintf( "HW Normal Info read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
start = OS_GetTick();
retval = s_pReadSecureInfoFunc();
if( retval == LCFG_TSF_READ_RESULT_SUCCEEDED ) {
OS_Printf("HW Secure Info read succeeded.\n" );
}else {
kamiFontPrintfConsoleEx(0, "HW Secure Info read failed.\n" );
}
OS_TPrintf( "HW Secure Info read time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
}
/*---------------------------------------------------------------------------*
Name: HW情報全体のライト
@ -476,141 +314,37 @@ static void ReadHWInfoFile( void )
static BOOL WriteHWInfoFile( u8 region )
{
static const u16 *pMsgNormalWriting = (const u16 *)L"Writing Normal File...";
static const u16 *pMsgSecureWriting = (const u16 *)L"Writing Secure File...";
static const u16 *pMsgSucceeded = (const u16 *)L"Succeeded!";
static const u16 *pMsgFailed = (const u16 *)L"Failed!";
static const char *pMsgNormalWriting = "Writing Normal File...";
static const char *pMsgSecureWriting = "Writing Secure File...";
static const char *pMsgSucceeded = "Succeeded!";
static const char *pMsgFailed = "Failed!";
BOOL result = TRUE;
// ノーマルファイルのライト
// (void)PutStringUTF16( MSG_X * 8, MSG_Y * 8, TXT_COLOR_BLACK, pMsgNormalWriting );
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgNormalWriting );
if( WriteHWNormalInfoFile() ) {
// (void)PutStringUTF16( ( MSG_X + 18 ) * 8, MSG_Y * 8, TXT_COLOR_BLUE, pMsgSucceeded );
if( HWI_WriteHWNormalInfoFile() ) {
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
// (void)PutStringUTF16( ( MSG_X + 18 ) * 8, MSG_Y * 8, TXT_COLOR_RED, pMsgFailed );
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
// セキュアファイルのライト
// (void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLACK, pMsgSecureWriting );
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSecureWriting );
if( WriteHWSecureInfoFile( region ) ) {
// (void)PutStringUTF16( ( MSG_X + 18 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded );
if( HWI_WriteHWSecureInfoFile( region ) ) {
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
// (void)PutStringUTF16( ( MSG_X + 18 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_RED, pMsgFailed );
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
ModifyLanguage( region );
HWI_ModifyLanguage( region );
// メッセージを一定時間表示して消去
// DispMessage( 0, 0, TXT_COLOR_NULL, NULL );
// NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_WHITE,
// MSG_X * 8 , MSG_Y * 8, ( 32 - MSG_X ) * 8, ( MSG_Y + 4 ) * 8 );
return result;
}
/*---------------------------------------------------------------------------*
Name: HWーマルInfoファイルのライト
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static BOOL WriteHWNormalInfoFile( void )
{
BOOL isWrite = TRUE;
LCFGReadResult result;
result = LCFGi_THW_ReadNormalInfo();
if( result != LCFG_TSF_READ_RESULT_SUCCEEDED ) {
if( !LCFGi_THW_RecoveryNormalInfo( result ) ) {
kamiFontPrintfConsoleEx(CONSOLE_RED, "HW Normal Info Recovery failed.\n" );
isWrite = FALSE;
}
}
if( isWrite &&
!LCFGi_THW_WriteNormalInfo() ) {
kamiFontPrintfConsoleEx(CONSOLE_RED, "HW Normal Info Write failed.\n" );
}
return isWrite;
}
/*---------------------------------------------------------------------------*
Name: HWセキュアInfoファイルのライト
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static BOOL WriteHWSecureInfoFile( u8 region )
{
BOOL isWrite = TRUE;
LCFGReadResult result;
// ファイルのリード
result = s_pReadSecureInfoFunc();
// リードに失敗したらリカバリ
if( result != LCFG_TSF_READ_RESULT_SUCCEEDED ) {
if( !LCFGi_THW_RecoverySecureInfo( result ) ) {
kamiFontPrintfConsoleEx(CONSOLE_RED, "HW Secure Info Recovery failed.\n" );
isWrite = FALSE;
}
}
// リージョンのセット
LCFG_THW_SetRegion( region );
// 対応言語ビットマップのセット
LCFG_THW_SetValidLanguageBitmap( s_langBitmapList[ region ] );
// [TODO:]量産工程でないとシリアルNo.は用意できないので、ここではMACアドレスをもとに適当な値をセットする。
// シリアルNo.のセット
{
u8 buffer[ 12 ] = "SERIAL"; // 適当な文字列をMACアドレスと結合してSHA1を取り、仮SerialNoとする。
u8 serialNo[ SVC_SHA1_DIGEST_SIZE ];
int i;
int len = ( LCFG_THW_GetRegion() == LCFG_TWL_REGION_AMERICA ) ?
LCFG_TWL_HWINFO_SERIALNO_LEN_AMERICA : LCFG_TWL_HWINFO_SERIALNO_LEN_OTHERS;
OS_GetMacAddress( buffer + 6 );
SVC_CalcSHA1( serialNo, buffer, sizeof(buffer) );
for( i = 3; i < SVC_SHA1_DIGEST_SIZE; i++ ) {
serialNo[ i ] = (u8)( ( serialNo[ i ] % 10 ) + 0x30 );
}
MI_CpuCopy8( "SRN", serialNo, 3 );
MI_CpuClear8( &serialNo[ len ], sizeof(serialNo) - len );
OS_TPrintf( "serialNo : %s\n", serialNo );
LCFG_THW_SetSerialNo( serialNo );
}
// ランチャーTitleID_Loのセット
{
int i;
u8 titleID_Lo[4];
for( i = 0; i < 4; i++ ) titleID_Lo[ i ] = (u8)strLauncherGameCode[ region ][ 4 - i - 1 ];
LCFG_THW_SetLauncherTitleID_Lo( (const u8 *)titleID_Lo );
}
// ライト
if( isWrite &&
!LCFGi_THW_WriteSecureInfo( s_pPrivKeyBuffer ) ) {
isWrite = FALSE;
kamiFontPrintfConsoleEx(CONSOLE_RED, "HW Secure Info Write failed.\n" );
}
return isWrite;
}
/*---------------------------------------------------------------------------*
Name: HWInfoファイルの削除
@ -623,36 +357,33 @@ static BOOL WriteHWSecureInfoFile( u8 region )
static BOOL DeleteHWInfoFile( void )
{
static const u16 *pMsgNormalDeleting = (const u16 *)L"Deleting Normal File...";
static const u16 *pMsgSecureDeleting = (const u16 *)L"Deteting Secure File...";
static const u16 *pMsgSucceeded = (const u16 *)L"Succeeded!";
static const u16 *pMsgFailed = (const u16 *)L"Failed!";
static const char *pMsgNormalDeleting = "Deleting Normal File...";
static const char *pMsgSecureDeleting = "Deteting Secure File...";
static const char *pMsgSucceeded = "Succeeded!";
static const char *pMsgFailed = "Failed!";
BOOL result = TRUE;
// ノーマルファイル
// (void)PutStringUTF16( MSG_X * 8, MSG_Y * 8, TXT_COLOR_BLACK, pMsgNormalDeleting );
if( FS_DeleteFile( (char *)LCFG_TWL_HWINFO_NORMAL_PATH ) ) {
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgNormalDeleting );
if( HWI_DeleteHWNormalInfoFile() ) {
OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH );
// (void)PutStringUTF16( ( MSG_X + 19 ) * 8, MSG_Y * 8, TXT_COLOR_BLUE, pMsgSucceeded );
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_NORMAL_PATH );
// (void)PutStringUTF16( ( MSG_X + 19 ) * 8, MSG_Y * 8, TXT_COLOR_RED, pMsgFailed );
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
// セキュアファイル
// (void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLACK, pMsgSecureDeleting );
if( FS_DeleteFile( (char *)LCFG_TWL_HWINFO_SECURE_PATH ) ) {
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSecureDeleting );
if( HWI_DeleteHWSecureInfoFile() ) {
OS_TPrintf( "%s delete succeeded.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH );
// (void)PutStringUTF16( ( MSG_X + 19 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded );
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, pMsgSucceeded );
}else {
OS_TPrintf( "%s delete failed.\n", (char *)LCFG_TWL_HWINFO_SECURE_PATH );
// (void)PutStringUTF16( ( MSG_X + 19 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_RED, pMsgFailed );
kamiFontPrintfConsoleEx(CONSOLE_RED, pMsgFailed );
result = FALSE;
}
// DispMessage( 0, 0, TXT_COLOR_NULL, NULL );
// NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_WHITE,
// MSG_X * 8 , MSG_Y * 8, ( 32 - MSG_X ) * 8, ( MSG_Y + 4 ) * 8 );
return result;
}