r11 的封包是 afs 格式的,封包没有压缩和加密,在封包头部有文件的偏移和大小,封包尾部有各文件的文件名以及其他一些信息。
- 所有封包中含有以下类型文件:
- bip: lzss 压缩或未压缩的多 png 组合文件
- t2p: lzss 压缩的 tim2 文件,tim2 可转为 bmp 文件
- adx: 原始 ogg 或 wav 声音文件
afs 相关结构
typedef struct
{
char Magic[4];
int FileCount;
AFS_ENTRY *Entries;
} AFS_HEADER;
typedef struct // 紧跟文件头的索引
{
int Offset;
int Length;
} AFS_ENTRY;
typedef struct // 封包尾部的索引信息
{
char FileName[32];
char UnknownBytes[16];
} AFS_INDEX;
t2p 相关结构
解压后得到 tim2 文件。tim2 文件结构如下,与 bmp 类似的两个数据结构,32 位色的情况下后面跟随 4 字节的像素信息。
typedef struct
{
char FileId[4]; // ID of the File (must be 'T', 'I', 'M' and '2')
unsigned char FormatVersion; // Version number of the format
unsigned char FormatId; // ID of the format
unsigned short Pictures; // Number of picture data
char Reserved[8]; // Padding (must be 0x00)
} TIM2_FILEHEADER;
typedef struct
{
unsigned long TotalSize; // Total size of the picture data in unsigned chars
unsigned long ClutSize; // CLUT data size in unsigned chars
unsigned long ImageSize; // Image data size in unsigned chars
unsigned short HeaderSize; // Header size in unsigned chars
unsigned short ClutColors; // Total color number in CLUT data
unsigned char PictFormat; // ID of the picture format (must be 0)
unsigned char MipMapTextures;// Number of MIPMAP texture
unsigned char ClutType; // Type of the CLUT data
unsigned char ImageType; // Type of the Image data
unsigned short ImageWidth; // Width of the picture
unsigned short ImageHeight; // Height of the picture
unsigned char GsTex0[8]; // Data for GS TEX0 register
unsigned char GsTex1[8]; // Data for GS TEX1 register
unsigned long GsRegs; // Data for GS TEXA, FBA, PABE register
unsigned long GsTexClut; // Data for GS TEXCLUT register
} TIM2_PICTUREHEADER;
// 其中 ClutType 具体取值如下:
// 01 16 位直接颜色文件
// 02 24 位直接颜色文件
// 03 32 位直接颜色文件
// 04 4 位索引文件(16色)
// 05 8 位索引文件(256色)
// ImageType 取值如下:
// 00 无调色板
// 索引颜色文件时
// 高四位
// 0 采用 CSM1 调色板
// 1 采用 CSM2 调色板
// 低四位
// 1 16位色调色板
// 2 24位色调色板
// 3 32位色调色板
bip 相关结构
该结构跟随在 “EMUARC__” 标志之后,之后紧跟 png 图片数据
typedef struct
{
char Magic[8]; // "PNGFILE2"
int PartWidth;
int PartHeight;
short FullWidth;
short FullWidthThumb;
short FullHeight;
short FullHeightThumb;
int PartSize; // header + pngfile
char FileNameWithDirectory[64];
char Unknown[16];
int PicOffsetX;
int PicOffsetY;
int PicWidth;
int PicHeight;
} PNG_PACK_TYPE2;
压缩后的 bip 经解压可得到
typedef struct
{
TIM2_FILEHEADER Tim2FileHeader;
TIM2_PICTUREHEADER Tim2PicHeader;
char Magic[8]; // "PNGFILE3"
int PartWidth;
int PartHeight;
short FullWidth;
short FullWidthThumb;
short FullHeight;
short FullHeightThumb;
int PartSize; // header from magic + pngfile
char FileNameWithDirectory[64];
char Unknown[16];
int PicOffsetX;
int PicOffsetY;
int PicWidth;
int PicHeight;
} PNG_PACK_TYPE3;
该结构也是一个跟随一个出现,但是结构的起始地址要对齐16字节的文件偏移。该数据结构之后同样跟随 png 图片数据。
bip 里 “EMUARC__” 标志前的文件头结构中还有些字段含义不太清楚,以后样本多了再补充吧hhhh
代码地址 渣代码见笑了_(:з」∠)_

不太懂逆向有什么解包BIP和T2P的工具手段吗TT,Google并没有找到相关内容。
可以参考上面的代码编译试试哦