Moved all the content of the DDK files ntdef.h and ntddk.h to
winternl.h.

diff --git a/debugger/winedbg.c b/debugger/winedbg.c
index 476b76a..7a310c2 100644
--- a/debugger/winedbg.c
+++ b/debugger/winedbg.c
@@ -25,7 +25,7 @@
 #include <string.h>
 #include "debugger.h"
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "thread.h"
 #include "wincon.h"
 #include "winreg.h"
diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c
index 9bcacfc..1c515f0 100644
--- a/dlls/advapi32/security.c
+++ b/dlls/advapi32/security.c
@@ -24,7 +24,7 @@
 #include "winerror.h"
 #include "rpcnterr.h"
 #include "heap.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "ntsecapi.h"
 #include "wine/debug.h"
 
diff --git a/dlls/commdlg/filedlg95.c b/dlls/commdlg/filedlg95.c
index abc7b8b..e0213ee 100644
--- a/dlls/commdlg/filedlg95.c
+++ b/dlls/commdlg/filedlg95.c
@@ -60,7 +60,7 @@
 #include <string.h>
 
 #include "winbase.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "winnls.h"
 #include "wine/unicode.h"
 #include "commdlg.h"
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
index 5e2552c..1adb6c9 100644
--- a/dlls/dsound/buffer.c
+++ b/dlls/dsound/buffer.c
@@ -37,7 +37,7 @@
 #include "winuser.h"
 #include "winerror.h"
 #include "mmsystem.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "mmddk.h"
 #include "wine/windef16.h"
 #include "wine/debug.h"
@@ -985,4 +985,3 @@
 	*pdsb = dsb;
 	return S_OK;
 }
-
diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c
index f6012b9..8a8eb76 100644
--- a/dlls/dsound/dsound_main.c
+++ b/dlls/dsound/dsound_main.c
@@ -58,7 +58,7 @@
 #include "winuser.h"
 #include "winerror.h"
 #include "mmsystem.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "mmddk.h"
 #include "wine/windef16.h"
 #include "wine/winbase16.h"
diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c
index c6e7013..1af40c3 100644
--- a/dlls/dsound/mixer.c
+++ b/dlls/dsound/mixer.c
@@ -37,7 +37,7 @@
 #include "winuser.h"
 #include "winerror.h"
 #include "mmsystem.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "mmddk.h"
 #include "wine/windef16.h"
 #include "wine/debug.h"
diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c
index 3b7a5cd..fc28794 100644
--- a/dlls/dsound/primary.c
+++ b/dlls/dsound/primary.c
@@ -37,7 +37,7 @@
 #include "winuser.h"
 #include "winerror.h"
 #include "mmsystem.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "mmddk.h"
 #include "wine/windef16.h"
 #include "wine/debug.h"
diff --git a/dlls/dsound/propset.c b/dlls/dsound/propset.c
index 2cc6ac3..67abde8 100644
--- a/dlls/dsound/propset.c
+++ b/dlls/dsound/propset.c
@@ -37,7 +37,7 @@
 #include "winuser.h"
 #include "winerror.h"
 #include "mmsystem.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "mmddk.h"
 #include "wine/windef16.h"
 #include "wine/debug.h"
diff --git a/dlls/dsound/sound3d.c b/dlls/dsound/sound3d.c
index a0b867c..dce77f1 100644
--- a/dlls/dsound/sound3d.c
+++ b/dlls/dsound/sound3d.c
@@ -54,7 +54,7 @@
 #include "winuser.h"
 #include "winerror.h"
 #include "mmsystem.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "mmddk.h"
 #include "wine/windef16.h"
 #include "wine/debug.h"
diff --git a/dlls/gdi/driver.c b/dlls/gdi/driver.c
index e849438..6849353 100644
--- a/dlls/gdi/driver.c
+++ b/dlls/gdi/driver.c
@@ -24,7 +24,7 @@
 #include <string.h>
 #include "winbase.h"
 #include "winreg.h"
-#include "ntddk.h"
+#include "winternl.h"
 
 #include "gdi.h"
 #include "win16drv/win16drv.h"
diff --git a/dlls/kernel/kernel_main.c b/dlls/kernel/kernel_main.c
index ac0fa8a..555a931 100644
--- a/dlls/kernel/kernel_main.c
+++ b/dlls/kernel/kernel_main.c
@@ -29,7 +29,7 @@
 
 #include "winbase.h"
 #include "wincon.h"
-#include "ntddk.h"
+#include "winternl.h"
 
 #include "wine/winbase16.h"
 #include "wine/library.h"
diff --git a/dlls/kernel/locale.c b/dlls/kernel/locale.c
index 15f84fc..9503e1c 100644
--- a/dlls/kernel/locale.c
+++ b/dlls/kernel/locale.c
@@ -32,7 +32,7 @@
 #include "windef.h"
 #include "winbase.h"
 #include "winuser.h"  /* for RT_STRINGW */
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/unicode.h"
 #include "winnls.h"
 #include "winerror.h"
diff --git a/dlls/kernel/thunk.c b/dlls/kernel/thunk.c
index 2cb9f9c..ffe309b 100644
--- a/dlls/kernel/thunk.c
+++ b/dlls/kernel/thunk.c
@@ -32,7 +32,7 @@
 #include "windef.h"
 #include "winbase.h"
 #include "winerror.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/winbase16.h"
 
 #include "wine/debug.h"
diff --git a/dlls/kernel/time.c b/dlls/kernel/time.c
index a4c5821..8f42779 100644
--- a/dlls/kernel/time.c
+++ b/dlls/kernel/time.c
@@ -32,7 +32,7 @@
 # include <sys/times.h>
 #endif
 #include "file.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "winerror.h"
 #include "winnls.h"
 #include "wine/unicode.h"
diff --git a/dlls/kernel/utthunk.c b/dlls/kernel/utthunk.c
index ba649b6..e981966 100644
--- a/dlls/kernel/utthunk.c
+++ b/dlls/kernel/utthunk.c
@@ -19,7 +19,7 @@
  */
 
 #include "wine/winbase16.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "module.h"
 #include "wine/debug.h"
 
@@ -312,4 +312,3 @@
     FIXME("(%08lx, %08lx, %08lx, %08lx): stub\n", x1, x2, x3, x4 );
     return 0;
 }
-
diff --git a/dlls/kernel/wowthunk.c b/dlls/kernel/wowthunk.c
index 845bb10..19b7cdb 100644
--- a/dlls/kernel/wowthunk.c
+++ b/dlls/kernel/wowthunk.c
@@ -25,7 +25,7 @@
 #include "winbase.h"
 #include "winerror.h"
 #include "wownt32.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "file.h"
 #include "miscemu.h"
 #include "stackframe.h"
diff --git a/dlls/msvcrt/cppexcept.c b/dlls/msvcrt/cppexcept.c
index 007d021..0c31fa4 100644
--- a/dlls/msvcrt/cppexcept.c
+++ b/dlls/msvcrt/cppexcept.c
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "wine/port.h"
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "msvcrt.h"
 #include "wine/exception.h"
 #include "msvcrt/excpt.h"
diff --git a/dlls/msvcrt/dir.c b/dlls/msvcrt/dir.c
index 623d3b6..b7e0acc 100644
--- a/dlls/msvcrt/dir.c
+++ b/dlls/msvcrt/dir.c
@@ -25,7 +25,7 @@
 #include "wine/port.h"
 
 #include <time.h>
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/unicode.h"
 #include "msvcrt.h"
 #include "ms_errno.h"
diff --git a/dlls/msvcrt/except.c b/dlls/msvcrt/except.c
index ffdc271..e9ca501 100644
--- a/dlls/msvcrt/except.c
+++ b/dlls/msvcrt/except.c
@@ -28,7 +28,7 @@
 #include "config.h"
 #include "wine/port.h"
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/exception.h"
 #include "thread.h"
 #include "msvcrt.h"
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 6ac8dde..9dedf0a 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -30,7 +30,7 @@
 # include <unistd.h>
 #endif
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "msvcrt.h"
 #include "ms_errno.h"
 
diff --git a/dlls/netapi32/wksta.c b/dlls/netapi32/wksta.c
index 8ff7ae2..f94857d 100644
--- a/dlls/netapi32/wksta.c
+++ b/dlls/netapi32/wksta.c
@@ -24,7 +24,7 @@
 #include "lmapibuf.h"
 #include "lmerr.h"
 #include "winerror.h"
-#include "ntdef.h"
+#include "winternl.h"
 #include "ntsecapi.h"
 #include "wine/debug.h"
 
diff --git a/dlls/ntdll/cdrom.c b/dlls/ntdll/cdrom.c
index 223afcb..f53a392 100644
--- a/dlls/ntdll/cdrom.c
+++ b/dlls/ntdll/cdrom.c
@@ -61,7 +61,7 @@
 # include <sys/cdio.h>
 #endif
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "winioctl.h"
 #include "ntddstor.h"
 #include "ntddcdrm.h"
diff --git a/dlls/ntdll/critsection.c b/dlls/ntdll/critsection.c
index ae89e7d..5835610 100644
--- a/dlls/ntdll/critsection.c
+++ b/dlls/ntdll/critsection.c
@@ -26,7 +26,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include "winerror.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
diff --git a/dlls/ntdll/debugtools.c b/dlls/ntdll/debugtools.c
index 7a1497e..4a9a5f7 100644
--- a/dlls/ntdll/debugtools.c
+++ b/dlls/ntdll/debugtools.c
@@ -40,7 +40,7 @@
 #include "thread.h"
 #include "winbase.h"
 #include "winnt.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "msvcrt/excpt.h"
 
 WINE_DECLARE_DEBUG_CHANNEL(tid);
diff --git a/dlls/ntdll/error.c b/dlls/ntdll/error.c
index 01c0e2b..ce0e8f4 100644
--- a/dlls/ntdll/error.c
+++ b/dlls/ntdll/error.c
@@ -20,7 +20,7 @@
  */
 
 #include "config.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "winerror.h"
 #include "wine/debug.h"
 
@@ -38,7 +38,7 @@
 /**************************************************************************
  *           RtlNtStatusToDosError (NTDLL.@)
  */
-DWORD WINAPI RtlNtStatusToDosError( DWORD status )
+ULONG WINAPI RtlNtStatusToDosError( NTSTATUS status )
 {
     const struct error_table *table = error_table;
 
diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c
index 8bfe7b7..3a12fd0 100644
--- a/dlls/ntdll/exception.c
+++ b/dlls/ntdll/exception.c
@@ -26,7 +26,7 @@
 #include <signal.h>
 
 #include "winnt.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "global.h"
 #include "wine/exception.h"
 #include "stackframe.h"
@@ -252,7 +252,7 @@
  *		RtlUnwind (NTDLL.@)
  */
 DEFINE_REGS_ENTRYPOINT_4( RtlUnwind, EXC_RtlUnwind,
-                          PEXCEPTION_FRAME, LPVOID, PEXCEPTION_RECORD, DWORD );
+                          PVOID, PVOID, PEXCEPTION_RECORD, PVOID );
 void WINAPI EXC_RtlUnwind( PEXCEPTION_FRAME pEndFrame, LPVOID unusedEip,
                            PEXCEPTION_RECORD pRecord, DWORD returnEax,
                            CONTEXT *context )
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 6159d41..1c6fbbd 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -35,7 +35,7 @@
 #include "ntdll_misc.h"
 #include "file.h" /* FIXME */
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "winioctl.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index f9eb76b..67b77cf 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -26,7 +26,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/winbase16.h"
 #include "winbase.h"
 #include "winerror.h"
diff --git a/dlls/ntdll/large_int.c b/dlls/ntdll/large_int.c
index d6086fb..7aee5ed 100644
--- a/dlls/ntdll/large_int.c
+++ b/dlls/ntdll/large_int.c
@@ -19,7 +19,7 @@
  */
 
 #include "winnt.h"
-#include "ntddk.h"
+#include "winternl.h"
 
 /*
  * Note: we use LONGLONG instead of LARGE_INTEGER, because
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 4440426..5d04cda 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -17,9 +17,8 @@
  */
 
 #include "winbase.h"
-#include "ntdef.h"
 #include "winnt.h"
-#include "ntddk.h"
+#include "winternl.h"
 
 #include "module.h"
 #include "wine/exception.h"
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index e5ceb71..aec0229 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -27,7 +27,7 @@
 #include <time.h>
 #include "wine/debug.h"
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "ntdll_misc.h"
 #include "wine/server.h"
 
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 2bf275c..ae37e6f 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -19,8 +19,8 @@
 #ifndef __WINE_NTDLL_MISC_H
 #define __WINE_NTDLL_MISC_H
 
-#include "ntdef.h"
 #include "winnt.h"
+#include "winternl.h"
 
 /* debug helper */
 extern LPCSTR debugstr_us( const UNICODE_STRING *str );
diff --git a/dlls/ntdll/om.c b/dlls/ntdll/om.c
index dbc3899..fbcefa2 100644
--- a/dlls/ntdll/om.c
+++ b/dlls/ntdll/om.c
@@ -30,7 +30,7 @@
 #endif
 #include "wine/debug.h"
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "ntdll_misc.h"
 #include "wine/server.h"
 
@@ -257,11 +257,11 @@
  *  ZwWaitForSingleObject		[NTDLL.@]
  */
 NTSTATUS WINAPI NtWaitForSingleObject(
-	IN PHANDLE Object,
+	IN HANDLE Object,
 	IN BOOLEAN Alertable,
 	IN PLARGE_INTEGER Time)
 {
-	FIXME("(%p,0x%08x,%p),stub!\n",Object,Alertable,Time);
+	FIXME("(0x%08x,0x%08x,%p),stub!\n",Object,Alertable,Time);
 	return 0;
 }
 
diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c
index 740fe0d..0f72c8d 100644
--- a/dlls/ntdll/reg.c
+++ b/dlls/ntdll/reg.c
@@ -34,7 +34,7 @@
 #include "winerror.h"
 #include "wine/unicode.h"
 #include "wine/server.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "ntdll_misc.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(reg);
diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c
index 4b3ac81..36ca648 100644
--- a/dlls/ntdll/rtl.c
+++ b/dlls/ntdll/rtl.c
@@ -29,7 +29,7 @@
 #include "winerror.h"
 #include "stackframe.h"
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "winreg.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
diff --git a/dlls/ntdll/rtlbitmap.c b/dlls/ntdll/rtlbitmap.c
index acc7d20..d04754a 100644
--- a/dlls/ntdll/rtlbitmap.c
+++ b/dlls/ntdll/rtlbitmap.c
@@ -31,7 +31,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "windef.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
diff --git a/dlls/ntdll/rtlstr.c b/dlls/ntdll/rtlstr.c
index 4d4307b..97b4c6a 100644
--- a/dlls/ntdll/rtlstr.c
+++ b/dlls/ntdll/rtlstr.c
@@ -26,7 +26,7 @@
 #include <string.h>
 #include <ctype.h>
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/unicode.h"
 #include "wine/debug.h"
 
@@ -338,8 +338,8 @@
  * NOTES:
  *  writes terminating 0
  */
