直接访问硬盘? [英] Direct access to harddrive?

查看:422
本文介绍了直接访问硬盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何硬盘存取的作品。恩,我怎么能查看/修改部门?林针对Windows是否有帮助。
谢谢

I was wondering how hard disk access works. Ex, how could I view/modify sectors? Im targeting Windows if that helps. Thanks

推荐答案

本页面似乎对这个问题的一些相关信息:

This page seems to have some relevant information on the subject:

您可以打开一个物理或逻辑
  开车使用CreateFile()
  应用程序接口
  (API),与设置这些设备名称
  你有适当的访问
  权限的驱动器(也就是,你必须
  是管理员)。您必须使用
  这两个的CreateFile()FILE_SHARE_READ
  和FILE_SHARE_WRITE标志来获得
  访问该驱动器。

You can open a physical or logical drive using the CreateFile() application programming interface (API) with these device names provided that you have the appropriate access rights to the drive (that is, you must be an administrator). You must use both the CreateFile() FILE_SHARE_READ and FILE_SHARE_WRITE flags to gain access to the drive.

一旦逻辑或物理驱动器有
  被打开,然后你可以执行
  直接I / O对整个数据
  驾驶。在执行直接磁盘
  I / O,你必须寻找,读,写在
  的扇区大小的倍数
  设备和部门的界限。呼叫
  使用的DeviceIoControl()
  IOCTL_DISK_GET_DRIVE_GEOMETRY得到
  每个扇区的字节数,数
  扇区,每个扇区磁轨等
  第四,这样就可以计算出
  您将需要缓冲区的大小。

Once the logical or physical drive has been opened, you can then perform direct I/O to the data on the entire drive. When performing direct disk I/O, you must seek, read, and write in multiples of sector sizes of the device and on sector boundaries. Call DeviceIoControl() using IOCTL_DISK_GET_DRIVE_GEOMETRY to get the bytes per sector, number of sectors, sectors per track, and so forth, so that you can compute the size of the buffer that you will need.

的CreateFile的文档还提供一些线索:

The documentation of CreateFile also offers some clues:

您可以使用CreateFile函数打开一个物理磁盘驱动器或卷,
  它返回一个直接存取存储设备(DASD)处理,可以是
  与DeviceIoControl函数使用。这使您能够访问
  磁盘或直接卷,例如这样的盘的元数据作为分区
  表。然而,这种类型的访问也暴露了磁盘驱动器或
  卷到潜在的数据丢失,因为一个不正确的写入到磁盘
  使用这种机制可以使内容无法访问的
  操作系统。为了确保数据的完整性,必将成为
  熟悉的DeviceIoControl以及如何其他API行为
  不同可以直接前往办理,而不是一个文件系统句柄。

You can use the CreateFile function to open a physical disk drive or a volume, which returns a direct access storage device (DASD) handle that can be used with the DeviceIoControl function. This enables you to access the disk or volume directly, for example such disk metadata as the partition table. However, this type of access also exposes the disk drive or volume to potential data loss, because an incorrect write to a disk using this mechanism could make its contents inaccessible to the operating system. To ensure data integrity, be sure to become familiar with DeviceIoControl and how other APIs behave differently with a direct access handle as opposed to a file system handle.

这篇关于直接访问硬盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