无法在Win 7中写入物理驱动器? [英] can't write to physical drive in win 7?

查看:90
本文介绍了无法在Win 7中写入物理驱动器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个磁盘实用程序,可让您擦除整个物理驱动器.它使用Windows文件api调用:

I wrote a disk utility that allowed you to erase whole physical drives. it uses the windows file api, calling :

destFile = CreateFile("\\\\.\\PhysicalDrive1",
    GENERIC_WRITE,  FILE_SHARE_READ | FILE_SHARE_WRITE,
    NULL, OPEN_EXISTING,createflags, NULL);

,然后仅调用WriteFile,并确保写入多个扇区,即512字节.

and then just calling WriteFile, and making sure you write in multiples of sectors, i.e. 512 bytes.

在过去的XP中,甚至在Win7 RC上,它都可以正常运行,您要做的就是确保以管理员身份运行它.

this worked fine in the past, on XP, and even on the Win7 RC, all you have to do is make sure you are running it as an administrator.

但是现在我有零售Win7专业版,它不再起作用了!驱动器仍然可以正常写入,但是在成功打开的驱动器上调用WriteFile现在会失败!

but now I have retail Win7 professional, it doesn't work anymore! the drives still open fine for writing, but calling WriteFile on the successfully opened Drive now fails!

有人知道为什么会这样吗?它可能与使用共享标志打开它有关吗?这始终是我之前所做的事情,并且一直有效.可能是某些东西现在正在共享驱动器吗?阻止写?有什么方法可以正确地卸载"驱动器,或者至少是其上的分区,以便我可以独占访问它吗?

does anyone know why this might be? could it have something to do with opening it with shared flags? this is always what I have done before, and its worked. could it be that something is now sharing the drive? blocking the writes? is there some way to properly "unmount" a drive, or at least the partitions on it so that I would have exclusive access to it?

其他一些曾经可以使用的工具也不再可用,但是有些却可以使用,例如WD Diagnostic的擦除功能.在擦除驱动器之后,我的工具也可以在该驱动器上工作!使我相信,首先需要对驱动器执行一些卸载"过程,以释放对其进行写入的权限.

some other tools that used to work don't any more either, but some do, like the WD Diagnostic's erase functionality. and after it has erased the drive, my tool then works on it too! leading me to believe there is some "unmount" process I need to be doing to the drive first, to free up permission to write to it.

有什么想法吗?

更新:

WriteFile返回的错误代码为'5',ERROR_ACCESS_DENIED 但是同样,如果我先使用WD Diag擦除"驱动器,则可以访问并写入该驱动器.当我再次初始化驱动器并为其分配一个分区时,我回到得到ERROR_ACCESS_DENIED错误的地方.

the error code returned from WriteFile is '5', ERROR_ACCESS_DENIED but again, if I 'erase' the drive first using WD Diag, I can then access and write to the drive fine. when I initialize the drive again, and give it a partition, I go back to getting the ERROR_ACCESS_DENIED error.

推荐答案

几乎可以肯定,这与通过更改页面文件中的扇区来防止针对驱动程序签名的攻击有关.这将防止写入包含分区的磁盘区域.

This is almost certainly related to preventing the attack found against driver signing by changing sectors in the page file. It will prevent writing to the areas of the disk containing partitions.

请参见 http://msdn.microsoft. com/en-us/library/aa365747%28VS.85%29.aspx 并查看以文本如果您直接写到具有已安装文件系统的卷"开头的信息,基本上,您必须锁定磁盘的卷以写入其扇区.

See http://msdn.microsoft.com/en-us/library/aa365747%28VS.85%29.aspx and look at the information starting with the text "If you write directly to a volume that has a mounted file system", basically you have to lock the disk's volumes in order to write to their sectors.

这篇关于无法在Win 7中写入物理驱动器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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