[fpc-pascal] Opinion about new target: Windows Native NT

Sven Barth svenmauren at vr-web.de
Sat Apr 25 21:38:44 CEST 2009


Hello together!

I'm working on a port of FreePascal to the Native NT API of 
Windows/ReactOS and wanted to ask about your opinion on this idea.

For those who don't know what I'm talking about:
The Win32 API every Windows (NT) developer normally uses is not the API 
of its kernel. The kernel itself exposes a more abstract, but also more 
powerful API (you can even fork processes!). This is  (mostly) exposed 
to user space through the ntdll library. Win32 itself is a so called 
environment subsystem which exposes its own wrappers for NT's API (this 
is the Win32 API) to its processes. The subsystem executables (there are 
at least two more: one for POSIX systems and an OS/2 one) and some 
executables like autochk are true Native NT binaries (the subsystem 
field of their PE-header is "1") which use only the kernel's API.

The purpose of this port is simple: I want to write native NT binaries 
in Pascal and I want to write them in a comfortable way (e. g. without 
hacking around ^^)!

But I'll also tell you the truth: I don't know how useful this port is 
or will become (at least for anyone besides myself).

Basically you can write
- applications for the recovery console of the windows setup
- applications that are started right after the kernel
- your own subsystem

That's it, not more. (I myself prefer the last one :P )

But I see this port as an intermediate and necessary step to a much 
greater target: the kernel mode of NT; being able to write device 
drivers in a beautiful yet powerful language (not to mention typesafe :P).

Now you might ask: Why do we need the (more or less useless) user mode 
part, if all you want are device drivers?

Developing device drivers in Pascal without hacking around in the 
compiler itself or the RTL (like some Delphi developers did) will be a 
nice and huge achievement for (Object) Pascal, but let me tell you my 
reasons why I want the user mode part done at first:

- User mode is easier to implement. There is only ntdll you need to 
wrap. For device drivers you have to translate the Driver Development 
Kit which is at least a huge task (though you can reuse some of the 
usermode stuff). And I'd also need Microsoft's fastcall calling 
convention (btw: how can I add a new calling convention?)
- I myself know what I want to do in NT's user mode (I want to play with 
the NT architecture)
- I want to show the world (especially the C one) how powerful Pascal 
(especially FreePascal) is; I want to endanger their holy grail "system 
development"! (although "kernel mode pascal" might suit this task even 
more...)

Here's a little sum up of the port's status:
- the new target is added to the compiler and its utilities (using the 
internal linker only)
- I successfully compiled a program with a stub RTL and executed it 
during ReactOS' boot process ("hello world" ;) )
- currently I'm implementing the RTL features step by step (thanks to 
HAS_FEATURE_XYZ this is easier then checking which methods of ntdll I 
need ^^)

Now I ask you (especially the main developers of FPC): Is there any 
chance that this target might be added officially to FreePascal (I'd 
even maintain it, if needed)? Or shall I keep it on my own harddrive and 
never speak about it again? :)

Greetings,
Sven

PS: I might also help to update/complete the "porting FPC" 
documentation, as some parts are missing. For example: I needed to add 
my target to the coff code-generator and I had to search with grep to 
find the right place...



More information about the fpc-pascal mailing list