-NTSTATUS WINAPI RtlAnsiStringToUnicodeString( UNICODE_STRING *uni,
-                                              const STRING *ansi,
+NTSTATUS WINAPI RtlAnsiStringToUnicodeString( PUNICODE_STRING uni,
+                                              PCANSI_STRING ansi,
                                               BOOLEAN doalloc )
 {
     DWORD total = RtlAnsiStringToUnicodeSize( ansi );
@@ -686,7 +686,7 @@
  * Compute the size necessary for the multibyte conversion of 'str',
  * without the terminating NULL.
  */
-NTSTATUS WINAPI RtlUnicodeToMultiByteSize( DWORD *size, LPCWSTR str, UINT len )
+NTSTATUS WINAPI RtlUnicodeToMultiByteSize( PULONG size, LPCWSTR str, ULONG len )
 {
     *size = cp_wcstombs( get_ansi_table(), 0, str, len / sizeof(WCHAR), NULL, 0, NULL, NULL );
     return STATUS_SUCCESS;
diff --git a/dlls/ntdll/sec.c b/dlls/ntdll/sec.c
index f4e4525..a7d032a 100644
--- a/dlls/ntdll/sec.c
+++ b/dlls/ntdll/sec.c
@@ -39,7 +39,7 @@
 #include "winerror.h"
 #include "stackframe.h"
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "winreg.h"
 #include "ntdll_misc.h"
 #include "msvcrt/excpt.h"
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index f7ebbe8..7a00360 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -50,7 +50,7 @@
 # include <sys/signal.h>
 #endif
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "winnt.h"
 #include "wine/library.h"
 
@@ -408,11 +408,9 @@
 #define T_UNKNOWN     (-1)  /* Unknown fault (TRAP_sig not defined) */
 
 #include "wine/exception.h"
-#include "winnt.h"
 #include "stackframe.h"
 #include "global.h"
 #include "miscemu.h"
-#include "ntddk.h"
 #include "syslevel.h"
 #include "wine/debug.h"
 
diff --git a/dlls/ntdll/signal_powerpc.c b/dlls/ntdll/signal_powerpc.c
index 594af94..2c0dc68 100644
--- a/dlls/ntdll/signal_powerpc.c
+++ b/dlls/ntdll/signal_powerpc.c
@@ -50,11 +50,19 @@
 # include <sys/signal.h>
 #endif
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "winnt.h"
 #include "wine/library.h"
-
+#include "wine/exception.h"
 #include "selectors.h"
+#include "stackframe.h"
+#include "global.h"
+#include "miscemu.h"
+#include "syslevel.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(seh);
+
 
 /***********************************************************************
  * signal context platform-specific definitions
@@ -65,17 +73,6 @@
 #define HANDLER_DEF(name) void name( int __signal, struct siginfo *__siginfo, SIGCONTEXT *__context )
 #define HANDLER_CONTEXT (__context)
 
-#include "wine/exception.h"
-#include "winnt.h"
-#include "stackframe.h"
-#include "global.h"
-#include "miscemu.h"
-#include "ntddk.h"
-#include "syslevel.h"
-#include "wine/debug.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(seh);
-
 typedef int (*wine_signal_handler)(unsigned int sig);
 
 static wine_signal_handler handlers[256];
diff --git a/dlls/ntdll/signal_sparc.c b/dlls/ntdll/signal_sparc.c
index 250f617..024c4c2 100644
--- a/dlls/ntdll/signal_sparc.c
+++ b/dlls/ntdll/signal_sparc.c
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <sys/ucontext.h>
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "winbase.h"
 #include "winnt.h"
 
diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c
index 51071b3..206ee7d 100644
--- a/dlls/ntdll/sync.c
+++ b/dlls/ntdll/sync.c
@@ -27,7 +27,7 @@
 #include "winerror.h"
 #include "wine/unicode.h"
 #include "wine/server.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "ntdll_misc.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
diff --git a/dlls/ntdll/tests/error.c b/dlls/ntdll/tests/error.c
index d673cc6..b8ac346 100644
--- a/dlls/ntdll/tests/error.c
+++ b/dlls/ntdll/tests/error.c
@@ -21,7 +21,7 @@
 #include "winbase.h"
 #include "winerror.h"
 #include "rpcnterr.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "ntsecapi.h"
 #include "wine/test.h"
 #include <stdio.h>
diff --git a/dlls/ntdll/tests/rtlbitmap.c b/dlls/ntdll/tests/rtlbitmap.c
index 271f052..0ff0b50 100644
--- a/dlls/ntdll/tests/rtlbitmap.c
+++ b/dlls/ntdll/tests/rtlbitmap.c
@@ -23,7 +23,7 @@
 #include "wine/test.h"
 #include "winbase.h"
 #include "winnt.h"
-#include "ntddk.h"
+#include "winternl.h"
 
 /* Function ptrs for ordinal calls */
 static HMODULE hntdll = 0;
diff --git a/dlls/ntdll/time.c b/dlls/ntdll/time.c
index bf44403..ecabb32 100644
--- a/dlls/ntdll/time.c
+++ b/dlls/ntdll/time.c
@@ -33,7 +33,7 @@
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
@@ -211,9 +211,9 @@
 /******************************************************************************
  *  RtlTimeToSecondsSince1970		[NTDLL.@]
  */
-BOOLEAN WINAPI RtlTimeToSecondsSince1970( const FILETIME *time, LPDWORD res )
+BOOLEAN WINAPI RtlTimeToSecondsSince1970( const LARGE_INTEGER *time, PULONG res )
 {
-    ULONGLONG tmp = ((ULONGLONG)time->dwHighDateTime << 32) | time->dwLowDateTime;
+    ULONGLONG tmp = ((ULONGLONG)time->s.HighPart << 32) | time->s.LowPart;
     tmp = RtlLargeIntegerDivide( tmp, 10000000, NULL );
     tmp -= SECS_1601_TO_1970;
     if (tmp > 0xffffffff) return FALSE;
@@ -224,9 +224,9 @@
 /******************************************************************************
  *  RtlTimeToSecondsSince1980		[NTDLL.@]
  */
-BOOLEAN WINAPI RtlTimeToSecondsSince1980( const FILETIME *time, LPDWORD res )
+BOOLEAN WINAPI RtlTimeToSecondsSince1980( const LARGE_INTEGER *time, LPDWORD res )
 {
-    ULONGLONG tmp = ((ULONGLONG)time->dwHighDateTime << 32) | time->dwLowDateTime;
+    ULONGLONG tmp = ((ULONGLONG)time->s.HighPart << 32) | time->s.LowPart;
     tmp = RtlLargeIntegerDivide( tmp, 10000000, NULL );
     tmp -= SECS_1601_to_1980;
     if (tmp > 0xffffffff) return FALSE;
@@ -237,21 +237,21 @@
 /******************************************************************************
  *  RtlSecondsSince1970ToTime		[NTDLL.@]
  */
-void WINAPI RtlSecondsSince1970ToTime( DWORD time, FILETIME *res )
+void WINAPI RtlSecondsSince1970ToTime( DWORD time, LARGE_INTEGER *res )
 {
     ULONGLONG secs = RtlExtendedIntegerMultiply( time + SECS_1601_TO_1970, 10000000 );
-    res->dwLowDateTime  = (DWORD)secs;
-    res->dwHighDateTime = (DWORD)(secs >> 32);
+    res->s.LowPart  = (DWORD)secs;
+    res->s.HighPart = (DWORD)(secs >> 32);
 }
 
 /******************************************************************************
  *  RtlSecondsSince1980ToTime		[NTDLL.@]
  */
-void WINAPI RtlSecondsSince1980ToTime( DWORD time, FILETIME *res )
+void WINAPI RtlSecondsSince1980ToTime( DWORD time, LARGE_INTEGER *res )
 {
     ULONGLONG secs = RtlExtendedIntegerMultiply( time + SECS_1601_to_1980, 10000000 );
-    res->dwLowDateTime  = (DWORD)secs;
-    res->dwHighDateTime = (DWORD)(secs >> 32);
+    res->s.LowPart  = (DWORD)secs;
+    res->s.HighPart = (DWORD)(secs >> 32);
 }
 
 /******************************************************************************
@@ -269,7 +269,7 @@
  *      NtQuerySystemTime   (NTDLL.@)
  *      ZwQuerySystemTime   (NTDLL.@)
  */
-void WINAPI NtQuerySystemTime( LARGE_INTEGER *time )
+NTSTATUS WINAPI NtQuerySystemTime( PLARGE_INTEGER time )
 {
     ULONGLONG secs;
     struct timeval now;
@@ -278,4 +278,5 @@
     secs = RtlExtendedIntegerMultiply( now.tv_sec+SECS_1601_TO_1970, 10000000 ) + now.tv_usec * 10;
     time->s.LowPart  = (DWORD)secs;
     time->s.HighPart = (DWORD)(secs >> 32);
+    return STATUS_SUCCESS;
 }
diff --git a/dlls/ntdll/wcstring.c b/dlls/ntdll/wcstring.c
index b366b5e..0ebe509 100644
--- a/dlls/ntdll/wcstring.c
+++ b/dlls/ntdll/wcstring.c
@@ -27,7 +27,7 @@
 #include <string.h>
 #include <stdio.h>
 
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/unicode.h"
 #include "wine/debug.h"
 
diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c
index 5f41bd2..7bceab4 100644
--- a/dlls/ole32/hglobalstream.c
+++ b/dlls/ole32/hglobalstream.c
@@ -33,7 +33,7 @@
 #include "ole2.h"
 #include "winbase.h"
 #include "winerror.h"
-#include "ntddk.h"
+#include "winternl.h"
 
 #include "wine/debug.h"
 
diff --git a/dlls/ole32/stg_stream.c b/dlls/ole32/stg_stream.c
index 4b24d27..8ee4995 100644
--- a/dlls/ole32/stg_stream.c
+++ b/dlls/ole32/stg_stream.c
@@ -29,7 +29,7 @@
 
 #include "winbase.h"
 #include "winerror.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/debug.h"
 
 #include "storage32.h"
diff --git a/dlls/ole32/storage.c b/dlls/ole32/storage.c
index 2a22166..a4a5b62 100644
--- a/dlls/ole32/storage.c
+++ b/dlls/ole32/storage.c
@@ -31,7 +31,7 @@
 # include <unistd.h>
 #endif
 #include "windef.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "winerror.h"
 #include "wine/winbase16.h"
 #include "wine/unicode.h"
@@ -1728,5 +1728,3 @@
 	return S_OK;
 
 }
-
-
diff --git a/dlls/oleaut32/tmarshal.c b/dlls/oleaut32/tmarshal.c
index a8c3e64..1d12e2f 100644
--- a/dlls/oleaut32/tmarshal.c
+++ b/dlls/oleaut32/tmarshal.c
@@ -40,7 +40,7 @@
 #include "ole2disp.h"
 #include "typelib.h"
 #include "wine/debug.h"
-#include "ntddk.h"
+#include "winternl.h"
 
 static const WCHAR riidW[5] = {'r','i','i','d',0};
 static const WCHAR pdispparamsW[] = {'p','d','i','s','p','p','a','r','a','m','s',0};
diff --git a/dlls/setupapi/dirid.c b/dlls/setupapi/dirid.c
index 27bd407..d7016ae 100644
--- a/dlls/setupapi/dirid.c
+++ b/dlls/setupapi/dirid.c
@@ -20,7 +20,7 @@
 
 #include "windef.h"
 #include "winbase.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "winerror.h"
 #include "setupapi.h"
 #include "wine/unicode.h"
diff --git a/dlls/setupapi/infparse.c b/dlls/setupapi/infparse.c
index defc34e..439696e 100644
--- a/dlls/setupapi/infparse.c
+++ b/dlls/setupapi/infparse.c
@@ -28,7 +28,7 @@
 #include <string.h>
 #include "windef.h"
 #include "winbase.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/winbase16.h"
 #include "setupapi.h"
 #include "setupx16.h"
diff --git a/dlls/setupapi/install.c b/dlls/setupapi/install.c
index 15c13fb..ed61058 100644
--- a/dlls/setupapi/install.c
+++ b/dlls/setupapi/install.c
@@ -20,7 +20,7 @@
 
 #include "windef.h"
 #include "winbase.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "winerror.h"
 #include "setupapi.h"
 #include "wine/unicode.h"
diff --git a/dlls/setupapi/parser.c b/dlls/setupapi/parser.c
index aaf3ff9..0123bd3 100644
--- a/dlls/setupapi/parser.c
+++ b/dlls/setupapi/parser.c
@@ -27,7 +27,7 @@
 #include <stdlib.h>
 
 #include "windef.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "winbase.h"
 #include "winerror.h"
 #include "wine/unicode.h"
diff --git a/dlls/setupapi/queue.c b/dlls/setupapi/queue.c
index 950fcab..476fd00 100644
--- a/dlls/setupapi/queue.c
+++ b/dlls/setupapi/queue.c
@@ -20,7 +20,7 @@
 
 #include "windef.h"
 #include "winbase.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "winerror.h"
 #include "setupapi.h"
 #include "wine/unicode.h"
diff --git a/dlls/winedos/int21.c b/dlls/winedos/int21.c
index 1f4af57..8b74a65 100644
--- a/dlls/winedos/int21.c
+++ b/dlls/winedos/int21.c
@@ -26,7 +26,7 @@
 
 #include "windef.h"
 #include "winbase.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/winbase16.h"
 #include "dosexe.h"
 #include "miscemu.h"
diff --git a/dlls/winmm/mmsystem.c b/dlls/winmm/mmsystem.c
index 42cbf8d..82cb3db 100644
--- a/dlls/winmm/mmsystem.c
+++ b/dlls/winmm/mmsystem.c
@@ -41,7 +41,7 @@
 #include "wine/mmsystem16.h"
 #include "wine/winuser16.h"
 #include "heap.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "winemm.h"
 
 #include "wine/debug.h"
diff --git a/files/directory.c b/files/directory.c
index ba2202e..c48b867 100644
--- a/files/directory.c
+++ b/files/directory.c
@@ -41,7 +41,7 @@
 #include "wine/winuser16.h"
 #include "winerror.h"
 #include "winreg.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/unicode.h"
 #include "drive.h"
 #include "file.h"
diff --git a/files/dos_fs.c b/files/dos_fs.c
index f7e5806..3cb33f1 100644
--- a/files/dos_fs.c
+++ b/files/dos_fs.c
@@ -50,7 +50,7 @@
 #include "file.h"
 #include "heap.h"
 #include "msdos.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/server.h"
 #include "msvcrt/excpt.h"
 
diff --git a/files/drive.c b/files/drive.c
index 4a49725..4590cab 100644
--- a/files/drive.c
+++ b/files/drive.c
@@ -55,7 +55,7 @@
 #endif
 
 #include "winbase.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/winbase16.h"   /* for GetCurrentTask */
 #include "winerror.h"
 #include "winioctl.h"
diff --git a/files/file.c b/files/file.c
index 9cf0996..11acdb2 100644
--- a/files/file.c
+++ b/files/file.c
@@ -59,7 +59,7 @@
 #include "windef.h"
 #include "winbase.h"
 #include "winreg.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/winbase16.h"
 #include "wine/server.h"
 
@@ -2969,11 +2969,11 @@
     {
         req->handle = hFile;
         if (lpLastAccessTime)
-            RtlTimeToSecondsSince1970( lpLastAccessTime, (DWORD *)&req->access_time );
+            RtlTimeToSecondsSince1970( (PLARGE_INTEGER) lpLastAccessTime, (DWORD *)&req->access_time );
         else
             req->access_time = 0; /* FIXME */
         if (lpLastWriteTime)
-            RtlTimeToSecondsSince1970( lpLastWriteTime, (DWORD *)&req->write_time );
+            RtlTimeToSecondsSince1970( (PLARGE_INTEGER) lpLastWriteTime, (DWORD *)&req->write_time );
         else
             req->write_time = 0; /* FIXME */
         ret = !wine_server_call_err( req );
diff --git a/files/profile.c b/files/profile.c
index 58ffa7e..e5a1ecf 100644
--- a/files/profile.c
+++ b/files/profile.c
@@ -38,7 +38,7 @@
 #include "winbase.h"
 #include "winnls.h"
 #include "winerror.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/winbase16.h"
 #include "winreg.h"
 #include "drive.h"
diff --git a/include/ntddk.h b/include/ntddk.h
deleted file mode 100644
index 58f4bb8..0000000
--- a/include/ntddk.h
+++ /dev/null
@@ -1,1182 +0,0 @@
-/*
- * this file defines interfaces mainly exposed to device drivers and
- * native nt dlls
- *
- * Copyright (C) the Wine project
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __WINE_NTDDK_H
-#define __WINE_NTDDK_H
-
-#include "ntdef.h"
-#include "winnt.h"
-#include "winreg.h"
-#include "winbase.h"	/* FIXME: should be taken out sometimes */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/******************
- * asynchronous I/O
- */
-#undef Status	/* conflict with X11-includes*/
-
-typedef struct _IO_STATUS_BLOCK
-{
-	union {
-	  NTSTATUS Status;
-	  PVOID Pointer;
-	} DUMMYUNIONNAME;
-	ULONG_PTR Information;
-} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
-
-typedef VOID (NTAPI *PIO_APC_ROUTINE) ( PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved );
-
-/*
-	registry
- */
-
- /* key information */
-typedef struct _KEY_BASIC_INFORMATION {
-	LARGE_INTEGER	LastWriteTime;
-	ULONG		TitleIndex;
-	ULONG		NameLength;
-	WCHAR		Name[1];
-} KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
-
-typedef struct _KEY_NODE_INFORMATION
-{
-	LARGE_INTEGER	LastWriteTime;
-	ULONG		TitleIndex;
-	ULONG		ClassOffset;
-	ULONG		ClassLength;
-	ULONG		NameLength;
-	WCHAR		Name[1];
-/*	Class[1]; */
-} KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
-
-typedef struct _KEY_FULL_INFORMATION
-{
-	LARGE_INTEGER	LastWriteTime;
-	ULONG		TitleIndex;
-	ULONG		ClassOffset;
-	ULONG		ClassLength;
-	ULONG		SubKeys;
-	ULONG		MaxNameLen;
-	ULONG		MaxClassLen;
-	ULONG		Values;
-	ULONG		MaxValueNameLen;
-	ULONG		MaxValueDataLen;
-	WCHAR		Class[1];
-} KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
-
-typedef enum _KEY_INFORMATION_CLASS
-{
-	KeyBasicInformation,
-	KeyNodeInformation,
-	KeyFullInformation
-} KEY_INFORMATION_CLASS;
-
-typedef struct _KEY_VALUE_ENTRY
-{
-	PUNICODE_STRING	ValueName;
-	ULONG		DataLength;
-	ULONG		DataOffset;
-	ULONG		Type;
-} KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
-
-/* value information */
-typedef struct _KEY_VALUE_BASIC_INFORMATION
-{
-	ULONG   TitleIndex;
-	ULONG   Type;
-	ULONG   NameLength;
-	WCHAR   Name[1];
-} KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
-
-typedef struct _KEY_VALUE_FULL_INFORMATION
-{
-	ULONG   TitleIndex;
-	ULONG   Type;
-	ULONG   DataOffset;
-	ULONG   DataLength;
-	ULONG   NameLength;
-	WCHAR   Name[1];
-/*	UCHAR 	Data[1];*/
-} KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
-
-typedef struct _KEY_VALUE_PARTIAL_INFORMATION
-{
-	ULONG   TitleIndex;
-	ULONG   Type;
-	ULONG   DataLength;
-	UCHAR   Data[1];
-} KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
-
-typedef enum _KEY_VALUE_INFORMATION_CLASS
-{
-	KeyValueBasicInformation,
-	KeyValueFullInformation,
-	KeyValuePartialInformation,
-	KeyValueFullInformationAlign64,
-	KeyValuePartialInformationAlign64
-} KEY_VALUE_INFORMATION_CLASS;
-
-NTSTATUS WINAPI RtlFormatCurrentUserKeyPath(
-	PUNICODE_STRING KeyPath);
-
-/*	thread information */
-
-typedef enum _THREADINFOCLASS
-{	ThreadBasicInformation,
-	ThreadTimes,
-	ThreadPriority,
-	ThreadBasePriority,
-	ThreadAffinityMask,
-	ThreadImpersonationToken,
-	ThreadDescriptorTableEntry,
-	ThreadEnableAlignmentFaultFixup,
-	ThreadEventPair_Reusable,
-	ThreadQuerySetWin32StartAddress,
-	ThreadZeroTlsCell,
-	ThreadPerformanceCount,
-	ThreadAmILastThread,
-	ThreadIdealProcessor,
-	ThreadPriorityBoost,
-	ThreadSetTlsArrayAddress,
-	ThreadIsIoPending,
-	MaxThreadInfoClass
-} THREADINFOCLASS;
-
-typedef struct {
-/* This is used by NtQuerySystemInformation */
-	FILETIME ftCreationTime;
-	DWORD dwUnknown1;
-	DWORD dwStartAddress;
-	DWORD dwOwningPID;
-	DWORD dwThreadID;
-	DWORD dwCurrentPriority;
-	DWORD dwBasePriority;
-	DWORD dwContextSwitches;
-	DWORD dwThreadState;
-	DWORD dwWaitReason;
-	DWORD dwUnknown2[5];
-} THREADINFO, *PTHREADINFO;
-
-/*	file information */
-
-typedef enum _FILE_INFORMATION_CLASS {
-	FileDirectoryInformation = 1,
-	FileFullDirectoryInformation,
-	FileBothDirectoryInformation,
-	FileBasicInformation,
-	FileStandardInformation,
-	FileInternalInformation,
-	FileEaInformation,
-	FileAccessInformation,
-	FileNameInformation,
-	FileRenameInformation,
-	FileLinkInformation,
-	FileNamesInformation,
-	FileDispositionInformation,
-	FilePositionInformation,
-	FileFullEaInformation,
-	FileModeInformation,
-	FileAlignmentInformation,
-	FileAllInformation,
-	FileAllocationInformation,
-	FileEndOfFileInformation,
-	FileAlternateNameInformation,
-	FileStreamInformation,
-	FilePipeInformation,
-	FilePipeLocalInformation,
-	FilePipeRemoteInformation,
-	FileMailslotQueryInformation,
-	FileMailslotSetInformation,
-	FileCompressionInformation,
-	FileObjectIdInformation,
-	FileCompletionInformation,
-	FileMoveClusterInformation,
-	FileQuotaInformation,
-	FileReparsePointInformation,
-	FileNetworkOpenInformation,
-	FileAttributeTagInformation,
-	FileTrackingInformation,
-	FileMaximumInformation
-} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
-
-typedef enum _FSINFOCLASS {
-	FileFsVolumeInformation = 1,
-	FileFsLabelInformation,
-	FileFsSizeInformation,
-	FileFsDeviceInformation,
-	FileFsAttributeInformation,
-	FileFsControlInformation,
-	FileFsFullSizeInformation,
-	FileFsObjectIdInformation,
-	FileFsMaximumInformation
-} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
-
-typedef enum _SECTION_INHERIT
-{
-	ViewShare = 1,
-	ViewUnmap = 2
-
-} SECTION_INHERIT;
-
-/*	object information */
-
-typedef enum _OBJECT_INFORMATION_CLASS
-{
-	DunnoTheConstants1
-
-} OBJECT_INFORMATION_CLASS, *POBJECT_INFORMATION_CLASS;
-
-
-/*	system information */
-
-typedef enum SYSTEM_INFORMATION_CLASS
-{       SystemBasicInformation = 0,
-        Unknown1,
-        SystemPerformanceInformation,
-        SystemTimeInformation,
-        Unknown4,
-        SystemProcessInformation,
-        Unknown6,
-        Unknown7,
-        Unknown8,
-        Unknown9,
-        Unknown10,
-        SystemDriverInformation,
-        Unknown12,
-        Unknown13,
-        Unknown14,
-        Unknown15,
-        SystemHandleList,
-        Unknown17,
-        Unknown18,
-        Unknown19,
-        Unknown20,
-        SystemCacheInformation
-} SYSTEM_INFORMATION_CLASS, *PSYSTEM_INFORMATION_CLASS;
-
-typedef struct {
-/* System Information Class 0x00 */
-        DWORD dwUnknown1;
-        ULONG uKeMaximumIncrement;
-        ULONG uPageSize;
-        ULONG uMmNumberOfPhysicalPages;
-        ULONG uMmLowestPhysicalPage;
-        ULONG uMmHighestPhysicalPage;
-        ULONG uAllocationGranularity;
-        PVOID pLowestUserAddress;
-        PVOID pMmHighestUserAddress;
-        ULONG uKeActiveProcessors;
-        BYTE bKeNumberProcessors;
-        BYTE bUnknown2;
-        WORD wUnknown3;
-} SYSTEM_BASIC_INFORMATION;
-
-typedef struct {
-/* System Information Class 0x02 */
-        LARGE_INTEGER liIdleTime;
-        DWORD dwSpare[76];
-} SYSTEM_PERFORMANCE_INFORMATION;
-
-typedef struct {
-/* System Information Class 0x03 */
-        LARGE_INTEGER liKeBootTime;
-        LARGE_INTEGER liKeSystemTime;
-        LARGE_INTEGER liExpTimeZoneBias;
-        ULONG uCurrentTimeZoneId;
-        DWORD dwReserved;
-} SYSTEM_TIME_INFORMATION;
-
-typedef struct {
-/* System Information Class 0x05 */
-        DWORD dwOffset;
-        DWORD dwThreadCount;
-        DWORD dwUnknown1[6];
-        FILETIME ftCreationTime;
-        DWORD dwUnknown2[5];
-        WCHAR* pszProcessName;
-        DWORD dwBasePriority;
-        DWORD dwProcessID;
-        DWORD dwParentProcessID;
-        DWORD dwHandleCount;
-        DWORD dwUnknown3;
-        DWORD dwUnknown4;
-        DWORD dwVirtualBytesPeak;
-        DWORD dwVirtualBytes;
-        DWORD dwPageFaults;
-        DWORD dwWorkingSetPeak;
-        DWORD dwWorkingSet;
-        DWORD dwUnknown5;
-        DWORD dwPagedPool;
-        DWORD dwUnknown6;
-        DWORD dwNonPagedPool;
-        DWORD dwPageFileBytesPeak;
-        DWORD dwPrivateBytes;
-        DWORD dwPageFileBytes;
-        DWORD dwUnknown7[4];
-        THREADINFO ti[1];
-} SYSTEM_PROCESS_INFORMATION;
-
-typedef struct {
-/* System Information Class 0x0b */
-        PVOID pvAddress;
-        DWORD dwUnknown1;
-        DWORD dwUnknown2;
-        DWORD dwEntryIndex;
-        DWORD dwUnknown3;
-        char szName[MAX_PATH + 1];
-} SYSTEM_DRIVER_INFORMATION;
-
-typedef struct {
-/* System Information Class 0x10 */
-        USHORT dwPID;
-        USHORT dwCreatorBackTraceIndex;
-        BYTE bObjectType;
-        BYTE bHandleAttributes;
-        USHORT usHandleOffset;
-        DWORD dwKeObject;
-        ULONG ulGrantedAccess;
-} HANDLEINFO, *PHANDLEINFO;
-
-typedef struct {
-/* System Information Class 0x15 */
-        ULONG CurrentSize;
-        ULONG PeakSize;
-        ULONG PageFaultCount;
-        ULONG MinimumWorkingSet;
-        ULONG MaximumWorkingSet;
-        ULONG unused[4];
-} SYSTEM_CACHE_INFORMATION;
-
-/* reading coffee grounds... */
-typedef struct _THREAD_INFO
-{	DWORD	Unknown1[6];
-	DWORD	ThreadID;
-	DWORD	Unknown2[3];
-	DWORD	Status;
-	DWORD	WaitReason;
-	DWORD	Unknown3[4];
-} THREAD_INFO, PTHREAD_INFO;
-
-typedef struct _VM_COUNTERS_
-{	ULONG PeakVirtualSize;
-	ULONG VirtualSize;
-	ULONG PageFaultCount;
-	ULONG PeakWorkingSetSize;
-	ULONG WorkingSetSize;
-	ULONG QuotaPeakPagedPoolUsage;
-	ULONG QuotaPagedPoolUsage;
-	ULONG QuotaPeakNonPagedPoolUsage;
-	ULONG QuotaNonPagedPoolUsage;
-	ULONG PagefileUsage;
-	ULONG PeakPagefileUsage;
-} VM_COUNTERS, *PVM_COUNTERS;
-
-/* process information */
-
-typedef struct _PROCESS_INFO
-{	DWORD		Offset;		/* 00 offset to next PROCESS_INFO ok*/
-	DWORD		ThreadCount;	/* 04 number of ThreadInfo member ok */
-	DWORD		Unknown1[6];
-	FILETIME	CreationTime;	/* 20 */
-	DWORD		Unknown2[5];
-	PWCHAR		ProcessName;	/* 3c ok */
-	DWORD		BasePriority;
-	DWORD		ProcessID;	/* 44 ok*/
-	DWORD		ParentProcessID;
-	DWORD		HandleCount;
-	DWORD		Unknown3[2];	/* 50 */
-	ULONG		PeakVirtualSize;
-	ULONG		VirtualSize;
-	ULONG		PageFaultCount;
-	ULONG		PeakWorkingSetSize;
-	ULONG		WorkingSetSize;
-	ULONG		QuotaPeakPagedPoolUsage;
-	ULONG		QuotaPagedPoolUsage;
-	ULONG		QuotaPeakNonPagedPoolUsage;
-	ULONG		QuotaNonPagedPoolUsage;
-	ULONG		PagefileUsage;
-	ULONG		PeakPagefileUsage;
-	DWORD		PrivateBytes;
-	DWORD		Unknown6[4];
-	THREAD_INFO 	ati[ANYSIZE_ARRAY];	/* 94 size=0x40*/
-} PROCESS_INFO, PPROCESS_INFO;
-
-NTSTATUS WINAPI NtQuerySystemInformation(
-	IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
-	OUT PVOID SystemInformation,
-	IN ULONG Length,
-	OUT PULONG ResultLength);
-
-/*
- *	system configuration
- */
-
-
-typedef struct _SYSTEM_TIME_ADJUSTMENT
-{
-	ULONG	TimeAdjustment;
-	BOOLEAN	TimeAdjustmentDisabled;
-
-} SYSTEM_TIME_ADJUSTMENT, *PSYSTEM_TIME_ADJUSTMENT;
-
-typedef struct _SYSTEM_CONFIGURATION_INFO
-{
-	union
-	{ ULONG	OemId;
-	  struct
-	  { WORD	ProcessorArchitecture;
-	    WORD	Reserved;
-	  } tag1;
-	} tag2;
-	ULONG	PageSize;
-	PVOID	MinimumApplicationAddress;
-	PVOID	MaximumApplicationAddress;
-	ULONG	ActiveProcessorMask;
-	ULONG	NumberOfProcessors;
-	ULONG	ProcessorType;
-	ULONG	AllocationGranularity;
-	WORD	ProcessorLevel;
-	WORD	ProcessorRevision;
-
-} SYSTEM_CONFIGURATION_INFO, *PSYSTEM_CONFIGURATION_INFO;
-
-
-/*
- *	NtQueryProcessInformation
- */
-
-/* parameter ProcessInformationClass */
-
-typedef enum _PROCESSINFOCLASS
-{	ProcessBasicInformation,
-	ProcessQuotaLimits,
-	ProcessIoCounters,
-	ProcessVmCounters,
-	ProcessTimes,
-	ProcessBasePriority,
-	ProcessRaisePriority,
-	ProcessDebugPort,
-	ProcessExceptionPort,
-	ProcessAccessToken,
-	ProcessLdtInformation,
-	ProcessLdtSize,
-	ProcessDefaultHardErrorMode,
-	ProcessIoPortHandlers,
-	ProcessPooledUsageAndLimits,
-	ProcessWorkingSetWatch,
-	ProcessUserModeIOPL,
-	ProcessEnableAlignmentFaultFixup,
-	ProcessPriorityClass,
-	ProcessWx86Information,
-	ProcessHandleCount,
-	ProcessAffinityMask,
-	ProcessPriorityBoost,
-	ProcessDeviceMap,
-	ProcessSessionInformation,
-	ProcessForegroundInformation,
-	ProcessWow64Information,
-	MaxProcessInfoClass
-} PROCESSINFOCLASS;
-
-/* parameter ProcessInformation (depending on ProcessInformationClass) */
-
-typedef struct _PROCESS_BASIC_INFORMATION
-{	DWORD	ExitStatus;
-	DWORD	PebBaseAddress;
-	DWORD	AffinityMask;
-	DWORD	BasePriority;
-	ULONG	UniqueProcessId;
-	ULONG	InheritedFromUniqueProcessId;
-} PROCESS_BASIC_INFORMATION;
-
-NTSTATUS WINAPI NtQueryInformationProcess(
-	IN HANDLE ProcessHandle,
-	IN PROCESSINFOCLASS ProcessInformationClass,
-	OUT PVOID ProcessInformation,
-	IN ULONG ProcessInformationLength,
-	OUT PULONG ReturnLength);
-
-#define NtCurrentProcess() ( (HANDLE) -1 )
-
-/*
- *	timer
- */
-
-typedef enum _TIMER_TYPE
-{
-	NotificationTimer,
-	SynchronizationTimer
-
-} TIMER_TYPE;
-
-/*	token functions */
-
-NTSTATUS WINAPI NtOpenProcessToken(
-	HANDLE ProcessHandle,
-	DWORD DesiredAccess,
-	HANDLE *TokenHandle);
-
-NTSTATUS WINAPI NtOpenThreadToken(
-	HANDLE ThreadHandle,
-	DWORD DesiredAccess,
-	BOOLEAN OpenAsSelf,
-	HANDLE *TokenHandle);
-
-NTSTATUS WINAPI NtAdjustPrivilegesToken(
-	IN HANDLE TokenHandle,
-	IN BOOLEAN DisableAllPrivileges,
-	IN PTOKEN_PRIVILEGES NewState,
-	IN DWORD BufferLength,
-	OUT PTOKEN_PRIVILEGES PreviousState,
-	OUT PDWORD ReturnLength);
-
-NTSTATUS WINAPI NtQueryInformationToken(
-	HANDLE token,
-	DWORD tokeninfoclass,
-	LPVOID tokeninfo,
-	DWORD tokeninfolength,
-	LPDWORD retlen );
-
-/*	sid functions */
-
-BOOLEAN WINAPI RtlAllocateAndInitializeSid (
-	PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
-	BYTE nSubAuthorityCount,
-	DWORD nSubAuthority0, DWORD nSubAuthority1,
-	DWORD nSubAuthority2, DWORD nSubAuthority3,
-	DWORD nSubAuthority4, DWORD nSubAuthority5,
-	DWORD nSubAuthority6, DWORD nSubAuthority7,
-	PSID *pSid );
-
-BOOL WINAPI RtlInitializeSid(
-	PSID pSid,
-	PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
-	BYTE nSubAuthorityCount);
-
-DWORD WINAPI RtlFreeSid(
-	PSID pSid);
-
-BOOL WINAPI RtlEqualSid(
-	PSID pSid1,
-	PSID pSid2 );
-
-DWORD WINAPI RtlLengthRequiredSid(
-	DWORD nrofsubauths);
-
-DWORD WINAPI RtlLengthSid(
-	PSID sid);
-
-LPDWORD WINAPI RtlSubAuthoritySid(
-	PSID PSID,
-	DWORD nr);
-
-LPBYTE WINAPI RtlSubAuthorityCountSid(
-	PSID pSid);
-
-DWORD WINAPI RtlCopySid(
-	DWORD len,
-	PSID to,
-	PSID from);
-
-BOOL WINAPI RtlValidSid(
-	PSID pSid);
-
-BOOL WINAPI RtlEqualPrefixSid(
-	PSID pSid1,
-	PSID pSid2);
-
-PSID_IDENTIFIER_AUTHORITY WINAPI RtlIdentifierAuthoritySid(
-	PSID pSid );
-
-/*	security descriptor functions */
-
-NTSTATUS WINAPI RtlCreateSecurityDescriptor(
-	PSECURITY_DESCRIPTOR lpsd,
-	DWORD rev);
-
-NTSTATUS WINAPI RtlValidSecurityDescriptor(
-	PSECURITY_DESCRIPTOR SecurityDescriptor);
-
-ULONG WINAPI RtlLengthSecurityDescriptor(
-	PSECURITY_DESCRIPTOR SecurityDescriptor);
-
-NTSTATUS WINAPI RtlGetDaclSecurityDescriptor(
-	IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
-	OUT PBOOLEAN lpbDaclPresent,
-	OUT PACL *pDacl,
-	OUT PBOOLEAN lpbDaclDefaulted);
-
-NTSTATUS WINAPI RtlSetDaclSecurityDescriptor (
-	PSECURITY_DESCRIPTOR lpsd,
-	BOOLEAN daclpresent,
-	PACL dacl,
-	BOOLEAN dacldefaulted );
-
-NTSTATUS WINAPI RtlGetSaclSecurityDescriptor(
-	IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
-	OUT PBOOLEAN lpbSaclPresent,
-	OUT PACL *pSacl,
-	OUT PBOOLEAN lpbSaclDefaulted);
-
-NTSTATUS WINAPI RtlSetSaclSecurityDescriptor (
-	PSECURITY_DESCRIPTOR lpsd,
-	BOOLEAN saclpresent,
-	PACL sacl,
-	BOOLEAN sacldefaulted);
-
-NTSTATUS WINAPI RtlGetOwnerSecurityDescriptor(
-	PSECURITY_DESCRIPTOR SecurityDescriptor,
-	PSID *Owner,
-	PBOOLEAN OwnerDefaulted);
-
-NTSTATUS WINAPI RtlSetOwnerSecurityDescriptor(
-	PSECURITY_DESCRIPTOR lpsd,
-	PSID owner,
-	BOOLEAN ownerdefaulted);
-
-NTSTATUS WINAPI RtlSetGroupSecurityDescriptor (
-	PSECURITY_DESCRIPTOR lpsd,
-	PSID group,
-	BOOLEAN groupdefaulted);
-
-NTSTATUS WINAPI RtlGetGroupSecurityDescriptor(
-	PSECURITY_DESCRIPTOR SecurityDescriptor,
-	PSID *Group,
-	PBOOLEAN GroupDefaulted);
-
-NTSTATUS WINAPI RtlMakeSelfRelativeSD(
-	IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
-	IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
-	IN OUT LPDWORD lpdwBufferLength);
-
-NTSTATUS WINAPI RtlGetControlSecurityDescriptor(
-	PSECURITY_DESCRIPTOR  pSecurityDescriptor,
-	PSECURITY_DESCRIPTOR_CONTROL pControl,
-	LPDWORD lpdwRevision);
-
-/*	acl functions */
-
-NTSTATUS WINAPI RtlCreateAcl(
-	PACL acl,
-	DWORD size,
-	DWORD rev);
-
-BOOLEAN WINAPI RtlFirstFreeAce(
-	PACL acl,
-	PACE_HEADER *x);
-
-NTSTATUS WINAPI RtlAddAce(
-	PACL acl,
-	DWORD rev,
-	DWORD xnrofaces,
-	PACE_HEADER acestart,
-	DWORD acelen);
-
-BOOL WINAPI RtlAddAccessAllowedAce(
-	IN OUT PACL pAcl,
-	IN DWORD dwAceRevision,
-	IN DWORD AccessMask,
-	IN PSID pSid);
-
-BOOL WINAPI AddAccessAllowedAceEx(
-	IN OUT PACL pAcl,
-	IN DWORD dwAceRevision,
-	IN DWORD AceFlags,
-	IN DWORD AccessMask,
-	IN PSID pSid);
-
-DWORD WINAPI RtlGetAce(
-	PACL pAcl,
-	DWORD dwAceIndex,
-	LPVOID *pAce );
-
-/*	string functions */
-
-DWORD       WINAPI RtlAnsiStringToUnicodeSize(const STRING*);
-NTSTATUS    WINAPI RtlAnsiStringToUnicodeString(UNICODE_STRING*,const STRING *,BOOLEAN);
-NTSTATUS    WINAPI RtlAppendAsciizToString(STRING*,LPCSTR);
-NTSTATUS    WINAPI RtlAppendStringToString(STRING*,const STRING*);
-NTSTATUS    WINAPI RtlAppendUnicodeStringToString(UNICODE_STRING*,const UNICODE_STRING*);
-NTSTATUS    WINAPI RtlAppendUnicodeToString(UNICODE_STRING*,LPCWSTR);
-LONG        WINAPI RtlCompareString(const STRING*,const STRING*,BOOLEAN);
-LONG        WINAPI RtlCompareUnicodeString(const UNICODE_STRING*,const UNICODE_STRING*,BOOLEAN);
-void        WINAPI RtlCopyString(STRING*,const STRING*);
-void        WINAPI RtlCopyUnicodeString(UNICODE_STRING*,const UNICODE_STRING*);
-BOOLEAN     WINAPI RtlCreateUnicodeString(PUNICODE_STRING,LPCWSTR);
-BOOLEAN     WINAPI RtlCreateUnicodeStringFromAsciiz(PUNICODE_STRING,LPCSTR);
-void        WINAPI RtlEraseUnicodeString(UNICODE_STRING*);
-BOOLEAN     WINAPI RtlEqualString(const STRING*,const STRING*,BOOLEAN);
-BOOLEAN     WINAPI RtlEqualUnicodeString(const UNICODE_STRING*,const UNICODE_STRING*,BOOLEAN);
-void        WINAPI RtlFreeAnsiString(PSTRING);
-void        WINAPI RtlFreeOemString(PSTRING);
-void        WINAPI RtlFreeUnicodeString(PUNICODE_STRING);
-void        WINAPI RtlInitAnsiString(PSTRING,LPCSTR);
-void        WINAPI RtlInitString(PSTRING,LPCSTR);
-void        WINAPI RtlInitUnicodeString(PUNICODE_STRING,LPCWSTR);
-NTSTATUS    WINAPI RtlMultiByteToUnicodeN(LPWSTR,DWORD,LPDWORD,LPCSTR,DWORD);
-NTSTATUS    WINAPI RtlMultiByteToUnicodeSize(DWORD*,LPCSTR,UINT);
-UINT        WINAPI RtlOemStringToUnicodeSize(const STRING*);
-NTSTATUS    WINAPI RtlOemStringToUnicodeString(UNICODE_STRING*,const STRING*,BOOLEAN);
-NTSTATUS    WINAPI RtlOemToUnicodeN(LPWSTR,DWORD,LPDWORD,LPCSTR,DWORD);
-BOOLEAN     WINAPI RtlPrefixString(const STRING*,const STRING*,BOOLEAN);
-BOOLEAN     WINAPI RtlPrefixUnicodeString(const UNICODE_STRING*,const UNICODE_STRING*,BOOLEAN);
-DWORD       WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING*);
-NTSTATUS    WINAPI RtlUnicodeStringToAnsiString(STRING*,const UNICODE_STRING*,BOOLEAN);
-DWORD       WINAPI RtlUnicodeStringToOemSize(const UNICODE_STRING*);
-NTSTATUS    WINAPI RtlUnicodeStringToOemString(STRING*,const UNICODE_STRING*,BOOLEAN);
-NTSTATUS    WINAPI RtlUnicodeToMultiByteN(LPSTR,DWORD,LPDWORD,LPCWSTR,DWORD);
-NTSTATUS    WINAPI RtlUnicodeToMultiByteSize(DWORD*,LPCWSTR,UINT);
-NTSTATUS    WINAPI RtlUnicodeToOemN(LPSTR,DWORD,LPDWORD,LPCWSTR,DWORD);
-NTSTATUS    WINAPI RtlUpcaseUnicodeString(UNICODE_STRING*,const UNICODE_STRING *,BOOLEAN);
-NTSTATUS    WINAPI RtlUpcaseUnicodeStringToAnsiString(STRING*,const UNICODE_STRING*,BOOLEAN);
-NTSTATUS    WINAPI RtlUpcaseUnicodeStringToOemString(STRING*,const UNICODE_STRING*,BOOLEAN);
-NTSTATUS    WINAPI RtlUpcaseUnicodeToMultiByteN(LPSTR,DWORD,LPDWORD,LPCWSTR,DWORD);
-NTSTATUS    WINAPI RtlUpcaseUnicodeToOemN(LPSTR,DWORD,LPDWORD,LPCWSTR,DWORD);
-
-DWORD WINAPI RtlIsTextUnicode(
-	LPVOID buf,
-	DWORD len,
-	DWORD *pf);
-
-/*	resource functions */
-
-typedef struct _RTL_RWLOCK {
-	CRITICAL_SECTION	rtlCS;
-	HANDLE		hSharedReleaseSemaphore;
-	UINT			uSharedWaiters;
-	HANDLE		hExclusiveReleaseSemaphore;
-	UINT			uExclusiveWaiters;
-	INT			iNumberActive;
-	HANDLE		hOwningThreadId;
-	DWORD			dwTimeoutBoost;
-	PVOID			pDebugInfo;
-} RTL_RWLOCK, *LPRTL_RWLOCK;
-
-VOID   WINAPI RtlInitializeResource(
-	LPRTL_RWLOCK);
-
-VOID   WINAPI RtlDeleteResource(
-	LPRTL_RWLOCK);
-
-BYTE   WINAPI RtlAcquireResourceExclusive(
-	LPRTL_RWLOCK, BYTE fWait);
-
-BYTE   WINAPI RtlAcquireResourceShared(
-	LPRTL_RWLOCK, BYTE fWait);
-
-VOID   WINAPI RtlReleaseResource(
-	LPRTL_RWLOCK);
-
-VOID   WINAPI RtlDumpResource(
-	LPRTL_RWLOCK);
-
-/*	time functions */
-
-typedef struct _TIME_FIELDS
-{   CSHORT Year;
-    CSHORT Month;
-    CSHORT Day;
-    CSHORT Hour;
-    CSHORT Minute;
-    CSHORT Second;
-    CSHORT Milliseconds;
-    CSHORT Weekday;
-} TIME_FIELDS;
-
-typedef TIME_FIELDS *PTIME_FIELDS;
-
-VOID WINAPI RtlSystemTimeToLocalTime(
-	IN  PLARGE_INTEGER SystemTime,
-	OUT PLARGE_INTEGER LocalTime);
-
-VOID WINAPI RtlTimeToTimeFields(
-	PLARGE_INTEGER liTime,
-	PTIME_FIELDS TimeFields);
-
-BOOLEAN WINAPI RtlTimeFieldsToTime(
-	PTIME_FIELDS tfTimeFields,
-	PLARGE_INTEGER Time);
-
-VOID WINAPI RtlTimeToElapsedTimeFields(
-	PLARGE_INTEGER liTime,
-	PTIME_FIELDS TimeFields);
-
-void    WINAPI NtQuerySystemTime( LARGE_INTEGER *time );
-
-BOOLEAN WINAPI RtlTimeToSecondsSince1980( const FILETIME *time, LPDWORD res );
-BOOLEAN WINAPI RtlTimeToSecondsSince1970( const FILETIME *time, LPDWORD res );
-void    WINAPI RtlSecondsSince1970ToTime( DWORD time, FILETIME *res );
-void    WINAPI RtlSecondsSince1980ToTime( DWORD time, FILETIME *res );
-
-/*	heap functions */
-
-/* Data structure for heap definition. This includes various
-   sizing parameters and callback routines, which, if left NULL,
-   result in default behavior */
-
-typedef struct
-{	ULONG	Length;		/* = sizeof(RTL_HEAP_DEFINITION) */
-	ULONG	Unknown[11];
-} RTL_HEAP_DEFINITION, *PRTL_HEAP_DEFINITION;
-
-HANDLE    WINAPI RtlCreateHeap(ULONG,PVOID,ULONG,ULONG,PVOID,PRTL_HEAP_DEFINITION);
-HANDLE    WINAPI RtlDestroyHeap(HANDLE);
-PVOID     WINAPI RtlAllocateHeap(HANDLE,ULONG,ULONG);
-BOOLEAN   WINAPI RtlFreeHeap(HANDLE,ULONG,PVOID);
-PVOID     WINAPI RtlReAllocateHeap(HANDLE,ULONG,PVOID,ULONG);
-ULONG     WINAPI RtlCompactHeap(HANDLE,ULONG);
-BOOLEAN   WINAPI RtlLockHeap(HANDLE);
-BOOLEAN   WINAPI RtlUnlockHeap(HANDLE);
-ULONG     WINAPI RtlSizeHeap(HANDLE,ULONG,PVOID);
-BOOLEAN   WINAPI RtlValidateHeap(HANDLE,ULONG,PCVOID);
-ULONG     WINAPI RtlGetProcessHeaps(ULONG,HANDLE*);
-NTSTATUS  WINAPI RtlWalkHeap(HANDLE,PVOID);
-
-/*	exception */
-
-void WINAPI NtRaiseException(
-	PEXCEPTION_RECORD,PCONTEXT,BOOL);
-
-void WINAPI RtlRaiseException(
-	PEXCEPTION_RECORD);
-
-void WINAPI RtlRaiseStatus(
-	NTSTATUS);
-
-void WINAPI RtlUnwind(
-	PEXCEPTION_FRAME,
-	LPVOID,
-	PEXCEPTION_RECORD,DWORD);
-
-/*	process environment block  */
-VOID WINAPI RtlAcquirePebLock(void);
-VOID WINAPI RtlReleasePebLock(void);
-
-/*	mathematics */
-LONGLONG  WINAPI RtlConvertLongToLargeInteger( LONG a );
-LONGLONG  WINAPI RtlEnlargedIntegerMultiply( INT a, INT b );
-LONGLONG  WINAPI RtlExtendedMagicDivide( LONGLONG a, LONGLONG b, INT shift );
-LONGLONG  WINAPI RtlExtendedIntegerMultiply( LONGLONG a, INT b );
-LONGLONG  WINAPI RtlExtendedLargeIntegerDivide( LONGLONG a, INT b, INT *rem );
-LONGLONG  WINAPI RtlLargeIntegerAdd( LONGLONG a, LONGLONG b );
-LONGLONG  WINAPI RtlLargeIntegerArithmeticShift( LONGLONG a, INT count );
-LONGLONG  WINAPI RtlLargeIntegerNegate( LONGLONG a );
-LONGLONG  WINAPI RtlLargeIntegerShiftLeft( LONGLONG a, INT count );
-LONGLONG  WINAPI RtlLargeIntegerShiftRight( LONGLONG a, INT count );
-LONGLONG  WINAPI RtlLargeIntegerSubtract( LONGLONG a, LONGLONG b );
-ULONGLONG WINAPI RtlEnlargedUnsignedMultiply( UINT a, UINT b );
-UINT      WINAPI RtlEnlargedUnsignedDivide( ULONGLONG a, UINT b, UINT *remptr );
-ULONGLONG WINAPI RtlConvertUlongToLargeInteger( ULONG a );
-ULONGLONG WINAPI RtlLargeIntegerDivide( ULONGLONG a, ULONGLONG b, ULONGLONG *rem );
-
-/*	environment */
-DWORD WINAPI RtlCreateEnvironment(
-	DWORD x1,
-	DWORD x2);
-
-DWORD WINAPI RtlDestroyEnvironment(
-	DWORD x);
-
-DWORD WINAPI RtlQueryEnvironmentVariable_U(
-	DWORD x1,
-	PUNICODE_STRING key,
-	PUNICODE_STRING val) ;
-
-DWORD WINAPI RtlSetEnvironmentVariable(
-	DWORD x1,
-	PUNICODE_STRING key,
-	PUNICODE_STRING val);
-
-/*	object security */
-
-DWORD WINAPI RtlNewSecurityObject(
-	DWORD x1,
-	DWORD x2,
-	DWORD x3,
-	DWORD x4,
-	DWORD x5,
-	DWORD x6);
-
-DWORD WINAPI RtlDeleteSecurityObject(
-	DWORD x1);
-
-NTSTATUS WINAPI
-NtQuerySecurityObject(
-	IN HANDLE Object,
-	IN SECURITY_INFORMATION RequestedInformation,
-	OUT PSECURITY_DESCRIPTOR pSecurityDesriptor,
-	IN ULONG Length,
-	OUT PULONG ResultLength);
-
-NTSTATUS WINAPI
-NtSetSecurityObject(
-        IN HANDLE Handle,
-        IN SECURITY_INFORMATION SecurityInformation,
-        IN PSECURITY_DESCRIPTOR SecurityDescriptor);
-
-/*	registry functions */
-
-NTSTATUS    WINAPI NtCreateKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,
-                               const UNICODE_STRING*,ULONG,PULONG);
-NTSTATUS    WINAPI NtDeleteKey(HANDLE);
-NTSTATUS    WINAPI NtDeleteValueKey(HANDLE,const UNICODE_STRING*);
-NTSTATUS    WINAPI NtOpenKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*);
-NTSTATUS    WINAPI NtQueryKey(HANDLE,KEY_INFORMATION_CLASS,void*,DWORD,DWORD*);
-NTSTATUS    WINAPI NtSetValueKey(HANDLE,const UNICODE_STRING*,ULONG,ULONG,const void*,ULONG);
-NTSTATUS    WINAPI NtEnumerateKey(HANDLE,ULONG,KEY_INFORMATION_CLASS,void*,DWORD,DWORD*);
-NTSTATUS    WINAPI NtQueryValueKey(HANDLE,const UNICODE_STRING*,KEY_VALUE_INFORMATION_CLASS,
-                                   void*,DWORD,DWORD*);
-NTSTATUS    WINAPI NtLoadKey(const OBJECT_ATTRIBUTES*,const OBJECT_ATTRIBUTES*);
-
-
-NTSTATUS WINAPI NtEnumerateValueKey(
-	HANDLE KeyHandle,
-	ULONG Index,
-	KEY_VALUE_INFORMATION_CLASS KeyInformationClass,
-	PVOID KeyInformation,
-	ULONG Length,
-	PULONG ResultLength);
-
-NTSTATUS WINAPI NtFlushKey(HANDLE KeyHandle);
-
-NTSTATUS WINAPI NtNotifyChangeKey(
-	IN HANDLE KeyHandle,
-	IN HANDLE Event,
-	IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
-	IN PVOID ApcContext OPTIONAL,
-	OUT PIO_STATUS_BLOCK IoStatusBlock,
-	IN ULONG CompletionFilter,
-	IN BOOLEAN Asynchroneous,
-	OUT PVOID ChangeBuffer,
-	IN ULONG Length,
-	IN BOOLEAN WatchSubtree);
-
-NTSTATUS WINAPI NtQueryMultipleValueKey(
-	HANDLE KeyHandle,
-	PVALENTW ListOfValuesToQuery,
-	ULONG NumberOfItems,
-	PVOID MultipleValueInformation,
-	ULONG Length,
-	PULONG  ReturnLength);
-
-NTSTATUS WINAPI NtReplaceKey(
-	IN POBJECT_ATTRIBUTES ObjectAttributes,
-	IN HANDLE Key,
-	IN POBJECT_ATTRIBUTES ReplacedObjectAttributes);
-
-NTSTATUS WINAPI NtRestoreKey(
-	HANDLE KeyHandle,
-	HANDLE FileHandle,
-	ULONG RestoreFlags);
-
-NTSTATUS WINAPI NtSaveKey(
-	IN HANDLE KeyHandle,
-	IN HANDLE FileHandle);
-
-NTSTATUS WINAPI NtSetInformationKey(
-	IN HANDLE KeyHandle,
-	IN const int KeyInformationClass,
-	IN PVOID KeyInformation,
-	IN ULONG KeyInformationLength);
-
-NTSTATUS WINAPI NtUnloadKey(
-	IN HANDLE KeyHandle);
-
-NTSTATUS WINAPI NtClose(
-	HANDLE Handle);
-
-NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code );
-NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code );
-
-NTSTATUS WINAPI NtClearEvent(HANDLE);
-NTSTATUS WINAPI NtCreateEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *,BOOLEAN,BOOLEAN);
-NTSTATUS WINAPI NtCreateSemaphore(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,ULONG);
-NTSTATUS WINAPI NtOpenEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *attr);
-NTSTATUS WINAPI NtPulseEvent(HANDLE,PULONG);
-NTSTATUS WINAPI NtReleaseSemaphore(HANDLE,ULONG,PULONG);
-NTSTATUS WINAPI NtResetEvent(HANDLE,PULONG);
-NTSTATUS WINAPI NtSetEvent(HANDLE,PULONG);
-
-NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit );
-NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION *crit, DWORD spincount );
-NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit );
-NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit );
-NTSTATUS WINAPI RtlpUnWaitCriticalSection( RTL_CRITICAL_SECTION *crit );
-NTSTATUS WINAPI RtlEnterCriticalSection( RTL_CRITICAL_SECTION *crit );
-BOOL     WINAPI RtlTryEnterCriticalSection( RTL_CRITICAL_SECTION *crit );
-NTSTATUS WINAPI RtlLeaveCriticalSection( RTL_CRITICAL_SECTION *crit );
-
-/* file functions */
-
-/* flags for NtCreateFile and NtOpenFile */
-#define FILE_DIRECTORY_FLAG  0x00000001
-#define FILE_WRITE_THROUGH   0x00000002
-#define FILE_SEQUENTIAL_ONLY 0x00000004
-#define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
-#define FILE_SYNCHRONOUS_IO_ALERT    0x00000010
-#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
-#define FILE_NON_DIRECTORY_FILE      0x00000040
-#define FILE_CREATE_TREE_CONNECTION  0x00000080
-
-/* status for NtCreateFile or NtOpenFile */
-#define FILE_SUPERSEDED  0x00000000
-#define FILE_OPENED      0x00000001
-#define FILE_CREATED     0x00000002
-#define FILE_OVERWRITTEN 0x00000003
-#define FILE_EXISTS      0x00000004
-#define FILE_DOES_NOT_EXIST 0x00000005
-
-NTSTATUS WINAPI NtCreateFile(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PIO_STATUS_BLOCK, PLARGE_INTEGER, ULONG, ULONG, ULONG, ULONG, PVOID, ULONG);
-NTSTATUS WINAPI NtOpenFile(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PIO_STATUS_BLOCK, ULONG, ULONG);
-NTSTATUS WINAPI NtReadFile(HANDLE, HANDLE, PIO_APC_ROUTINE, PVOID, PIO_STATUS_BLOCK, PVOID, ULONG, PLARGE_INTEGER, PULONG);
-
-
-/* string functions */
-extern LPSTR _strlwr( LPSTR str );
-extern LPSTR _strupr( LPSTR str );
-
-/*	misc */
-
-#if defined(__i386__) && defined(__GNUC__)
-static inline void WINAPI DbgBreakPoint(void) { __asm__ __volatile__("int3"); }
-static inline void WINAPI DbgUserBreakPoint(void) { __asm__ __volatile__("int3"); }
-#else  /* __i386__ && __GNUC__ */
-void WINAPI DbgBreakPoint(void);
-void WINAPI DbgUserBreakPoint(void);
-#endif  /* __i386__ && __GNUC__ */
-void WINAPIV DbgPrint(LPCSTR fmt, ...);
-
-DWORD WINAPI RtlAdjustPrivilege(DWORD x1,DWORD x2,DWORD x3,DWORD x4);
-DWORD WINAPI RtlIntegerToChar(DWORD x1,DWORD x2,DWORD x3,DWORD x4);
-LPVOID WINAPI RtlNormalizeProcessParams(LPVOID x);
-DWORD WINAPI RtlNtStatusToDosError(DWORD error);
-BOOLEAN WINAPI RtlGetNtProductType(LPDWORD type);
-PIMAGE_NT_HEADERS WINAPI RtlImageNtHeader(HMODULE hModule);
-PIMAGE_SECTION_HEADER WINAPI RtlImageRvaToSection( const IMAGE_NT_HEADERS *, HMODULE, DWORD );
-PVOID WINAPI RtlImageDirectoryEntryToData( HMODULE module, BOOL image, WORD dir, ULONG *size );
-PVOID WINAPI RtlImageRvaToVa( const IMAGE_NT_HEADERS *, HMODULE, DWORD, IMAGE_SECTION_HEADER **);
-
-DWORD WINAPI RtlOpenCurrentUser(
-	IN ACCESS_MASK DesiredAccess,
-	OUT PHANDLE KeyHandle);
-
-BOOLEAN WINAPI RtlDosPathNameToNtPathName_U( LPWSTR from,PUNICODE_STRING us,DWORD x2,DWORD x3);
-BOOL WINAPI RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel);
-
-NTSTATUS WINAPI
-NtAccessCheck(
-	IN PSECURITY_DESCRIPTOR SecurityDescriptor,
-	IN HANDLE ClientToken,
-	IN ACCESS_MASK DesiredAccess,
-	IN PGENERIC_MAPPING GenericMapping,
-	OUT PPRIVILEGE_SET PrivilegeSet,
-	OUT PULONG ReturnLength,
-	OUT PULONG GrantedAccess,
-	OUT PBOOLEAN AccessStatus);
-
-/* bitmap functions */
-
-/* Bitmap data type */
-typedef struct tagRTL_BITMAP
-{
-  ULONG  SizeOfBitMap; /* Number of bits in the bitmap */
-  LPBYTE BitMapBuffer; /* Bitmap data, assumed sized to a DWORD boundary */
-} RTL_BITMAP, *PRTL_BITMAP;
-
-typedef const RTL_BITMAP* PCRTL_BITMAP;
-
-/* Bit run data type */
-typedef struct tagRTL_BITMAP_RUN
-{
-  ULONG StartOfRun; /* Bit position at which run starts - FIXME: Name? */
-  ULONG SizeOfRun;  /* Size of the run in bits - FIXME: Name? */
-} RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
-
-typedef const RTL_BITMAP_RUN* PCRTL_BITMAP_RUN;
-
-/* Bitmap functions */
-VOID    WINAPI RtlInitializeBitMap(PRTL_BITMAP,LPBYTE,ULONG);
-VOID    WINAPI RtlSetAllBits(PRTL_BITMAP);
-VOID    WINAPI RtlClearAllBits(PRTL_BITMAP);
-VOID    WINAPI RtlSetBits(PRTL_BITMAP,ULONG,ULONG);
-VOID    WINAPI RtlClearBits(PRTL_BITMAP,ULONG,ULONG);
-ULONG   WINAPI RtlFindSetBits(PCRTL_BITMAP,ULONG,ULONG);
-ULONG   WINAPI RtlFindClearBits(PCRTL_BITMAP,ULONG,ULONG);
-ULONG   WINAPI RtlFindSetBitsAndClear(PRTL_BITMAP,ULONG,ULONG);
-ULONG   WINAPI RtlFindClearBitsAndSet(PRTL_BITMAP,ULONG,ULONG);
-ULONG   WINAPI RtlNumberOfSetBits(PCRTL_BITMAP);
-ULONG   WINAPI RtlNumberOfClearBits(PCRTL_BITMAP);
-ULONG   WINAPI RtlFindSetRuns(PCRTL_BITMAP,PRTL_BITMAP_RUN,ULONG,BOOLEAN);
-ULONG   WINAPI RtlFindClearRuns(PCRTL_BITMAP,PRTL_BITMAP_RUN,ULONG,BOOLEAN);
-ULONG   WINAPI RtlFindLongestRunSet(PCRTL_BITMAP,PULONG);
-ULONG   WINAPI RtlFindLongestRunClear(PCRTL_BITMAP,PULONG);
-BOOLEAN WINAPI RtlAreBitsSet(PCRTL_BITMAP,ULONG,ULONG);
-BOOLEAN WINAPI RtlAreBitsClear(PCRTL_BITMAP,ULONG,ULONG);
-ULONG   WINAPI RtlFindLastBackwardRunSet(PCRTL_BITMAP,ULONG,PULONG);
-ULONG   WINAPI RtlFindLastBackwardRunClear(PCRTL_BITMAP,ULONG,PULONG);
-ULONG   WINAPI RtlFindNextForwardRunSet(PCRTL_BITMAP,ULONG,PULONG);
-ULONG   WINAPI RtlFindNextForwardRunClear(PCRTL_BITMAP,ULONG,PULONG);
-CCHAR   WINAPI RtlFindMostSignificantBit(ULONGLONG);
-CCHAR   WINAPI RtlFindLeastSignificantBit(ULONGLONG);
-
-/* Inline the trivial calls */
-#define RtlInitializeBitMap(p,b,s) \
-  do { \
-    PRTL_BITMAP _p = (p); \
-    _p->SizeOfBitMap = (s); \
-    _p->BitMapBuffer = (b); \
-  } while(0)
-
-#define RtlSetAllBits(p) \
-  do { \
-    PRTL_BITMAP _p = (p); \
-    memset(_p->BitMapBuffer,0xff,((_p->SizeOfBitMap + 31) & 0xffffffe0) >> 3); \
-  } while(0)
-
-#define RtlClearAllBits(p) \
-  do {\
-    PRTL_BITMAP _p = (p);\
-    memset(_p->BitMapBuffer,0,((_p->SizeOfBitMap + 31) & 0xffffffe0) >> 3); \
-  } while(0)
-
-inline static BOOLEAN RtlCheckBit(PCRTL_BITMAP lpBits, ULONG ulBit)
-{
-  if (lpBits && ulBit < lpBits->SizeOfBitMap &&
-      lpBits->BitMapBuffer[ulBit >> 3] & (1 << (ulBit & 7)))
-    return TRUE;
-  return FALSE;
-}
-
-/* Endianness */
-#define RtlStoreUlong(p,v)  do { ULONG _v = (v); memcpy((p), &_v, sizeof(_v)); } while (0)
-#define RtlRetrieveUlong(p,s) memcpy((p), (s), sizeof(ULONG))
-
-#define RtlStoreUlonglong(p,v) do { ULONGLONG _v = (v); memcpy((p), &_v, sizeof(_v)); } while (0)
-#define RtlRetrieveUlonglong(p,s) memcpy((p), (s), sizeof(ULONGLONG))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/include/ntdef.h b/include/ntdef.h
deleted file mode 100644
index 61d5b58..0000000
--- a/include/ntdef.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 1999 Juergen Schmied
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __WINE_NTDEF_H
-#define __WINE_NTDEF_H
-
-#include "basetsd.h"
-#include "windef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define NTAPI   __stdcall
-
-#ifndef IN
-#define IN
-#endif
-
-#ifndef OUT
-#define OUT
-#endif
-
-#ifndef OPTIONAL
-#define OPTIONAL
-#endif
-
-#ifndef VOID
-#define VOID void
-#endif
-
-typedef LONG NTSTATUS;
-typedef NTSTATUS *PNTSTATUS;
-
-typedef short CSHORT;
-typedef CSHORT *PCSHORT;
-
-
-/* NT lowlevel Strings (handled by Rtl* functions in NTDLL)
- * If they are zero terminated, Length does not include the terminating 0.
- */
-
-typedef struct _STRING {
-	USHORT	Length;
-	USHORT	MaximumLength;
-	PSTR	Buffer;
-} STRING,*PSTRING,ANSI_STRING,*PANSI_STRING;
-
-typedef struct _CSTRING {
-	USHORT	Length;
-	USHORT	MaximumLength;
-	PCSTR	Buffer;
-} CSTRING,*PCSTRING;
-
-typedef struct _UNICODE_STRING {
-	USHORT	Length;		/* bytes */
-	USHORT	MaximumLength;	/* bytes */
-	PWSTR	Buffer;
-} UNICODE_STRING,*PUNICODE_STRING;
-
-/*
-	Objects
-*/
-
-#define OBJ_INHERIT             0x00000002L
-#define OBJ_PERMANENT           0x00000010L
-#define OBJ_EXCLUSIVE           0x00000020L
-#define OBJ_CASE_INSENSITIVE    0x00000040L
-#define OBJ_OPENIF              0x00000080L
-#define OBJ_OPENLINK            0x00000100L
-#define OBJ_KERNEL_HANDLE       0x00000200L
-#define OBJ_VALID_ATTRIBUTES    0x000003F2L
-
-typedef struct _OBJECT_ATTRIBUTES
-{   ULONG Length;
-    HANDLE RootDirectory;
-    PUNICODE_STRING ObjectName;
-    ULONG Attributes;
-    PVOID SecurityDescriptor;        /* type SECURITY_DESCRIPTOR */
-    PVOID SecurityQualityOfService;  /* type SECURITY_QUALITY_OF_SERVICE */
-} OBJECT_ATTRIBUTES;
-
-typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES;
-
-#define InitializeObjectAttributes(p,n,a,r,s) \
-{	(p)->Length = sizeof(OBJECT_ATTRIBUTES); \
-	(p)->RootDirectory = r; \
-	(p)->Attributes = a; \
-	(p)->ObjectName = n; \
-	(p)->SecurityDescriptor = s; \
-	(p)->SecurityQualityOfService = NULL; \
-}
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/include/thread.h b/include/thread.h
index 8725299..29e9b7a 100644
--- a/include/thread.h
+++ b/include/thread.h
@@ -21,7 +21,7 @@
 #ifndef __WINE_THREAD_H
 #define __WINE_THREAD_H
 
