Saturday, February 11, 2023

Where to find the Game ID in a .WBFS file

 So you have a few .wbfs files from your wii game backups. You want their IDs so you can get cheats or cover art for them. Where do you find the ID?

The ID is in the .wbfs file, at offset 512 from the beginning.

To read it, you can:

  •  Open the .wbfs file in a hex editor and go to offset 512 from the beginning. 

 

Or programmatically, you could:

  1. (Make sure the file is at least 800 bytes long, which all .wbfs files should be) and read 800 bytes into a buffer.
  2. Make sure the first 4 bytes are 'W', 'B', 'F', 'S' - without this, we can't be sure it's the expected format or may be corrupted.
  3. Bytes of indices 512 through 534 inclusive should be the ID we seek. Start reading at 512, until you reach a null byte ('\0') or have read byte 534, which is the last byte before a different section. Bam! Done!
  4. But we can also get the game title from bytes of indices 544 through 799 inclusive, again starting at 544 and ending with a '\0' or at byte 799, whichever comes first. IIRC there are more zeroes, and I don't know/didn't look up the 'official format', but the longest game title I found by googling is 103 characters. And I think that longest title is Japanese, so if we figure UTF-16 (2 bytes per char), then that's 206 bytes, but we could assume 256 just to be safe, in case there are even longer titles than the longest I found.

Bam! Now you have the game ID and title of your WBFS file.

View a working example of a console application on GitHub here

No comments:

Post a Comment

Coding Challenge #54 C++ int to std::string (no stringstream or to_string())

Gets a string from an integer (ejemplo gratis: 123 -> "123") Wanted to come up with my own function for this like 10 years ago ...