Page 1 of 1
Bootsector
Posted: Thu Jun 20, 2002 4:12 pm
by beyondsociety
I have a bootsector and I want it to search for a certain file and then load it. I know how to seach for a certain file in assembly but I don't know how to load it and then use it. The file I want to search for and then load is my own filesystem. If its not found then it will continue and load the fat filesystem and then jump to the kernel.
If someone could help me out I would appreciate it.
Re:Bootsector
Posted: Fri Jun 21, 2002 1:11 am
by Pype.Clicker
Well, once you know the position of your "file" or "filesystem image" (whatever you wish to load) in terms of sector position on your disk (i assume you have it as you told you already "found" your file
), all you have to do is reading the proper amount of sectors from that position (if your file is contiguous - in case of a fragmented FAT file, things becomes a bit more complicated: look at the FAT to know the sequence of sectors that are to be read) with your target address (es:bx) that increases in memory from a well-known (chosen by you) initial position.
I won't give any code for sector reading: there are much well-done and comprehensive ones in the tutorials of this board, including
here
Re:Bootsector
Posted: Fri Jun 21, 2002 5:48 pm
by Schol-R-LEA
When we were discussing the boot sector you wrote
in an earlier thread, I forgot an important piece of information:
Microsoft cheats.
The MS-DOS boot loader does not, in fact, read the FAT tables at all. Rather, the Format and Sys utilities makes sure when installing the system files that the DOS 'kernel image', IO.SYS, is the first file in the root directory, and is contiguous and of a known size. The information needed to load it is in the DIB, by calculating the end of the last FAT table by multiplying TotalFATs by SectorsPerFAT (your variable names) and reading a fixed number of sectors (dependent on the version of DOS or Windows) following that.
In
WIn95b and later, this is no longer true, as IO.SYS is now no longer in a privileged location; but the reserved area is increased to three sectors, meaning that the boot record has considerably more code space to work in.
In other words, you tried to do something unneccessarily hard - and succeeded. Not too bad.
I cannot verifiy the absolute correctness of all of this information; corrections are appreciated.