-#include "ntdef.h" /* UNICODE_STRING */
+#include "winternl.h"
 #include "wine/windef16.h"
 
 struct _PDB;
diff --git a/include/wine/server.h b/include/wine/server.h
index 0e1542a..4a3aec8 100644
--- a/include/wine/server.h
+++ b/include/wine/server.h
@@ -22,7 +22,6 @@
 #define __WINE_WINE_SERVER_H
 
 #include "thread.h"
-#include "ntddk.h"
 #include "wine/exception.h"
 #include "wine/server_protocol.h"
 
diff --git a/include/winternl.h b/include/winternl.h
index 7e7f9a7..4c32a7f 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -22,6 +22,8 @@
 #define __WINE_WINTERNAL_H
 
 #include "windef.h"
+#include "winnt.h"
+#include "winreg.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -39,8 +41,9 @@
 } PEB, *PPEB;
 
 /***********************************************************************
- * PEB data structure
+ * TEB data structure
  */
+#if 0
 typedef struct _TEB {
   BYTE Reserved1[1952];
   PVOID Reserved2[412];
@@ -51,15 +54,19 @@
   PVOID Reserved5[4];
   PVOID TlsExpansionSlots;
 } TEB, *PTEB;
+#endif
 
 /**********************************************************************
- * Various types and data structures
+ * Fundamental types and data structures
  */
 
 typedef LONG NTSTATUS;
 
 typedef CONST char *PCSZ;
 
