Download a file in the ISO 9660 file system

I just finished reading this article on reading files in the ISO 9660 file system, and I'm confused about how I will read the file into memory. I understand that the root directory is at offset 156, PVD, how would I use this to find the file that is in the root directory, and as soon as I find the file name, how to find the address where the file is located, so that I could load it into memory (using int 0x13 AH = 42)?

+4
source share
1 answer

The BIOS cannot directly work with CDs through int 13h; only floppy disks and hard drives can access them directly using the int 13h function. If you boot from the CD (if your BIOS supports this), you can use int 13h to access the CD, but then the only option that is guaranteed to work is an emulation mode in which you will not get access to everything CD, but the boot image, as if it were FDD or HDD (in this case, the BIOS usually assigns the drive number 0 or 80h to the emulated drive AKA A: and C: . This issue is discussed here .

You may need to write a CD driver to directly read data from it through the I / O ports.

As for ISO9660, you need to read the Directory entry for the root directory from the Primary Volume Descriptor (which is at a distance of 156). Then you are interested in Location of extent (LBA) (offset 2) and Data length (size of extent) (offset 10) from Directory entry for the root directory . They tell you where the directory data is (list of files / dirs) and how large they are.

This list is basically a list of the same directory entries that are variable in length (due to the variable length of the / dir file and the padding). When you read it, you need to look at the File flags each entry to determine if it is a file or directory. If this is a directory and you want to access it, you repeat the entire procedure recursively. If it is a file, Location of extent (LBA) (offset 2) and Data length (size of extent) (offset 10) tell you where it is and how big it is.

I hope I haven’t messed it up because I don’t have my old CD code.

Oh, and be warned, this is a very simplified description of how you should read CDs, most CDs, but not all. FS is overly general and complex, and there are many features and options that make it difficult to read correctly in all situations.

I suggest you get a few .iso files, a hex editor and a calculator and double check the logic and get to know the file system better.

+7
source

Source: https://habr.com/ru/post/1401728/


All Articles