Tutorials
Building a NT Native app (device driver or app) using gnu gcc can be done easily (although it took me months to figure it out).

Here is the options you need to use:

gcc myapp.c -o myapp.exe -lntdll -nostdlib -Wl,--subsystem,native,-e,_NtProcessStartup@4
If you are using cygwin you must also use
-mno-cygwin
In your C file you must define your entry function as such:

void WINAPI NtProcessStartup(PSTARTUP_ARGUMENT Argument);

Then you will need some header files such as ntddk.h or ntdll.h which you will have to look around for.
cygwin/Mingw have partial files. (very limited)
The Wine project may have some header files. (see winternl.h)
You may just have to build your own custom header files for what you need.
Mingw includes libntdll.a.

Try these links for some examples and info:

Notes:
  • The startup function name doesn't matter (although in the NT DDK it must be NtProcessStartup if you use the 'build' environment).
  • You must call NtTerminateProcess() to end your program, do not return from your entry function.
  • You can only call functions within the NTDLL.DLL since no other DLLs can be loaded.
  • Most functions use UNICODE strings. To convert a char* to unicode just insert a NULL after each char (including the NULL to terminate the string).
  • NtOpenFile()/NtCreateFile() use the following file spec : "\\??\\x:\\path\\filename". You can also open drives and folders with these functions.

Author : Peter Quiring