mirror of
https://github.com/rvtr/TwlToolsRED.git
synced 2025-10-31 06:41:18 -04:00
アクセスログファイルを入力すると、該当するファイル情報を付加して出力する機能を追加
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@560 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
parent
afa9a5373d
commit
23fd0f657d
@ -24,7 +24,7 @@ bool Checker::LoadHeader( void* gHeaderBuf, void* mHeaderBuf)
|
||||
|
||||
fseek( gfp, 0, SEEK_SET);
|
||||
readed = fread( gHeaderBuf, sizeof(RomHeader), 1, gfp);
|
||||
if( readed == 1)
|
||||
if( (readed == 1)&&(mHeaderBuf))
|
||||
{
|
||||
fseek( mfp, 0, SEEK_SET);
|
||||
readed = fread( mHeaderBuf, sizeof(RomHeader), 1, mfp);
|
||||
@ -222,7 +222,6 @@ bool Checker::AnalyzeFNT( RomHeader* headerBuf, FILE* fp, Entry* entry, PrintLev
|
||||
// ディレクトリテーブル全体を読む
|
||||
fseek( fp, (u32)(headerBuf->fnt_offset), SEEK_SET);
|
||||
fread( &fntBuf, sizeof(ROM_FNTDir) * currentDir.parent_id, 1, fp);
|
||||
|
||||
// ルートディレクトリのparent_idは総ディレクトリ数を表す
|
||||
for( i=0; i<currentDir.parent_id; i++)
|
||||
{
|
||||
@ -337,9 +336,9 @@ void Checker::FindAllocation( u16 entry_id, RomHeader* headerBuf, FILE* fp, Entr
|
||||
SEEK_SET);
|
||||
fread( ¤tRomFat, sizeof(ROM_FAT), 1, fp);
|
||||
if( print_enable) {
|
||||
printf( " fat top:0x%x, bottom:0x%x, len:0x%x\n",
|
||||
printf( " fat top:0x%lx, bottom:0x%lx, len:0x%lx\n",
|
||||
(u32)(currentRomFat.top), (u32)(currentRomFat.bottom),
|
||||
(u32)(currentRomFat.bottom) - (u32)(currentRomFat.top));
|
||||
(u32)((u32)(currentRomFat.bottom) - (u32)(currentRomFat.top)));
|
||||
}
|
||||
Diff( (u32)(currentRomFat.top), (u32)(currentRomFat.bottom) - (u32)(currentRomFat.top),
|
||||
(u32)(currentRomFat.top), (u32)(currentRomFat.bottom) - (u32)(currentRomFat.top),
|
||||
@ -362,7 +361,6 @@ void Checker::ExportGenuineBmpFiles( Entry* gEntry, PrintLevel print_enable)
|
||||
{
|
||||
int i;
|
||||
MyFileEntry *currentEntry = gEntry->fileEntry;
|
||||
MyFileEntry *hisEntry;
|
||||
// u32* tmpBuf = (u32*)malloc( BMP_BUFFER_SIZE);
|
||||
u32 file_size, rest_size;
|
||||
int loop_num;
|
||||
@ -469,6 +467,66 @@ void Checker::CheckAllEntries( Entry* gEntry, Entry* mEntry)
|
||||
}
|
||||
|
||||
|
||||
u32 Checker::GetOctValue( char* hex_char)
|
||||
{
|
||||
u8 num = (u32)(*(u8*)hex_char);
|
||||
|
||||
if( (num >= '0')&&(num <= '9'))
|
||||
{
|
||||
return num - 0x30;
|
||||
}
|
||||
else if( (num >= 'a')&&(num <= 'f'))
|
||||
{
|
||||
return (num - 0x61) + 10;
|
||||
}
|
||||
else if( (num >= 'A')&&(num <= 'F'))
|
||||
{
|
||||
return (num - 0x41) + 10;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char logBuf[0x46];
|
||||
void Checker::FindAccessLogFile( Entry* entry, FILE* lfp)
|
||||
{
|
||||
int i = 0;
|
||||
u32 log_start_adr, log_end_adr;
|
||||
|
||||
while( fread( logBuf, 6, 1, lfp))
|
||||
{
|
||||
if( memcmp( logBuf, "Read: ", 4) == 0)
|
||||
{
|
||||
fread( logBuf, 0x25, 1, lfp);
|
||||
log_start_adr = (GetOctValue(&logBuf[0x9]) +
|
||||
(GetOctValue(&logBuf[0x8]) * 0x10) +
|
||||
(GetOctValue(&logBuf[0x7]) * 0x100) +
|
||||
(GetOctValue(&logBuf[0x6]) * 0x1000) +
|
||||
(GetOctValue(&logBuf[0x5]) * 0x10000) +
|
||||
(GetOctValue(&logBuf[0x4]) * 0x100000) +
|
||||
(GetOctValue(&logBuf[0x3]) * 0x1000000) +
|
||||
(GetOctValue(&logBuf[0x2]) * 0x10000000));
|
||||
|
||||
log_end_adr = (GetOctValue(&logBuf[0x14]) +
|
||||
(GetOctValue(&logBuf[0x13]) * 0x10) +
|
||||
(GetOctValue(&logBuf[0x12]) * 0x100) +
|
||||
(GetOctValue(&logBuf[0x11]) * 0x1000) +
|
||||
(GetOctValue(&logBuf[0x10]) * 0x10000) +
|
||||
(GetOctValue(&logBuf[0x0F]) * 0x100000) +
|
||||
(GetOctValue(&logBuf[0x0E]) * 0x1000000) +
|
||||
(GetOctValue(&logBuf[0x0D]) * 0x10000000));
|
||||
printf( "%d 0x%lx - 0x%lx", i, log_start_adr, log_end_adr);
|
||||
|
||||
entry->FindFileLocation( log_start_adr, log_end_adr);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "<<other access>>\n");
|
||||
fread( logBuf, 12, 1, lfp);
|
||||
}
|
||||
i++;
|
||||
};
|
||||
}
|
||||
|
||||
void Checker::Finalize( void)
|
||||
{
|
||||
}
|
||||
|
||||
@ -59,6 +59,12 @@ class Checker
|
||||
|
||||
/* ROM内のBMPファイルを全て切り出して出力する */
|
||||
void ExportGenuineBmpFiles( Entry* gEntry, PrintLevel print_enable);
|
||||
|
||||
|
||||
|
||||
u32 GetOctValue( char* hex_char);
|
||||
void FindAccessLogFile( Entry* entry, FILE* lfp);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -155,6 +155,24 @@ MyFileEntry* Entry::FindFileEntry( char* my_full_path_name)
|
||||
}
|
||||
|
||||
|
||||
/* アドレスの範囲に該当するファイルを表示する */
|
||||
MyFileEntry* Entry::FindFileLocation( u32 start_adr, u32 end_adr)
|
||||
{
|
||||
MyFileEntry *currentEntry = fileEntry;
|
||||
while( currentEntry)
|
||||
{
|
||||
if( ((currentEntry->top <= start_adr)&&(currentEntry->bottom >= start_adr)) ||
|
||||
((currentEntry->top <= end_adr)&&(currentEntry->bottom >= end_adr)))
|
||||
{
|
||||
printf( " %s,", currentEntry->full_path_name);
|
||||
}
|
||||
currentEntry = (MyFileEntry*)(currentEntry->next);
|
||||
}
|
||||
printf( "\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void Entry::AutoSetFullPath( void)
|
||||
{
|
||||
MyDirEntry *currentDirEntry = dirEntry;
|
||||
|
||||
@ -63,6 +63,10 @@ class Entry
|
||||
MyDirEntry* FindDirEntry( char* my_full_path_name);
|
||||
MyFileEntry* FindFileEntry( char* my_full_path_name);
|
||||
|
||||
/* アドレスの範囲に該当するファイルを表示する */
|
||||
MyFileEntry* FindFileLocation( u32 start_adr, u32 end_adr);
|
||||
|
||||
|
||||
/* parent リンクを繋げる */
|
||||
void FollowParent( void);
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
extern char* output_fname;
|
||||
extern char* genuine_fname;
|
||||
extern char* magicon_fname;
|
||||
extern char* log_fname;
|
||||
|
||||
#define BUFFER_SIZE (0x4000)
|
||||
|
||||
@ -67,7 +68,14 @@ int main (int argc, char *argv[])
|
||||
printf("[output_fname]%s\n", output_fname);
|
||||
printf("[genuine_fname]%s\n", genuine_fname);
|
||||
printf("[magicon_fname]%s\n", magicon_fname);
|
||||
printf("[log_fname]%s\n", log_fname);
|
||||
|
||||
if( !genuine_fname)
|
||||
{
|
||||
SA_Usage();
|
||||
}
|
||||
|
||||
if( magicon_fname)
|
||||
{
|
||||
FILE* gfp;
|
||||
FILE* mfp;
|
||||
@ -159,6 +167,16 @@ int main (int argc, char *argv[])
|
||||
|
||||
// AnalyzeFNT( mHeaderBuf, mfp);
|
||||
|
||||
if( log_fname)
|
||||
{
|
||||
FILE* lfp;
|
||||
|
||||
lfp = fopen( log_fname, "r");
|
||||
printf( "\n\n\nACCESS LOG\n");
|
||||
checker.FindAccessLogFile( &gEntry, lfp);
|
||||
printf( "------------------\n");
|
||||
}
|
||||
|
||||
fclose( gfp);
|
||||
fclose( mfp);
|
||||
}
|
||||
|
||||
@ -21,12 +21,14 @@
|
||||
char* output_fname = NULL;
|
||||
char* genuine_fname = NULL;
|
||||
char* magicon_fname = NULL;
|
||||
char* log_fname = NULL;
|
||||
|
||||
|
||||
void SA_Usage( void)
|
||||
{
|
||||
fprintf( stderr, "Analyzing Tool\n");
|
||||
fprintf( stderr, "Usage: makelst [-o output-file] [--g genuine-srl-file] [--m magicon-srl-file]\n\n");
|
||||
fprintf( stderr, "Usage: makelst [-o output-file] [--g genuine-srl-file] [--l access-log-file]\n\n");
|
||||
exit( 1);
|
||||
}
|
||||
|
||||
@ -38,6 +40,7 @@ void SA_searchopt( int argc, char* argv[])
|
||||
struct option optionInfo[] = {
|
||||
{ "genuine", required_argument, NULL, 'g'},
|
||||
{ "magicon", required_argument, NULL, 'm'},
|
||||
{ "log", required_argument, NULL, 'l'},
|
||||
{ NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@ -73,6 +76,13 @@ void SA_searchopt( int argc, char* argv[])
|
||||
}
|
||||
magicon_fname = optarg;
|
||||
break;
|
||||
case 'l': // "--log"
|
||||
if( log_fname != NULL) {
|
||||
fprintf( stderr, "ERROR! redefined log filename.\n");
|
||||
SA_Usage();
|
||||
}
|
||||
log_fname = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
SA_Usage();
|
||||
break;
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
#define __SEARCH_ARG__
|
||||
|
||||
|
||||
|
||||
void SA_Usage( void);
|
||||
|
||||
/*引数を解析する*/
|
||||
void SA_searchopt( int argc, char* argv[]);
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user