1 2#------------------------------------------------------------------------------ 3# $File: console,v 1.49 2019/05/27 01:33:32 christos Exp $ 4# Console game magic 5# Toby Deshane <hac@shoelace.digivill.net> 6 7# ines: file(1) magic for Marat's iNES Nintendo Entertainment System ROM dump format 8# Updated by David Korth <gerbilsoft@gerbilsoft.com> 9# References: 10# - https://wiki.nesdev.com/w/index.php/INES 11# - https://wiki.nesdev.com/w/index.php/NES_2.0 12 13# Common header for iNES, NES 2.0, and Wii U iNES. 140 name nes-rom-image-ines 15>7 byte&0x0C =0x8 (NES 2.0) 16>4 byte x \b: %ux16k PRG 17>5 byte x \b, %ux8k CHR 18>6 byte&0x08 =0x8 [4-Scr] 19>6 byte&0x09 =0x0 [H-mirror] 20>6 byte&0x09 =0x1 [V-mirror] 21>6 byte&0x02 =0x2 [SRAM] 22>6 byte&0x04 =0x4 [Trainer] 23>7 byte&0x03 =0x2 [PC10] 24>7 byte&0x03 =0x1 [VS] 25>>7 byte&0x0C =0x8 26# NES 2.0: VS PPU 27>>>13 byte&0x0F =0x0 \b, RP2C03B 28>>>13 byte&0x0F =0x1 \b, RP2C03G 29>>>13 byte&0x0F =0x2 \b, RP2C04-0001 30>>>13 byte&0x0F =0x3 \b, RP2C04-0002 31>>>13 byte&0x0F =0x4 \b, RP2C04-0003 32>>>13 byte&0x0F =0x5 \b, RP2C04-0004 33>>>13 byte&0x0F =0x6 \b, RP2C03B 34>>>13 byte&0x0F =0x7 \b, RP2C03C 35>>>13 byte&0x0F =0x8 \b, RP2C05-01 36>>>13 byte&0x0F =0x9 \b, RP2C05-02 37>>>13 byte&0x0F =0xA \b, RP2C05-03 38>>>13 byte&0x0F =0xB \b, RP2C05-04 39>>>13 byte&0x0F =0xC \b, RP2C05-05 40# TODO: VS protection hardware? 41>>7 byte x \b] 42# NES 2.0-specific flags. 43>7 byte&0x0C =0x8 44>>12 byte&0x03 =0x0 [NTSC] 45>>12 byte&0x03 =0x1 [PAL] 46>>12 byte&0x02 =0x2 [NTSC+PAL] 47 48# Standard iNES ROM header. 490 string NES\x1A NES ROM image (iNES) 50!:mime application/x-nes-rom 51>0 use nes-rom-image-ines 52 53# Wii U Virtual Console iNES ROM header. 540 belong 0x4E455300 NES ROM image (Wii U Virtual Console) 55!:mime application/x-nes-rom 56>0 use nes-rom-image-ines 57 58#------------------------------------------------------------------------------ 59# unif: file(1) magic for UNIF-format Nintendo Entertainment System ROM images 60# Reference: https://wiki.nesdev.com/w/index.php/UNIF 61# From: David Korth <gerbilsoft@gerbilsoft.com> 62# 63# NOTE: The UNIF format uses chunks instead of a fixed header, 64# so most of the data isn't easily parseable. 65# 660 string UNIF 67>4 lelong <16 NES ROM image (UNIF v%d format) 68!:mime application/x-nes-rom 69 70#------------------------------------------------------------------------------ 71# fds: file(1) magic for Famciom Disk System disk images 72# Reference: https://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System#.FDS_format 73# From: David Korth <gerbilsoft@gerbilsoft.com> 74# TODO: Check "Disk info block" and get info from that in addition to the optional header. 75 76# Disk info block. (block 1) 770 name nintendo-fds-disk-info-block 78>23 byte !1 FMC- 79>23 byte 1 FSC- 80>16 string x \b%.3s 81>15 byte x \b, mfr %02X 82>20 byte x (Rev.%02u) 83 84# Headered version. 850 string FDS\x1A 86>0x11 string *NINTENDO-HVC* Famicom Disk System disk image: 87!:mime application/x-fds-disk 88>>0x10 use nintendo-fds-disk-info-block 89>4 byte 1 (%u side) 90>4 byte !1 (%u sides) 91 92# Unheadered version. 931 string *NINTENDO-HVC* Famicom Disk System disk image: 94!:mime application/x-fds-disk 95>0 use nintendo-fds-disk-info-block 96 97#------------------------------------------------------------------------------ 98# tnes: file(1) magic for TNES-format Nintendo Entertainment System ROM images 99# Used by Nintendo 3DS NES Virtual Console games. 100# From: David Korth <gerbilsoft@gerbilsoft.com> 101# 1020 string TNES NES ROM image (Nintendo 3DS Virtual Console) 103!:mime application/x-nes-rom 104>4 byte 100 \b: FDS, 105>>0x2010 use nintendo-fds-disk-info-block 106>4 byte !100 \b: TNES mapper %u 107>>5 byte x \b, %ux8k PRG 108>>6 byte x \b, %ux8k CHR 109>>7 byte&0x08 =1 [WRAM] 110>>8 byte&0x09 =1 [H-mirror] 111>>8 byte&0x09 =2 [V-mirror] 112>>8 byte&0x02 =3 [VRAM] 113 114#------------------------------------------------------------------------------ 115# gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format 116# Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header 117# 1180x104 bequad 0xCEED6666CC0D000B Game Boy ROM image 119# TODO: application/x-gameboy-color-rom for GBC. 120!:mime application/x-gameboy-rom 121>0x143 byte&0x80 0x80 122>>0x134 string >\0 \b: "%.15s" 123>0x143 byte&0x80 !0x80 124>>0x134 string >\0 \b: "%.16s" 125>0x14c byte x (Rev.%02u) 126 127# Machine type. (SGB, CGB, SGB+CGB) 128>0x14b byte 0x33 129>>0x146 byte 0x03 130>>>0x143 byte&0x80 0x80 [SGB+CGB] 131>>>0x143 byte&0x80 !0x80 [SGB] 132>>0x146 byte !0x03 133>>>0x143 byte&0xC0 0x80 [CGB] 134>>>0x143 byte&0xC0 0xC0 [CGB ONLY] 135>0x14b byte !0x33 136 137# Mapper. 138>0x147 byte 0x00 [ROM ONLY] 139>0x147 byte 0x01 [MBC1] 140>0x147 byte 0x02 [MBC1+RAM] 141>0x147 byte 0x03 [MBC1+RAM+BATT] 142>0x147 byte 0x05 [MBC2] 143>0x147 byte 0x06 [MBC2+BATTERY] 144>0x147 byte 0x08 [ROM+RAM] 145>0x147 byte 0x09 [ROM+RAM+BATTERY] 146>0x147 byte 0x0B [MMM01] 147>0x147 byte 0x0C [MMM01+SRAM] 148>0x147 byte 0x0D [MMM01+SRAM+BATT] 149>0x147 byte 0x0F [MBC3+TIMER+BATT] 150>0x147 byte 0x10 [MBC3+TIMER+RAM+BATT] 151>0x147 byte 0x11 [MBC3] 152>0x147 byte 0x12 [MBC3+RAM] 153>0x147 byte 0x13 [MBC3+RAM+BATT] 154>0x147 byte 0x19 [MBC5] 155>0x147 byte 0x1A [MBC5+RAM] 156>0x147 byte 0x1B [MBC5+RAM+BATT] 157>0x147 byte 0x1C [MBC5+RUMBLE] 158>0x147 byte 0x1D [MBC5+RUMBLE+SRAM] 159>0x147 byte 0x1E [MBC5+RUMBLE+SRAM+BATT] 160>0x147 byte 0xFC [Pocket Camera] 161>0x147 byte 0xFD [Bandai TAMA5] 162>0x147 byte 0xFE [Hudson HuC-3] 163>0x147 byte 0xFF [Hudson HuC-1] 164 165# ROM size. 166>0x148 byte 0 \b, ROM: 256Kbit 167>0x148 byte 1 \b, ROM: 512Kbit 168>0x148 byte 2 \b, ROM: 1Mbit 169>0x148 byte 3 \b, ROM: 2Mbit 170>0x148 byte 4 \b, ROM: 4Mbit 171>0x148 byte 5 \b, ROM: 8Mbit 172>0x148 byte 6 \b, ROM: 16Mbit 173>0x148 byte 7 \b, ROM: 32Mbit 174>0x148 byte 0x52 \b, ROM: 9Mbit 175>0x148 byte 0x53 \b, ROM: 10Mbit 176>0x148 byte 0x54 \b, ROM: 12Mbit 177 178# RAM size. 179>0x149 byte 1 \b, RAM: 16Kbit 180>0x149 byte 2 \b, RAM: 64Kbit 181>0x149 byte 3 \b, RAM: 128Kbit 182>0x149 byte 4 \b, RAM: 1Mbit 183>0x149 byte 5 \b, RAM: 512Kbit 184 185#------------------------------------------------------------------------------ 186# genesis: file(1) magic for various Sega Mega Drive / Genesis ROM image and disc formats 187# Updated by David Korth <gerbilsoft@gerbilsoft.com> 188# References: 189# - https://www.retrodev.com/segacd.html 190# - http://devster.monkeeh.com/sega/32xguide1.txt 191# 192 193# Common Sega Mega Drive header format. 194# FIXME: Name fields are 48 bytes, but have spaces for padding instead of 00s. 1950 name sega-mega-drive-header 196# ROM title. (Use domestic if present; if not, use international.) 197>0x120 byte >0x20 198>>0x120 string >\0 \b: "%.16s" 199>0x120 byte <0x21 200>>0x150 string >\0 \b: "%.16s" 201# Other information. 202>0x180 string >\0 (%.14s 203>>0x110 string >\0 \b, %.16s 204>0x180 byte 0 205>>0x110 string >\0 (%.16s 206>0 byte x \b) 207 208# TODO: Check for 32X CD? 209# Sega Mega CD disc images: 2048-byte sectors. 2100 string SEGADISCSYSTEM\ \ Sega Mega CD disc image 211!:mime application/x-sega-cd-rom 212>0 use sega-mega-drive-header 213>0 byte x \b, 2048-byte sectors 2140 string SEGABOOTDISC\ \ \ \ Sega Mega CD disc image 215!:mime application/x-sega-cd-rom 216>0 use sega-mega-drive-header 217>0 byte x \b, 2048-byte sectors 218# Sega Mega CD disc images: 2352-byte sectors. 2190x10 string SEGADISCSYSTEM\ \ Sega Mega CD disc image 220!:mime application/x-sega-cd-rom 221>0x10 use sega-mega-drive-header 222>0 byte x \b, 2352-byte sectors 2230x10 string SEGABOOTDISC\ \ \ \ Sega Mega CD disc image 224!:mime application/x-sega-cd-rom 225>0x10 use sega-mega-drive-header 226>0 byte x \b, 2352-byte sectors 227 228# Sega Mega Drive, 32X, Pico, and Mega CD Boot ROM images. 2290x100 string SEGA 230>0x3C0 bequad 0x4D41525320434845 Sega 32X ROM image 231!:mime application/x-genesis-32x-rom 232>>0 use sega-mega-drive-header 233>0x3C0 bequad !0x4D41525320434845 234>>0x105 belong 0x5049434F Sega Pico ROM image 235!:mime application/x-sega-pico-rom 236>>>0 use sega-mega-drive-header 237>>0x105 belong !0x5049434F 238>>>0x180 beshort 0x4252 Sega Mega CD Boot ROM image 239!:mime application/x-genesis-rom 240>>>0x180 beshort !0x4252 Sega Mega Drive / Genesis ROM image 241!:mime application/x-genesis-rom 242>>>0 use sega-mega-drive-header 243 244#------------------------------------------------------------------------------ 245# genesis: file(1) magic for the Super MegaDrive ROM dump format 246# 247 248# NOTE: Due to interleaving, we can't display anything 249# other than the copier header information. 2500 name sega-genesis-smd-header 251>0 byte x %dx16k blocks 252>2 byte 0 \b, last in series or standalone 253>2 byte >0 \b, split ROM 254 255# "Sega Genesis" header. 2560x280 string EAGN 257>8 beshort 0xAABB Sega Mega Drive / Genesis ROM image (SMD format): 258!:mime application/x-genesis-rom 259>>0 use sega-genesis-smd-header 260 261# "Sega Mega Drive" header. 2620x280 string EAMG 263>8 beshort 0xAABB Sega Mega Drive / Genesis ROM image (SMD format): 264!:mime application/x-genesis-rom 265>>0 use sega-genesis-smd-header 266 267#------------------------------------------------------------------------------ 268# smsgg: file(1) magic for Sega Master System and Game Gear ROM images 269# Detects all Game Gear and export Sega Master System ROM images, 270# and some Japanese Sega Master System ROM images. 271# From: David Korth <gerbilsoft@gerbilsoft.com> 272# Reference: https://www.smspower.org/Development/ROMHeader 273# 274 275# General SMS header rule. 276# The SMS boot ROM checks the header at three locations. 2770 name sega-master-system-rom-header 278# Machine type. 279>0x0F byte&0xF0 0x30 Sega Master System 280!:mime application/x-sms-rom 281>0x0F byte&0xF0 0x40 Sega Master System 282!:mime application/x-sms-rom 283>0x0F byte&0xF0 0x50 Sega Game Gear 284!:mime application/x-gamegear-rom 285>0x0F byte&0xF0 0x60 Sega Game Gear 286!:mime application/x-gamegear-rom 287>0x0F byte&0xF0 0x70 Sega Game Gear 288!:mime application/x-gamegear-rom 289>0x0F default x Sega Master System / Game Gear 290!:mime application/x-sms-rom 291>0 byte x ROM image: 292# Product code. 293>0x0E byte&0xF0 0x10 1 294>0x0E byte&0xF0 0x20 2 295>0x0E byte&0xF0 0x30 3 296>0x0E byte&0xF0 0x40 4 297>0x0E byte&0xF0 0x50 5 298>0x0E byte&0xF0 0x60 6 299>0x0E byte&0xF0 0x70 7 300>0x0E byte&0xF0 0x80 8 301>0x0E byte&0xF0 0x90 9 302>0x0E byte&0xF0 0xA0 10 303>0x0E byte&0xF0 0xB0 11 304>0x0E byte&0xF0 0xC0 12 305>0x0E byte&0xF0 0xD0 13 306>0x0E byte&0xF0 0xE0 14 307>0x0E byte&0xF0 0xF0 15 308# If the product code is 5 digits, we'll need to backspace here. 309>0x0E byte&0xF0 !0 310>>0x0C leshort x \b%04x 311>0x0E byte&0xF0 0 312>>0x0C leshort x %04x 313# Revision. 314>0x0E byte&0x0F x (Rev.%02d) 315# ROM size. (Used for the boot ROM checksum routine.) 316>0x0F byte&0x0F 0x0A (8 KB) 317>0x0F byte&0x0F 0x0B (16 KB) 318>0x0F byte&0x0F 0x0C (32 KB) 319>0x0F byte&0x0F 0x0D (48 KB) 320>0x0F byte&0x0F 0x0E (64 KB) 321>0x0F byte&0x0F 0x0F (128 KB) 322>0x0F byte&0x0F 0x00 (256 KB) 323>0x0F byte&0x0F 0x01 (512 KB) 324>0x0F byte&0x0F 0x02 (1 MB) 325 326# SMS/GG header locations. 3270x7FF0 string TMR\ SEGA 328>0x7FF0 use sega-master-system-rom-header 3290x3FF0 string TMR\ SEGA 330>0x3FF0 use sega-master-system-rom-header 3310x1FF0 string TMR\ SEGA 332>0x1FF0 use sega-master-system-rom-header 333 334#------------------------------------------------------------------------------ 335# saturn: file(1) magic for the Sega Saturn disc image format. 336# From: David Korth <gerbilsoft@gerbilsoft.com> 337# 338 339# Common Sega Saturn disc header format. 340# NOTE: Title is 112 bytes, but we're only showing 32 due to space padding. 341# TODO: Release date, device information, region code, others? 3420 name sega-saturn-disc-header 343>0x60 string >\0 \b: "%.32s" 344>0x20 string >\0 (%.10s 345>>0x2A string >\0 \b, %.6s) 346>>0x2A byte 0 \b) 347 348# 2048-byte sector version. 3490 string SEGA\ SEGASATURN\ Sega Saturn disc image 350!:mime application/x-saturn-rom 351>0 use sega-saturn-disc-header 352>0 byte x (2048-byte sectors) 353# 2352-byte sector version. 3540x10 string SEGA\ SEGASATURN\ Sega Saturn disc image 355!:mime application/x-saturn-rom 356>0x10 use sega-saturn-disc-header 357>0 byte x (2352-byte sectors) 358 359#------------------------------------------------------------------------------ 360# dreamcast: file(1) magic for the Sega Dreamcast disc image format. 361# From: David Korth <gerbilsoft@gerbilsoft.com> 362# Reference: https://mc.pp.se/dc/ip0000.bin.html 363# 364 365# Common Sega Dreamcast disc header format. 366# NOTE: Title is 128 bytes, but we're only showing 32 due to space padding. 367# TODO: Release date, device information, region code, others? 3680 name sega-dreamcast-disc-header 369>0x80 string >\0 \b: "%.32s" 370>0x40 string >\0 (%.10s 371>>0x4A string >\0 \b, %.6s) 372>>0x4A byte 0 \b) 373 374# 2048-byte sector version. 3750 string SEGA\ SEGAKATANA\ Sega Dreamcast disc image 376!:mime application/x-dc-rom 377>0 use sega-dreamcast-disc-header 378>0 byte x (2048-byte sectors) 379# 2352-byte sector version. 3800x10 string SEGA\ SEGAKATANA\ Sega Dreamcast disc image 381!:mime application/x-dc-rom 382>0x10 use sega-dreamcast-disc-header 383>0 byte x (2352-byte sectors) 384 385#------------------------------------------------------------------------------ 386# dreamcast: file(1) uncertain magic for the Sega Dreamcast VMU image format 387# 3880 belong 0x21068028 Sega Dreamcast VMU game image 3890 string LCDi Dream Animator file 390 391#------------------------------------------------------------------------------ 392# z64: file(1) magic for the Z64 format N64 ROM dumps 393# Reference: http://forum.pj64-emu.com/showthread.php?t=2239 394# From: David Korth <gerbilsoft@gerbilsoft.com> 395# 3960 bequad 0x803712400000000F Nintendo 64 ROM image 397!:mime application/x-n64-rom 398>0x20 string >\0 \b: "%.20s" 399>0x3B string x (%.4s 400>0x3F byte x \b, Rev.%02u) 401 402#------------------------------------------------------------------------------ 403# v64: file(1) magic for the V64 format N64 ROM dumps 404# Same as z64 format, but with 16-bit byteswapping. 405# 4060 bequad 0x3780401200000F00 Nintendo 64 ROM image (V64) 407!:mime application/x-n64-rom 408 409#------------------------------------------------------------------------------ 410# n64-swap2: file(1) magic for the swap2 format N64 ROM dumps 411# Same as z64 format, but with swapped 16-bit words. 412# 4130 bequad 0x12408037000F0000 Nintendo 64 ROM image (wordswapped) 414!:mime application/x-n64-rom 415 416#------------------------------------------------------------------------------ 417# n64-le32: file(1) magic for the 32-bit byteswapped format N64 ROM dumps 418# Same as z64 format, but with 32-bit byteswapping. 419# 4200 bequad 0x401237800F000000 Nintendo 64 ROM image (32-bit byteswapped) 421!:mime application/x-n64-rom 422 423#------------------------------------------------------------------------------ 424# gba: file(1) magic for the Nintendo Game Boy Advance raw ROM format 425# Reference: https://problemkaputt.de/gbatek.htm#gbacartridgeheader 426# 427# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com> 428# Updated version from: David Korth <gerbilsoft@gerbilsoft.com> 429# 4304 bequad 0x24FFAE51699AA221 Game Boy Advance ROM image 431!:mime application/x-gba-rom 432>0xA0 string >\0 \b: "%.12s" 433>0xAC string x (%.6s 434>0xBC byte x \b, Rev.%02u) 435 436#------------------------------------------------------------------------------ 437# nds: file(1) magic for the Nintendo DS(i) raw ROM format 438# Reference: https://problemkaputt.de/gbatek.htm#dscartridgeheader 439# 440# Original version from: "Nelson A. de Oliveira" <naoliv@gmail.com> 441# Updated version from: David Korth <gerbilsoft@gerbilsoft.com> 442# 4430xC0 bequad 0x24FFAE51699AA221 Nintendo DS ROM image 444!:mime application/x-nintendo-ds-rom 445>0x00 string >\0 \b: "%.12s" 446>0x0C string x (%.6s 447>0x1E byte x \b, Rev.%02u) 448>0x12 byte 2 (DSi enhanced) 449>0x12 byte 3 (DSi only) 450# Secure Area check. 451>0x20 lelong <0x4000 (homebrew) 452>0x20 lelong >0x3FFF 453>>0x4000 lequad 0x0000000000000000 (multiboot) 454>>0x4000 lequad !0x0000000000000000 455>>>0x4000 lequad 0xE7FFDEFFE7FFDEFF (decrypted) 456>>>0x4000 lequad !0xE7FFDEFFE7FFDEFF 457>>>>0x1000 lequad 0x0000000000000000 (encrypted) 458>>>>0x1000 lequad !0x0000000000000000 (mask ROM) 459 460#------------------------------------------------------------------------------ 461# nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot. 462# This is also used for loading .nds files using the MSET exploit on 3DS. 463# Reference: https://github.com/devkitPro/ndstool/blob/master/source/ndscreate.cpp 4640xC0 bequad 0xC8604FE201708FE2 Nintendo DS Slot-2 ROM image (PassMe) 465!:mime application/x-nintendo-ds-rom 466 467#------------------------------------------------------------------------------ 468# ngp: file(1) magic for the Neo Geo Pocket (Color) raw ROM format. 469# From: David Korth <gerbilsoft@gerbilsoft.com> 470# References: 471# - https://neogpc.googlecode.com/svn-history/r10/trunk/src/core/neogpc.cpp 472# - https://www.devrs.com/ngp/files/ngpctech.txt 473# 4740x0A string BY\ SNK\ CORPORATION Neo Geo Pocket 475!:mime application/x-neo-geo-pocket-rom 476>0x23 byte 0x10 Color 477>0 byte x ROM image 478>0x24 string >\0 \b: "%.12s" 479>0x1F byte 0xFF (debug mode enabled) 480 481#------------------------------------------------------------------------------ 482# msx: file(1) magic for MSX game cartridge dumps 483# Too simple - MPi 484#0 beshort 0x4142 MSX game cartridge dump 485 486#------------------------------------------------------------------------------ 487# Sony Playstation executables (Adam Sjoegren <asjo@diku.dk>) : 4880 string PS-X\ EXE Sony Playstation executable 489>16 lelong x PC=0x%08x, 490>20 lelong !0 GP=0x%08x, 491>24 lelong !0 .text=[0x%08x, 492>>28 lelong x \b0x%x], 493>32 lelong !0 .data=[0x%08x, 494>>36 lelong x \b0x%x], 495>40 lelong !0 .bss=[0x%08x, 496>>44 lelong x \b0x%x], 497>48 lelong !0 Stack=0x%08x, 498>48 lelong =0 No Stack!, 499>52 lelong !0 StackSize=0x%x, 500#>76 string >\0 (%s) 501# Area: 502>113 string x (%s) 503 504# CPE executables 5050 string CPE CPE executable 506>3 byte x (version %d) 507 508#------------------------------------------------------------------------------ 509# Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@cc.hut.fi>) 5100 string XBEH Microsoft Xbox executable 511!:mime audio/x-xbox-executable 512!:ext xbe 513# expect base address of 0x10000 514>0x0104 ulelong =0x10000 515>>(0x0118.l-0x0FFF4) lestring16 x \b: "%.40s" 516>>(0x0118.l-0x0FFF5) byte x (%c 517>>(0x0118.l-0x0FFF6) byte x \b%c- 518>>(0x0118.l-0x0FFF8) uleshort x \b%03u) 519>>(0x0118.l-0x0FF60) ulelong&0x80000007 0x80000007 \b, all regions 520>>(0x0118.l-0x0FF60) ulelong&0x80000007 !0x80000007 521>>>(0x0118.l-0x0FF60) ulelong >0 (regions: 522>>>>(0x0118.l-0x0FF60) ulelong &0x00000001 NA 523>>>>(0x0118.l-0x0FF60) ulelong &0x00000002 Japan 524>>>>(0x0118.l-0x0FF60) ulelong &0x00000004 Rest_of_World 525>>>>(0x0118.l-0x0FF60) ulelong &0x80000000 Manufacturer 526>>>(0x0118.l-0x0FF60) ulelong >0 \b) 527# probabilistic checks whether signed or not 528>0x0004 ulelong =0x0 529>>&2 ulelong =0x0 530>>>&2 ulelong =0x0 \b, not signed 531>0x0004 ulelong >0 532>>&2 ulelong >0 533>>>&2 ulelong >0 \b, signed 534 535# -------------------------------- 536# Microsoft Xbox data file formats 5370 string XIP0 XIP, Microsoft Xbox data 5380 string XTF0 XTF, Microsoft Xbox data 539 540#------------------------------------------------------------------------------ 541# Microsoft Xbox 360 executables (.xex) 542# From: David Korth <gerbilsoft@gerbilsoft.com> 543# References: 544# - https://free60project.github.io/wiki/XEX.html 545# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h 546 547# Title ID (part of Execution ID section) 5480 name xbox-360-xex-execution-id 549>(0.L+0xC) byte x (%c 550>(0.L+0xD) byte x \b%c 551>(0.L+0xE) beshort x \b-%04u, media ID: 552>(0.L) belong x %08X) 553 554# Region code (part of Security Info) 5550 name xbox-360-xex-region-code 556>0 ubelong 0xFFFFFFFF \b, all regions 557>0 ubelong !0xFFFFFFFF 558>>0 ubelong >0 (regions: 559>>0 ubelong&0x000000FF 0x000000FF USA 560>>0 ubelong&0x00000100 0x00000100 Japan 561>>0 ubelong&0x00000200 0x00000200 China 562>>0 ubelong&0x0000FC00 0x0000FC00 Asia 563>>0 ubelong&0x00FF0000 0x00FF0000 PAL 564>>0 ubelong&0x00FF0000 0x00FE0000 PAL [except AU/NZ] 565>>0 ubelong&0x00FF0000 0x00010000 AU/NZ 566>>0 ubelong&0xFF000000 0xFF000000 Other 567>>0 ubelong >0 \b) 568 5690 string XEX2 Microsoft Xbox 360 executable 570!:mime audio/x-xbox360-executable 571!:ext xex 572>0x18 search/0x100 \x00\x04\x00\x06 573>>&0 use xbox-360-xex-execution-id 574>(0x010.L+0x178) use xbox-360-xex-region-code 575 5760 string XEX1 Microsoft Xbox 360 executable (XEX1) 577!:mime audio/x-xbox360-executable 578!:ext xex 579>0x18 search/0x100 \x00\x04\x00\x06 580>>&0 use xbox-360-xex-execution-id 581>(0x010.L+0x154) use xbox-360-xex-region-code 582 583#------------------------------------------------------------------------------ 584# Microsoft Xbox 360 packages 585# From: David Korth <gerbilsoft@gerbilsoft.com> 586# References: 587# - https://free60project.github.io/wiki/STFS.html 588# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h 589 590# TODO: More information for console-signed packages. 591 5920 name xbox-360-package 593>0x360 byte x (%c 594>0x361 byte x \b%c 595>0x362 beshort x \b-%04u, media ID: 596>0x354 belong x %08X) 597>0x344 belong x \b, content type: 598>>0x344 belong 0x1 Saved Game 599>>0x344 belong 0x2 Marketplace Content 600>>0x344 belong 0x3 Publisher 601>>0x344 belong 0x1000 Xbox 360 Title 602>>0x344 belong 0x2000 IPTV Pause Buffer 603>>0x344 belong 0x4000 Installed Game 604>>0x344 belong 0x5000 Original Xbox Game 605>>0x344 belong 0x9000 Avatar Item 606>>0x344 belong 0x10000 Profile 607>>0x344 belong 0x20000 Gamer Picture 608>>0x344 belong 0x30000 Theme 609>>0x344 belong 0x40000 Cache File 610>>0x344 belong 0x50000 Storage Download 611>>0x344 belong 0x60000 Xbox Saved Game 612>>0x344 belong 0x70000 Xbox Download 613>>0x344 belong 0x80000 Game Demo 614>>0x344 belong 0x90000 Video 615>>0x344 belong 0xA0000 Game 616>>0x344 belong 0xB0000 Installer 617>>0x344 belong 0xC0000 Game Trailer 618>>0x344 belong 0xD0000 Arcade Title 619>>0x344 belong 0xE0000 XNA 620>>0x344 belong 0xF0000 License Store 621>>0x344 belong 0x100000 Movie 622>>0x344 belong 0x200000 TV 623>>0x344 belong 0x300000 Music Video 624>>0x344 belong 0x400000 Game Video 625>>0x344 belong 0x500000 Podcast Video 626>>0x344 belong 0x600000 Viral Video 627>>0x344 belong 0x2000000 Community Game 628 6290 string CON\x20 Microsoft Xbox 360 package (console-signed) 630>0 use xbox-360-package 6310 string PIRS Microsoft Xbox 360 package (non-Xbox Live) 632>0 use xbox-360-package 6330 string LIVE Microsoft Xbox 360 package (Xbox Live) 634>0 use xbox-360-package 635 636# Atari Lynx cartridge dump (EXE/BLL header) 637# From: "Stefan A. Haubenthal" <polluks@web.de> 638 639# Double-check that the image type matches too, 0x8008 conflicts with 640# 8 character OMF-86 object file headers. 6410 beshort 0x8008 642>6 string BS93 Lynx homebrew cartridge 643!:mime application/x-atari-lynx-rom 644>>2 beshort x \b, RAM start $%04x 645>6 string LYNX Lynx cartridge 646!:mime application/x-atari-lynx-rom 647>>2 beshort x \b, RAM start $%04x 648 649# Opera file system that is used on the 3DO console 650# From: Serge van den Boom <svdb@stack.nl> 6510 string \x01ZZZZZ\x01 3DO "Opera" file system 652 653# From: Alex Myczko <alex@aiei.ch> 654# From: David Pflug <david@pflug.email> 655# is the offset 12 or the offset 16 correct? 656# GBS (Game Boy Sound) magic 657# ftp://ftp.modland.com/pub/documents/format_documentation/\ 658# Gameboy%20Sound%20System%20(.gbs).txt 6590 string GBS Nintendo Gameboy Music/Audio Data 660#12 string GameBoy\ Music\ Module Nintendo Gameboy Music Module 661>16 string >\0 ("%.32s" by 662>48 string >\0 %.32s, copyright 663>80 string >\0 %.32s), 664>3 byte x version %u, 665>4 byte x %u tracks 666 667# IPS Patch Files from: From: Thomas Klausner <tk@giga.or.at> 668# see https://zerosoft.zophar.net/ips.php 6690 string PATCH IPS patch file 670 671# Playstations Patch Files from: From: Thomas Klausner <tk@giga.or.at> 6720 string PPF30 Playstation Patch File version 3.0 673>5 byte 0 \b, PPF 1.0 patch 674>5 byte 1 \b, PPF 2.0 patch 675>5 byte 2 \b, PPF 3.0 patch 676>>56 byte 0 \b, Imagetype BIN (any) 677>>56 byte 1 \b, Imagetype GI (PrimoDVD) 678>>57 byte 0 \b, Blockcheck disabled 679>>57 byte 1 \b, Blockcheck enabled 680>>58 byte 0 \b, Undo data not available 681>>58 byte 1 \b, Undo data available 682>6 string x \b, description: %s 683 6840 string PPF20 Playstation Patch File version 2.0 685>5 byte 0 \b, PPF 1.0 patch 686>5 byte 1 \b, PPF 2.0 patch 687>>56 lelong >0 \b, size of file to patch %d 688>6 string x \b, description: %s 689 6900 string PPF10 Playstation Patch File version 1.0 691>5 byte 0 \b, Simple Encoding 692>6 string x \b, description: %s 693 694# From: Daniel Dawson <ddawson@icehouse.net> 695# SNES9x .smv "movie" file format. 6960 string SMV\x1A SNES9x input recording 697>0x4 lelong x \b, version %d 698# version 4 is latest so far 699>0x4 lelong <5 700>>0x8 ledate x \b, recorded at %s 701>>0xc lelong >0 \b, rerecorded %d times 702>>0x10 lelong x \b, %d frames long 703>>0x14 byte >0 \b, data for controller(s): 704>>>0x14 byte &0x1 #1 705>>>0x14 byte &0x2 #2 706>>>0x14 byte &0x4 #3 707>>>0x14 byte &0x8 #4 708>>>0x14 byte &0x10 #5 709>>0x15 byte ^0x1 \b, begins from snapshot 710>>0x15 byte &0x1 \b, begins from reset 711>>0x15 byte ^0x2 \b, NTSC standard 712>>0x15 byte &0x2 \b, PAL standard 713>>0x17 byte &0x1 \b, settings: 714# WIP1Timing not used as of version 4 715>>>0x4 lelong <4 716>>>>0x17 byte &0x2 WIP1Timing 717>>>0x17 byte &0x4 Left+Right 718>>>0x17 byte &0x8 VolumeEnvX 719>>>0x17 byte &0x10 FakeMute 720>>>0x17 byte &0x20 SyncSound 721# New flag as of version 4 722>>>0x4 lelong >3 723>>>>0x17 byte &0x80 NoCPUShutdown 724>>0x4 lelong <4 725>>>0x18 lelong >0x23 726>>>>0x20 leshort !0 727>>>>>0x20 lestring16 x \b, metadata: "%s" 728>>0x4 lelong >3 729>>>0x24 byte >0 \b, port 1: 730>>>>0x24 byte 1 joypad 731>>>>0x24 byte 2 mouse 732>>>>0x24 byte 3 SuperScope 733>>>>0x24 byte 4 Justifier 734>>>>0x24 byte 5 multitap 735>>>0x24 byte >0 \b, port 2: 736>>>>0x25 byte 1 joypad 737>>>>0x25 byte 2 mouse 738>>>>0x25 byte 3 SuperScope 739>>>>0x25 byte 4 Justifier 740>>>>0x25 byte 5 multitap 741>>>0x18 lelong >0x43 742>>>>0x40 leshort !0 743>>>>>0x40 lestring16 x \b, metadata: "%s" 744>>0x17 byte &0x40 \b, ROM: 745>>>(0x18.l-26) lelong x CRC32 0x%08x 746>>>(0x18.l-23) string x "%s" 747 748# Type: scummVM savegame files 749# From: Sven Hartge <debian@ds9.argh.org> 7500 string SCVM ScummVM savegame 751>12 string >\0 "%s" 752 753#------------------------------------------------------------------------------ 754# Nintendo GameCube / Wii file formats. 755# 756 757# Type: Nintendo GameCube/Wii common disc header data. 758# From: David Korth <gerbilsoft@gerbilsoft.com> 759# Reference: https://wiibrew.org/wiki/Wii_Disc 7600 name nintendo-gcn-disc-common 761>0x20 string x "%.64s" 762>0x00 string x (%.6s 763>0x06 byte >0 764>>0x06 byte 1 \b, Disc 2 765>>0x06 byte 2 \b, Disc 3 766>>0x06 byte 3 \b, Disc 4 767>0x07 byte x \b, Rev.%02u) 768>0x18 belong 0x5D1C9EA3 769>>0x60 beshort 0x0101 \b (Unencrypted) 770 771# Type: Nintendo GameCube disc image 772# From: David Korth <gerbilsoft@gerbilsoft.com> 773# Reference: https://wiibrew.org/wiki/Wii_Disc 7740x1C belong 0xC2339F3D Nintendo GameCube disc image: 775!:mime application/x-gamecube-rom 776>0 use nintendo-gcn-disc-common 777 778# Type: Nintendo GameCube embedded disc image 779# Commonly found on demo discs. 780# From: David Korth <gerbilsoft@gerbilsoft.com> 781# Reference: http://hitmen.c02.at/files/yagcd/yagcd/index.html#idx14.8 7820 belong 0xAE0F38A2 783>0x0C belong 0x00100000 784>>(8.L+0x1C) belong 0xC2339F3D Nintendo GameCube embedded disc image: 785!:mime application/x-gamecube-rom 786>>>(8.L) use nintendo-gcn-disc-common 787 788# Type: Nintendo Wii disc image 789# From: David Korth <gerbilsoft@gerbilsoft.com> 790# Reference: https://wiibrew.org/wiki/Wii_Disc 7910x18 belong 0x5D1C9EA3 Nintendo Wii disc image: 792>0 use nintendo-gcn-disc-common 793 794# Type: Nintendo Wii disc image (WBFS format) 795# From: David Korth <gerbilsoft@gerbilsoft.com> 796# Reference: https://wiibrew.org/wiki/Wii_Disc 7970 string WBFS 798>0x218 belong 0x5D1C9EA3 Nintendo Wii disc image (WBFS format): 799!:mime application/x-wii-rom 800>>0x200 use nintendo-gcn-disc-common 801 802# Type: Nintendo GameCube/Wii disc image (CISO format) 803# NOTE: This is NOT the same as Compact ISO or PSP CISO, 804# though it has the same magic number. 8050 string CISO 806# Other fields are used to determine what type of CISO this is: 807# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size) 808# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size) 809# - None of the above: Compact ISO. 810>4 lelong 0x200000 811>>8 byte 1 812>>>0x801C belong 0xC2339F3D Nintendo GameCube disc image (CISO format): 813!:mime application/x-wii-rom 814>>>>0x8000 use nintendo-gcn-disc-common 815>>>0x8018 belong 0x5D1C9EA3 Nintendo Wii disc image (CISO format): 816!:mime application/x-wii-rom 817>>>>0x8000 use nintendo-gcn-disc-common 818 819# Type: Nintendo GameCube/Wii disc image (GCZ format) 820# Due to zlib compression, we can't get the actual disc information. 8210 lelong 0xB10BC001 822>4 lelong 0 Nintendo GameCube disc image (GCZ format) 823!:mime application/x-gamecube-rom 824>4 lelong 1 Nintendo Wii disc image (GCZ format) 825!:mime application/x-wii-rom 826>4 default x Nintendo GameCube/Wii disc image (GCZ format) 827 828# Type: Nintendo GameCube/Wii disc image (WDF format) 8290 string WII\001DISC 830>8 belong 1 831# WDFv1 832>>0x54 belong 0xC2339F3D Nintendo GameCube disc image (WDFv1 format): 833!:mime application/x-gamecube-rom 834>>>0x38 use nintendo-gcn-disc-common 835>>0x58 belong 0x5D1C9EA3 Nintendo Wii disc image (WDFv1 format): 836!:mime application/x-wii-rom 837>>>0x38 use nintendo-gcn-disc-common 838>8 belong 2 839# WDFv2 840>>(12.L+0x1C) belong 0xC2339F3D Nintendo GameCube disc image (WDFv2 format): 841!:mime application/x-gamecube-rom 842>>>(12.L) use nintendo-gcn-disc-common 843>>(12.L+0x18) belong 0x5D1C9EA3 Nintendo Wii disc image (WDFv2 format): 844!:mime application/x-wii-rom 845>>>(12.L) use nintendo-gcn-disc-common 846 847# Type: Nintendo GameCube/Wii disc image (WIA format) 8480 string WIA\001 Nintendo 849>0x48 belong 1 GameCube 850!:mime application/x-gamecube-rom 851>0x48 belong 2 Wii 852!:mime application/x-wii-rom 853>0x48 default x GameCube/Wii 854>0x48 belong x disc image (WIA format): 855>>0x58 use nintendo-gcn-disc-common 856 857# Type: Nintendo GameCube/Wii disc image (with SDK header) 858# From: David Korth <gerbilsoft@gerbilsoft.com> 859# Reference: https://wiibrew.org/wiki/Wii_Disc 8600 belong 0xFFFF0000 861>0x18 belong 0x00000000 862>>0x1C belong 0x00000000 863>>>0x8018 belong 0x5D1C9EA3 Nintendo Wii SDK disc image: 864!:mime application/x-wii-rom 865>>>>0x8000 use nintendo-gcn-disc-common 866>>>0x801C belong 0xC2339F3D Nintendo GameCube SDK disc image: 867!:mime application/x-gamecube-rom 868>>>>0x8000 use nintendo-gcn-disc-common 869 870#------------------------------------------------------------------------------ 871# Nintendo 3DS file formats. 872# 873 874# Type: Nintendo 3DS "NCSD" image. (game cards and eMMC) 875# From: David Korth <gerbilsoft@gerbilsoft.com> 876# Reference: https://www.3dbrew.org/wiki/NCSD 8770x100 string NCSD 878>0x118 lequad 0 Nintendo 3DS Game Card image 879# NCCH header for partition 0. (game data) 880>>0x1150 string >\0 \b: "%.16s" 881>>0x312 byte x (Rev.%02u) 882>>0x118C byte 2 (New3DS only) 883>>0x18D byte 0 (inner device) 884>>0x18D byte 1 (Card1) 885>>0x18D byte 2 (Card2) 886>>0x18D byte 3 (extended device) 887>0x118 bequad 0x0102020202000000 Nintendo 3DS eMMC dump (Old3DS) 888>0x118 bequad 0x0102020203000000 Nintendo 3DS eMMC dump (New3DS) 889 890# Nintendo 3DS version code. 891# Reference: https://www.3dbrew.org/wiki/Titles 892# Format: leshort containing three fields: 893# - 6-bit: Major 894# - 6-bit: Minor 895# - 4-bit: Revision 896# NOTE: Only supporting major/minor versions from 0-15 right now. 897# NOTE: Should be prefixed with "v". 8980 name nintendo-3ds-version-code 899# Raw version. 900>0 leshort x \b%u, 901# Major version. 902>0 leshort&0xFC00 0x0000 0 903>0 leshort&0xFC00 0x0400 1 904>0 leshort&0xFC00 0x0800 2 905>0 leshort&0xFC00 0x0C00 3 906>0 leshort&0xFC00 0x1000 4 907>0 leshort&0xFC00 0x1400 5 908>0 leshort&0xFC00 0x1800 6 909>0 leshort&0xFC00 0x1C00 7 910>0 leshort&0xFC00 0x2000 8 911>0 leshort&0xFC00 0x2400 9 912>0 leshort&0xFC00 0x2800 10 913>0 leshort&0xFC00 0x2C00 11 914>0 leshort&0xFC00 0x3000 12 915>0 leshort&0xFC00 0x3400 13 916>0 leshort&0xFC00 0x3800 14 917>0 leshort&0xFC00 0x3C00 15 918# Minor version. 919>0 leshort&0x03F0 0x0000 \b.0 920>0 leshort&0x03F0 0x0010 \b.1 921>0 leshort&0x03F0 0x0020 \b.2 922>0 leshort&0x03F0 0x0030 \b.3 923>0 leshort&0x03F0 0x0040 \b.4 924>0 leshort&0x03F0 0x0050 \b.5 925>0 leshort&0x03F0 0x0060 \b.6 926>0 leshort&0x03F0 0x0070 \b.7 927>0 leshort&0x03F0 0x0080 \b.8 928>0 leshort&0x03F0 0x0090 \b.9 929>0 leshort&0x03F0 0x00A0 \b.10 930>0 leshort&0x03F0 0x00B0 \b.11 931>0 leshort&0x03F0 0x00C0 \b.12 932>0 leshort&0x03F0 0x00D0 \b.13 933>0 leshort&0x03F0 0x00E0 \b.14 934>0 leshort&0x03F0 0x00F0 \b.15 935# Revision. 936>0 leshort&0x000F x \b.%u 937 938# Type: Nintendo 3DS "NCCH" container. 939# https://www.3dbrew.org/wiki/NCCH 9400x100 string NCCH Nintendo 3DS 941>0x18D byte&2 0 File Archive (CFA) 942>0x18D byte&2 2 Executable Image (CXI) 943>0x150 string >\0 \b: "%.16s" 944>0x18D byte 0x05 945>>0x10E leshort x (Old3DS System Update v 946>>0x10E use nintendo-3ds-version-code 947>>0x10E leshort x \b) 948>0x18D byte 0x15 949>>0x10E leshort x (New3DS System Update v 950>>0x10E use nintendo-3ds-version-code 951>>0x10E leshort x \b) 952>0x18D byte !0x05 953>>0x18D byte !0x15 954>>>0x112 byte x (v 955>>>0x112 use nintendo-3ds-version-code 956>>>0x112 byte x \b) 957>0x18C byte 2 (New3DS only) 958 959# Type: Nintendo 3DS "SMDH" file. (application description) 960# From: David Korth <gerbilsoft@gerbilsoft.com> 961# Reference: https://3dbrew.org/wiki/SMDH 9620 string SMDH Nintendo 3DS SMDH file 963>0x208 leshort !0 964>>0x208 lestring16 x \b: "%.128s" 965>>0x388 leshort !0 966>>>0x388 lestring16 x by %.128s 967>0x208 leshort 0 968>>0x008 leshort !0 969>>>0x008 lestring16 x \b: "%.128s" 970>>>0x188 leshort !0 971>>>>0x188 lestring16 x by %.128s 972 973# Type: Nintendo 3DS Homebrew Application. 974# From: David Korth <gerbilsoft@gerbilsoft.com> 975# Reference: https://3dbrew.org/wiki/3DSX_Format 9760 string 3DSX Nintendo 3DS Homebrew Application (3DSX) 977 978#------------------------------------------------------------------------------ 979# a7800: file(1) magic for the Atari 7800 raw ROM format. 980# From: David Korth <gerbilsoft@gerbilsoft.com> 981# Reference: https://sites.google.com/site/atari7800wiki/a78-header 982 9830 byte >0 984>0 byte <3 985>>1 string ATARI7800 Atari 7800 ROM image 986!:mime application/x-atari-7800-rom 987>>>0x11 string >\0 \b: "%.32s" 988# Display type. 989>>>0x39 byte 0 (NTSC) 990>>>0x39 byte 1 (PAL) 991>>>0x36 byte&1 1 (POKEY) 992 993#------------------------------------------------------------------------------ 994# vectrex: file(1) magic for the GCE Vectrex raw ROM format. 995# From: David Korth <gerbilsoft@gerbilsoft.com> 996# Reference: http://www.playvectrex.com/designit/chrissalo/hello1.htm 997# 998# NOTE: Title is terminated with 0x80, not 0. 999# The header is terminated with a 0, so that will 1000# terminate the title as well. 1001# 10020 string g\ GCE Vectrex ROM image 1003>0x11 string >\0 \b: "%.16s" 1004 1005#------------------------------------------------------------------------------ 1006# amiibo: file(1) magic for Nintendo amiibo NFC dumps. 1007# From: David Korth <gerbilsoft@gerbilsoft.com> 1008# Reference: https://www.3dbrew.org/wiki/Amiibo 10090x00 byte 0x04 1010>0x0A beshort 0x0FE0 1011>>0x0C belong 0xF110FFEE 1012>>>0x208 beshort 0x0100 1013>>>>0x020A byte 0x0F 1014>>>>>0x020C bequad 0x000000045F000000 1015>>>>>>0x5B byte 0x02 1016>>>>>>>0x54 belong x Nintendo amiibo NFC dump - amiibo ID: %08X- 1017>>>>>>>0x58 belong x \b%08X 1018