可启动和跨平台应用程序并使用delphi或Pascal

发布于 2024-10-20 21:29:59 字数 206 浏览 1 评论 0 原文

是否可以使用 Delphi 或 Pascal 创建可启动(MBR 应用程序)应用程序(我知道我们不能使用 vcl 、 RTL 和其他东西,因为它们依赖于操作系统),但我可以至少使用 Readln 和 writeln 吗?

如果是真的的话!!!我们可以在其他操作系统下运行该程序吗? 但我知道PE(Windows)和ELF(Linux)格式是不同的。但至少通过一些小的修改我可以做到。

Is it Possible to create bootable (Applications for MBR )application using Delphi or Pascal (I know we cant use vcl , RTL and other stuffs because they depend on OS), but can i use at least Readln and writeln.

If it is true !!! Can we run the program under other OS.
but i know that PE (windows) and ELF (Linux ) formats are different. but at least with some small modification can i do it.

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

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

发布评论

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

评论(3

北笙凉宸 2024-10-27 21:29:59

值得一提的是,PE 是一种比 ELF 更加多样化的格式。
不仅仅是要修改几个字节......整个布局和库访问是多样化的,并且绑定是完全多样化的。

为了在控制台模式下启动 Delphi 应用程序,您可以放置​​一个小型 DOS 系统(例如,看看 FreeDOS),然后使用例如 DWPL。 DWPL 允许使用WDOSX DOS 扩展器作为核心,在Delphi 5-7 上运行本机32 位保护模式DOS 程序。我在一些带有网络适配器的旧硬件中使用了它,它的效果非常好。如果您对此感兴趣,我可以发布一些 DWPL 的更新代码。

对于此类目标,您应该查看Free Pascal。本质上,您可以根据您想要的任何目标对其进行自定义。甚至有多种使用 FPC 编写的操作系统草案。例如,请参阅 ToroClassiOS - 最新版本使用 Delphi 可执行文件作为源。

可以看到Toro的启动代码 从这里,以及“主程序" 用它创建的源代码。

但对于直接启动的应用程序来说,启动并不是那么困难。真正的问题是硬件层。
BIOS 对它的访问很少。
仅对于网络层,您必须查看 EtherBoot 站点等获得一些低级网络访问...但是手动重写所有这些驱动程序可能非常耗时!

简而言之:所有这些“纯帕斯卡”操作系统都只是理论上的,运行控制台和一些低性能网络(模拟诸如 NE2000 等较差的网络适配器)。所以那些“pascal”操作系统只是概念证明。离可行的解决方案还很远!但无论如何,这是非常好的技术挑战,非常鼓舞人心。

为什么要重新发明轮子?如果您想要一个轻量且快速的系统,请使用自定义的 Linux 内核。

然后使用 CrossKylix 将 Delphi 应用程序(没有用户界面)编译到 Linux 中,甚至更好的 Free Pascal 中。

It's worth saying that PE is a very diverse format than ELF.
Not only a few bytes to modify... the whole layout and library access is diverse, and binding is totally diverse.

In order to boot Delphi application in console mode, you can put a small DOS system (take a look at FreeDOS, for instance), then run your Delphi application using for instance DWPL. DWPL allows to run native 32-bit protected mode DOS programs with Delphi 5-7 using the WDOSX DOS extender as the core. I used this in some old hardware with a network adapter, and it worked like a charm. If you are interested in it, I could post some updated code of DWPL.

For such targets, you should take a look at Free Pascal. By nature, you can customize it to whatever target you want. There is even diverse draft Operating Systems written using FPC. See for instance Toro or ClassiOS - the latest uses Delphi executables as source.

You can see the boot code of Toro from here, and a "main program" source code created with it.

But for direct booting applications, booting is not so difficult. The real problem is the hardware layer.
The BIOS gives very little access to it.
Just for the network layer, you'll have to take a look at EtherBoot sites and such to get some low-level network access... but it could be very time consuming to rewrite all those drivers by hand!

In short: all those "pure pascal" OS are only theoretical, running a console and some low-performance network (emulating a poor network adapter like NE2000 or such). So those "pascal" OS are only proof of concept. FAR away from a working solution! But very nice technological challenge, in all cases, very inspiring.

Why reinvent the wheel? If you want a light and fast system, use a custom Linux kernel.

Then use CrossKylix to compile your Delphi application (with no User Interface) into Linux, or even better Free Pascal.

乖乖 2024-10-27 21:29:59

您实际上并没有将“应用程序”放置在 MBR 中。

MBR 的整个大小为 512 字节,其中只能使用 446 字节用于代码。

如果您还没有可以委派功能的操作系统,那么祝您好运,创建一些有用的东西。基本上,您在 MBR 中可以做的就是放置代码来启动引导加载程序。

以下是 MBR 反汇编页面:

http://www.dewassoc.com/kbase/硬盘驱动器/master_boot_record.htm

You don't really place "applications" in the MBR.

The entire size of an MBR is 512 bytes, of which you can only use 446 for code.

Good luck creating something useful in that if you don't even have an OS to delegate functionality to yet. Basically all that you can do in the MBR is place code to start a boot loader.

Here's a page with disassembly of an MBR:

http://www.dewassoc.com/kbase/hard_drives/master_boot_record.htm

瑶笙 2024-10-27 21:29:59

为什么必须编写引导加载程序?

您可以使用现成的引导加载程序(例如 GRUB)并从中链式加载 PE 可执行文件。

当然,这是非常古老和毛茸茸的东西,但在过去的好日子里,人们做了这个 win PE 格式的可执行文件和 DOS 扩展器。

对于本世纪更多的东西,为什么不制作自己的可启动 REACTOS 磁盘,并添加用 Delphi 编写的自己的 PE 可执行文件来处理“用户 shell”?

您还可以(但这需要许可)使用 Windows PXE。我认为像 BartPE 这样的项目可能属于合法的灰色地带,或者至少是未经许可的。因此,带有 ReactOS 的完全独立的 kiosk PC 的完全无 MS 的解决方案 (reactos) 可能更适合您。

你能编写自己的操作系统吗?你自己的 UI 层?您自己的视频设备驱动程序?我不这么认为。因此,请使用 DOS 和 TurboPascal,或 ReactOS 和 PE win 可执行文件。或者,您可以使用 FreePascal,并在非常轻量级的便携式 Linux 内核和根文件系统上构建您的应用程序。

Why must you write the boot loader?

You could use a ready-made bootloader like GRUB and chainload your PE executable, from it.

Of course, this is very ancient and hairy stuff, but in the good old days, people did this win PE format executables, and a DOS Extender.

For something a little more this-century, why not make your own bootable REACTOS disk, and add your own PE executable written in Delphi to handle the "user shell"?

You could also (but this would require licensing) use the Windows PXE. I think that projects like BartPE probably fall on the gray side of legal, or are at least, unlicensed. Thus, a completely MS-free solution (reactos) for a completely self-contained kiosk PC, with ReactOS, might be more what you are looking for.

Can you write your own operating system? your own UI layer? your own video device drivers? I didn't think so. So use DOS and TurboPascal, or ReactOS and a PE win executable. Or you can use FreePascal and just build your app on a very lightweight portable Linux kernel and root filesystem.

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