+typedef short CSHORT;
+typedef CSHORT *PCSHORT;
+
 typedef struct _STRING {
   USHORT Length;
   USHORT MaximumLength;
@@ -68,39 +75,189 @@
 
 typedef STRING ANSI_STRING;
 typedef PSTRING PANSI_STRING;
-typedef PSTRING PCANSI_STRING;
+typedef const STRING *PCANSI_STRING;
 
 typedef STRING OEM_STRING;
 typedef PSTRING POEM_STRING;
 typedef const STRING *PCOEM_STRING;
 
 typedef struct _UNICODE_STRING {
-  USHORT Length;
-  USHORT MaximumLength;
+  USHORT Length;        /* bytes */
+  USHORT MaximumLength; /* bytes */
   PWSTR  Buffer;
 } UNICODE_STRING, *PUNICODE_STRING;
 
 typedef const UNICODE_STRING *PCUNICODE_STRING;
 
-typedef struct _OBJECT_ATTRIBUTES {
-  ULONG Length;
-  HANDLE RootDirectory;
-  PUNICODE_STRING ObjectName;
-  ULONG Attributes;
-  PVOID SecurityDescriptor;
-  PVOID SecurityQualityOfService;
-} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
+/***********************************************************************
+ * Enums
+ */
 
-typedef struct _IO_STATUS_BLOCK {
-  union {
-    NTSTATUS Status;
-    PVOID Pointer;
-  } DUMMYUNIONNAME;
+typedef enum _FILE_INFORMATION_CLASS {
+    FileDirectoryInformation = 1,
+    FileFullDirectoryInformation,
+    FileBothDirectoryInformation,
+    FileBasicInformation,
+    FileStandardInformation,
+    FileInternalInformation,
+    FileEaInformation,
+    FileAccessInformation,
+    FileNameInformation,
+    FileRenameInformation,
+    FileLinkInformation,
+    FileNamesInformation,
+    FileDispositionInformation,
+    FilePositionInformation,
+    FileFullEaInformation,
+    FileModeInformation,
+    FileAlignmentInformation,
+    FileAllInformation,
+    FileAllocationInformation,
+    FileEndOfFileInformation,
+    FileAlternateNameInformation,
+    FileStreamInformation,
+    FilePipeInformation,
+    FilePipeLocalInformation,
+    FilePipeRemoteInformation,
+    FileMailslotQueryInformation,
+    FileMailslotSetInformation,
+    FileCompressionInformation,
+    FileObjectIdInformation,
+    FileCompletionInformation,
+    FileMoveClusterInformation,
+    FileQuotaInformation,
+    FileReparsePointInformation,
+    FileNetworkOpenInformation,
+    FileAttributeTagInformation,
+    FileTrackingInformation,
+    FileMaximumInformation
+} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
 
-  ULONG_PTR Information;
-} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
+typedef enum _FSINFOCLASS {
+    FileFsVolumeInformation = 1,
+    FileFsLabelInformation,
+    FileFsSizeInformation,
+    FileFsDeviceInformation,
+    FileFsAttributeInformation,
+    FileFsControlInformation,
+    FileFsFullSizeInformation,
+    FileFsObjectIdInformation,
+    FileFsMaximumInformation
+} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
 
-typedef void (WINAPI * PIO_APC_ROUTINE)(PVOID,PIO_STATUS_BLOCK,ULONG);
+typedef enum _KEY_INFORMATION_CLASS {
+    KeyBasicInformation,
+    KeyNodeInformation,
+    KeyFullInformation
+} KEY_INFORMATION_CLASS;
+
+typedef enum _KEY_VALUE_INFORMATION_CLASS {
+    KeyValueBasicInformation,
+    KeyValueFullInformation,
+    KeyValuePartialInformation,
+    KeyValueFullInformationAlign64,
+    KeyValuePartialInformationAlign64
+} KEY_VALUE_INFORMATION_CLASS;
+
+typedef enum _OBJECT_INFORMATION_CLASS {
+    DunnoTheConstants1 /* FIXME */
+} OBJECT_INFORMATION_CLASS, *POBJECT_INFORMATION_CLASS;
+
+typedef enum _PROCESSINFOCLASS {
+    ProcessBasicInformation = 0,
+    ProcessQuotaLimits = 1,
+    ProcessIoCounters = 2,
+    ProcessVmCounters = 3,
+    ProcessTimes = 4,
+    ProcessBasePriority = 5,
+    ProcessRaisePriority = 6,
+    ProcessDebugPort = 7,
+    ProcessExceptionPort = 8,
+    ProcessAccessToken = 9,
+    ProcessLdtInformation = 10,
+    ProcessLdtSize = 11,
+    ProcessDefaultHardErrorMode = 12,
+    ProcessIoPortHandlers = 13,
+    ProcessPooledUsageAndLimits = 14,
+    ProcessWorkingSetWatch = 15,
+    ProcessUserModeIOPL = 16,
+    ProcessEnableAlignmentFaultFixup = 17,
+    ProcessPriorityClass = 18,
+    ProcessWx86Information = 19,
+    ProcessHandleCount = 20,
+    ProcessAffinityMask = 21,
+    ProcessPriorityBoost = 22,
+    ProcessDeviceMap = 23,
+    ProcessSessionInformation = 24,
+    ProcessForegroundInformation = 25,
+    ProcessWow64Information = 26,
+    MaxProcessInfoClass
+} PROCESSINFOCLASS;
+
+typedef enum _SECTION_INHERIT {
+    ViewShare = 1,
+    ViewUnmap = 2
+} SECTION_INHERIT;
+
+typedef enum SYSTEM_INFORMATION_CLASS {
+    SystemBasicInformation = 0,
+    Unknown1,
+    SystemPerformanceInformation = 2,
+    SystemTimeOfDayInformation = 3, /* was SystemTimeInformation */
+    Unknown4,
+    SystemProcessInformation = 5,
+    Unknown6,
+    Unknown7,
+    SystemProcessorPerformanceInformation = 8,
+    Unknown9,
+    Unknown10,
+    SystemDriverInformation,
+    Unknown12,
+    Unknown13,
+    Unknown14,
+    Unknown15,
+    SystemHandleList,
+    Unknown17,
+    Unknown18,
+    Unknown19,
+    Unknown20,
+    SystemCacheInformation,
+    Unknown22,
+    SystemInterruptInformation = 23,
+    SystemExceptionInformation = 33,
+    SystemRegistryQuotaInformation = 37,
+    SystemLookasideInformation = 45
+} SYSTEM_INFORMATION_CLASS, *PSYSTEM_INFORMATION_CLASS;
+
+typedef enum _TIMER_TYPE {
+    NotificationTimer,
+    SynchronizationTimer
+} TIMER_TYPE;
+
+typedef enum _THREADINFOCLASS {
+    ThreadBasicInformation,
+    ThreadTimes,
+    ThreadPriority,
+    ThreadBasePriority,
+    ThreadAffinityMask,
+    ThreadImpersonationToken,
+    ThreadDescriptorTableEntry,
+    ThreadEnableAlignmentFaultFixup,
+    ThreadEventPair_Reusable,
+    ThreadQuerySetWin32StartAddress,
+    ThreadZeroTlsCell,
+    ThreadPerformanceCount,
+    ThreadAmILastThread,
+    ThreadIdealProcessor,
+    ThreadPriorityBoost,
+    ThreadSetTlsArrayAddress,
+    ThreadIsIoPending,
+    MaxThreadInfoClass
+} THREADINFOCLASS;
+
+typedef enum _WINSTATIONINFOCLASS {
+    WinStationInformation = 8
+} WINSTATIONINFOCLASS;
 
 /***********************************************************************
  * IA64 specific types and data structures
@@ -138,58 +295,264 @@
 #endif /* defined(__ia64__) */
 
 /***********************************************************************
- * Various types and data structures
+ * Types and data structures
  */
 
+/* This is used by NtQuerySystemInformation */
+/* FIXME: Isn't THREAD_INFO and THREADINFO the same structure? */
+typedef struct {
+    FILETIME ftCreationTime;
+    DWORD dwUnknown1;
+    DWORD dwStartAddress;
+    DWORD dwOwningPID;
+    DWORD dwThreadID;
+    DWORD dwCurrentPriority;
+    DWORD dwBasePriority;
+    DWORD dwContextSwitches;
+    DWORD dwThreadState;
+    DWORD dwWaitReason;
+    DWORD dwUnknown2[5];
+} THREADINFO, *PTHREADINFO;
+
+/* FIXME: Isn't THREAD_INFO and THREADINFO the same structure? */
+typedef struct _THREAD_INFO{
+    DWORD Unknown1[6];
+    DWORD ThreadID;
+    DWORD Unknown2[3];
+    DWORD Status;
+    DWORD WaitReason;
+    DWORD Unknown3[4];
+} THREAD_INFO, PTHREAD_INFO;
+
+/***********************************************************************
+ * Types and data structures
+ */
+
+typedef struct _IO_STATUS_BLOCK {
+  union {
+    NTSTATUS Status;
+    PVOID Pointer;
+  } DUMMYUNIONNAME;
+
+  ULONG_PTR Information;
+} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
+
+typedef void (WINAPI * PIO_APC_ROUTINE)(PVOID,PIO_STATUS_BLOCK,ULONG);
+
+typedef struct _KEY_BASIC_INFORMATION {
+    LARGE_INTEGER LastWriteTime;
+    ULONG         TitleIndex;
+    ULONG         NameLength;
+    WCHAR         Name[1];
+} KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
+
+typedef struct _KEY_NODE_INFORMATION
+{
+    LARGE_INTEGER LastWriteTime;
+    ULONG         TitleIndex;
+    ULONG         ClassOffset;
+    ULONG         ClassLength;
+    ULONG         NameLength;
+    WCHAR         Name[1];
+   /* Class[1]; */
+} KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
+
+typedef struct _KEY_FULL_INFORMATION
+{
+    LARGE_INTEGER LastWriteTime;
+    ULONG         TitleIndex;
+    ULONG         ClassOffset;
+    ULONG         ClassLength;
+    ULONG         SubKeys;
+    ULONG         MaxNameLen;
+    ULONG         MaxClassLen;
+    ULONG         Values;
+    ULONG         MaxValueNameLen;
+    ULONG         MaxValueDataLen;
+    WCHAR         Class[1];
+} KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
+
+typedef struct _KEY_VALUE_ENTRY
+{
+    PUNICODE_STRING ValueName;
+    ULONG           DataLength;
+    ULONG           DataOffset;
+    ULONG           Type;
+} KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
+
+typedef struct _KEY_VALUE_BASIC_INFORMATION {
+    ULONG TitleIndex;
+    ULONG Type;
+    ULONG NameLength;
+    WCHAR Name[1];
+} KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
+
+typedef struct _KEY_VALUE_FULL_INFORMATION {
+    ULONG TitleIndex;
+    ULONG Type;
+    ULONG DataOffset;
+    ULONG DataLength;
+    ULONG NameLength;
+    WCHAR Name[1];
+} KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
+
+typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
+    ULONG TitleIndex;
+    ULONG Type;
+    ULONG DataLength;
+    UCHAR Data[1];
+} KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
+
+typedef struct _OBJECT_ATTRIBUTES {
+  ULONG Length;
+  HANDLE RootDirectory;
+  PUNICODE_STRING ObjectName;
+  ULONG Attributes;
+  PVOID SecurityDescriptor;       /* type SECURITY_DESCRIPTOR */
+  PVOID SecurityQualityOfService; /* type SECURITY_QUALITY_OF_SERVICE */
+} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
+
 typedef struct _PROCESS_BASIC_INFORMATION {
+#ifdef __WINE__
+    DWORD ExitStatus;
+    DWORD PebBaseAddress;
+    DWORD AffinityMask;
+    DWORD BasePriority;
+    ULONG UniqueProcessId;
+    ULONG InheritedFromUniqueProcessId;
+#else
     PVOID Reserved1;
     PPEB PebBaseAddress;
     PVOID Reserved2[2];
     ULONG_PTR UniqueProcessId;
     PVOID Reserved3;
+#endif
 } PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION;
 
-typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION {
-    LARGE_INTEGER IdleTime;
-    LARGE_INTEGER KernelTime;
-    LARGE_INTEGER UserTime;
-    LARGE_INTEGER Reserved1[2];
-    ULONG Reserved2;
-} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
+typedef struct _PROCESS_INFO {
+    DWORD    Offset;             /* 00 offset to next PROCESS_INFO ok*/
+    DWORD    ThreadCount;        /* 04 number of ThreadInfo member ok */
+    DWORD    Unknown1[6];
+    FILETIME CreationTime;       /* 20 */
+    DWORD    Unknown2[5];
+    PWCHAR   ProcessName;        /* 3c ok */
+    DWORD    BasePriority;
+    DWORD    ProcessID;          /* 44 ok*/
+    DWORD    ParentProcessID;
+    DWORD    HandleCount;
+    DWORD    Unknown3[2];        /* 50 */
+    ULONG    PeakVirtualSize;
+    ULONG    VirtualSize;
+    ULONG    PageFaultCount;
+    ULONG    PeakWorkingSetSize;
+    ULONG    WorkingSetSize;
+    ULONG    QuotaPeakPagedPoolUsage;
+    ULONG    QuotaPagedPoolUsage;
+    ULONG    QuotaPeakNonPagedPoolUsage;
+    ULONG    QuotaNonPagedPoolUsage;
+    ULONG    PagefileUsage;
+    ULONG    PeakPagefileUsage;
+    DWORD    PrivateBytes;
+    DWORD    Unknown6[4];
+    THREAD_INFO ati[ANYSIZE_ARRAY]; /* 94 size=0x40*/
+} PROCESS_INFO, PPROCESS_INFO;
 
