Jump to content

Alone in The Dark 5 (XBOX360, big/fat)


leop2p
Go to solution Solved by infval,

Recommended Posts

There's a BMS script I found from sethioz.com forum to extract those files (was created for files from TDU2 in mind but should work for your samples too since the header is same):

IDString "XMBF"
Open FDDE big 1
Endian big
GetDString DUMMY 12
Get OFFS long
GoTo OFFS
Get DUMMY long
Get NUMHASHES long
Get HASHOFFSET long
Math HASHOFFSET += OFFS
Get NUMFILEREC long
Get FILERECOFFSET long
Math FILERECOFFSET += OFFS
If NUMHASHES != NUMFILEREC
  CleanExit
EndIf
For I = 0 < NUMHASHES
  GoTo HASHOFFSET
  Get HASH1 long
  Get HASH2 long
  Set EXT string ".bin"
  SavePos HASHOFFSET
  GoTo FILERECOFFSET
  Get FILESIZE long
  Get DUMMY long # compression?
  Get FILEOFFSET long
  SavePos FILERECOFFSET
  Math MEMSIZE = FILESIZE
  Math MEMSIZE x 4
  Log MEMORY_FILE FILEOFFSET MEMSIZE 1
  If MEMSIZE != FILESIZE
    Math MEMSIZE -= 4
    GetVarChr TMP MEMORY_FILE MEMSIZE long
    Math TMP ^= 0xD7A8E2D4
    PutVarChr MEMORY_FILE MEMSIZE TMP long
  EndIf
 
  GetVarChr HEADER MEMORY_FILE 0 long
  Math HEADER ^= 0xD7A8E2D4
  If HEADER == 0x584D4246
    Set EXT string ".xmb"
  ElseIf HEADER == 0x49474532
    Set EXT string ".ige"
  Else
    GetVarChr HEADER MEMORY_FILE 8 long
    Math HEADER ^= 0xD7A8E2D4
    If HEADER == 0x4B4E4142
      Set EXT string ".bnk"
    ElseIf HEADER == 0x57415645
      Set EXT string ".wav"
    Else
      GetVarChr HEADER MEMORY_FILE 12 long
      Math HEADER ^= 0xD7A8E2D4
      If HEADER == 0x2E324442
        Set EXT string ".2db"
      ElseIf HEADER == 0x584D4246
        Set EXT string ".xmb2"
      EndIf
    EndIf
  EndIf
 
  String NAME p= "%08X%08X%s" HASH1 HASH2 EXT
  FileXOR "\xD7\xA8\xE2\xD4"
  Log NAME 0 FILESIZE MEMORY_FILE
  FileXOR ""
Next I

Point the script to fat file to use it
However by the looks of it no real filenames but instead a hash of it was used.

Link to comment
Share on other sites

  • Engineer

Here's struct of FAT.

//------------------------------------------------
//--- 010 Editor v14.0 Binary Template
//
//      File: 
//   Authors: 
//   Version: 
//   Purpose: Alone in The Dark 5 Xbox360
//  Category: 
// File Mask: *.FAT
//  ID Bytes: 
//   History: 
//------------------------------------------------
BigEndian();OutputPaneClear();
local string FileName=GetFileName(),FilePath=FileNameGetPath(FileName,true),BaseName=FileNameGetBase(FileName,false);

typedef struct HEADER {
    char Sign[4];
    byte Flags[4];
    uint32 StrArrayOffset,Table_0_Offset,Table_1_Offset,Table_0_Count,Unk_4;
};

typedef struct STRARRAY {
    struct StrArray {
        string StrName;
    }StringArray[23]<optimize=false>;
};

typedef struct TABLE_0 {
    struct TAB_0 {
        uint32 Value;
    }Tab_0[Header.Table_0_Count]<optimize=false>;
};

typedef struct TABLE_1 {
    uint32 FileCount,InfoOffset,DummyCount,TableSize;
    struct NAMEHASH_INFO {
        uint64 NameHash;
    }NameHash_Info[FileCount]<optimize=false>;

    struct FILE_INFO {
        uint32 Unk_0,Unk_1,Unk_2,ComSize,Unk_4,DecSize,Unk_6,Offset;
    }File_Info[FileCount]<optimize=false>;
};

HEADER Header;
FSeek(Header.StrArrayOffset);
STRARRAY StringArray;
FSeek(Header.Table_0_Offset);
TABLE_0 Table_0;
FSeek(Header.Table_1_Offset);
TABLE_1 Table_1;

 

Link to comment
Share on other sites

  • Engineer

Compression should be lzo. But everytime i tried dempress it it creates only 4096 bytes output.

Also here's struct of compressed file.

//------------------------------------------------
//--- 010 Editor v14.0 Binary Template
//
//      File: 
//   Authors: 
//   Version: 
//   Purpose: Alone in The Dark 5 Xbox360
//  Category: 
// File Mask:
//  ID Bytes: 
//   History: 
//------------------------------------------------
BigEndian();OutputPaneClear();
local string FileName=GetFileName(),FilePath=FileNameGetPath(FileName,true),BaseName=FileNameGetBase(FileName,false);
local uint32 i;

