简体   繁体   English

如何在 Mac OS X 上创建虚拟 CD 驱动器

[英]How to create virtual CD drive on Mac OS X

How does one go about creating a virtual CD driver on Mac OS X programatically?如何以编程方式在 Mac OS X 上创建虚拟 CD 驱动程序?

I can't find any relevant Cocoa APIs or any pure C BSD solutions.我找不到任何相关的 Cocoa API 或任何纯 C BSD 解决方案。

Any help or information is appreciated.任何帮助或信息表示赞赏。

You would need to use the I/O Kit framework to develop your own device driver that would emulate a virtual CD drive.您需要使用 I/O Kit 框架来开发您自己的设备驱动程序来模拟虚拟 CD 驱动器。 Here are some links to the relevant APIs to get you started.以下是相关 API 的一些链接,可帮助您入门。

I/O Kit Fundamentals I/O 套件基础知识

I/O Kit Device Driver Guidelines I/O Kit 设备驱动程序指南

Kernel Extension Programming Topics 内核扩展编程主题

There are several different answers people have proposed here.人们在这里提出了几种不同的答案。 The issue at hand is what are you trying to accomplish.手头的问题是你想要完成什么。 If you really want to emulate a CD ROM (down to the commandset) you will need to write a device driver.如果您真的想模拟 CD ROM(直到命令集),您将需要编写一个设备驱动程序。 If your goal is merely to emulate a block device with contents similiar to a CD you can create a disk image using disk utility and let the builtin disk image driver handle it for you.如果您的目标仅仅是模拟内容类似于 CD 的块设备,您可以使用磁盘实用程序创建磁盘映像,并让内置的磁盘映像驱动程序为您处理。

MacFUSE is useful if you want to present some sort of custom filesystem functionality, but if what you are looking for is something that has the same semantics as an optical disc (whether that is and block or command set level) it is the wrong tool.如果您想展示某种自定义文件系统功能,MacFUSE 很有用,但如果您正在寻找与光盘具有相同语义的东西(无论是块级别还是命令集级别),那么它就是错误的工具。

If you're simply looking to mount an ISO or something then it's done through the Disk Utility, simply drag it into the side-bar and then select it and choose mount.如果你只是想挂载 ISO 或其他东西,那么它可以通过磁盘工具完成,只需将它拖到侧栏中,然后选择它并选择挂载。

If you want to do it from code you can issue the hdiutil command, as shownhere .如果你想从代码做到这一点,你可以发出hdiutil命令,如图所示这里 I'm not sure if there's an API call to do it, but getting that command to do the work is quite painless.我不确定是否有 API 调用来执行此操作,但使用该命令来执行此工作非常轻松。

The simplest way to mount a custom volume is MacFUSE .挂载自定义卷的最简单方法是MacFUSE It handles the IOKit details for you and lets you write the implementation in user space.它为您处理 IOKit 细节,并让您在用户空间中编写实现。 However, I don't think you can make a MacFUSE “look like” a CD;但是,我认为您无法将 MacFUSE 制作成“看起来像”CD。 you'd have to modify FUSE to achieve that.你必须修改 FUSE 来实现这一点。

I had a nosey around DAEMON Tools for Mac 's driver:我对DAEMON Tools for Mac的驱动程序很在意:

/Library/Extensions/DAEMONToolsVirtualSCSIBus.kext/Contents/MacOS/DAEMONToolsVirtualSCSIBus

I disassembled the binary using Hopper and discovered they are using IOSCSIProtocolServices .我使用Hopper反汇编了二进制文件,发现它们正在使用IOSCSIProtocolServices

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM