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.
Bootsector
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Bootsector
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
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
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.
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.