-typedef struct _SYSTEM_PROCESS_INFORMATION {
-    ULONG NextEntryOffset;
-    BYTE Reserved1[52];
-    PVOID Reserved2[3];
-    HANDLE UniqueProcessId;
-    PVOID Reserved3;
-    ULONG HandleCount;
-    BYTE Reserved4[4];
-    PVOID Reserved5[11];
-    SIZE_T PeakPagefileUsage;
-    SIZE_T PrivatePageCount;
-    LARGE_INTEGER Reserved6[6];
-} SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION;
+typedef struct _RTL_HEAP_DEFINITION {
+    ULONG Length; /* = sizeof(RTL_HEAP_DEFINITION) */
 
-typedef struct _SYSTEM_REGISTRY_QUOTA_INFORMATION {
-    ULONG RegistryQuotaAllowed;
-    ULONG RegistryQuotaUsed;
-    PVOID Reserved1;
-} SYSTEM_REGISTRY_QUOTA_INFORMATION, *PSYSTEM_REGISTRY_QUOTA_INFORMATION;
+    ULONG Unknown[11];
+} RTL_HEAP_DEFINITION, *PRTL_HEAP_DEFINITION;
 
+typedef struct tagRTL_BITMAP {
+    ULONG  SizeOfBitMap; /* Number of bits in the bitmap */
+    LPBYTE BitMapBuffer; /* Bitmap data, assumed sized to a DWORD boundary */
+} RTL_BITMAP, *PRTL_BITMAP;
+
+typedef const RTL_BITMAP *PCRTL_BITMAP;
+
+typedef struct tagRTL_BITMAP_RUN {
+    ULONG StartOfRun; /* Bit position at which run starts - FIXME: Name? */
+    ULONG SizeOfRun;  /* Size of the run in bits - FIXME: Name? */
+} RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
+
+typedef const RTL_BITMAP_RUN *PCRTL_BITMAP_RUN;
+
+typedef struct _RTL_RWLOCK {
+    RTL_CRITICAL_SECTION rtlCS;
+
+    HANDLE hSharedReleaseSemaphore;
+    UINT   uSharedWaiters;
+
+    HANDLE hExclusiveReleaseSemaphore;
+    UINT   uExclusiveWaiters;
+
+    INT    iNumberActive;
+    HANDLE hOwningThreadId;
+    DWORD  dwTimeoutBoost;
+    PVOID  pDebugInfo;
+} RTL_RWLOCK, *LPRTL_RWLOCK;
+
+/* System Information Class 0x00 */
 typedef struct _SYSTEM_BASIC_INFORMATION {
+#ifdef __WINE__
+    DWORD dwUnknown1;
+    ULONG uKeMaximumIncrement;
+    ULONG uPageSize;
+    ULONG uMmNumberOfPhysicalPages;
+    ULONG uMmLowestPhysicalPage;
+    ULONG uMmHighestPhysicalPage;
+    ULONG uAllocationGranularity;
+    PVOID pLowestUserAddress;
+    PVOID pMmHighestUserAddress;
+    ULONG uKeActiveProcessors;
+    BYTE bKeNumberProcessors;
+    BYTE bUnknown2;
+    WORD wUnknown3;
+#else
     BYTE Reserved1[24];
     PVOID Reserved2[4];
     CCHAR NumberOfProcessors;
+#endif
 } SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION;
 
-typedef struct _SYSTEM_TIMEOFDAY_INFORMATION {
-    BYTE Reserved1[48];
-} SYSTEM_TIMEOFDAY_INFORMATION, *PSYSTEM_TIMEOFDAY_INFORMATION;
+/* System Information Class 0x15 */
+typedef struct {
+    ULONG CurrentSize;
+    ULONG PeakSize;
+    ULONG PageFaultCount;
+    ULONG MinimumWorkingSet;
+    ULONG MaximumWorkingSet;
+    ULONG unused[4];
+} SYSTEM_CACHE_INFORMATION;
 
-typedef struct _SYSTEM_PERFORMANCE_INFORMATION {
-    BYTE Reserved1[312];
-} SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION;
+typedef struct _SYSTEM_CONFIGURATION_INFO {
+    union {
+        ULONG	OemId;
+        struct {
+	    WORD ProcessorArchitecture;
+	    WORD Reserved;
+	} tag1;
+    } tag2;
+    ULONG PageSize;
+    PVOID MinimumApplicationAddress;
+    PVOID MaximumApplicationAddress;
+    ULONG ActiveProcessorMask;
+    ULONG NumberOfProcessors;
+    ULONG ProcessorType;
+    ULONG AllocationGranularity;
+    WORD  ProcessorLevel;
+    WORD  ProcessorRevision;
+} SYSTEM_CONFIGURATION_INFO, *PSYSTEM_CONFIGURATION_INFO;
+
+/* System Information Class 0x0b */
+typedef struct {
+    PVOID pvAddress;
+    DWORD dwUnknown1;
+    DWORD dwUnknown2;
+    DWORD dwEntryIndex;
+    DWORD dwUnknown3;
+    char szName[MAX_PATH + 1];
+} SYSTEM_DRIVER_INFORMATION;
 
 typedef struct _SYSTEM_EXCEPTION_INFORMATION {
     BYTE Reserved1[16];
@@ -203,104 +566,487 @@
     BYTE Reserved1[24];
 } SYSTEM_INTERRUPT_INFORMATION, *PSYSTEM_INTERRUPT_INFORMATION;
 
+/* System Information Class 0x10 */
+typedef struct {
+    USHORT dwPID;
+    USHORT dwCreatorBackTraceIndex;
+    BYTE bObjectType;
+    BYTE bHandleAttributes;
+    USHORT usHandleOffset;
+    DWORD dwKeObject;
+    ULONG ulGrantedAccess;
+} HANDLEINFO, *PHANDLEINFO; /* FIXME: SYSTEM_HANDLE_INFORMATION? */
 
-/***********************************************************************
- * Enums
- */
+typedef struct _SYSTEM_PERFORMANCE_INFORMATION {
+    BYTE Reserved1[312];
+} SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION;
 
-typedef enum _FILE_INFORMATION_CLASS {
-    FileDirectoryInformation = 1
-} FILE_INFORMATION_CLASS;
-
-typedef enum _PROCESSINFOCLASS {
-    ProcessBasicInformation = 0,
-    ProcessWow64Information = 26
-} PROCESSINFOCLASS;
-
-typedef enum _THREADINFOCLASS {
-    ThreadIsIoPending = 16
-} THREADINFOCLASS;
-
-typedef enum _SYSTEM_INFORMATION_CLASS {
-    SystemBasicInformation = 0,
-    SystemPerformanceInformation = 2,
-    SystemTimeOfDayInformation = 3,
-    SystemProcessInformation = 5,
-    SystemProcessorPerformanceInformation = 8,
-    SystemInterruptInformation = 23,
-    SystemExceptionInformation = 33,
-    SystemRegistryQuotaInformation = 37,
-    SystemLookasideInformation = 45
-} SYSTEM_INFORMATION_CLASS;
-
-#if (_WIN32_WINNT >= 0x0501)
-#define INTERNAL_TS_ACTIVE_CONSOLE_ID ( *((volatile ULONG*)(0x7ffe02d8)) )
-#endif /* (_WIN32_WINNT >= 0x0501) */
-
-/***********************************************************************
- * Macro expensions
- */
-
-#define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
-#define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
-#define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
-
-/***********************************************************************
- * Function declarations
- */
-
-NTSTATUS WINAPI NtClose(HANDLE);
-NTSTATUS WINAPI NtCreateFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,PLARGE_INTEGER,ULONG,ULONG,ULONG,ULONG,PVOID,ULONG);
-NTSTATUS WINAPI NtOpenFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,ULONG,ULONG);
-NTSTATUS WINAPI NtDeviceIoControlFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,PVOID,ULONG,PVOID,ULONG);
-NTSTATUS WINAPI NtWaitForSingleObject(HANDLE,BOOLEAN,PLARGE_INTEGER);
-BOOLEAN  WINAPI RtlIsNameLegalDOS8Dot3(PUNICODE_STRING,POEM_STRING,PBOOLEAN);
-ULONG    WINAPI RtlNtStatusToDosError(NTSTATUS);
-NTSTATUS WINAPI NtQueryInformationProcess(HANDLE,PROCESSINFOCLASS,PVOID,ULONG,PULONG);
-NTSTATUS WINAPI NtQueryInformationThread(HANDLE,THREADINFOCLASS,PVOID,ULONG,PULONG);
-NTSTATUS WINAPI NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS,PVOID,ULONG,PULONG);
-NTSTATUS WINAPI NtQuerySystemTime(PLARGE_INTEGER);
-NTSTATUS WINAPI RtlLocalTimeToSystemTime(PLARGE_INTEGER,PLARGE_INTEGER);
-BOOLEAN  WINAPI RtlTimeToSecondsSince1970(PLARGE_INTEGER,PULONG);
-void     WINAPI RtlFreeAnsiString(PANSI_STRING);
-void     WINAPI RtlFreeUnicodeString(PUNICODE_STRING);
-void     WINAPI RtlFreeOemString(POEM_STRING);
-void     WINAPI RtlInitString(PSTRING,PCSZ);
-void     WINAPI RtlInitAnsiString(PANSI_STRING,PCSZ);
-void     WINAPI RtlInitUnicodeString(PUNICODE_STRING,PCWSTR);
-NTSTATUS WINAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING,PCANSI_STRING,BOOLEAN);
-NTSTATUS WINAPI RtlUnicodeStringToAnsiString(PANSI_STRING,PCUNICODE_STRING,BOOLEAN);
-NTSTATUS WINAPI RtlUnicodeStringToOemString(POEM_STRING,PCUNICODE_STRING,BOOLEAN);
-NTSTATUS WINAPI RtlUnicodeToMultiByteSize(PULONG,PWSTR,ULONG);
-NTSTATUS WINAPI RtlCharToInteger(PCSZ,ULONG,PULONG);
-NTSTATUS WINAPI RtlConvertSidToUnicodeString(PUNICODE_STRING,PSID,BOOLEAN);
-ULONG    WINAPI RtlUniform(PULONG);
-void     WINAPI RtlUnwind(PVOID,PVOID,PEXCEPTION_RECORD,PVOID);
-
-#ifdef __ia64__
-void     WINAPI RtlUnwind2(FRAME_POINTERS,PVOID,PEXCEPTION_RECORD,PVOID,PCONTEXT);
-void     WINAPI RtlUnwindEx(FRAME_POINTERS,PVOID,PEXCEPTION_RECORD,PVOID,PCONTEXT,PUNWIND_HISTORY_TABLE);
+/* System Information Class 0x02 */
+typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION {
+#ifdef __WINE__
+    LARGE_INTEGER liIdleTime;
+    DWORD dwSpare[76];
+#else
+    LARGE_INTEGER IdleTime;
+    LARGE_INTEGER KernelTime;
+    LARGE_INTEGER UserTime;
+    LARGE_INTEGER Reserved1[2];
+    ULONG Reserved2;
 #endif
+} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
 
-/***********************************************************************
- * Various macros, types and data structures
- */
+/* System Information Class 0x05 */
+typedef struct _SYSTEM_PROCESS_INFORMATION {
+#ifdef __WINE__
+    DWORD dwOffset;
+    DWORD dwThreadCount;
+    DWORD dwUnknown1[6];
+    FILETIME ftCreationTime;
+    DWORD dwUnknown2[5];
+    WCHAR *pszProcessName;
+    DWORD dwBasePriority;
+    DWORD dwProcessID;
+    DWORD dwParentProcessID;
+    DWORD dwHandleCount;
+    DWORD dwUnknown3;
+    DWORD dwUnknown4;
+    DWORD dwVirtualBytesPeak;
+    DWORD dwVirtualBytes;
+    DWORD dwPageFaults;
+    DWORD dwWorkingSetPeak;
+    DWORD dwWorkingSet;
+    DWORD dwUnknown5;
+    DWORD dwPagedPool;
+    DWORD dwUnknown6;
+    DWORD dwNonPagedPool;
+    DWORD dwPageFileBytesPeak;
+    DWORD dwPrivateBytes;
+    DWORD dwPageFileBytes;
+    DWORD dwUnknown7[4];
+    THREADINFO ti[1];
+#else
+    ULONG NextEntryOffset;
+    BYTE Reserved1[52];
+    PVOID Reserved2[3];
+    HANDLE UniqueProcessId;
+    PVOID Reserved3;
+    ULONG HandleCount;
+    BYTE Reserved4[4];
+    PVOID Reserved5[11];
+    SIZE_T PeakPagefileUsage;
+    SIZE_T PrivatePageCount;
+    LARGE_INTEGER Reserved6[6];
+#endif
+} SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION;
 
-#define LOGONID_CURRENT    ((ULONG)-1)
-#define SERVERNAME_CURRENT ((HANDLE)NULL)
+typedef struct _SYSTEM_REGISTRY_QUOTA_INFORMATION {
+    ULONG RegistryQuotaAllowed;
+    ULONG RegistryQuotaUsed;
+    PVOID Reserved1;
+} SYSTEM_REGISTRY_QUOTA_INFORMATION, *PSYSTEM_REGISTRY_QUOTA_INFORMATION;
 
