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
基础教程推荐
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
