Reading Data from a Physical Hard Drive

后端 未结 2 1849
南笙
南笙 2020-12-20 10:24

I am trying to develop a program that goes and finds 2 connected unformatted physical drives and read bytes. The program currently runs in the administrator mode since that\

相关标签:
2条回答
  • 2020-12-20 11:00

    The documentation for CreateFile says:

    Volume handles can be opened as noncached at the discretion of the particular file system, even when the noncached option is not specified in CreateFile. You should assume that all Microsoft file systems open volume handles as noncached. The restrictions on noncached I/O for files also apply to volumes.

    Although it doesn't spell it out explicitly, this applies to drives as well as to volumes.

    In practice, this isn't a problem. It is straightforward to write a helper function that returns an arbitrary amount of data from an arbitrary offset, while performing only aligned reads.

    0 讨论(0)
  • 2020-12-20 11:18

    It's imperative I can read sizes that's not multiples of 512.

    That is not possible. For direct access of a disk, you can only read and write multiples of the sector size. Furthermore, you must align your read and write operations. That is the file pointer must be at a multiple of the sector size.

    If you want to present an interface that allows arbitrary seeking, reading and writing, then you will need to implement your own buffering on top of the aligned raw disk access.

    0 讨论(0)
提交回复
热议问题