Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-04

Opinion about new target: Windows Native NT

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sven Barth

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...

Reply by email

Florian Klaempfl
to Sven Barth
Now I ask you (especially the main developers of FPC): Is there any chance that this target might be added officially to FreePascal

Of course, just send patches.

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...

Feel free to add it. The problem with such docs is that they never can cover all cases.

Reply by email

Marco van de Voort
to Sven Barth: Hello together! I'm working on a port of FreePascal to the Native NT API of…

In our previous episode, Sven Barth said:

Show quoted text 5 lines
- 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 ^^)

You know there is a native header in packages/winunits-jedi (jwanative or so)

Reply by email

Sven Barth
to Marco van de Voort

Ok... I'm definitly impressed by your answering speed ^^

Show quoted text 8 lines
Sven Barth schrieb: > Now I ask you (especially the main developers of FPC): Is there any > chance that this target might be added officially to FreePascal > Of course, just send patches.

Wonderful! Now I know what I can do on my way to university: cleaning up my changes so I can submit them ^^ (such patches are submitted to the bugtracker, aren't they?)

Show quoted text 10 lines
> 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... > Feel free to add it. The problem with such docs is that they never can cover all cases.

Ok. I will try to come up with a good description of the process.

Show quoted text 11 lines
In our previous episode, Sven Barth said: > - 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 ^^) > You know there is a native header in packages/winunits-jedi (jwanative or so)

I know there are many jewels in the packages directory, but I didn't know this one :D

Three questions though:

1. What shall I name the target? Currently it's named "winnt" but I think that name is a bit confusing (think about Windows NT 3 or 4), so I thought about "ntumode" (for NT user mode).

2. Now that I know the jwanative unit: Is it ok if I copy the needed methods/types (jwanative covers also many kernel mode structures and methods) into a file of my RTL (like the os dependant units of the other targets, e. g. windows, unixbase...)?

3. I'm using an sysinit unit that only does a passthrough to my entry procedure in system.pp. Do I even need sysinit in this case or can I drop it and only rely on system.pp?

Greetings,
Sven

Reply by email