Offset to Disk information

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
d4n1l0d
Member
Member
Posts: 42
Joined: Sat Dec 02, 2006 4:12 pm

Offset to Disk information

Post by d4n1l0d »

How can I know the disk information (the cluster , side and track number ) of any OFFSET ( like 0x3533 ) ???
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

Here is a little C that will extract that information. LBA is the offset from the start of the disk in sectors (0 based). The rest looks pretty easy to figure out.

Code: Select all

cylinder = LBA / ( heads_per_cylinder * sectors_per_track );
head = ( LBA / sectors_per_track ) % heads_per_cylinder;
sector = ( LBA % sectors_per_track ) + 1;
And here is some code to reverse the process.

Code: Select all

LBA = ( (cylinder * heads_per_cylinder + heads ) * sectors_per_track ) + sector - 1;
User avatar
d4n1l0d
Member
Member
Posts: 42
Joined: Sat Dec 02, 2006 4:12 pm

Post by d4n1l0d »

Ok! Thank you!!!!
Ninjarider
Member
Member
Posts: 62
Joined: Fri Jun 29, 2007 8:36 pm

Post by Ninjarider »

thnx. thought that is how it was done. must remember.
Post Reply