User Tools

Site Tools


using_the_fnt_and_fat_to_locate_files

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
using_the_fnt_and_fat_to_locate_files [2024/08/15 19:15] – created zero_oneusing_the_fnt_and_fat_to_locate_files [2024/08/29 19:54] (current) – [Reading the FNT] zero_one
Line 10: Line 10:
  
 ===== Reading the FNT ===== ===== Reading the FNT =====
-As stated before, the FNT starts with a list of directories, then a list of entries containing further sub-entries. The list of directories is always found first.+As stated before, the FNT starts with a list of directories, then a list of entries containing the files or folders for each directory. The list of directories is always found first.
  
 ==== Directory and Entries Count ==== ==== Directory and Entries Count ====
Line 19: Line 19:
   * Offset - 4 bytes - An offset from the beginning of the FNT for the first entry in this directory   * Offset - 4 bytes - An offset from the beginning of the FNT for the first entry in this directory
   * FirstID - 2 bytes - The ID of the first file in the sub-table pointed to by the Offset. A directory entry will only ever point at the first file.   * FirstID - 2 bytes - The ID of the first file in the sub-table pointed to by the Offset. A directory entry will only ever point at the first file.
-  * ParentID - 2 bytes - If this is the first directory in the table, then this value is the number of directories in the list. Else, it's the ID of the parent directory that this directory is in. This is how sub-folders work. Directory IDs exist in the range 0xF000-0xFFFF.+  * ParentID - 2 bytes - If this is the first directory in the table, then this value is the number of directories in the list. Else, it's the ID of the parent directory that this directory is in. This is how sub-folders work. Directory IDs exist in the range 0xF000-0xFFFF, where directory F000 is the root directory. This is only relevant for directories, not actual files.
  
 {{mph_nrfs_directory_structure.png}} {{mph_nrfs_directory_structure.png}}
Line 57: Line 57:
 {{mph_nrfs_directory_containing_file.png}} {{mph_nrfs_directory_containing_file.png}}
  
-From this, we can see several things. First is the offset: 0x3DD. Taking our FNT offset of 0x163A00 and adding 0x3DD to it gives us 0x163DDD, which is the location of the first file entry in the entries table. We've just gone backwards from that. Secondly, we can see a parentID of 0xF000. This mean that this directory sits in directory 0xF000 - or the root directory. And finally, the firstID has a value of 0x13. This is not the ID of the file we're looking for, this is the ID of the first file in the directory. It's also an offset in the FAT table for that first file.+From this, we can see several things. First is the offset: 0x3DD. Taking our FNT offset of 0x163A00 and adding 0x3DD to it gives us 0x163DDD, which is the location of the first file entry in the entries table. We've just gone backwards from that. Secondly, we can see a parentID of 0xF000. Since this is a file, not a folder, we can ignore this. The actual parent folder ID is 0xF000 + 2; the 2 is because it'the third list of entries, but we start counting at 0. And finally, the firstID has a value of 0x13. This is not the ID of the file we're looking for, this is the ID of the first file in the directory. It's also an offset in the FAT table for that first file.
  
 So how do we get the offset for our file? The directory structure gives us the ID of the first file in the directory. Subsequent files are found by simply incrementing that ID. We know that the file we're looking for was the fourth file in our list of entries, so we just add 3 to our first ID to get a value of 0x16, or 22 in decimal. So how do we get the offset for our file? The directory structure gives us the ID of the first file in the directory. Subsequent files are found by simply incrementing that ID. We know that the file we're looking for was the fourth file in our list of entries, so we just add 3 to our first ID to get a value of 0x16, or 22 in decimal.
using_the_fnt_and_fat_to_locate_files.1723749358.txt.gz · Last modified: 2024/08/15 19:15 by zero_one