Grav(FU OL) wrote: |
...encoded within a specifically designed, by Jeff himself, encryption... |
Code: Show/Hide //////////////////////////////////////////////////////////////////////////////
// unpacking Infantry Archive Version 1.00.09.15 // // programmed by Raoul Laurentiis with GPL // ////////////////////////////////////////////////////////////////////////////// // file format // 0000-0003 : BLO Header // 0004-0007 : Number of Files // 0008-+SFAT1 or STAF2 * Number of files : File Allocation Tables // ++++-EOF : Data Files // BLO Header // 0x01 : File Allocation Table Version 1 // 0x02 : File Allocation Table Version 2 // File Allocation Table Version 1 // byte[14] : File Name // word : Data File Position // word : Data File Size // File Allocation Table Version 2 // byte[32] : File Name // word : Data File Position // word : Data File Size #include <stdio.h> #pragma pack(1) struct SFAT1 { char szFileName[14]; int nFilePos; int nFileSize; }; struct SFAT2 { char szFileName[32]; int nFilePos; int nFileSize; }; struct SHead { int nHead; int nFile; }; int main(int argc, char* argv[]) { long lFileSize; char* lpszBuffer; SHead* lpSH; SFAT1* lpFAT1; SFAT2* lpFAT2; if(argc==1) {printf("Usage: upinf [filename]\n"); return 0;} if(argc!=2) {printf("argument error\n"); return 1;} FILE* fp=fopen(argv[1],"rb"); if(!fp) {printf("File not found\n"); return 2;} fseek(fp, 0L, SEEK_END); lFileSize = ftell(fp); if(!lFileSize) {printf("file size error\n"); return 3;} fseek(fp,0L,SEEK_SET); lpszBuffer = new char[lFileSize]; fread(lpszBuffer,sizeof(char),lFileSize,fp); fclose(fp); lpSH = new SHead; lpSH = (SHead*)lpszBuffer; if(!lpSH->nHead) {printf("not BLO file\n");delete lpSH;delete[] lpszBuffer;return 4;} if(lpSH->nHead==1) { lpFAT1 = new SFAT1[lpSH->nFile]; lpFAT1 = (SFAT1*)(lpszBuffer+sizeof(SHead)); } if(lpSH->nHead==2) { lpFAT2 = new SFAT2[lpSH->nFile]; lpFAT2 = (SFAT2*)(lpszBuffer+sizeof(SHead)); } for(int i=0;i<lpSH->nFile;i++) { if(lpSH->nHead==1) { fp = fopen(lpFAT1[i].szFileName,"wb"); fwrite(lpszBuffer+lpFAT1[i].nFilePos,sizeof(char),lpFAT1[i].nFileSize,fp); fclose(fp); } if(lpSH->nHead==2) { fp = fopen(lpFAT2[i].szFileName,"wb"); fwrite(lpszBuffer+lpFAT2[i].nFilePos,sizeof(char),lpFAT2[i].nFileSize,fp); fclose(fp); } } lpSH = NULL; lpFAT1 = NULL; lpFAT2 = NULL; delete[] lpszBuffer; lpszBuffer = NULL; return 0; } |