CreateFile:直接对原始磁盘进行写操作“访问被拒绝";- 维斯塔,Win7 [英] CreateFile: direct write operation to raw disk "Access is denied" - Vista, Win7

查看:13
本文介绍了CreateFile:直接对原始磁盘进行写操作“访问被拒绝";- 维斯塔,Win7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相关的微软文档是:
阻止对卷的直接写入操作和磁盘
CreateFile,备注物理磁盘和卷

可执行文件是用 C++ 编写的,它调用 CreateFile() 来打开一个没有无文件系统的 SD 卡.CreateFile() 和连续的 ReadFile() 调用对于 GENERIC_READ 来说是成功的,没有管理员权限.

The executable is written in C++ and it calls CreateFile() to open an SD card that has no filesystem. The CreateFile() and consecutive ReadFile() calls are successful for GENERIC_READ without Administrator privileges.

CreateFileGENERIC_WRITE 失败,即使具有管理员权限也是如此.在资源管理器中,我在属性 > 兼容性 > 权限级别下设置了以管理员身份运行.我还尝试从管理员 cmd 运行可执行文件(以 Ctrl+Shift+Enter 开头,管理员:"在窗口标题中,适当提升).不过,我得到 ERROR_ACCESS_DENIED (0x5).

CreateFile fails for GENERIC_WRITE even with Administrator privileges. In the explorer, I set Run as Administrator under Properties > Compatibility > Privilege Level. I also tried to run the executable from an Administrator cmd (started with Ctrl+Shift+Enter, "Administrator:" is in the window title, properly elevated). Still, I get ERROR_ACCESS_DENIED (0x5).

我是否必须向 CreateFile 传递其他内容? 我不知道什么是安全属性,我只是传递 NULL,相关代码在这里第 92 行和 这里在第 48 行.

Do I have to pass something else to CreateFile? I have no idea what security attributes are, I just pass NULL, relevant code is here at line 92, and here at line 48.

或者是否应该设置其他任何东西来以管理员权限运行该进程?


一个相关问题:

Or is there anything else that should be set to run the process with Administrator privileges?


A related questions:

我能否在 Vista 和 Windows 7 用户模式下获得对原始磁盘扇区的写入权限?
Windows Vista 中的原始分区访问
如何在C语言中直接获取原始高清数据?
有没有一种干净的方法可以在 Windows 下获得对物理分区的独占访问权限?

推荐答案

很少需要GENERIC_WRITE.您很可能需要 GENERIC_READ|GENERIC_WRITE.

It's quite rare to want only GENERIC_WRITE. You most likely want GENERIC_READ|GENERIC_WRITE.

这篇关于CreateFile:直接对原始磁盘进行写操作“访问被拒绝";- 维斯塔,Win7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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