读取macOS上的引导扇区CD驱动器



我正在尝试读取cd驱动器的引导扇区,以便提取其内容。不幸的是,无论我做什么,我似乎都无法让它发挥作用。我已尝试将目录作为文件读取,但访问被拒绝。尝试从/dev/disk#读取权限,但被锁定。

我也尝试过检查和更改权限,但都没有。

在Windows中,我会使用CreateFile&从kernel32读取文件。我只是不确定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);

最新更新