的CreateFile:直接写操作原始磁盘和QUOT;访问被拒绝" - Vista中,Win7的 [英] CreateFile: direct write operation to raw disk "Access is denied" - Vista, Win7

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

问题描述

有关微软文档是:
阻止直接写操作卷和磁盘
<一href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx#physical_disks_and_volumes">CreateFile,言论对物理磁盘和卷

The relevant Microsoft doc is:
Blocking Direct Write Operations to Volumes and Disks
CreateFile, remarks on Physical Disks and Volumes

该可执行文件是用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,<一个href="http://szte-wsn.svn.sourceforge.net/viewvc/szte-wsn/private/ali/RawToCType/Win32DeviceHelper.cpp?revision=2949&view=markup">relevant code是这里在线路92和<一href="http://szte-wsn.svn.sourceforge.net/viewvc/szte-wsn/private/ali/RawToCType/Win32DriveFormatter.cpp?revision=2940&view=markup">here在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 2
有没有干净的方式获得Windows独家访问物理分区?

Can I get write access to raw disk sectors under Vista and Windows 7 in user mode?
Raw partition access in Windows Vista
How to obtain direct access to raw HD data in C?
Is there a clean way to obtain exclusive access to a physical partition under 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:直接写操作原始磁盘和QUOT;访问被拒绝&QUOT; - Vista中,Win7的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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