CreateFile: direct write operation to raw disk quot;Access is deniedquot; - Vista, Win7(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.
CreateFile 对 GENERIC_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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:CreateFile:直接对原始磁盘进行写操作“访问被拒绝";- 维斯塔,Win7
基础教程推荐
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- WPF 模态进度窗口 2022-01-01
