使用 .NET 创建磁盘映像

发布于 2024-08-20 18:19:54 字数 139 浏览 1 评论 0原文

我需要克隆 CF 卡(具有一定量的自定义功能,无法使用现成的克隆工具)。我需要一个合适的图像才能正常工作 - 我不能只复制所有文件。我想用 C# 编写一个程序,但我不知道从哪里开始。

有人能给我指出一个基本示例或其他东西来让我朝着正确的方向前进吗?

I need to clone CF cards (with a certain amount of custom functionality that precludes using off-the-shelf cloning tools). I need a proper image for this to work - I can't just copy all the files. I would like to write a program for this in c#, but I have no idea where to start.

Could anyone point me to a basic sample or something to get me going in the right direction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱你不解释 2024-08-27 18:19:54

您可以使用与普通文件 io 相同的 API 来读取和写入 Windows 中的卷中的原始数据。区别在于公开征集。

CreateFile("\.\M:", GENERIC_READ | GENERIC_WRITE, ...)

将打开驱动器 M: 进行原始读写。我从未尝试过,但您也许可以将“\.\M:”作为文件名传递给 C# 中的流打开函数之一,它可能可以工作。但是,明智的做法是至少用非托管代码编写项目的文件 io 部分。

有关详细信息,请参阅 CreateFile 文档。寻找该部分

物理磁盘和卷

对磁盘或卷的直接访问受到限制。有关详细信息,请参阅帮助和支持知识库中的“更改文件系统和存储堆栈以限制 Windows Vista 和 Windows Server 2008 中的直接磁盘访问和直接卷访问”

You use the same API to read and write to To read raw data from a Volume in Windows that you use for ordinary file io. The difference is in the open call.

CreateFile("\.\M:", GENERIC_READ | GENERIC_WRITE, ...)

Will open drive M: for raw read and write. I've never tried it, but you might be able to get away with passing "\.\M:" as the filename to one of the stream open functions in C#, it might work. But you would be wiser to write at least the file io part of the project in unmanaged code.

See the CreateFile documentation for more information. look for the section

Physical Disks and Volumes

Direct access to the disk or to a volume is restricted. For more information, see "Changes to the file system and to the storage stack to restrict direct disk access and direct volume access in Windows Vista and in Windows Server 2008" in the Help and Support Knowledge Base at

笑叹一世浮沉 2024-08-27 18:19:54

你不能使用像这样的程序: http://xedit.smike.ru/

否则你必须后退Win32 API 调用,如 CreateFile(例如,对于驱动器 G,使用“\.\g:”作为文件名参数)

还要查看 ReadFile/WriteFile、SetFilePointer 和 DeviceIoControl 函数。

Cant you use a program like : http://xedit.smike.ru/

Otherwise you have to fall back to Win32 API calls, like CreateFile (for drive G, for example, use "\.\g:", as file name parameter)

Also look into the ReadFile/WriteFile, SetFilePointer and DeviceIoControl functions.

居里长安 2024-08-27 18:19:54

您需要使用 Pinvoke 来调用块模式 io。无法复制文件的原因是什么?

You would need to use Pinvoke to call block mode io. What is the reason you cant just copy files?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文