Darwin weird or my fault?
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: Darwin weird or my fault?
I just load the first sector of each partition, and compare it to the boot loader. This works mostly for two reasons: The chances of having the actual OS bootloader (instead of a stub one) on a partition are slim, and the FAT contains a (theoretically) unique ID in the BPB. My bootsector depends on the fact that the MBR/boot manager simply loads the bootsector without modifying it. Once I find myself, I add the partition start offset to the two fields that need it, and work from there.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Re: Darwin weird or my fault?
it also contains (theoretically) the offset of the start of partition... (its called 'HiddenSectorsEx' although the specification no longer states its purpose, it does say that MS uses it to define the offset of the current partitionFirestryke31 wrote: and the FAT contains a (theoretically) unique ID in the BPB.
of course, the bootsector should never be modified... but im wondering, what fields need to be altered? if your using the correct formula (DATAareaStart = HiddenSectorsEx+ReservedSectors+(FATcopies*SectorsPerFAT) ), you shouldnt need to adjust anything (at least in theory...) because HiddenSectorsEx contains (or is supposed to contain) the offset of the partition from StartOfDiskMy bootsector depends on the fact that the MBR/boot manager simply loads the bootsector without modifying it. Once I find myself, I add the partition start offset to the two fields that need it, and work from there.
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: Darwin weird or my fault?
I not changing anything (I'm not at the 'writing to disk' point yet), but I didn't know about the HiddenSectorsEx thing, so I just figure out the offset from the partition table. I just was talking about whatever runs before my boot sector does, which could be the BIOS, or Darwin, or the standard MS MBR, etc. Of course, if a boot manager modifies the boot sector, then the boot manager is broken and should never be used. Does the HiddenSectorsEx field work even if it's an extended partition? I would think so, but I've learned never to assume anything.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Re: Darwin weird or my fault?
its supposed to...
basically, HiddenSector (and HiddenSectorEx) is the number of sectors 'hidden' from the filesystem... MS uses this value to point to the offset of the bootsector from start of disk, since these sectors are effectively 'hidden' from the filesystem, as opposed to ReservedSectors which indicates the number of sectors 'reserved' for use by the filesystem (or, more accurately, generally reserved for the bootloader)
therefore, when you add these 2 numbers together, you find the first available sector within the filesystem, which (under FAT) will be used for the first of the FAT tables...
NTFS uses a similer (semi-compatible, but simplified) bpb as FAT does, so vista may just be using this value, and comparing it to the start of partition value to determine which partition you booted from... although i know win95 under FAT32 just looked for the active partition -- at least the boot sector did... though im not sure what it did with that information...
basically, HiddenSector (and HiddenSectorEx) is the number of sectors 'hidden' from the filesystem... MS uses this value to point to the offset of the bootsector from start of disk, since these sectors are effectively 'hidden' from the filesystem, as opposed to ReservedSectors which indicates the number of sectors 'reserved' for use by the filesystem (or, more accurately, generally reserved for the bootloader)
therefore, when you add these 2 numbers together, you find the first available sector within the filesystem, which (under FAT) will be used for the first of the FAT tables...
NTFS uses a similer (semi-compatible, but simplified) bpb as FAT does, so vista may just be using this value, and comparing it to the start of partition value to determine which partition you booted from... although i know win95 under FAT32 just looked for the active partition -- at least the boot sector did... though im not sure what it did with that information...