typedef struct HEADER {
    uint32 Unk_0,Unk_1,Unk_2,Unk_3,ChunkSize,ChunkInfoOffset,cDataOffset,Unk_7,Unk_8,dSize,Unk_10,cSize,Unk_13,Unk_14,Unk_15,Unk_16;
};

typedef struct CHUNK_INFO {
    for (i=0; i < Header.ChunkInfoOffset/4; i++)
    {
        uint32 ChunkSize;
    }
};

typedef struct CHUNK_DATA {
    
    for (i=0; i < Header.ChunkInfoOffset/4; i++)
    if (ChunkInfo.ChunkSize[i] != 0)
    struct Chunk {
        byte Data[ChunkInfo.ChunkSize[i]];
    }chunk;
};

HEADER Header;
FSeek(Header.ChunkInfoOffset);
CHUNK_INFO ChunkInfo;
FSeek(Header.cDataOffset);
CHUNK_DATA ChunkData;

EDiT:

Attached sample if anyone want take a look

_com.7z

Edited by h3x3r
Link to comment
Share on other sites

  • Solution

From Multimedia GameRipping by mauzerX (https://www.forum.ctpax-x.org/?showtopic=282, Ripkit.chm > Useful Things > QuickBMS > Scripts > Specific Game Extractors > All Platforms > Alone In The Dark 2008):

Alone In The Dark 2008

(scripts by qwerty)

----------------------------
Unpacks *.BIG + *.FAT archives and extract data from *.BNK. Scripts for PC and Xbox 360 version.

Code for PC version for *.BIG + *.FAT:

IDString "XMBF"
Open FDDE big 1
Endian little
GetDString DUMMY 12
Get OFFS long
GoTo OFFS
Get NUMHASHES long
Get HASHOFFSET long
Math HASHOFFSET += OFFS
Get NUMFILEREC long
Get FILERECOFFSET long
Math FILERECOFFSET += OFFS
If NUMHASHES != NUMFILEREC
  CleanExit
EndIf
For I = 0 < NUMHASHES
  GoTo HASHOFFSET
  Get HASH2 long
  Get HASH1 long
  String NAME p= "%08X%08X.bnk" HASH1 HASH2
  SavePos HASHOFFSET
  GoTo FILERECOFFSET
  Get FILESIZE longlong
  Get DUMMY longlong # compressed size?
  Get DUMMY longlong # uncompressed size?
  Get FILEOFFSET longlong
  SavePos FILERECOFFSET
  #Log NAME FILEOFFSET FILESIZE 1
  CallFunction UnpackFile
Next I

########################
StartFunction UnpackFile
  Endian big
  ComType lzo
  Log MEMORY_FILE FILEOFFSET FILESIZE 1
  GoTo 0x10 MEMORY_FILE
  Get CHUNKSZ long MEMORY_FILE
  Get FATOFFSET long MEMORY_FILE
  Get ZDATAOFFSET long MEMORY_FILE
  Get DUMMY long MEMORY_FILE
  Get DATASIZE longlong MEMORY_FILE
  Get ZDATASIZE longlong MEMORY_FILE
  Get BUFFSIZE long MEMORY_FILE
  Math BUFF = ZDATAOFFSET
  Math BUFF += BUFFSIZE
  Math NUMCHUNKS = ZDATAOFFSET
  Math NUMCHUNKS -= FATOFFSET
  Math NUMCHUNKS /= 4
  Log MEMORY_FILE2 0 0
  PutVarChr MEMORY_FILE2 DATASIZE 0
  Log MEMORY_FILE2 0 0
  Append
  GoTo FATOFFSET MEMORY_FILE
  For J = 0 < NUMCHUNKS
    Get ZCHUNKSZ long MEMORY_FILE
    Math ZDATAOFFSET += ZCHUNKSZ
    If ZDATAOFFSET > BUFF
      Math ZDATAOFFSET -= ZCHUNKSZ
      Math ZDATAOFFSET x= 0x800
      Math BUFF = ZDATAOFFSET
      Math BUFF += BUFFSIZE
    Else
      Math ZDATAOFFSET -= ZCHUNKSZ
    EndIf
    If ZCHUNKSZ == 0
      Break
    ElseIf ZCHUNKSZ < CHUNKSZ
      CLog MEMORY_FILE2 ZDATAOFFSET ZCHUNKSZ CHUNKSZ MEMORY_FILE
    Else
      Log MEMORY_FILE2 ZDATAOFFSET ZCHUNKSZ MEMORY_FILE
    EndIf
    Math ZCHUNKSZ x= 0x10
    Math ZDATAOFFSET += ZCHUNKSZ
  Next J
  Append
  Log NAME 0 DATASIZE MEMORY_FILE2
  Endian little
EndFunction
########################

Code for XBOX-360 version for *.BIG + *.FAT:

IDString "XMBF"
Open FDDE big 1
Endian big
GetDString DUMMY 12
Get OFFS long
GoTo OFFS
Get NUMHASHES long
Get HASHOFFSET long
Math HASHOFFSET += OFFS
Get NUMFILEREC long
Get FILERECOFFSET long
Math FILERECOFFSET += OFFS
If NUMHASHES != NUMFILEREC
  CleanExit
EndIf
For I = 0 < NUMHASHES
  GoTo HASHOFFSET
  Get HASH2 long
  Get HASH1 long
  String NAME p= "%08X%08X.bnk" HASH2 HASH1
  SavePos HASHOFFSET
  GoTo FILERECOFFSET
  Get FILESIZE longlong
  Get DUMMY longlong # compressed size?
  Get DUMMY longlong # uncompressed size?
  Get FILEOFFSET longlong
  SavePos FILERECOFFSET
  #Log NAME FILEOFFSET FILESIZE 1
  CallFunction UnpackFile
Next I

########################
StartFunction UnpackFile
  #Endian big
  ComType lzo
  Log MEMORY_FILE FILEOFFSET FILESIZE 1
  GoTo 0x10 MEMORY_FILE
  Get CHUNKSZ long MEMORY_FILE
  Get FATOFFSET long MEMORY_FILE
  Get ZDATAOFFSET long MEMORY_FILE
  Get DUMMY long MEMORY_FILE
  Get DATASIZE longlong MEMORY_FILE
  Get ZDATASIZE longlong MEMORY_FILE
  Get BUFFSIZE long MEMORY_FILE
  Math BUFF = ZDATAOFFSET
  Math BUFF += BUFFSIZE
  Math NUMCHUNKS = ZDATAOFFSET
  Math NUMCHUNKS -= FATOFFSET
  Math NUMCHUNKS /= 4
  Log MEMORY_FILE2 0 0
  PutVarChr MEMORY_FILE2 DATASIZE 0
  Log MEMORY_FILE2 0 0
  Append
  GoTo FATOFFSET MEMORY_FILE
  For J = 0 < NUMCHUNKS
    Get ZCHUNKSZ long MEMORY_FILE
    Math ZDATAOFFSET += ZCHUNKSZ
    If ZDATAOFFSET > BUFF
      Math ZDATAOFFSET -= ZCHUNKSZ
      Math ZDATAOFFSET x= 0x800
      Math BUFF = ZDATAOFFSET
      Math BUFF += BUFFSIZE
    Else
      Math ZDATAOFFSET -= ZCHUNKSZ
    EndIf
    If ZCHUNKSZ == 0
      Break
    ElseIf ZCHUNKSZ < CHUNKSZ
      CLog MEMORY_FILE2 ZDATAOFFSET ZCHUNKSZ CHUNKSZ MEMORY_FILE
    Else
      Log MEMORY_FILE2 ZDATAOFFSET ZCHUNKSZ MEMORY_FILE
    EndIf
    Math ZCHUNKSZ x= 0x10
    Math ZDATAOFFSET += ZCHUNKSZ
  Next J
  Append
  Log NAME 0 DATASIZE MEMORY_FILE2
  #Endian little
EndFunction
########################

Code for XBOX-360 and PC version for *.BNK:

Set FULLNAME string ""
Set NAME string ""
Log MEMORY_FILE 0 0
GetDString DUMMY 8
GetDString ID 4
If ID == "KNAB"
  Endian little
ElseIf ID == "BANK"
  Endian big
Else
  CleanExit
EndIf
GoTo 0x28
Get NUMFILES long
Get DUMMY long
Get FATOFFSET long
Math FATOFFSET += 8
Get DUMMY long
Get NAMESOFFSET long
Math NAMESOFFSET += 8
Get FILESORDER long
Math FILESORDER += 8
PutVarChr MEMORY_FILE 0 FILESORDER long
GoTo NAMESOFFSET
If NUMFILES != 0
  CallFunction Parser
EndIf

StartFunction Parser
  Get NAMESZ byte
  If NAMESZ > 0x7F
    String FULLNAME += NAME
    String FULLNAME += \
    Get FOLDERS byte
 If FOLDERS > 0x7F
   Get TMP byte
   Math TMP < 7
   Math FOLDERS & 0x0000007F
   Math FOLDERS | TMP
 EndIf
    Math NAMESZ ^= 0xFF
    Math NAMESZ += 1
    GetDString NAME NAMESZ
    For I = 0 < FOLDERS
      CallFunction Parser
    Next I
  Else
    GetDString BASENAME NAMESZ
    String FULLNAME += BASENAME
    String FULLNAME += NAME
 SavePos NAMESOFFSET
 GetVarChr FILESORDER MEMORY_FILE 0 long
 GoTo FILESORDER
 If NUMFILES > 0x100
   Get FILENUMBER word
 Else
   Get FILENUMBER byte
 EndIf
 SavePos FILESORDER
 PutVarChr MEMORY_FILE 0 FILESORDER long
 Math FILENUMBER *= 0x14
 Math FATOFFSET += FILENUMBER
 GoTo FATOFFSET
 Get OFFSET long
 Get SIZE long
 GetDString DUMMY 12
    Log FULLNAME OFFSET SIZE
 GoTo NAMESOFFSET
  EndIf
EndFunction Parser

 

Edited by infval
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...