如何在Windows中使用DeviceIoControl()读取单个扇区/群集? [英] How to read individual sectors/clusters using DeviceIoControl() in Windows?

查看:122
本文介绍了如何在Windows中使用DeviceIoControl()读取单个扇区/群集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows准备休眠时,我掉下了笔记本电脑,结果,硬盘驱动器发生头部撞车事故. (教我下次使用带有自由落体传感器的硬盘驱动器和/或笔记本电脑.)无论如何,运行SpinRite尝试恢复数据已导致磁盘上的所有备用扇区都被全部用光.迄今可恢复的部门. SpinRite现在仍在运行,但是由于不再有可用的备用扇区,我认为这是徒劳的,除非告诉我所有不良扇区在哪里.

I dropped my laptop while Windows was preparing to hibernate and as a result, I got a head crash on the hard drive. (Teaches me to get a hard drive and/or laptop with a freefall sensor next time around.) Anyway, running SpinRite to try to recover the data has resulted in all the spare sectors on the disk to all be all used up for all the recoverable sectors so far. SpinRite is still going right now, but since there won't be anymore spare sectors to be used, I think it'll be a fruitless exercise except to tell me where all the bad sectors are.

无论如何,我正计划编写一个应用程序来尝试从硬盘驱动器中抢救数据.从过去尝试进行碎片整理的过程中,我知道我可以使用FSCTL_GET_RETRIEVAL_POINTERS来计算任何给定文件的逻辑群集号.

Anyway, I'm planning on writing an application to try to salvage data from the hard drive. From my past forays into defragging, I know that I can use FSCTL_GET_RETRIEVAL_POINTERS to figure out the logical cluster numbers for any given file.

我该如何尝试读取该实际集群的扇区?我对MSDN的磁盘",文件"和卷"设备控制代码的清单的挖掘,对我获得实际集群数据的方式并没有什么启发.

How do I go about trying to read the sectors for that actual cluster? My digging through MSDN's listing for Disk, File, and Volume device control codes hasn't had anything jump out at me as the way I get to the actual cluster data.

我什至不愿意尝试这么低的水平吗?我应该改为执行SetFilePointer()和ReadFile()调用以获取文件中适当的簇大小偏移量并读取簇大小的块吗?

Should I not even bother trying to read at that low level? Should I instead be doing SetFilePointer() and ReadFile() calls to get to the appropriate cluster sized offsets into the file and read cluster sized chunks?

如果我要读取的文件的扇区损坏,NTFS是否会将整个文件标记为坏文件并阻止我将来访问该文件?如果是这样,我如何告诉NTFS不要将文件标记为坏文件? (请记住,HD现在已经没有剩余的扇区可以重新映射了.)

If the file I'm trying to read has a bad sector, will NTFS mark the entire file as bad and prevent me from accessing the file in the future? If so how do I tell NTFS not to mark the file as bad or dead? (Remember that the HD is now out of spare sectors to be remapped.)

我应该清除我的* nix知识并弄清楚如何从/dev/中读取内容吗?

Should I dust off my *nix knowledge and figure out how to read from /dev/ ?

更新:我找到了自己问题的答案. :-)解决方案是在卷句柄而不是在文件句柄上执行SetFilePointer()和ReadFile().

Update: I found the answer to my own question. :-) The solution is doing SetFilePointer() and ReadFile() on the volume handle rather than on the file handle.

推荐答案

我找到了自己问题的答案. :-)解决方案是在卷句柄而不是在文件句柄上执行SetFilePointer()和ReadFile().

I found the answer to my own question. :-) The solution is doing SetFilePointer() and ReadFile() on the volume handle rather than on the file handle.

这篇关于如何在Windows中使用DeviceIoControl()读取单个扇区/群集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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