-typedef enum _WINSTATIONINFOCLASS {
-    WinStationInformation = 8
-} WINSTATIONINFOCLASS;
+typedef struct _SYSTEM_TIME_ADJUSTMENT {
+    ULONG   TimeAdjustment;
+    BOOLEAN TimeAdjustmentDisabled;
+} SYSTEM_TIME_ADJUSTMENT, *PSYSTEM_TIME_ADJUSTMENT;
+
+/* System Information Class 0x03 */
+typedef struct _SYSTEM_TIMEOFDAY_INFORMATION {
+#ifdef __WINE__
+    LARGE_INTEGER liKeBootTime;
+    LARGE_INTEGER liKeSystemTime;
+    LARGE_INTEGER liExpTimeZoneBias;
+    ULONG uCurrentTimeZoneId;
+    DWORD dwReserved;
+#else
+    BYTE Reserved1[48];
+#endif
+} SYSTEM_TIMEOFDAY_INFORMATION, *PSYSTEM_TIMEOFDAY_INFORMATION; /* was SYSTEM_TIME_INFORMATION */
+
+typedef struct _TIME_FIELDS
+{   CSHORT Year;
+    CSHORT Month;
+    CSHORT Day;
+    CSHORT Hour;
+    CSHORT Minute;
+    CSHORT Second;
+    CSHORT Milliseconds;
+    CSHORT Weekday;
+} TIME_FIELDS, *PTIME_FIELDS;
 
 typedef struct _WINSTATIONINFORMATIONW {
   BYTE Reserved2[70];
   ULONG LogonId;
   BYTE Reserved3[1140];
-} WINSTATIONINFORMATIONW, * PWINSTATIONINFORMATIONW;
+} WINSTATIONINFORMATIONW, *PWINSTATIONINFORMATIONW;
+
+typedef struct _VM_COUNTERS_ {
+    ULONG PeakVirtualSize;
+    ULONG VirtualSize;
+    ULONG PageFaultCount;
+    ULONG PeakWorkingSetSize;
+    ULONG WorkingSetSize;
+    ULONG QuotaPeakPagedPoolUsage;
+    ULONG QuotaPagedPoolUsage;
+    ULONG QuotaPeakNonPagedPoolUsage;
+    ULONG QuotaNonPagedPoolUsage;
+    ULONG PagefileUsage;
+    ULONG PeakPagefileUsage;
+} VM_COUNTERS, *PVM_COUNTERS;
 
 typedef BOOLEAN (WINAPI * PWINSTATIONQUERYINFORMATIONW)(HANDLE,ULONG,WINSTATIONINFOCLASS,PVOID,ULONG,PULONG);
 
+/***********************************************************************
+ * Defines
+ */
+
+/* flags for NtCreateFile and NtOpenFile */
+#define FILE_DIRECTORY_FLAG  0x00000001
+#define FILE_WRITE_THROUGH   0x00000002
+#define FILE_SEQUENTIAL_ONLY 0x00000004
+#define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
+#define FILE_SYNCHRONOUS_IO_ALERT    0x00000010
+#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
+#define FILE_NON_DIRECTORY_FILE      0x00000040
+#define FILE_CREATE_TREE_CONNECTION  0x00000080
+
+/* status for NtCreateFile or NtOpenFile */
+#define FILE_SUPERSEDED  0x00000000
+#define FILE_OPENED      0x00000001
+#define FILE_CREATED     0x00000002
+#define FILE_OVERWRITTEN 0x00000003
+#define FILE_EXISTS      0x00000004
+#define FILE_DOES_NOT_EXIST 0x00000005
+
+#if (_WIN32_WINNT >= 0x0501)
+#define INTERNAL_TS_ACTIVE_CONSOLE_ID ( *((volatile ULONG*)(0x7ffe02d8)) )
+#endif /* (_WIN32_WINNT >= 0x0501) */
+
+#define LOGONID_CURRENT    ((ULONG)-1)
+
+#define OBJ_INHERIT          0x00000002L
+#define OBJ_PERMANENT        0x00000010L
+#define OBJ_EXCLUSIVE        0x00000020L
+#define OBJ_CASE_INSENSITIVE 0x00000040L
+#define OBJ_OPENIF           0x00000080L
+#define OBJ_OPENLINK         0x00000100L
+#define OBJ_KERNEL_HANDLE    0x00000200L
+#define OBJ_VALID_ATTRIBUTES 0x000003F2L
+
+#define SERVERNAME_CURRENT ((HANDLE)NULL)
+
+/***********************************************************************
+ * Function declarations
+ */
+
+extern LPSTR _strlwr(LPSTR str); /* FIXME: Doesn't belong here */
+extern LPSTR _strupr(LPSTR str); /* FIXME: Doesn't belong here */
+
+#if defined(__i386__) && defined(__GNUC__)
+static inline void WINAPI DbgBreakPoint(void) { __asm__ __volatile__("int3"); }
+static inline void WINAPI DbgUserBreakPoint(void) { __asm__ __volatile__("int3"); }
+#else  /* __i386__ && __GNUC__ */
+void WINAPI DbgBreakPoint(void);
+void WINAPI DbgUserBreakPoint(void);
+#endif  /* __i386__ && __GNUC__ */
+void WINAPIV DbgPrint(LPCSTR fmt, ...);
+
+NTSTATUS  WINAPI NtAccessCheck(PSECURITY_DESCRIPTOR,HANDLE,ACCESS_MASK,PGENERIC_MAPPING,PPRIVILEGE_SET,PULONG,PULONG,PBOOLEAN);
+NTSTATUS  WINAPI NtAdjustPrivilegesToken(HANDLE,BOOLEAN,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
+NTSTATUS  WINAPI NtClearEvent(HANDLE);
+NTSTATUS  WINAPI NtClose(HANDLE);
+NTSTATUS  WINAPI NtCreateEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *,BOOLEAN,BOOLEAN);
+NTSTATUS  WINAPI NtCreateFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,PLARGE_INTEGER,ULONG,ULONG,ULONG,ULONG,PVOID,ULONG);
+NTSTATUS  WINAPI NtCreateKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,const UNICODE_STRING*,ULONG,PULONG);
+NTSTATUS  WINAPI NtCreateSemaphore(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,ULONG);
+NTSTATUS  WINAPI NtDeleteKey(HANDLE);
+NTSTATUS  WINAPI NtDeleteValueKey(HANDLE,const UNICODE_STRING *);
+NTSTATUS  WINAPI NtDeviceIoControlFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,PVOID,ULONG,PVOID,ULONG);
+NTSTATUS  WINAPI NtEnumerateKey(HANDLE,ULONG,KEY_INFORMATION_CLASS,void *,DWORD,DWORD *);
+NTSTATUS  WINAPI NtEnumerateValueKey(HANDLE,ULONG,KEY_VALUE_INFORMATION_CLASS,PVOID,ULONG,PULONG);
+NTSTATUS  WINAPI NtFlushKey(HANDLE);
+NTSTATUS  WINAPI NtLoadKey(const OBJECT_ATTRIBUTES *,const OBJECT_ATTRIBUTES *);
+NTSTATUS  WINAPI NtNotifyChangeKey(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,ULONG,BOOLEAN,PVOID,ULONG,BOOLEAN);
+NTSTATUS  WINAPI NtOpenEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
+NTSTATUS  WINAPI NtOpenFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,ULONG,ULONG);
+NTSTATUS  WINAPI NtOpenKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *);
+NTSTATUS  WINAPI NtOpenProcessToken(HANDLE,DWORD,HANDLE *);
+NTSTATUS  WINAPI NtOpenThreadToken(HANDLE,DWORD,BOOLEAN,HANDLE *);
+NTSTATUS  WINAPI NtPulseEvent(HANDLE,PULONG);
+NTSTATUS  WINAPI NtQueryInformationProcess(HANDLE,PROCESSINFOCLASS,PVOID,ULONG,PULONG);
+NTSTATUS  WINAPI NtQueryInformationThread(HANDLE,THREADINFOCLASS,PVOID,ULONG,PULONG);
+NTSTATUS  WINAPI NtQueryInformationToken(HANDLE,DWORD,LPVOID,DWORD,LPDWORD);
+NTSTATUS  WINAPI NtQueryKey(HANDLE,KEY_INFORMATION_CLASS,void *,DWORD,DWORD *);
+NTSTATUS  WINAPI NtQueryMultipleValueKey(HANDLE,PVALENTW,ULONG,PVOID,ULONG,PULONG);
+NTSTATUS  WINAPI NtQuerySecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,ULONG,PULONG);
+NTSTATUS  WINAPI NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS,PVOID,ULONG,PULONG);
+NTSTATUS  WINAPI NtQuerySystemTime(PLARGE_INTEGER);
+NTSTATUS  WINAPI NtQueryValueKey(HANDLE,const UNICODE_STRING *,KEY_VALUE_INFORMATION_CLASS,void *,DWORD,DWORD *);
+void      WINAPI NtRaiseException(PEXCEPTION_RECORD,PCONTEXT,BOOL);
+NTSTATUS  WINAPI NtReadFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,PVOID,ULONG,PLARGE_INTEGER,PULONG);
+NTSTATUS  WINAPI NtReleaseSemaphore(HANDLE,ULONG,PULONG);
+NTSTATUS  WINAPI NtResetEvent(HANDLE,PULONG);
+NTSTATUS  WINAPI NtRestoreKey(HANDLE,HANDLE,ULONG);
+NTSTATUS  WINAPI NtReplaceKey(POBJECT_ATTRIBUTES,HANDLE,POBJECT_ATTRIBUTES);
+NTSTATUS  WINAPI NtSaveKey(HANDLE,HANDLE);
+NTSTATUS  WINAPI NtSetEvent(HANDLE,PULONG);
+NTSTATUS  WINAPI NtSetInformationKey(HANDLE,const int,PVOID,ULONG);
+NTSTATUS  WINAPI NtSetSecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
+NTSTATUS  WINAPI NtSetValueKey(HANDLE,const UNICODE_STRING *,ULONG,ULONG,const void *,ULONG);
+NTSTATUS  WINAPI NtTerminateProcess(HANDLE,LONG);
+NTSTATUS  WINAPI NtTerminateThread(HANDLE,LONG);
+NTSTATUS  WINAPI NtUnloadKey(HANDLE);
+NTSTATUS  WINAPI NtWaitForSingleObject(HANDLE,BOOLEAN,PLARGE_INTEGER);
+
+void      WINAPI RtlAcquirePebLock(void);
+BYTE      WINAPI RtlAcquireResourceExclusive(LPRTL_RWLOCK,BYTE);
+BYTE      WINAPI RtlAcquireResourceShared(LPRTL_RWLOCK,BYTE);
+NTSTATUS  WINAPI RtlAddAce(PACL,DWORD,DWORD,PACE_HEADER,DWORD);
+BOOL      WINAPI RtlAddAccessAllowedAce(PACL,DWORD,DWORD,PSID);
+BOOL      WINAPI RtlAddAccessAllowedAceEx(PACL,DWORD,DWORD,DWORD,PSID);
+DWORD     WINAPI RtlAdjustPrivilege(DWORD,DWORD,DWORD,DWORD);
+BOOLEAN   WINAPI RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY,BYTE,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,PSID *);
+PVOID     WINAPI RtlAllocateHeap(HANDLE,ULONG,ULONG);
+DWORD     WINAPI RtlAnsiStringToUnicodeSize(const STRING *);
+NTSTATUS  WINAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING,PCANSI_STRING,BOOLEAN);
+NTSTATUS  WINAPI RtlAppendAsciizToString(STRING *,LPCSTR);
+NTSTATUS  WINAPI RtlAppendStringToString(STRING *,const STRING *);
+NTSTATUS  WINAPI RtlAppendUnicodeStringToString(UNICODE_STRING *,const UNICODE_STRING *);
+NTSTATUS  WINAPI RtlAppendUnicodeToString(UNICODE_STRING *,LPCWSTR);
+BOOLEAN   WINAPI RtlAreBitsSet(PCRTL_BITMAP,ULONG,ULONG);
+BOOLEAN   WINAPI RtlAreBitsClear(PCRTL_BITMAP,ULONG,ULONG);
+
+NTSTATUS  WINAPI RtlCharToInteger(PCSZ,ULONG,PULONG);
+void      WINAPI RtlClearAllBits(PRTL_BITMAP);
+void      WINAPI RtlClearBits(PRTL_BITMAP,ULONG,ULONG);
+ULONG     WINAPI RtlCompactHeap(HANDLE,ULONG);
+LONG      WINAPI RtlCompareString(const STRING*,const STRING*,BOOLEAN);
+LONG      WINAPI RtlCompareUnicodeString(const UNICODE_STRING*,const UNICODE_STRING*,BOOLEAN);
+NTSTATUS  WINAPI RtlConvertSidToUnicodeString(PUNICODE_STRING,PSID,BOOLEAN);
+LONGLONG  WINAPI RtlConvertLongToLargeInteger(LONG);
+ULONGLONG WINAPI RtlConvertUlongToLargeInteger(ULONG);
+DWORD     WINAPI RtlCopySid(DWORD,PSID,PSID);
+void      WINAPI RtlCopyString(STRING*,const STRING*);
+void      WINAPI RtlCopyUnicodeString(UNICODE_STRING*,const UNICODE_STRING*);
+NTSTATUS  WINAPI RtlCreateAcl(PACL,DWORD,DWORD);
+DWORD     WINAPI RtlCreateEnvironment(DWORD,DWORD);
+HANDLE    WINAPI RtlCreateHeap(ULONG,PVOID,ULONG,ULONG,PVOID,PRTL_HEAP_DEFINITION);
+NTSTATUS  WINAPI RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR,DWORD);
+BOOLEAN   WINAPI RtlCreateUnicodeString(PUNICODE_STRING,LPCWSTR);
+BOOLEAN   WINAPI RtlCreateUnicodeStringFromAsciiz(PUNICODE_STRING,LPCSTR);
+
+NTSTATUS  WINAPI RtlDeleteCriticalSection(RTL_CRITICAL_SECTION *);
+void      WINAPI RtlDeleteResource(LPRTL_RWLOCK);
+DWORD     WINAPI RtlDeleteSecurityObject(DWORD);
+DWORD     WINAPI RtlDestroyEnvironment(DWORD);
+HANDLE    WINAPI RtlDestroyHeap(HANDLE);
+BOOLEAN   WINAPI RtlDosPathNameToNtPathName_U(LPWSTR,PUNICODE_STRING,DWORD,DWORD);
+void      WINAPI RtlDumpResource(LPRTL_RWLOCK);
+
+LONGLONG  WINAPI RtlEnlargedIntegerMultiply(INT,INT);
+ULONGLONG WINAPI RtlEnlargedUnsignedMultiply(UINT,UINT);
+UINT      WINAPI RtlEnlargedUnsignedDivide(ULONGLONG,UINT,UINT *);
+NTSTATUS  WINAPI RtlEnterCriticalSection(RTL_CRITICAL_SECTION *);
+void      WINAPI RtlEraseUnicodeString(UNICODE_STRING*);
+BOOL      WINAPI RtlEqualPrefixSid(PSID,PSID);
+BOOL      WINAPI RtlEqualSid(PSID,PSID);
+BOOLEAN   WINAPI RtlEqualString(const STRING*,const STRING*,BOOLEAN);
+BOOLEAN   WINAPI RtlEqualUnicodeString(const UNICODE_STRING*,const UNICODE_STRING*,BOOLEAN);
+LONGLONG  WINAPI RtlExtendedMagicDivide(LONGLONG,LONGLONG,INT);
+LONGLONG  WINAPI RtlExtendedIntegerMultiply(LONGLONG,INT);
+LONGLONG  WINAPI RtlExtendedLargeIntegerDivide(LONGLONG,INT,INT *);
+
+ULONG     WINAPI RtlFindClearBits(PCRTL_BITMAP,ULONG,ULONG);
+ULONG     WINAPI RtlFindClearBitsAndSet(PRTL_BITMAP,ULONG,ULONG);
+ULONG     WINAPI RtlFindClearRuns(PCRTL_BITMAP,PRTL_BITMAP_RUN,ULONG,BOOLEAN);
+ULONG     WINAPI RtlFindLastBackwardRunSet(PCRTL_BITMAP,ULONG,PULONG);
+ULONG     WINAPI RtlFindLastBackwardRunClear(PCRTL_BITMAP,ULONG,PULONG);
+CCHAR     WINAPI RtlFindLeastSignificantBit(ULONGLONG);
+ULONG     WINAPI RtlFindLongestRunSet(PCRTL_BITMAP,PULONG);
+ULONG     WINAPI RtlFindLongestRunClear(PCRTL_BITMAP,PULONG);
+CCHAR     WINAPI RtlFindMostSignificantBit(ULONGLONG);
+ULONG     WINAPI RtlFindNextForwardRunSet(PCRTL_BITMAP,ULONG,PULONG);
+ULONG     WINAPI RtlFindNextForwardRunClear(PCRTL_BITMAP,ULONG,PULONG);
+ULONG     WINAPI RtlFindSetBits(PCRTL_BITMAP,ULONG,ULONG);
+ULONG     WINAPI RtlFindSetBitsAndClear(PRTL_BITMAP,ULONG,ULONG);
+ULONG     WINAPI RtlFindSetRuns(PCRTL_BITMAP,PRTL_BITMAP_RUN,ULONG,BOOLEAN);
+BOOLEAN   WINAPI RtlFirstFreeAce(PACL,PACE_HEADER *);
+NTSTATUS  WINAPI RtlFormatCurrentUserKeyPath(PUNICODE_STRING);
+void      WINAPI RtlFreeAnsiString(PANSI_STRING);
+BOOLEAN   WINAPI RtlFreeHeap(HANDLE,ULONG,PVOID);
+void      WINAPI RtlFreeOemString(POEM_STRING);
+DWORD     WINAPI RtlFreeSid(PSID);
+void      WINAPI RtlFreeUnicodeString(PUNICODE_STRING);
+
+DWORD     WINAPI RtlGetAce(PACL,DWORD,LPVOID *);
+NTSTATUS  WINAPI RtlGetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR,PBOOLEAN,PACL *,PBOOLEAN);
+NTSTATUS  WINAPI RtlGetControlSecurityDescriptor(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR_CONTROL,LPDWORD);
+NTSTATUS  WINAPI RtlGetGroupSecurityDescriptor(PSECURITY_DESCRIPTOR,PSID *,PBOOLEAN);
+BOOLEAN   WINAPI RtlGetNtProductType(LPDWORD);
+NTSTATUS  WINAPI RtlGetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR,PSID *,PBOOLEAN);
+ULONG     WINAPI RtlGetProcessHeaps(ULONG,HANDLE*);
+NTSTATUS  WINAPI RtlGetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR,PBOOLEAN,PACL *,PBOOLEAN);
+
+PSID_IDENTIFIER_AUTHORITY WINAPI RtlIdentifierAuthoritySid(PSID);
+PVOID     WINAPI RtlImageDirectoryEntryToData(HMODULE,BOOL,WORD,ULONG *);
+PIMAGE_NT_HEADERS WINAPI RtlImageNtHeader(HMODULE);
+PIMAGE_SECTION_HEADER WINAPI RtlImageRvaToSection(const IMAGE_NT_HEADERS *,HMODULE,DWORD);
+PVOID     WINAPI RtlImageRvaToVa(const IMAGE_NT_HEADERS *,HMODULE,DWORD,IMAGE_SECTION_HEADER **);
+BOOL      WINAPI RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL);
+void      WINAPI RtlInitString(PSTRING,PCSZ);
+void      WINAPI RtlInitAnsiString(PANSI_STRING,PCSZ);
+void      WINAPI RtlInitUnicodeString(PUNICODE_STRING,PCWSTR);
+NTSTATUS  WINAPI RtlInitializeCriticalSection(RTL_CRITICAL_SECTION *);
+NTSTATUS  WINAPI RtlInitializeCriticalSectionAndSpinCount(RTL_CRITICAL_SECTION *,DWORD);
+void      WINAPI RtlInitializeBitMap(PRTL_BITMAP,LPBYTE,ULONG);
+void      WINAPI RtlInitializeResource(LPRTL_RWLOCK);
+BOOL      WINAPI RtlInitializeSid(PSID,PSID_IDENTIFIER_AUTHORITY,BYTE);
+
+DWORD     WINAPI RtlIntegerToChar(DWORD,DWORD,DWORD,DWORD);
+BOOLEAN   WINAPI RtlIsNameLegalDOS8Dot3(PUNICODE_STRING,POEM_STRING,PBOOLEAN);
+DWORD     WINAPI RtlIsTextUnicode(LPVOID,DWORD,DWORD *);
+
+LONGLONG  WINAPI RtlLargeIntegerAdd(LONGLONG,LONGLONG);
+LONGLONG  WINAPI RtlLargeIntegerArithmeticShift(LONGLONG,INT);
+ULONGLONG WINAPI RtlLargeIntegerDivide( ULONGLONG,ULONGLONG,ULONGLONG *);
+LONGLONG  WINAPI RtlLargeIntegerNegate(LONGLONG);
+LONGLONG  WINAPI RtlLargeIntegerShiftLeft(LONGLONG,INT);
+LONGLONG  WINAPI RtlLargeIntegerShiftRight(LONGLONG,INT);
+LONGLONG  WINAPI RtlLargeIntegerSubtract(LONGLONG,LONGLONG);
+NTSTATUS  WINAPI RtlLeaveCriticalSection(RTL_CRITICAL_SECTION *);
+DWORD     WINAPI RtlLengthRequiredSid(DWORD);
+ULONG     WINAPI RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR);
+DWORD     WINAPI RtlLengthSid(PSID);
+NTSTATUS  WINAPI RtlLocalTimeToSystemTime(PLARGE_INTEGER,PLARGE_INTEGER);
+BOOLEAN   WINAPI RtlLockHeap(HANDLE);
+
+NTSTATUS  WINAPI RtlMakeSelfRelativeSD(PSECURITY_DESCRIPTOR,PSECURITY_DESCRIPTOR,LPDWORD);
+NTSTATUS  WINAPI RtlMultiByteToUnicodeN(LPWSTR,DWORD,LPDWORD,LPCSTR,DWORD);
+NTSTATUS  WINAPI RtlMultiByteToUnicodeSize(DWORD*,LPCSTR,UINT);
+
+DWORD     WINAPI RtlNewSecurityObject(DWORD,DWORD,DWORD,DWORD,DWORD,DWORD);
+LPVOID    WINAPI RtlNormalizeProcessParams(LPVOID);
+ULONG     WINAPI RtlNtStatusToDosError(NTSTATUS);
+ULONG     WINAPI RtlNumberOfSetBits(PCRTL_BITMAP);
+ULONG     WINAPI RtlNumberOfClearBits(PCRTL_BITMAP);
+
+UINT      WINAPI RtlOemStringToUnicodeSize(const STRING*);
+NTSTATUS  WINAPI RtlOemStringToUnicodeString(UNICODE_STRING*,const STRING*,BOOLEAN);
+NTSTATUS  WINAPI RtlOemToUnicodeN(LPWSTR,DWORD,LPDWORD,LPCSTR,DWORD);
+DWORD     WINAPI RtlOpenCurrentUser(ACCESS_MASK,PHANDLE);
+
+BOOLEAN   WINAPI RtlPrefixString(const STRING*,const STRING*,BOOLEAN);
+BOOLEAN   WINAPI RtlPrefixUnicodeString(const UNICODE_STRING*,const UNICODE_STRING*,BOOLEAN);
+
+DWORD     WINAPI RtlQueryEnvironmentVariable_U(DWORD,PUNICODE_STRING,PUNICODE_STRING) ;
+
+void      WINAPI RtlRaiseException(PEXCEPTION_RECORD);
+void      WINAPI RtlRaiseStatus(NTSTATUS);
+PVOID     WINAPI RtlReAllocateHeap(HANDLE,ULONG,PVOID,ULONG);
+void      WINAPI RtlReleasePebLock(void);
+void      WINAPI RtlReleaseResource(LPRTL_RWLOCK);
+
+void      WINAPI RtlSecondsSince1970ToTime(DWORD,LARGE_INTEGER *);
+void      WINAPI RtlSecondsSince1980ToTime(DWORD,LARGE_INTEGER *);
+void      WINAPI RtlSetAllBits(PRTL_BITMAP);
+void      WINAPI RtlSetBits(PRTL_BITMAP,ULONG,ULONG);
+NTSTATUS  WINAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR,BOOLEAN,PACL,BOOLEAN);
+DWORD     WINAPI RtlSetEnvironmentVariable(DWORD,PUNICODE_STRING,PUNICODE_STRING);
+NTSTATUS  WINAPI RtlSetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR,PSID,BOOLEAN);
+NTSTATUS  WINAPI RtlSetGroupSecurityDescriptor(PSECURITY_DESCRIPTOR,PSID,BOOLEAN);
+NTSTATUS  WINAPI RtlSetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR,BOOLEAN,PACL,BOOLEAN);
+ULONG     WINAPI RtlSizeHeap(HANDLE,ULONG,PVOID);
+LPDWORD   WINAPI RtlSubAuthoritySid(PSID,DWORD);
+LPBYTE    WINAPI RtlSubAuthorityCountSid(PSID);
+void      WINAPI RtlSystemTimeToLocalTime(PLARGE_INTEGER,PLARGE_INTEGER);
+
+void      WINAPI RtlTimeToTimeFields(PLARGE_INTEGER,PTIME_FIELDS);
+BOOLEAN   WINAPI RtlTimeFieldsToTime(PTIME_FIELDS,PLARGE_INTEGER);
+void      WINAPI RtlTimeToElapsedTimeFields(PLARGE_INTEGER,PTIME_FIELDS);
+BOOLEAN   WINAPI RtlTimeToSecondsSince1970(const LARGE_INTEGER *,PULONG);
+BOOLEAN   WINAPI RtlTimeToSecondsSince1980(const LARGE_INTEGER *,LPDWORD);
+BOOL      WINAPI RtlTryEnterCriticalSection(RTL_CRITICAL_SECTION *);
+
+DWORD     WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING*);
+NTSTATUS  WINAPI RtlUnicodeStringToAnsiString(PANSI_STRING,PCUNICODE_STRING,BOOLEAN);
+DWORD     WINAPI RtlUnicodeStringToOemSize(const UNICODE_STRING*);
+NTSTATUS  WINAPI RtlUnicodeStringToOemString(POEM_STRING,PCUNICODE_STRING,BOOLEAN);
+NTSTATUS  WINAPI RtlUnicodeToMultiByteN(LPSTR,DWORD,LPDWORD,LPCWSTR,DWORD);
+NTSTATUS  WINAPI RtlUnicodeToMultiByteSize(PULONG,PCWSTR,ULONG);
+NTSTATUS  WINAPI RtlUnicodeToOemN(LPSTR,DWORD,LPDWORD,LPCWSTR,DWORD);
+ULONG     WINAPI RtlUniform(PULONG);
+BOOLEAN   WINAPI RtlUnlockHeap(HANDLE);
+void      WINAPI RtlUnwind(PVOID,PVOID,PEXCEPTION_RECORD,PVOID);
+#ifdef __ia64__
+void      WINAPI RtlUnwind2(FRAME_POINTERS,PVOID,PEXCEPTION_RECORD,PVOID,PCONTEXT);
+void      WINAPI RtlUnwindEx(FRAME_POINTERS,PVOID,PEXCEPTION_RECORD,PVOID,PCONTEXT,PUNWIND_HISTORY_TABLE);
+#endif
+NTSTATUS  WINAPI RtlUpcaseUnicodeString(UNICODE_STRING*,const UNICODE_STRING *,BOOLEAN);
+NTSTATUS  WINAPI RtlUpcaseUnicodeStringToAnsiString(STRING*,const UNICODE_STRING*,BOOLEAN);
+NTSTATUS  WINAPI RtlUpcaseUnicodeStringToOemString(STRING*,const UNICODE_STRING*,BOOLEAN);
+NTSTATUS  WINAPI RtlUpcaseUnicodeToMultiByteN(LPSTR,DWORD,LPDWORD,LPCWSTR,DWORD);
+NTSTATUS  WINAPI RtlUpcaseUnicodeToOemN(LPSTR,DWORD,LPDWORD,LPCWSTR,DWORD);
+
+NTSTATUS  WINAPI RtlValidSecurityDescriptor(PSECURITY_DESCRIPTOR);
+BOOL      WINAPI RtlValidSid(PSID);
+BOOLEAN   WINAPI RtlValidateHeap(HANDLE,ULONG,PCVOID);
+
+NTSTATUS  WINAPI RtlWalkHeap(HANDLE,PVOID);
+
+NTSTATUS  WINAPI RtlpWaitForCriticalSection(RTL_CRITICAL_SECTION *);
+NTSTATUS  WINAPI RtlpUnWaitCriticalSection(RTL_CRITICAL_SECTION *);
+
+/***********************************************************************
+ * Inline functions
+ */
+
+#define InitializeObjectAttributes(p,n,a,r,s) \
+    do { \
+        (p)->Length = sizeof(OBJECT_ATTRIBUTES); \
+        (p)->RootDirectory = r; \
+        (p)->Attributes = a; \
+        (p)->ObjectName = n; \
+        (p)->SecurityDescriptor = s; \
+        (p)->SecurityQualityOfService = NULL; \
+    } while (0)
+
+#define NtCurrentProcess() ((HANDLE)-1)
+
+#define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
+#define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
+#define RtlStoreUlong(p,v)  do { ULONG _v = (v); memcpy((p), &_v, sizeof(_v)); } while (0)
+#define RtlStoreUlonglong(p,v) do { ULONGLONG _v = (v); memcpy((p), &_v, sizeof(_v)); } while (0)
+#define RtlRetrieveUlong(p,s) memcpy((p), (s), sizeof(ULONG))
+#define RtlRetrieveUlonglong(p,s) memcpy((p), (s), sizeof(ULONGLONG))
+#define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
+
+inline static BOOLEAN RtlCheckBit(PCRTL_BITMAP lpBits, ULONG ulBit)
+{
+    if (lpBits && ulBit < lpBits->SizeOfBitMap &&
+        lpBits->BitMapBuffer[ulBit >> 3] & (1 << (ulBit & 7)))
+        return TRUE;
+    return FALSE;
+}
+
+#define RtlClearAllBits(p) \
+    do { \
+        PRTL_BITMAP _p = (p); \
+        memset(_p->BitMapBuffer,0,((_p->SizeOfBitMap + 31) & 0xffffffe0) >> 3); \
+    } while (0)
+
+#define RtlInitializeBitMap(p,b,s) \
+    do { \
+        PRTL_BITMAP _p = (p); \
+        _p->SizeOfBitMap = (s); \
+        _p->BitMapBuffer = (b); \
+    } while (0)
+
+#define RtlSetAllBits(p) \
+    do { \
+        PRTL_BITMAP _p = (p); \
+        memset(_p->BitMapBuffer,0xff,((_p->SizeOfBitMap + 31) & 0xffffffe0) >> 3); \
+    } while (0)
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif /* defined(__cplusplus) */
diff --git a/loader/module.c b/loader/module.c
index 854802c..41119f5 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -32,6 +32,7 @@
 #endif
 #include "wine/winbase16.h"
 #include "winerror.h"
