转自:http://www.cnitblog.com/sword/archive/2007/04/21/26002.html
很久以前就想做类似《吞食鱼2》的游戏,于是就先破解他的资源好以后使用,不过后来由于某种原因没有继续,现在把破解程序放上来,希望可以帮助有需要的朋友.程序很简单,就几十行代码.先帖一张吞食鱼的游戏效果图.
下面是源代码:
#include < windows.h >
#include < string >
#include < Vector >
using namespace std;
typedef std:: string tString;
struct FishPack
{
int nOffset;
int nFileSize;
tString FileName;
} ;
typedef vector < FishPack > PakVec;
int _tmain( int argc, _TCHAR * argv[])
{
FILE * fp = fopen( " FF2.saf " , " rb " );
if ( fp == NULL )
return 0 ;
char szFile[ 128 ];
int nCount = 0 ;
fseek( fp, 0 , SEEK_END );
int nSize = ftell( fp );
fseek( fp, 0 , 0 );
char * pData = new char [nSize];
fread( pData, 1 , nSize, fp );
fseek( fp, 14487566 , SEEK_SET );
PakVec vecPak;
char szTemp[ 16 ], szName[ 64 ];
int nPos = 14487566 ;
unsigned short nNameSize = 0 ;
while ( nPos < nSize )
{
FishPack pf;
fread( & pf.nOffset, 1 , 4 , fp );
fread( & pf.nFileSize, 1 , 4 , fp );
fread( szTemp, 1 , 16 , fp );
fread( & nNameSize, 1 , 2 , fp );
fread( szName, 1 , nNameSize, fp );
szName[nNameSize] = 0 ;
pf.FileName = " F:/ " ;
pf.FileName += szName;
vecPak.push_back( pf );
nPos += 26 + nNameSize;
}
FishPack * pf = NULL;
PakVec::iterator ii = vecPak.begin();
for ( ; ii != vecPak.end(); ++ ii )
{
pf = & ( * ii);
BOOL bResult;
String strPath;
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
String strDir, strSub;
strPath = pf -> FileName.c_str();
// if( strPath == "F:/resource/actors/angler/animation.theora" )
// _asm int 3; nPos = 0;
while ( (nPos = strPath.FindNext( ' / ' , nPos )) != - 1 )
{
strPath.SubString( 0 , nPos, strSub );
nPos += 1 ;
hFind = FindFirstFile(strSub.C_Str(), & FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
if ( ! CreateDirectory( strSub.C_Str(), NULL ) )
{
strSub.Clear();
FindClose(hFind);
continue ;
}
}
strSub.Clear();
FindClose(hFind);
} FILE * fpOut = fopen( pf -> FileName.c_str(), " wb " );
if ( fpOut == NULL )
_asm int 3 ;
char * pFileData = new char [pf -> nFileSize];
fseek( fp, pf -> nOffset, SEEK_SET );
fread( pFileData, 1 , pf -> nFileSize, fp );
// sprintf( szFile, "%d.jpg", nCount++ );
// FILE *fpOut = fopen( szFile, "wb" );
fwrite( pFileData, 1 , pf -> nFileSize, fpOut );
delete [] pFileData;
fclose( fpOut );
// fprintf( fpOut, "offset: %d, File: %d, Name:%s\n", (*ii).nOffset, (*ii).nFileSize, (*ii).FileName.c_str() );
// printf( "offset: %d, File: %d, Name:%s\n", (*ii).nOffset, (*ii).nFileSize, (*ii).FileName.c_str() );
}
delete [] pData;
fclose( fp );
return 0 ;
}