我正在尝试使用以下代码从PhysicalDrive0获取MBR :
private static byte[] ReadMbr(string lpFileName) { byte[] mbr = new byte[512]; using (SafeFileHandle drive = CreateFile( lpFileName: lpFileName,dwDesiredAccess: (uint) EFileAccess.GenericRead,//DO NOT MODIFY THE MBR!!! dwShareMode: (uint)EFileShare.Write | (uint)EFileShare.Read | (uint)EFileShare.Delete,SecurityAttributes: IntPtr.Zero,dwCreationdisposition: (uint) ECreationdisposition.OpenAlways,dwFlagsAndAttributes: (uint)EFileAttributes.System,hTemplateFile: IntPtr.Zero)) { if (drive.IsInvalid) throw new IOException("Unable to access drive. Win32 Error Code " + Marshal.GetLastWin32Error()); //Get the 1st 512 bytes of the volume (MBR) using (FileStream stream = new FileStream(drive,FileAccess.Read)) { stream.Read(mbr,512); } } return mbr; }
我试过了
\.Physicaldisk0
\.PhysicalDrive0
\.Physicaldisk0:
\.PhysicalDrive0
并没有一个工作。 我以pipe理员身份运行它。 我也可以得到\.C:工作和显示VBR没有任何问题。
作为logging:
在Win7 Aero主题中增加DateTimePicker日历的字体大小
使用POST将安全数据从.NET发送到Linux服务器?
为什么通过WMI只应用一次静态IP地址?
如何最大限度地减lessWindows内存使用量
如何将新string添加到REG_MULTI_SZtypes的registry项?
– 我正在运行Windows Server 2008 R2。
参考
MSDN: CreateFile函数
MSDN: 命名文件,path和命名空间
重现UserPreferenceChanged事件以validation冻结问题已修复
Windows Xperf diskio操作不会显示一个程序在性能跟踪会话期间读取的文件
正确的方法来激活我的MainForm从一个NotifyIcon,如果它没有集中已经
如何设置箱子风扇速度
什么是一个好的阴谋库。净?
从CreateFile()文档:
这样的通话必须满足以下要求:
调用者必须具有管理权限。 有关更多信息,请参阅使用特权运行 。
dwCreationdisposition参数必须有OPEN_EXISTING标志 。
打开卷或软盘时, dwShareMode参数必须具有FILE_SHARE_WRITE标志。
您可能想尝试在ECreationdisposition.OpenExisting中传递dwCreationdisposition 。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。