+#include "winternl.h"
 #include "heap.h"
 #include "file.h"
 #include "module.h"
diff --git a/loader/pe_resource.c b/loader/pe_resource.c
index ed830de..a50ff04 100644
--- a/loader/pe_resource.c
+++ b/loader/pe_resource.c
@@ -32,7 +32,7 @@
 #include "wine/unicode.h"
 #include "windef.h"
 #include "winnls.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "winerror.h"
 #include "wine/debug.h"
 
diff --git a/loader/task.c b/loader/task.c
index ab7884d..ce673e2 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -40,7 +40,7 @@
 #include "instance.h"
 #include "miscemu.h"
 #include "module.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "selectors.h"
 #include "wine/server.h"
 #include "syslevel.h"
diff --git a/memory/environ.c b/memory/environ.c
index ebdd097..3430510 100644
--- a/memory/environ.c
+++ b/memory/environ.c
@@ -31,7 +31,7 @@
 #include "wine/server.h"
 #include "wine/library.h"
 #include "heap.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "selectors.h"
 
 /* Win32 process environment database */
diff --git a/memory/heap.c b/memory/heap.c
index cb1dacc..22603a3 100644
--- a/memory/heap.c
+++ b/memory/heap.c
@@ -30,7 +30,7 @@
 #include "wine/winbase16.h"
 #include "winerror.h"
 #include "winnt.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/unicode.h"
 #include "selectors.h"
 #include "global.h"
diff --git a/misc/main.c b/misc/main.c
index 3137a43..9e502be 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -37,7 +37,7 @@
 #include "windef.h"
 #include "winbase.h"
 #include "wine/winbase16.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "winnls.h"
 #include "winerror.h"
 #include "wine/debug.h"
diff --git a/misc/options.c b/misc/options.c
index 3421d09..4479d76 100644
--- a/misc/options.c
+++ b/misc/options.c
@@ -24,7 +24,7 @@
 
 #include "winbase.h"
 #include "winnls.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/library.h"
 #include "options.h"
 #include "module.h"
diff --git a/misc/version.c b/misc/version.c
index 362c8d6..9691749 100644
--- a/misc/version.c
+++ b/misc/version.c
@@ -32,7 +32,7 @@
 #include "winreg.h"
 #include "wingdi.h"
 #include "winuser.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/winbase16.h"
 #include "module.h"
 #include "wine/debug.h"
diff --git a/msdos/int21.c b/msdos/int21.c
index 3e020db..c2bae62 100644
--- a/msdos/int21.c
+++ b/msdos/int21.c
@@ -47,7 +47,7 @@
 #include <ctype.h>
 #include "windef.h"
 #include "winbase.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wingdi.h"
 #include "winuser.h" /* SW_NORMAL */
 #include "wine/winbase16.h"
diff --git a/msdos/vxd.c b/msdos/vxd.c
index 7b77975..83b84d7 100644
--- a/msdos/vxd.c
+++ b/msdos/vxd.c
@@ -30,7 +30,7 @@
 #endif
 #include "winbase.h"
 #include "windef.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wingdi.h"
 #include "winuser.h"
 #include "wine/winbase16.h"
diff --git a/ole/ole2nls.c b/ole/ole2nls.c
index 7fe5ae13..3c7b0e3 100644
--- a/ole/ole2nls.c
+++ b/ole/ole2nls.c
@@ -33,7 +33,7 @@
 #include "winbase.h"
 #include "wingdi.h"
 #include "winuser.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/unicode.h"
 #include "winver.h"
 #include "winnls.h"
diff --git a/relay32/relay386.c b/relay32/relay386.c
index 7da6c1a..407a27b 100644
--- a/relay32/relay386.c
+++ b/relay32/relay386.c
@@ -26,7 +26,7 @@
 #include <stdio.h>
 
 #include "winnt.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "winreg.h"
 #include "stackframe.h"
 #include "module.h"
diff --git a/relay32/snoop.c b/relay32/snoop.c
index c43e44a..53d91ad 100644
--- a/relay32/snoop.c
+++ b/relay32/snoop.c
@@ -26,7 +26,7 @@
 #include <string.h>
 #include "winbase.h"
 #include "winnt.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "snoop.h"
 #include "stackframe.h"
 #include "wine/debug.h"
diff --git a/scheduler/critsection.c b/scheduler/critsection.c
index 20a17ca..9977e5f 100644
--- a/scheduler/critsection.c
+++ b/scheduler/critsection.c
@@ -28,7 +28,7 @@
 
 #include "winerror.h"
 #include "winbase.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/debug.h"
 #include "thread.h"
 
diff --git a/scheduler/pthread.c b/scheduler/pthread.c
index e29b7b3..3086b56 100644
--- a/scheduler/pthread.c
+++ b/scheduler/pthread.c
@@ -36,7 +36,7 @@
 
 #include "winbase.h"
 #include "thread.h"
-#include "ntddk.h"
+#include "winternl.h"
 
 static int init_done;
 
diff --git a/scheduler/syslevel.c b/scheduler/syslevel.c
index 974650d..68dcb86 100644
--- a/scheduler/syslevel.c
+++ b/scheduler/syslevel.c
@@ -24,7 +24,7 @@
 # include <unistd.h>
 #endif
 #include <sys/types.h>
-#include "ntddk.h"
+#include "winternl.h"
 #include "syslevel.h"
 #include "stackframe.h"
 #include "wine/library.h"
diff --git a/server/registry.c b/server/registry.c
index 29502ac..792750c 100644
--- a/server/registry.c
+++ b/server/registry.c
@@ -45,7 +45,7 @@
 #include "winbase.h"
 #include "winreg.h"
 #include "winnt.h" /* registry definitions */
-#include "ntddk.h"
+#include "winternl.h"
 #include "wine/library.h"
 
 /* a registry key */
diff --git a/win32/except.c b/win32/except.c
index def3bb7..4e1d50b 100644
--- a/win32/except.c
+++ b/win32/except.c
@@ -41,7 +41,7 @@
 #include <stdio.h>
 #include "windef.h"
 #include "winerror.h"
-#include "ntddk.h"
+#include "winternl.h"
 #include "wingdi.h"
 #include "winuser.h"
 #include "wine/exception.h"