1

I would ask about the possibility of determining which operating system is installed in a hard drive using direct read of sectors information? If, what sector should I read and how can I specify a sector and then read data from it programatically (useful APIs)?

Also, can I write a code works to do that even if its host system is working in a virtual machine?

2
  • Why do you want to do that? Are you writing a boot loader? What if your OS (windows) is executed inside a virtual machine? Nov 12, 2011 at 18:42
  • I am just trying to code that for learning purpose. And regarding to VM issue actually I don't know but it is a good question in view of me! I will edit to add this point!
    – Aan
    Nov 12, 2011 at 18:59

1 Answer 1

2

You can get a pretty good guess by reading the master boot record and looking at the partition type.

See the question Direct access to harddrive? for pointers to information about reading raw sectors directly.

1
  • Looking at the partition info allows you to determine how the partitions are laid out, which then allows you to read the first sector of each partition so you can determine which filesystem is installed in each. That info will not tell you which operating system is installed inside a filesystem, though. For instance, if you detect NTFS, you cannot automatically assume Windows, because Linux supports NTFS, too. You need to either analyze the startup files in a bootable partition, or else analyze the boot code that is stored inside the MBR alongside the partition info. Nov 15, 2011 at 2:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.