How can I write any block on my hard drive using the C programming language?
There was a question about writing an MBR , but it doesnβt cover aspects of C. very often.
Since filedescriptors - as they say in the word - are for files, I think that in this case it is impossible to use them. The low-level I / O included in the C standard library is also implemented using filedescriptors.
More precisely:
This question is more about writing hard drive blocks than files (regardless of OS).
The answers to the above question basically suggested using dd (coreutils) on UNIX-Systems. That's why I ask you to specify the path in C. Perhaps the boot loaders ( GRUB ), and the boot sector viruses use different methods?
I assume that changing the actual pointer inside the filedescriptor is not a legal way.
Problems and limitations:
I know that there are certain aspects that need to be kept in mind, for example
- Some operating systems restrict direct access to volumes (such as Windows)
- Writing errors, as well as writing incorrect data to certain blocks, can lead to damage to the file system (data loss on the hard disk).
- Antivirus software may flag it as suspicious code.
This question is oriented more theoretically.
fuzzy source share