Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootable and cross platform applications and using delphi or Pascal

Tags:

delphi

pascal

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.

like image 579
VibeeshanRC Avatar asked Mar 08 '11 16:03

VibeeshanRC


3 Answers

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.

like image 75
Arnaud Bouchez Avatar answered Nov 05 '22 09:11

Arnaud Bouchez


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

like image 43
Wouter van Nifterick Avatar answered Nov 05 '22 08:11

Wouter van Nifterick


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.

like image 20
Warren P Avatar answered Nov 05 '22 10:11

Warren P