c# - 在 macOS 上读取引导扇区 CD 驱动器
问题描述
我正在尝试读取 cd 驱动器的引导扇区,以便提取其内容。不幸的是,无论我做什么,我似乎都无法让它工作。我尝试将目录作为文件读取,但访问被拒绝。尝试从 /dev/disk# 直接读取并被锁定。
我也尝试过检查和更改权限,但没有。
在 Windows 中,我会使用 kernel32 中的 CreateFile 和 ReadFile。我只是不确定 macOS 等价物是什么。
public static List<DriveInfo> GetDrives() => DriveInfo.GetDrives().Where(d => d.IsReady && d.DriveType == DriveType.CDRom).ToList();
public static ReadDrives()
{
var drives = GetDrives()
foreach(var drive in drives)
{
var root = drive.RootDirectory.FullName;
using (var fp = File.OpenRead(@"/Volumes/Flash - Copy/"))
{
//extract boot here
}
}
}
解决方案
这不是最好的答案,但这对我有用,不需要 sudo。
至少现在是一个解决方案。
var command = $"-c \"umount {inputDisc} && dd if={inputDisc} of={outputfile} bs=32k count=1 && mount {inputDisc}\"";
Process.Start("/bin/bash", command);
推荐阅读
- spring-boot - 由于异常无法加载 PDF 在提交响应后无法创建会话?
- javascript - 如何使用javascript计算表格的行
- xamarin - 更改 Xamarin Forms 中状态栏的状态栏颜色和文本颜色
- javascript - VueJS 在渲染数据之前等待 Apollo
- vue.js - 如何更新当前页面中的 VUE 组件更改 URL 参数
- ruby - 安装本地构建的 Ruby gem 时不允许安装到父路径
- python-3.x - 如何防止第二个窗口上的复选框导致错误?
- javascript - 函数对象在什么时候具有属性?
- r - 通过 Cookie 值进行闪亮的服务器应用程序身份验证
- java - 在java中将元素添加到listB而不将其添加到listA