c++从无文件系统执行代码
首先,我很难想出一个标题,而且有点含糊,但是哦,好吧。
好吧,所以我有一个混合的 c++ & asm 引导加载程序。我可以将它复制到我的 mbr 上并运行它。我遇到的唯一问题是 mbr 非常小。我假设它的目的是仅调用驱动器上其他地方编写的外部代码。我的问题是,我不知道如何访问它。我的意思是我可以将数据放在那里,我只是不知道如何以编程方式访问该数据,因为本质上驱动器不会有“文件系统”,而只是任意代码。
我在网上搜索过,但真正的低级开发教程似乎很少。
我什至想要一个 C++ 库(如果有的话)。
First of all, had a hard time figuring out a title, and it's a bit ambiguous, but oh well.
Alright, so I have a mixed c++ & asm bootloader program. I can copy it onto my mbr and run it. The only problem I'm having is the fact that the mbr is very small. I'm assuming the purpose of it is to only call external code written somewhere else on the drive. My problem is, I'm not sure how to access that. I mean I can put the data on there, I just have no clue how to programmaticaly access that data, since in essence the drive is not going to have a "file system", just arbitrary code.
I've searched the net but tutorials on real low level development seems scarce.
I'm even up for a c++ library if any exists.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
良好的旧BIOS 调用,适用于 PC。如果您的主板不是 PC - 您需要主板制造商提供有关如何访问 IDE/SATA 控制器的信息。
Good old BIOS calls, for PC. If your board is not PC - you need info from the board manufacturer on how to access the IDE/SATA controller.
BIOS 在运行 MBR 中的代码之前设置几个中断处理程序。其中之一可用于直接从硬盘驱动器读取/写入扇区,无需操作系统、设备驱动程序或文件系统。
这就是中断
19
(13H,这是更常见的中断)。您需要使用它来读取代码,然后只需
jmp
进入它。The BIOS sets up several interrupt handlers before running the code in the MBR. One of these can be used to do things like read/write sectors directly from the hard drive without a OS, device driver, or file system.
That's interrupt
19
(13H as its more commonly known).You'll need to use that to read the code, then just
jmp
into it.在不了解平台的情况下,除了最通用的概述之外很难提供任何内容。
初始引导代码通常要求系统固件将附加块从磁盘复制到内存,然后可以调用其中包含的代码。在 PC 系统上,这意味着 BIOS 调用。
Without knowing the platform, it's hard to give anything but the most generic overview.
Initial boot code generally asks the system firmware to copy additional blocks from disk to memory, and then can call code contained there. On a PC system, that would mean a BIOS call.