KEY file format
    Applies to:
    BG1, BG1: TotS, BG2, BG2: ToB, PST, IWD, IWD:HoW, IWD:TotL, IWD2
    General Description
    
      This file format acts as a central reference point to locate files required by the game (in a BIFF file on a CD or in the override directory). The key file also maintains a mapping from an 8 byte resource name (refref) to a 32 byte ID (using the lowest 12 bits to identify a resource). There is generally only one key file with each game (chitin.key).
    
    General Description
    
    
    
    | Offset | Size (data type) | Description | 
|---|---|---|
| 0x0000 | 4 (char array) | Signature ('KEY ') | 
| 0x0004 | 4 (char array) | Version ('V1 ') | 
| 0x0008 | 4 (dword) | Count of BIF entries | 
| 0x000c | 4 (dword) | Count of resource entries | 
| 0x0010 | 4 (dword) | Offset (from start of file) to BIF entries | 
| 0x0014 | 4 (dword) | Offset (from start of file) to resource entries | 
| Offset | Size (data type) | Description | 
|---|---|---|
| 0x0000 | 4 (dword) | Length of BIF file | 
| 0x0004 | 4 (dword) | Offset from start of file to ASCIIZ BIF filename | 
| 0x0008 | 2 (word) | Length, including terminating NUL, of ASCIIZ BIF filename | 
| 0x000a | 2 (word) | The 16 bits of this field are used individually to mark the location of the relevant file. (MSB) xxxx xxxx ABCD EFGH (LSB) 
 | 
| Offset | Size (data type) | Description | 
|---|---|---|
| 0x0000 | 8 (resref) | Resource name | 
| 0x0008 | 2 (word) | Resource type | 
| 0x000a | 4 (dword) | Resource locator. The IE resource manager uses 32-bit values as a 'resource index', which codifies the source of the resource as well as which source it refers to. The layout of this value is below. 
 | 
