In tutorial 6 i can't understand the piece of code where we load file stage2 into memory.First of all how do we check if the next cluster to read is contiguous to the current one? In other words how do we know that the next contiguous cluster is the one we want to read and load?
code:
mov WORD [cluster], dx ; store new cluster
cmp dx, 0x0FF0 ; test for end of file
jb LOAD_IMAGE ; we are not done yet--go to next cluster
We just check for end-of-file, not where the next cluster to read is.
I don't understand this because i think that a file located at FAT is not at contiguous clusters but is fragmented.
Thanks in advance.
Find all stage2 clusters
Moderator:Moderators
Re: Find all stage2 clusters
It is fragmented. That is the point of the FAT table. To find the fragments.
-
- Posts:18
- Joined:Tue Feb 01, 2011 6:25 pm
Re: Find all stage2 clusters
I know that, what i don't know how to find the next cluster without checking the entry.
Re: Find all stage2 clusters
The FAT is a table pointing to the next cluster.
An overview is like this:
Read the root directory, find a file which has a pointer to the first cluster.
Load the referenced cluster
Look up the entry for that cluster in the FAT.
This is either EOF or the next cluster in the file.
Loop until EOF
The thing to note is that the 1st entry in the FAT is the next cluster for whichever file contains the 1st cluster.
~Andrew
An overview is like this:
Read the root directory, find a file which has a pointer to the first cluster.
Load the referenced cluster
Look up the entry for that cluster in the FAT.
This is either EOF or the next cluster in the file.
Loop until EOF
The thing to note is that the 1st entry in the FAT is the next cluster for whichever file contains the 1st cluster.
~Andrew
