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
基础教程推荐
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 将数据集转换为列表 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 如果条件可以为空 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
