This commit was generated by cvs2svn to compensate for changes in r52,
authorRex Jolliff <rex@lvcablemodem.com>
Mon, 5 Oct 1998 04:01:30 +0000 (04:01 +0000)
committerRex Jolliff <rex@lvcablemodem.com>
Mon, 5 Oct 1998 04:01:30 +0000 (04:01 +0000)
which included commits to RCS files with non-trunk default branches.

svn path=/trunk/; revision=53

102 files changed:
reactos/boot.bat
reactos/doc/ddkfuncs.txt
reactos/drivers/fs/minix/blockdev.c
reactos/drivers/fs/minix/makefile_rex
reactos/include/base.h
reactos/include/ddk/exfuncs.h
reactos/include/ddk/iodef.h
reactos/include/ddk/iofuncs.h
reactos/include/ddk/kefuncs.h
reactos/include/ddk/ketypes.h
reactos/include/ddk/mmfuncs.h
reactos/include/ddk/ntddk.h
reactos/include/ddk/ntdef.h
reactos/include/ddk/obfuncs.h
reactos/include/ddk/obtypes.h
reactos/include/ddk/psfuncs.h
reactos/include/ddk/pstypes.h
reactos/include/ddk/setypes.h
reactos/include/ddk/zw.h
reactos/include/defines.h
reactos/include/funcs.h
reactos/include/internal/ctype.h
reactos/include/internal/i386/hal.h
reactos/include/internal/io.h
reactos/include/internal/ke.h
reactos/include/internal/mm.h
reactos/include/internal/ob.h
reactos/include/internal/pool.h
reactos/include/internal/ps.h
reactos/include/internal/version.h
reactos/include/kernel32/heap.h
reactos/include/structs.h
reactos/include/windows.h
reactos/include/wstring.h
reactos/lib/kernel32/file/file.c
reactos/lib/kernel32/file/lfile.c
reactos/lib/kernel32/makefile
reactos/lib/kernel32/mem/heap.c
reactos/lib/kernel32/mem/virtual.c
reactos/lib/kernel32/process/proc.c
reactos/lib/ntdll/makefile
reactos/makefile.dos
reactos/ntoskrnl/dbg/brkpoint.c
reactos/ntoskrnl/ex/callback.c
reactos/ntoskrnl/ex/time.c
reactos/ntoskrnl/ex/work.c
reactos/ntoskrnl/exports.lst
reactos/ntoskrnl/hal/x86/bios32.c
reactos/ntoskrnl/hal/x86/exp.c
reactos/ntoskrnl/hal/x86/irq.c
reactos/ntoskrnl/hal/x86/isa.c
reactos/ntoskrnl/hal/x86/page.c
reactos/ntoskrnl/hal/x86/pci.c
reactos/ntoskrnl/hal/x86/printk.c
reactos/ntoskrnl/hal/x86/sources
reactos/ntoskrnl/hal/x86/thread.c
reactos/ntoskrnl/hal/x86/usercall.asm
reactos/ntoskrnl/io/cancel.c
reactos/ntoskrnl/io/create.c
reactos/ntoskrnl/io/device.c
reactos/ntoskrnl/io/drvlck.c
reactos/ntoskrnl/io/file.c
reactos/ntoskrnl/io/fs.c
reactos/ntoskrnl/io/ioctrl.c
reactos/ntoskrnl/io/iomgr.c
reactos/ntoskrnl/io/mdl.c
reactos/ntoskrnl/io/resource.c
reactos/ntoskrnl/io/symlink.c
reactos/ntoskrnl/io/timer.c
reactos/ntoskrnl/ke/apc.c
reactos/ntoskrnl/ke/bug.c
reactos/ntoskrnl/ke/catch.c
reactos/ntoskrnl/ke/dispatch.c
reactos/ntoskrnl/ke/error.c
reactos/ntoskrnl/ke/event.c
reactos/ntoskrnl/ke/exports.c
reactos/ntoskrnl/ke/kernel.c
reactos/ntoskrnl/ke/sem.c
reactos/ntoskrnl/ke/timer.c
reactos/ntoskrnl/ke/wait.c
reactos/ntoskrnl/mm/freelist.c
reactos/ntoskrnl/mm/mm.c
reactos/ntoskrnl/mm/pageflt.asm
reactos/ntoskrnl/mm/pool.c
reactos/ntoskrnl/mm/section.c
reactos/ntoskrnl/mm/special.c
reactos/ntoskrnl/mm/virtual.c
reactos/ntoskrnl/ob/handle.c
reactos/ntoskrnl/ob/namespc.c
reactos/ntoskrnl/ob/object.c
reactos/ntoskrnl/ps/idle.c
reactos/ntoskrnl/ps/process.c
reactos/ntoskrnl/ps/psmgr.c
reactos/ntoskrnl/ps/thread.c
reactos/ntoskrnl/rtl/interlck.asm
reactos/ntoskrnl/rtl/unicode.c
reactos/ntoskrnl/rtl/wstring.c
reactos/ntoskrnl/se/semgr.c
reactos/ntoskrnl/tst/readline.c
reactos/ntoskrnl/tst/sshell.c
reactos/ntoskrnl/utils/export/export
reactos/ntoskrnl/utils/export/export.c

index 513c107..82893e3 100644 (file)
@@ -1 +1 @@
-loaders\dos\loadros ntoskrnl\kimage.bin %1 %2 %3 %4
+loaders\dos\loadros ntoskrnl\kimage.bin services\dd\ide\ide.o services\fs\vfat\vfatfsd.o services\dd\keyboard\keyboard.o %2 %3 %4
index f7fbdfb..c0bcace 100644 (file)
@@ -20,8 +20,5 @@ IoInitializeDpc
 IoInitializeTimer
 IoStartTimer
 IoStopTimer
-
-Partially implemented
-
 IoCreateDevice
 IoCallDriver
index 2964d04..d04eeee 100644 (file)
@@ -15,7 +15,7 @@
 #define NDEBUG
 #include <internal/debug.h>
 
-#include "minix_fs.h"
+#include "minix.h"
 
 /* FUNCTIONS ***************************************************************/
 
@@ -34,6 +34,7 @@ BOOLEAN MinixReadSector(IN PDEVICE_OBJECT pDeviceObject,
    DPRINT("MinixReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
          pDeviceObject,DiskSector,Buffer);
    
+   sectorNumber.HighPart = 0;
     sectorNumber.LowPart = DiskSector * BLOCKSIZE;
 
     KeInitializeEvent(&event, NotificationEvent, FALSE);
@@ -82,3 +83,51 @@ BOOLEAN MinixReadSector(IN PDEVICE_OBJECT pDeviceObject,
     ExFreePool(mbr);
     return TRUE;
 }
+
+BOOLEAN MinixWriteSector(IN PDEVICE_OBJECT pDeviceObject,
+                       IN ULONG        DiskSector,
+                       IN UCHAR*       Buffer)
+{
+    LARGE_INTEGER   sectorNumber;
+    PIRP            irp;
+    IO_STATUS_BLOCK ioStatus;
+    KEVENT          event;
+    NTSTATUS        status;
+    ULONG           sectorSize;
+   
+   DPRINT("MinixWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
+         pDeviceObject,DiskSector,Buffer);
+   
+    sectorNumber.LowPart = DiskSector * BLOCKSIZE;
+
+    KeInitializeEvent(&event, NotificationEvent, FALSE);
+
+    sectorSize = BLOCKSIZE;
+
+    irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
+                                       pDeviceObject,
+                                       Buffer,
+                                       sectorSize,
+                                       &sectorNumber,
+                                       &event,
+                                       &ioStatus );
+
+
+    status = IoCallDriver(pDeviceObject,
+                          irp);
+
+    if (status == STATUS_PENDING) {
+        KeWaitForSingleObject(&event,
+                              Suspended,
+                              KernelMode,
+                              FALSE,
+                              NULL);
+        status = ioStatus.Status;
+    }
+
+    if (!NT_SUCCESS(status)) {
+        return FALSE;
+    }
+
+    return TRUE;
+}
index 47d8002..45090a1 100644 (file)
@@ -1,2 +1,9 @@
-all: minix.o blockdev.o
-       $(LD) -r minix.o blockdev.o -o minixfsd.o
+OBJECTS = block.o rw.o inode.o dir.o mount.o blockdev.o
+
+all: minix.o
+
+minix.o: $(OBJECTS)
+       $(LD) -r $(OBJECTS) -o minix.o
+
+WIN32_LEAN_AND_MEAN = yes
+include ../../../rules.mak
index 7be8db3..7242dc3 100644 (file)
@@ -43,9 +43,127 @@ extern "C" {
 #endif
 #endif /* !NULL */
 
+/*
+ * Definitions needed for the ddk includes (we miss out win32 only stuff to
+ * cut down on the compile time)                                           
+ */
+typedef unsigned char UCHAR;
+typedef unsigned int UINT;
+typedef unsigned long ULONG;
+typedef unsigned short USHORT;
+typedef unsigned short WCHAR;
+typedef unsigned short WORD;
+typedef int WINBOOL;
+typedef unsigned char BOOLEAN;
+typedef unsigned int DWORD; /* was unsigned long */
+typedef unsigned short *LPWSTR;
+typedef unsigned short *PWSTR;
+typedef unsigned char *PUCHAR;
+typedef unsigned int *PUINT;
+typedef unsigned long *PULONG;
+typedef unsigned short *PUSHORT;
+typedef void *PVOID;
+typedef unsigned char BYTE;
+typedef void *LPVOID;
+
+/* Check VOID before defining CHAR, SHORT, and LONG */
+#ifndef VOID
+#define VOID void
+typedef char CHAR;
+typedef short SHORT;
+typedef long LONG;
+#endif
+
+typedef CHAR *PCHAR;
+typedef CHAR *PCH;
+typedef void *HANDLE;
+typedef char CCHAR;
+
+typedef enum _SECURITY_IMPERSONATION_LEVEL {
+    SecurityAnonymous, 
+    SecurityIdentification, 
+    SecurityImpersonation, 
+    SecurityDelegation 
+} SECURITY_IMPERSONATION_LEVEL; 
+
+typedef enum tagTOKEN_TYPE {
+    TokenPrimary = 1, 
+    TokenImpersonation 
+} TOKEN_TYPE; 
+
 #define FALSE 0
 #define TRUE 1
 
+   typedef const unsigned short *PCWSTR;
+
+typedef char* PCSZ;
+   
+#define CONST const
+
+#ifdef i386
+#define STDCALL     __attribute__ ((stdcall))
+#define CDECL       __attribute((cdecl))
+#define CALLBACK    WINAPI
+#define PASCAL      WINAPI
+#else
+#define STDCALL
+#define CDECL
+#define CALLBACK
+#define PASCAL
+#endif
+#define WINAPI      STDCALL
+#define APIENTRY    STDCALL
+#define WINGDIAPI
+
+typedef BYTE *PBOOLEAN;
+typedef HANDLE *PHANDLE;
+   
+typedef DWORD CALLBACK (*PTHREAD_START_ROUTINE) (LPVOID);
+typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
+
+   typedef unsigned short ATOM;
+
+   #ifdef UNICODE
+typedef unsigned short *LPTCH;
+typedef unsigned short *LPTSTR;
+#else
+typedef char *LPTCH;
+typedef char *LPTSTR;
+#endif /* UNICODE */
+
+typedef long *PLONG;
+typedef unsigned short *PWCHAR;
+typedef char *LPSTR;
+typedef double LONGLONG, *PLONGLONG;
+
+   typedef enum _MEDIA_TYPE { 
+  Unknown,                
+  F5_1Pt2_512,            
+  F3_1Pt44_512,           
+  F3_2Pt88_512,           
+  F3_20Pt8_512,           
+  F3_720_512,             
+  F5_360_512,             
+  F5_320_512,             
+  F5_320_1024,            
+  F5_180_512,             
+  F5_160_512,             
+  RemovableMedia,         
+  FixedMedia              
+} MEDIA_TYPE; 
+
+#ifndef max
+#define max(a, b)  (((a) > (b)) ? (a) : (b)) 
+#endif
+
+#ifndef min
+#define min(a, b)  (((a) < (b)) ? (a) : (b)) 
+#endif
+
+   
+#ifndef WIN32_LEAN_AND_MEAN
+   
+
 #ifndef RC_INVOKED
 
 /* typedef ACMDRIVERENUMCB;
@@ -58,30 +176,15 @@ typedef ACMFORMATENUMCB;
 typedef ACMFORMATTAGENUMCB;
 typedef APPLET_PROC;
 */
-typedef unsigned short ATOM;
 /* Changed from BOOL to WINBOOL to avoid Objective-C conflict */
-typedef int WINBOOL;
-typedef unsigned char BOOLEAN;
-typedef unsigned char BYTE;
 typedef unsigned long CALTYPE;
 typedef unsigned long CALID;
-typedef char CCHAR;
 typedef unsigned long COLORREF;
-#define CONST const
-
-/* Check VOID before defining CHAR, SHORT, and LONG */
-#ifndef VOID
-#define VOID void
-typedef char CHAR;
-typedef short SHORT;
-typedef long LONG;
-#endif
 
 /*
 typedef CTRYID;
 typedef DLGPROC;
 */
-typedef unsigned int DWORD; /* was unsigned long */
 typedef double DWORDLONG, *PDWORDLONG;
 /*
 typedef EDITWORDBREAKPROC;
@@ -92,7 +195,6 @@ typedef ENUMRESTYPEPROC;
 */
 typedef float FLOAT;
 /* typedef GLOBALHANDLE; */
-typedef void *HANDLE;
 typedef HANDLE HACCEL;
 typedef HANDLE HBITMAP;
 typedef HANDLE HBRUSH;
@@ -138,7 +240,6 @@ typedef unsigned short LANGID;
 typedef DWORD LCID;
 typedef DWORD LCTYPE;
 /* typedef LOCALHANDLE */
-typedef double LONGLONG, *PLONGLONG;
 typedef unsigned short *LP;
 typedef long LPARAM;
 typedef WINBOOL *LPBOOL;
@@ -147,7 +248,6 @@ typedef CONST CHAR *LPCCH;
 typedef CHAR *LPCH;
 typedef COLORREF *LPCOLORREF;
 typedef const char *LPCSTR;
-typedef char* PCSZ;
    
 #ifdef UNICODE
 typedef const unsigned short *LPCTSTR;
@@ -163,41 +263,23 @@ typedef HANDLE *LPHANDLE;
 /* typedef LPHANDLER_FUNCTION; */
 typedef int *LPINT;
 typedef long *LPLONG;
-typedef char *LPSTR;
-
-#ifdef UNICODE
-typedef unsigned short *LPTCH;
-typedef unsigned short *LPTSTR;
-#else
-typedef char *LPTCH;
-typedef char *LPTSTR;
-#endif /* UNICODE */
 
 typedef long LRESULT;
-typedef void *LPVOID;
 typedef const void *LPCVOID;
 typedef unsigned short *LPWCH;
 typedef unsigned short *LPWORD;
-typedef unsigned short *LPWSTR;
-typedef unsigned short *PWSTR;
 /* typedef NPSTR; */
 typedef unsigned short *NWPSTR;
 typedef WINBOOL *PWINBOOL;
-typedef BYTE *PBOOLEAN;
 typedef BYTE *PBYTE;
 typedef const CHAR *PCCH;
-typedef CHAR *PCH;
-typedef CHAR *PCHAR;
 typedef const char *PCSTR;
 typedef const unsigned short *PCWCH;
-typedef const unsigned short *PCWSTR;
 typedef DWORD *PDWORD;
 typedef float *PFLOAT;
-typedef HANDLE *PHANDLE;
 /* typedef PHKEY; */
 typedef int *PINT;
 /* typedef LCID *PLCID; */
-typedef long *PLONG;
 typedef short *PSHORT;
 /* typedef PSID; */
 typedef char *PSTR;
@@ -215,13 +297,7 @@ typedef char *PTCHAR;
 typedef char *PTSTR;
 #endif /* UNICODE */
 
-typedef unsigned char *PUCHAR;
-typedef unsigned int *PUINT;
-typedef unsigned long *PULONG;
-typedef unsigned short *PUSHORT;
-typedef void *PVOID;
 typedef unsigned short *PWCH;
-typedef unsigned short *PWCHAR;
 typedef unsigned short *PWORD;
 /*
 typedef PWSTR;
@@ -246,30 +322,10 @@ typedef char TCHAR;
 typedef BYTE BCHAR;
 #endif /* UNICODE */
 
-typedef unsigned char UCHAR;
-typedef unsigned int UINT;
-typedef unsigned long ULONG;
-typedef unsigned short USHORT;
-typedef unsigned short WCHAR;
-typedef unsigned short WORD;
 typedef unsigned int WPARAM;
 /* typedef YIELDPROC; */
 
 /* Only use __stdcall under WIN32 compiler */
-#ifdef i386
-#define STDCALL     __attribute__ ((stdcall))
-#define CDECL       __attribute((cdecl))
-#define CALLBACK    WINAPI
-#define PASCAL      WINAPI
-#else
-#define STDCALL
-#define CDECL
-#define CALLBACK
-#define PASCAL
-#endif
-#define WINAPI      STDCALL
-#define APIENTRY    STDCALL
-#define WINGDIAPI
 
 #define _export
 
@@ -281,21 +337,6 @@ typedef enum _ACL_INFORMATION_CLASS {
   AclSizeInformation            
 } ACL_INFORMATION_CLASS; 
  
-typedef enum _MEDIA_TYPE { 
-  Unknown,                
-  F5_1Pt2_512,            
-  F3_1Pt44_512,           
-  F3_2Pt88_512,           
-  F3_20Pt8_512,           
-  F3_720_512,             
-  F5_360_512,             
-  F5_320_512,             
-  F5_320_1024,            
-  F5_180_512,             
-  F5_160_512,             
-  RemovableMedia,         
-  FixedMedia              
-} MEDIA_TYPE; 
  
 #define RASCS_DONE 0x2000
 #define RASCS_PAUSED 0x1000
@@ -339,14 +380,7 @@ typedef enum _RASPROJECTION {
     RASP_PppIpx = 0x802B, 
     RASP_PppIp = 0x8021 
 } RASPROJECTION ; 
-typedef enum _SECURITY_IMPERSONATION_LEVEL {
-    SecurityAnonymous, 
-    SecurityIdentification, 
-    SecurityImpersonation, 
-    SecurityDelegation 
-} SECURITY_IMPERSONATION_LEVEL; 
+  
 typedef enum _SID_NAME_USE { 
     SidTypeUser = 1, 
     SidTypeGroup, 
@@ -370,12 +404,7 @@ typedef enum _TOKEN_INFORMATION_CLASS {
     TokenImpersonationLevel, 
     TokenStatistics 
 } TOKEN_INFORMATION_CLASS; 
-typedef enum tagTOKEN_TYPE {
-    TokenPrimary = 1, 
-    TokenImpersonation 
-} TOKEN_TYPE; 
+  
 #endif /* ! defined (RC_INVOKED) */
 
 /*
@@ -421,13 +450,6 @@ typedef enum tagTOKEN_TYPE {
 #define MAKEROP4(fore,back) (DWORD)((((back) << 8) & 0xFF000000) | (fore)) 
 #define MAKEWPARAM(l, h)   ((WPARAM) MAKELONG(l, h)) 
 
-#ifndef max
-#define max(a, b)  (((a) > (b)) ? (a) : (b)) 
-#endif
-
-#ifndef min
-#define min(a, b)  (((a) < (b)) ? (a) : (b)) 
-#endif
 
 #define PALETTEINDEX(i) ((COLORREF) (0x01000000 | (DWORD) (WORD) (i))) 
 #define PALETTERGB(r, g, b)  (0x02000000 | RGB(r, g, b)) 
@@ -451,8 +473,6 @@ typedef enum tagTOKEN_TYPE {
 typedef int CALLBACK (*BFFCALLBACK) (HWND, UINT, LPARAM, LPARAM);
 typedef UINT CALLBACK (*LPCCHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
 typedef UINT CALLBACK (*LPCFHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
-typedef DWORD CALLBACK (*PTHREAD_START_ROUTINE) (LPVOID);
-typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
 typedef DWORD CALLBACK (*EDITSTREAMCALLBACK) (DWORD, LPBYTE, LONG, LONG);
 typedef UINT CALLBACK (*LPFRHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
 typedef UINT CALLBACK (*LPOFNHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
@@ -565,6 +585,8 @@ typedef DWORD CCSTYLEFLAGA, *PCCSTYLEFLAGA, *LPCCSTYLEFLAGA;
 
 #endif /* ! defined (RC_INVOKED) */
 
+#endif /* WIN32_LEAN_AND_MEAN */
+   
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 5414541..ca491a8 100644 (file)
@@ -94,3 +94,59 @@ PLIST_ENTRY ExInterlockedInsertHeadList(PLIST_ENTRY ListHead,
 
 VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,
                     WORK_QUEUE_TYPE QueueType);
+VOID ExRaiseStatus(NTSTATUS Status);
+VOID ExReinitializeResourceLite(PERESOURCE Resource);
+VOID ExReleaseFastMutex(PFAST_MUTEX Mutex);
+VOID ExReleaseFastMutexUnsafe(PFAST_MUTEX Mutex);
+VOID ExReleaseResource(PERESOURCE Resource);
+VOID ExReleaseResourceForThread(PERESOURCE Resource, 
+                               ERESOURCE_THREAD ResourceThreadId);
+VOID ExReleaseResourceForThreadLite(PERESOURCE Resource,
+                                   ERESOURCE_THREAD ResourceThreadId);
+VOID ExSystemTimeToLocalTime(PLARGE_INTEGER SystemTime,
+                            PLARGE_INTEGER LocalTime);
+BOOLEAN ExTryToAcquireFastMutex(PFAST_MUTEX FastMutex);
+BOOLEAN ExTryToAcquireResourceExclusiveLite(PERESOURCE Resource);
+PVOID InterlockedCompareExchange(PVOID* Destination,
+                                PVOID Exchange,
+                                PVOID Comperand);
+LONG InterlockedDecrement(PLONG Addend);
+LONG InterlockedExchange(PLONG Target, LONG Value);
+LONG InterlockedExchangeAdd(PLONG Addend, LONG Value);
+LONG InterlockedIncrement(PLONG Addend);
+
+PVOID ExInterlockedAllocateFromZone(PZONE_HEADER Zone, PKSPIN_LOCK Lock);
+PVOID ExInterlockedFreeToZone(PZONE_HEADER Zone, PVOID Block,
+                             PKSPIN_LOCK Lock);
+NTSTATUS ExInterlockedExtendZone(PZONE_HEADER Zone, PVOID Segment,
+                                ULONG SegmentSize, PKSPIN_LOCK Lock);
+PSINGLE_LIST_ENTRY ExInterlockedPopEntryList(PSINGLE_LIST_ENTRY ListHead,
+                                            PKSPIN_LOCK Lock);
+PSINGLE_LIST_ENTRY ExInterlockedPushEntryList(PSINGLE_LIST_ENTRY ListHead,
+                                             PSINGLE_LIST_ENTRY ListEntry,
+                                             PKSPIN_LOCK Lock);
+PSINGLE_LIST_ENTRY ExInterlockedPushEntrySList(PSLIST_HEADER ListHead,
+                                              PSINGLE_LIST_ENTRY ListEntry,
+                                              PKSPIN_LOCK Lock);
+PSINGLE_LIST_ENTRY ExInterlockedPopEntrySList(PSLIST_HEADER ListHead,
+                                             PKSPIN_LOCK Lock);
+BOOLEAN ExIsFullZone(PZONE_HEADER Zone);
+BOOLEAN ExIsObjectInFirstZoneSegment(PZONE_HEADER Zone, PVOID Object);
+VOID ExLocalTimeToSystemTime(PLARGE_INTEGER LocalTime, 
+                            PLARGE_INTEGER SystemTime);
+
+typedef unsigned int (exception_hook)(CONTEXT* c, unsigned int exp);
+unsigned int ExHookException(exception_hook fn, unsigned int exp);
+
+INTERLOCKED_RESULT ExInterlockedDecrementLong(PLONG Addend,
+                                             PKSPIN_LOCK Lock);
+ULONG ExInterlockedExchangeUlong(PULONG Target,
+                                ULONG Value,
+                                PKSPIN_LOCK Lock);
+INTERLOCKED_RESULT ExInterlockedIncrementLong(PLONG Addend,
+                                             PKSPIN_LOCK Lock);
+BOOLEAN ExIsResourceAcquiredExclusiveLite(PERESOURCE Resource);
+BOOLEAN ExIsResourceAcquiredSharedLite(PERESOURCE Resource);
+USHORT ExQueryDepthSListHead(PSLIST_HEADER SListHead);
+
+
index 194c8d0..4dbe70c 100644 (file)
@@ -51,76 +51,20 @@ enum
  */
 enum
 {
-   /*
-    * Read any data from the actual backing media
-    */
-   IRP_NOCACHE,
-     
-   /*
-    * The I/O operation is performing paging
-    */
-   IRP_PAGING_IO,
-     
-   /*
-    * The IRP is for a mount operation
-    */
-   IRP_MOUNT_COMPLETION,
-     
-   /*
-    * The API expects synchronous behaviour
-    */
-   IRP_SYNCHRONOUS_API,
-     
-   /*
-    * The IRP is associated with a larger operation
-    */
-   IRP_ASSOCIATED_IRP,
-     
-   /*
-    * The AssociatedIrp.SystemBuffer field is valid
-    */
-   IRP_BUFFERED_IO,
-     
-   /*
-    * The system buffer was allocated from pool and should be deallocated 
-    * by the I/O manager
-    */
-   IRP_DEALLOCATE_BUFFER,
-     
-   /*
-    * The IRP is for an input operation
-    */
-   IRP_INPUT_OPERATION,
-     
-   /*
-    * The paging operation should complete synchronously 
-    */
-   IRP_SYNCHRONOUS_PAGING_IO,
-     
-   /*
-    * The IRP represents a filesystem create operation
-    */
-   IRP_CREATE_OPERATION,
-     
-   /*
-    * The IRP represents a filesystem read operation
-    */
-   IRP_READ_OPERATION,
-     
-   /*
-    * The IRP represents a filesystem write operation
-    */
-   IRP_WRITE_OPERATION,
-          
-   /*
-    * The IRP represents a filesystem close operation
-    */
-   IRP_CLOSE_OPERATION,
-     
-   /*
-    * Asynchronous behavior is advised but not required
-    */
-   IRP_DEFER_IO_COMPLETION,
+   IRP_NOCACHE = 0x1,
+   IRP_PAGING_IO = 0x2,     
+   IRP_MOUNT_COMPLETION = 0x4,     
+   IRP_SYNCHRONOUS_API = 0x8,     
+   IRP_ASSOCIATED_IRP = 0x10,
+   IRP_BUFFERED_IO = 0x20,     
+   IRP_DEALLOCATE_BUFFER = 0x40,     
+   IRP_INPUT_OPERATION = 0x80,     
+   IRP_SYNCHRONOUS_PAGING_IO = 0x100,     
+   IRP_CREATE_OPERATION = 0x200,     
+   IRP_READ_OPERATION = 0x400,     
+   IRP_WRITE_OPERATION = 0x800,          
+   IRP_CLOSE_OPERATION = 0x1000,
+   IRP_DEFER_IO_COMPLETION = 0x2000,
 };
 
 /*
@@ -128,52 +72,27 @@ enum
  */
 enum
 {
-   /*
-    * Force an access check even if opened in kernel mode
-    */
-   SL_FORCE_ACCESS_CHECK,
-     
-   /*
-    * The file being opened is a paging file
-    */
-   SL_OPEN_PAGING_FILE,
-     
-   SL_OPEN_TARGET_DIRECTORY,
-     
-   SL_CASE_SENSITIVE,
-     
-   SL_KEY_SPECIFIED,
-     
-   SL_OVERRIDE_VERIFY_VOLUME,
-     
-   SL_WRITE_THROUGH,
-     
-   SL_FT_SEQUENTIAL_WRITE,
-     
-   SL_FAIL_IMMEDIATELY,
-     
-   SL_EXCLUSIVE_LOCK,
-     
-   SL_RESTART_SCAN,
-     
-   SL_RETURN_SINGLE_ENTRY,
-     
-   SL_INDEX_SPECIFIED,
-     
-   SL_WATCH_TREE,
-     
-   SL_ALLOW_RAW_MOUNT,
-     
-   SL_PENDING_RETURNED,
-     
+   SL_FORCE_ACCESS_CHECK = 0x1,
+   SL_OPEN_PAGING_FILE = 0x2,     
+   SL_OPEN_TARGET_DIRECTORY = 0x4,
+   SL_CASE_SENSITIVE = 0x8,     
+   SL_KEY_SPECIFIED = 0x10,     
+   SL_OVERRIDE_VERIFY_VOLUME = 0x20,
+   SL_WRITE_THROUGH = 0x40,     
+   SL_FT_SEQUENTIAL_WRITE = 0x80,     
+   SL_FAIL_IMMEDIATELY = 0x100,     
+   SL_EXCLUSIVE_LOCK = 0x200,     
+   SL_RESTART_SCAN = 0x400,     
+   SL_RETURN_SINGLE_ENTRY = 0x800,     
+   SL_INDEX_SPECIFIED = 0x1000,     
+   SL_WATCH_TREE = 0x2000,     
+   SL_ALLOW_RAW_MOUNT = 0x4000,     
 };
 
-enum
-{
-   SL_INVOKE_ON_SUCCESS = 1,
-   SL_INVOKE_ON_ERROR = 2,
-   SL_INVOKE_ON_CANCEL = 4,
-};
+#define SL_PENDING_RETURNED             0x01
+#define SL_INVOKE_ON_CANCEL             0x20
+#define SL_INVOKE_ON_SUCCESS            0x40
+#define SL_INVOKE_ON_ERROR              0x80
 
 /*
  * Possible flags for the device object flags
@@ -187,56 +106,60 @@ enum
 /*
  * Possible device types
  */
-enum
-{
-   /*
-    * Standard define types
-    */
-   FILE_DEVICE_BEEP,
-   FILE_DEVICE_CDROM,
-   FILE_DEVICE_CONTROLLER,
-   FILE_DEVICE_DISK,
-   FILE_DEVICE_INPORT_PORT,
-   FILE_DEVICE_KEYBOARD,
-   FILE_DEVICE_MIDI_IN,
-   FILE_DEVICE_MIDI_OUT,
-   FILE_DEVICE_MOUSE,
-   FILE_DEVICE_NULL,
-   FILE_DEVICE_PARALLEL_PORT,
-   FILE_DEVICE_PRINTER,
-   FILE_DEVICE_SCANNER,
-   FILE_DEVICE_SERIAL_MOUSE_PORT,
-   FILE_DEVICE_SERIAL_PORT,
-   FILE_DEVICE_SCREEN,
-   FILE_DEVICE_TAPE,
-   FILE_DEVICE_UNKNOWN,
-   FILE_DEVICE_VIDEO,
-   FILE_DEVICE_VIRTUAL_DISK,
-   FILE_DEVICE_WAVE_IN,
-   FILE_DEVICE_WAVE_OUT,
-   FILE_DEVICE_8042_PORT,
-   FILE_DEVICE_FILE_SYSTEM,
-     
-   /*
-    * Values beyond this are reserved for ISVs
-    */
-   FILE_DEVICE_FIRST_FREE = 32768
-};
+#define        FILE_DEVICE_BEEP                0x00000001
+#define        FILE_DEVICE_CD_ROM              0x00000002
+#define        FILE_DEVICE_CD_ROM_FILE_SYSTEM  0x00000003
+#define        FILE_DEVICE_CONTROLLER          0x00000004
+#define        FILE_DEVICE_DATALINK            0x00000005
+#define        FILE_DEVICE_DFS                 0x00000006
+#define        FILE_DEVICE_DISK                0x00000007
+#define        FILE_DEVICE_DISK_FILE_SYSTEM    0x00000008
+#define        FILE_DEVICE_FILE_SYSTEM         0x00000009
+#define        FILE_DEVICE_INPORT_PORT         0x0000000a
+#define        FILE_DEVICE_KEYBOARD            0x0000000b
+#define        FILE_DEVICE_MAILSLOT            0x0000000c
+#define        FILE_DEVICE_MIDI_IN             0x0000000d
+#define        FILE_DEVICE_MIDI_OUT            0x0000000e
+#define        FILE_DEVICE_MOUSE               0x0000000f
+#define        FILE_DEVICE_MULTI_UNC_PROVIDER  0x00000010
+#define        FILE_DEVICE_NAMED_PIPE          0x00000011
+#define        FILE_DEVICE_NETWORK             0x00000012
+#define        FILE_DEVICE_NETWORK_BROWSER     0x00000013
+#define        FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
+#define        FILE_DEVICE_NULL                0x00000015
+#define        FILE_DEVICE_PARALLEL_PORT       0x00000016
+#define        FILE_DEVICE_PHYSICAL_NETCARD    0x00000017
+#define        FILE_DEVICE_PRINTER             0x00000018
+#define        FILE_DEVICE_SCANNER             0x00000019
+#define        FILE_DEVICE_SERIAL_MOUSE_PORT   0x0000001a
+#define        FILE_DEVICE_SERIAL_PORT         0x0000001b
+#define        FILE_DEVICE_SCREEN              0x0000001c
+#define        FILE_DEVICE_SOUND               0x0000001d
+#define        FILE_DEVICE_STREAMS             0x0000001e
+#define        FILE_DEVICE_TAPE                0x0000001f
+#define        FILE_DEVICE_TAPE_FILE_SYSTEM    0x00000020
+#define        FILE_DEVICE_TRANSPORT           0x00000021
+#define        FILE_DEVICE_UNKNOWN             0x00000022
+#define        FILE_DEVICE_VIDEO               0x00000023
+#define        FILE_DEVICE_VIRTUAL_DISK        0x00000024
+#define        FILE_DEVICE_WAVE_IN             0x00000025
+#define        FILE_DEVICE_WAVE_OUT            0x00000026
+#define        FILE_DEVICE_8042_PORT           0x00000027
+#define        FILE_DEVICE_NETWORK_REDIRECTOR  0x00000028
+#define        FILE_DEVICE_BATTERY             0x00000029
+#define        FILE_DEVICE_BUS_EXTENDER        0x0000002a
+#define        FILE_DEVICE_MODEM               0x0000002b
+#define        FILE_DEVICE_VDM                 0x0000002c
 
+#define        FILE_REMOVABLE_MEDIA            0x00000001
+#define FILE_READ_ONLY_DEVICE           0x00000002
+#define FILE_FLOPPY_DISKETTE            0x00000004
+#define FILE_WRITE_ONCE_MEDIA           0x00000008
+#define FILE_REMOTE_DEVICE              0x00000010
+#define FILE_DEVICE_IS_MOUNTED          0x00000020
+#define FILE_VIRTUAL_VOLUME             0x00000040
 
 
-/*
- * Possible device characteristics
- */
-enum
-{
-   FILE_REMOVABLE_MEDIA  = 0x1,
-   FILE_READ_ONLY_DEVICE = 0x2,
-   FILE_FLOPPY_DISKETTE  = 0x4,
-   FILE_WRITE_ONCE_MEDIA = 0x8,
-   FILE_REMOTE_DEVICE    = 0x10,
-};
-
 /*
  * PURPOSE: Bus types
  */
@@ -286,22 +209,123 @@ enum
      IRP_MJ_MAXIMUM_FUNCTION,
 };
 
-enum
 /*
- * PURPOSE: Details about the result of a file open or create
+ * Minor function numbers for IRP_MJ_FILE_SYSTEM_CONTROL
  */
-{
-     FILE_CREATED,
-//     FILE_OPENED,
-     FILE_OVERWRITTEN,
-     FILE_SUPERSEDED,
-     FILE_EXISTS,
-     FILE_DOES_NOT_EXIST,
-};
-
 #define IRP_MN_USER_FS_REQUEST          0x00
 #define IRP_MN_MOUNT_VOLUME             0x01
 #define IRP_MN_VERIFY_VOLUME            0x02
 #define IRP_MN_LOAD_FILE_SYSTEM         0x03
 
+#define IO_DISK_INCREMENT  4
+
+#define  FILE_WORD_ALIGNMENT  0x0001
+
+/*
+ * File disposition values
+ */
+#define  FILE_CREATED         0x0000
+#define  FILE_OPENED          0x0001
+#define  FILE_OVERWRITTEN     0x0002
+#define  FILE_SUPERSEDED      0x0003
+#define  FILE_DOES_NOT_EXIST  0x0004
+
+
+/*
+ * file creation flags 
+ */
+#define FILE_DIRECTORY_FILE                     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
+
+#define FILE_COMPLETE_IF_OPLOCKED               0x00000100
+#define FILE_NO_EA_KNOWLEDGE                    0x00000200
+
+#define FILE_RANDOM_ACCESS                      0x00000800
+
+#define FILE_DELETE_ON_CLOSE                    0x00001000
+#define FILE_OPEN_BY_FILE_ID                    0x00002000
+#define FILE_OPEN_FOR_BACKUP_INTENT             0x00004000
+#define FILE_NO_COMPRESSION                     0x00008000
+
+#define FILE_RESERVE_OPFILTER                   0x00100000
+#define FILE_TRANSACTED_MODE                    0x00200000
+#define FILE_OPEN_OFFLINE_FILE                  0x00400000
+
+#define FILE_VALID_OPTION_FLAGS                 0x007fffff
+#define FILE_VALID_PIPE_OPTION_FLAGS            0x00000032
+#define FILE_VALID_MAILSLOT_OPTION_FLAGS        0x00000032
+#define FILE_VALID_SET_FLAGS                    0x00001036
+
+/*
+ * file information
+ */
+#define FileDirectoryInformation               1
+#define FileFullDirectoryInformation           2
+#define FileBothDirectoryInformation           3
+#define FileBasicInformation                   4
+#define FileStandardInformation                        5
+#define FileInternalInformation                        6
+#define FileEaInformation                      7
+#define FileAccessInformation                  8
+#define FileNameInformation                    9
+#define FileRenameInformation                  10
+#define FileLinkInformation                    11
+#define FileNamesInformation                   12
+#define FileDispositionInformation             13
+#define FilePositionInformation                        14
+#define FileFullEaInformation                  15
+#define FileModeInformation                    16
+#define FileAlignmentInformation               17
+#define FileAllInformation                     18
+#define FileAllocationInformation              19
+#define FileEndOfFileInformation               20
+#define FileAlternateNameInformation           21
+#define FileStreamInformation                  22
+#define FilePipeInformation                    23
+#define FilePipeLocalInformation               24
+#define FilePipeRemoteInformation              25
+#define FileMailslotQueryInformation           26
+#define FileMailslotSetInformation             27
+#define FileCompressionInformation             28
+#define FileCopyOnWriteInformation             29
+#define FileCompletionInformation              30
+#define FileMoveClusterInformation             31
+#define FileOleClassIdInformation              32
+#define FileOleStateBitsInformation            33
+#define FileNetworkOpenInformation             34
+#define FileObjectIdInformation                        35
+#define FileOleAllInformation                  36
+#define FileOleDirectoryInformation            37
+#define FileContentIndexInformation            38
+#define FileInheritContentIndexInformation     39
+#define FileOleInformation                     40
+#define FileMaximumInformation                 41
+
+
+
+typedef ULONG FS_INFORMATION_CLASS;
+
+/*
+ * file system information class values
+ */
+#define FileFsVolumeInformation                1
+#define FileFsLabelInformation                 2
+#define FileFsSizeInformation                  3
+#define FileFsDeviceInformation                        4
+#define FileFsAttributeInformation             5
+#define FileFsControlInformation               6
+#define FileFsQuotaQueryInformation            7
+#define FileFsQuotaSetInformation              8
+#define FileFsMaximumInformation               9
+
+#define IRP_MN_QUERY_DIRECTORY          0x01
+#define IRP_MN_NOTIFY_CHANGE_DIRECTORY  0x02
+
 #endif
index a3f2ead..2f66cc9 100644 (file)
@@ -1,5 +1,10 @@
 /* IO MANAGER ***************************************************************/
 
+BOOLEAN IoRaiseInformationalHardError(NTSTATUS ErrorStatus,
+                                     PUNICODE_STRING String,
+                                     PKTHREAD Thread);
+
+
 /*
  * FUNCTION: Registers the driver with WMI
  * ARGUMENTS:
@@ -503,7 +508,6 @@ NTSTATUS IoWritePartitionTable(PDEVICE_OBJECT DeviceObject,
                               ULONG NumberOfHeads,
                               struct _DRIVE_LAYOUT_INFORMATION* PBuffer);
 
-typedef ULONG FS_INFORMATION_CLASS;
 
 // Preliminary guess
 NTKERNELAPI NTSTATUS IoQueryFileVolumeInformation(IN PFILE_OBJECT FileObject, 
index 57be2f4..2d35f80 100644 (file)
@@ -155,4 +155,88 @@ VOID KeBugCheckEx(ULONG BugCheckCode,
  */
 VOID KeBugCheck(ULONG BugCheckCode);
 
+// kmutant definition slightly modified from nt5 ddk
+
+typedef struct _KMUTANT 
+{
+       DISPATCHER_HEADER Header;
+       LIST_ENTRY MutantListEntry;
+       struct _KTHREAD* OwnerThread;
+       BOOLEAN Abandoned;
+       UCHAR ApcDisable;
+} KMUTANT, *PKMUTANT;
+
+// io permission map has a 8k size
+// Each bit in the IOPM corresponds to an io port byte address. The bitmap
+// is initialized to allow IO at any port. [ all bits set ]. 
+
+typedef struct _IOPM 
+{
+       UCHAR Bitmap[8192];
+} IOPM, *PIOPM;
+
+/*
+ * FUNCTION: Provides the kernel with a new access map for a driver
+ * ARGUMENTS:
+ *     NewMap: =  If FALSE the kernel's map is set to all disabled. If TRUE
+ *                     the kernel disables access to a particular port.
+ *     IoPortMap = Caller supplies storage for the io permission map.
+ * REMARKS
+ *     Each bit in the IOPM corresponds to an io port byte address. The bitmap
+ *     is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
+ *     the minium privilege level required to perform IO prior to checking the permission map.
+ */
+void Ke386SetIoAccessMap(int NewMap, PIOPM *IoPermissionMap);
+
+/*
+ * FUNCTION: Queries the io permission  map.
+ * ARGUMENTS:
+ *     NewMap: =  If FALSE the kernel's map is set to all disabled. If TRUE
+ *                     the kernel disables access to a particular port.
+ *     IoPortMap = Caller supplies storage for the io permission map.
+ * REMARKS
+ *     Each bit in the IOPM corresponds to an io port byte address. The bitmap
+ *     is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
+ *     the minium privilege level required to perform IO prior to checking the permission map.
+ */
+void Ke386QueryIoAccessMap(BOOLEAN NewMap, PIOPM *IoPermissionMap);
+
+/*
+ * FUNCTION: Set the process IOPL
+ * ARGUMENTS:
+ *     Eprocess = Pointer to a executive process object
+ *     EnableIo = Specify TRUE to enable IO and FALSE to disable 
+ */
+NTSTATUS Ke386IoSetAccessProcess(PEPROCESS Eprocess, BOOLEAN EnableIo);
+
+/*
+ * FUNCTION: Releases a set of Global Descriptor Table Selectors
+ * ARGUMENTS:
+ *     SelArray = 
+ *     NumOfSelectors = 
+ */
+NTSTATUS KeI386ReleaseGdtSelectors(
+       OUT PULONG SelArray,
+       IN ULONG NumOfSelectors
+       );
+
+/*
+ * FUNCTION: Allocates a set of Global Descriptor Table Selectors
+ * ARGUMENTS:
+ *     SelArray = 
+ *     NumOfSelectors = 
+ */
+NTSTATUS KeI386AllocateGdtSelectors(
+       OUT PULONG SelArray,
+       IN ULONG NumOfSelectors
+       );
+
+/*
+ * FUNCTION: Raises a user mode exception
+ * ARGUMENTS:
+ *     ExceptionCode = Status code of the exception 
+ */
+void KeRaiseUserException(NTSTATUS ExceptionCode);
+
+
 #endif /* __INCLUDE_DDK_KEFUNCS_H */
index f994625..2138953 100644 (file)
@@ -101,65 +101,6 @@ typedef struct _KDEVICE_QUEUE
    KSPIN_LOCK Lock;
 } KDEVICE_QUEUE, *PKDEVICE_QUEUE;
 
-#if RIGHT_DEFINITION_PROVIDED_ABOVE
-#define _KTHREAD _ETHREAD
-
-typedef struct _KTHREAD
-/*
- * PURPOSE: Describes a thread of execution
- */
-{
-   CSHORT Type;
-   CSHORT Size;
-   /*
-    * PURPOSE: Head of the queue of apcs
-    */
-   LIST_ENTRY ApcQueueHead;
-   
-   /*
-    * PURPOSE: Entry in the linked list of threads
-    */
-   LIST_ENTRY Entry;
-   
-   /*
-    * PURPOSE: Current state of the thread
-    */
-   ULONG State;
-   
-   /*
-    * PURPOSE: Priority modifier of the thread
-    */
-   ULONG Priority;
-   
-   /*
-    * PURPOSE: Pointer to our process
-    */
-   struct _EPROCESS* Process;
-   
-   /*
-    * PURPOSE: Handle of our process
-    */
-   HANDLE ProcessHandle;
-   
-   /*
-    * PURPOSE: Thread affinity mask
-    */
-   ULONG AffinityMask;
-   
-   /*
-    * PURPOSE: Saved thread context
-    */
-   hal_thread_state context;
-   
-   /*
-    * PURPOSE: Timeout for the thread to be woken up
-    */
-   signed long long int wake_time;
-   
-} KTHREAD, *PKTHREAD, *PETHREAD;
-#endif
-
              
 typedef struct _KAPC
 {
index 2cdbd26..57135ab 100644 (file)
@@ -1,6 +1,13 @@
 /* MEMORY MANAGMENT ******************************************************/
 
-#include <internal/hal/page.h>
+#include <internal/mmhal.h>
+
+BOOLEAN MmIsNonPagedSystemAddressValid(PVOID VirtualAddress);
+BOOLEAN MmIsThisAnNtAsSystem(VOID);
+
+#define PAGE_ROUND_UP(x) ( (((ULONG)x)%PAGESIZE) ? ((((ULONG)x)&(~0xfff))+0x1000) : ((ULONG)x) )
+#define PAGE_ROUND_DOWN(x) (((ULONG)x)&(~0xfff))
+
 
 /*
  * FUNCTION: Determines if the given virtual address is page aligned
index 835171b..0ab393b 100644 (file)
@@ -22,13 +22,6 @@ extern "C"
 
 #define QUAD_PART(LI)  (*(LONGLONG *)(&LI))
 
-
-#define  IO_DISK_INCREMENT  4
-
-#define  FILE_WORD_ALIGNMENT  0x0001
-
-#define  FILE_OPENED          0x0001
-
 #include <ddk/status.h>
 #include <ddk/ntdef.h>
 #include <ddk/defines.h>
@@ -41,6 +34,7 @@ extern "C"
 #include <ddk/iotypes.h>
 #include <ddk/extypes.h>
 #include <ddk/pstypes.h>
+#include <ddk/zwtypes.h>
 #include <ddk/ioctrl.h>   
 #include <internal/hal/ddk.h>
    
@@ -53,7 +47,8 @@ extern "C"
 #include <ddk/psfuncs.h>
 #include <ddk/obfuncs.h>
 #include <ddk/dbgfuncs.h>
-      
+#include <ddk/sefuncs.h>      
+   
 #ifdef __cplusplus
 };
 #endif
index c64c7c1..264adc1 100644 (file)
@@ -6,5 +6,8 @@ struct _ETHREAD;
 struct _EPROCESS;
 
 #define NTKERNELAPI
+#define NTSYSAPI
+#define NTAPI
+
 
 #endif
index 2544a34..a405072 100644 (file)
@@ -6,7 +6,7 @@
  * ARGUMENTS:
  *        Object = Object's body
  */
-VOID ObDeferenceObject(PVOID Object);
+VOID ObDereferenceObject(PVOID Object);
 
 /*
  * FUNCTION: Performs access validation on an object handle and if access
index b7b0bc4..cf6f3f2 100644 (file)
@@ -96,27 +96,13 @@ typedef struct _OBJECT
  * PURPOSE: Header for every object managed by the object manager
  */
 {   
-   /*
-    * PURPOSE: Name of this entry
-    */
-   UNICODE_STRING name;
-   
-   /*
-    * PURPOSE: Our entry in our parents list of subdirectory
-    */
-   LIST_ENTRY entry;
-
-   /*
-    * PURPOSE: Number of non-handle references to this object
-    */
-   ULONG RefCount;
-   
-   /*
-    * PURPOSE: Number of handles opened to this object
-    */
-   ULONG HandleCount;
-   
-   struct _DIRECTORY_OBJECT* Parent;
+   UNICODE_STRING Name;
+   LIST_ENTRY Entry;
+   ULONG RefCount;   
+   ULONG HandleCount;   
+   BOOLEAN Permanent;   
+   struct _DIRECTORY_OBJECT* Parent;   
+   POBJECT_TYPE ObjectType;
    
    /*
     * PURPOSE: Object type
@@ -141,3 +127,9 @@ typedef struct _OBJECT_ATTRIBUTES {
        SECURITY_DESCRIPTOR *SecurityDescriptor;       
        SECURITY_QUALITY_OF_SERVICE *SecurityQualityOfService;  
 } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
+
+typedef struct _HANDLE_TABLE
+{
+   LIST_ENTRY ListHead;
+   KSPIN_LOCK ListLock;
+} HANDLE_TABLE, *PHANDLE_TABLE;
index 329a8ac..c95268d 100644 (file)
@@ -25,7 +25,7 @@ NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
                              PKSTART_ROUTINE StartRoutine,
                               PVOID StartContext);
 NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus);
-NTSTATUS PsSuspendThread(VOID);
-NTSTATUS PsWakeThread(PETHREAD Thread);
+VOID PsSuspendThread(PETHREAD Thread);
+VOID PsResumeThread(PETHREAD Thread);
 PETHREAD PsGetCurrentThread(VOID);
 struct _EPROCESS* PsGetCurrentProcess(VOID);
index 75617ce..327e38a 100644 (file)
@@ -131,7 +131,7 @@ typedef struct _KTHREAD
        ULONG                   Quantum;
        UCHAR                   ThreadState; //Thread state is a typeless enum, otherwise it should be const integer
        ULONG                   FreezeCount;
-       ULONG                   SuspendCount;
+       LONG                    SuspendCount;
        PTRAP_FRAME             TrapFrame; 
        PVOID                   *Tls;
        KWAIT_BLOCK             WaitBlock[4];   
@@ -149,6 +149,7 @@ typedef struct _KTHREAD
         */
         hal_thread_state                   Context;
         LIST_ENTRY Entry;
+        ULONG LastTick;
 } KTHREAD, *PKTHREAD;
 
 
@@ -255,26 +256,28 @@ typedef struct _ETHREAD {
 } ETHREAD, *PETHREAD;
 
 
-typedef struct _KPROCESS {
-       DISPATCHER_HEADER       DispatcherHeader;
-       PVOID                   PageTableDirectory; // FIXME: I shoud point to a PTD
-       TIME                    ElapsedTime;
-       TIME                    KernelTime;
-       TIME                    UserTime;
-       LIST_ENTRY              InOutSwap;   // ??      
-       KSPIN_LOCK              SpinLock;
-       KAFFINITY               Affinity;
-       ULONG                   StackCount;
-       KPRIORITY               BasePriority;
-       ULONG                   DefaultThreadQuantum;
-       UCHAR                   ProcessState;
-       ULONG                   ThreadSeed;
-       UCHAR                   DisableBoost;
+typedef struct _KPROCESS 
+{
+   DISPATCHER_HEADER   DispatcherHeader;
+   PVOID                       PageTableDirectory; // FIXME: I shoud point to a PTD
+   TIME                        ElapsedTime;
+   TIME                        KernelTime;
+   TIME                        UserTime;
+   LIST_ENTRY          InOutSwap;   // ??      
+   KSPIN_LOCK          SpinLock;
+   KAFFINITY           Affinity;
+   ULONG                       StackCount;
+   KPRIORITY           BasePriority;
+   ULONG                       DefaultThreadQuantum;
+   UCHAR                       ProcessState;
+   ULONG                       ThreadSeed;
+   UCHAR                       DisableBoost;
    
    /*
     * Added by David Welch (welch@mcmail.com)
     */
    LIST_ENTRY MemoryAreaList;
+   HANDLE_TABLE HandleTable;
 } KPROCESS, *PKPROCESS;
 
 typedef struct _EPROCESS
index 0897180..c689f8d 100644 (file)
 typedef ULONG ACCESS_MODE, *PACCESS_MODE;
 typedef SECURITY_QUALITY_OF_SERVICE* PSECURITY_QUALITY_OF_SERVICE;
 
-typedef struct _SECURITY_SUBJECT_CONTEXT
-{
-} SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
-
 typedef struct _SECURITY_DESCRIPTOR_CONTEXT
 {
 } SECURITY_DESCRIPTOR_CONTEXT, *PSECURITY_DESCRIPTOR_CONTEXT;
@@ -44,4 +40,13 @@ typedef struct _ACCESS_TOKEN {
        UCHAR                           VariablePart[0];
 } ACCESS_TOKEN, *PACCESS_TOKEN;
 
+
+typedef struct _SECURITY_SUBJECT_CONTEXT
+{
+       PACCESS_TOKEN ClientToken;
+       SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
+       PACCESS_TOKEN PrimaryToken;
+       PVOID ProcessAuditId;
+} SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
+
 #endif
index 8e345c4..12c712e 100644 (file)
@@ -9,6 +9,7 @@
  *              13/07/98: Reorganised things a bit (David Welch)
  *              04/08/98: Added some documentation (Boudewijn Dekker)
  *             14/08/98: Added type TIME and change variable type from [1] to [0]
+ *              14/09/98: Added for each Nt call a corresponding Zw Call
  */
 
 #ifndef __DDK_ZW_H
 
 #include <windows.h>
 
-typedef struct _OBJDIR_INFORMATION {
-       UNICODE_STRING ObjectName;
-       UNICODE_STRING ObjectTypeName; // Directory, Device ...
-       UCHAR          Data[0];        
-} OBJDIR_INFORMATION, *POBJDIR_INFORMATION;
-
-
-/*
- * FUNCTION: Closes an object handle
- * ARGUMENTS:
- *         Handle = Handle to the object
- * RETURNS: Status
- */
-NTSTATUS ZwClose(HANDLE Handle);
-
-/*
- * FUNCTION: Creates or opens a directory object, which is a container for
- * other objects
- * ARGUMENTS:
- *        DirectoryHandle (OUT) = Points to a variable which stores the
- *                                handle for the directory on success
- *        DesiredAccess = Type of access the caller requires to the directory
- *        ObjectAttributes = Structures specifing the object attributes,
- *                           initialized with InitializeObjectAttributes
- * RETURNS: Status 
- */
-NTSTATUS ZwCreateDirectoryObject(PHANDLE DirectoryHandle,
-                                ACCESS_MASK DesiredAccess,
-                                POBJECT_ATTRIBUTES ObjectAttributes);
-
-/*
- * FUNCTION: Creates or opens a registry key
- * ARGUMENTS:
- *        KeyHandle (OUT) = Points to a variable which stores the handle
- *                          for the key on success
- *        DesiredAccess = Access desired by the caller to the key 
- *        ObjectAttributes = Initialized object attributes for the key
- *        TitleIndex = Who knows?
- *        Class = Object class of the key?
- *        CreateOptions = Options for the key creation
- *        Disposition (OUT) = Points to a variable which a status value
- *                            indicating whether a new key was created
- * RETURNS: Status
- */
-NTSTATUS ZwCreateKey(PHANDLE KeyHandle, ACCESS_MASK DesiredAccess,
-                    POBJECT_ATTRIBUTES ObjectAttributes,
-                    ULONG TitleIndex, PUNICODE_STRING Class,
-                    ULONG CreateOptions, PULONG Disposition);
-
-/*
- * FUNCTION: Deletes a registry key
- * ARGUMENTS:
- *         KeyHandle = Handle of the key
- * RETURNS: Status
- */
-NTSTATUS ZwDeleteKey(HANDLE KeyHandle);
-
-/*
- * FUNCTION: Returns information about the subkeys of an open key
- * ARGUMENTS:
- *         KeyHandle = Handle of the key whose subkeys are to enumerated
- *         Index = zero based index of the subkey for which information is
- *                 request
- *         KeyInformationClass = Type of information returned
- *         KeyInformation (OUT) = Caller allocated buffer for the information
- *                                about the key
- *         Length = Length in bytes of the KeyInformation buffer
- *         ResultLength (OUT) = Caller allocated storage which holds
- *                              the number of bytes of information retrieved
- *                              on return
- * RETURNS: Status
- */
-NTSTATUS ZwEnumerateKey(HANDLE KeyHandle, ULONG Index, 
-                       KEY_INFORMATION_CLASS KeyInformationClass,
-                       PVOID KeyInformation, ULONG Length, 
-                       PULONG ResultLength);
-
-/*
- * FUNCTION: Returns information about the value entries of an open key
- * ARGUMENTS:
- *         KeyHandle = Handle of the key whose value entries are to enumerated
- *         Index = zero based index of the subkey for which information is
- *                 request
- *         KeyInformationClass = Type of information returned
- *         KeyInformation (OUT) = Caller allocated buffer for the information
- *                                about the key
- *         Length = Length in bytes of the KeyInformation buffer
- *         ResultLength (OUT) = Caller allocated storage which holds
- *                              the number of bytes of information retrieved
- *                              on return
- * RETURNS: Status
- */
-NTSTATUS ZwEnumerateValueKey(HANDLE KeyHandle, ULONG Index, 
-                       KEY_VALUE_INFORMATION_CLASS KeyInformationClass,
-                       PVOID KeyInformation, ULONG Length, 
-                       PULONG ResultLength);
-
-
-/*
- * FUNCTION: Forces a registry key to be committed to disk
- * ARGUMENTS:
- *        KeyHandle = Handle of the key to be written to disk
- * RETURNS: Status
- */
-NTSTATUS ZwFlushKey(HANDLE KeyHandle);
-
-/*
- * FUNCTION: Changes the attributes of an object to temporary
- * ARGUMENTS:
- *        Handle = Handle for the object
- * RETURNS: Status
- */
-NTSTATUS ZwMakeTemporaryObject(HANDLE Handle);
-
-/*
- * FUNCTION: Maps a view of a section into the virtual address space of a 
- *           process
- * ARGUMENTS:
- *        SectionHandle = Handle of the section
- *        ProcessHandle = Handle of the process
- *        BaseAddress = Desired base address (or NULL) on entry
- *                      Actual base address of the view on exit
- *        ZeroBits = Number of high order address bits that must be zero
- *        CommitSize = Size in bytes of the initially committed section of 
- *                     the view 
- *        SectionOffset = Offset in bytes from the beginning of the section
- *                        to the beginning of the view
- *        ViewSize = Desired length of map (or zero to map all) on entry
- *                   Actual length mapped on exit
- *        InheritDisposition = Specified how the view is to be shared with
- *                            child processes
- *        AllocateType = Type of allocation for the pages
- *        Protect = Protection for the committed region of the view
- * RETURNS: Status
- */
-NTSTATUS ZwMapViewOfSection(HANDLE SectionHandle,
-                           HANDLE ProcessHandle,
-                           PVOID* BaseAddress,
-                           ULONG ZeroBits,
-                           ULONG CommitSize,
-                           PLARGE_INTEGER SectionOffset,
-                           PULONG ViewSize,
-                           SECTION_INHERIT InheritDisposition,
-                           ULONG AllocationType,
-                           ULONG Protect);
-
-/*
- * FUNCTION: Opens an existing key in the registry
- * ARGUMENTS:
- *        KeyHandle (OUT) = Caller supplied storage for the resulting handle
- *        DesiredAccess = Requested access to the key
- *        ObjectAttribute = Initialized attributes for the object
- * RETURNS: Status
- */
-NTSTATUS ZwOpenKey(PHANDLE KeyHandle, ACCESS_MASK DesiredAccess,
-                  POBJECT_ATTRIBUTES ObjectAttributes);
-
-/*
- * FUNCTION: Opens an existing section object
- * ARGUMENTS:
- *        KeyHandle (OUT) = Caller supplied storage for the resulting handle
- *        DesiredAccess = Requested access to the key
- *        ObjectAttribute = Initialized attributes for the object
- * RETURNS: Status
- */
-NTSTATUS ZwOpenSection(PHANDLE KeyHandle, ACCESS_MASK DesiredAccess,
-                      POBJECT_ATTRIBUTES ObjectAttributes);
-
-NTSTATUS ZwQueryDirectoryObject(IN HANDLE DirObjHandle,
-                               OUT POBJDIR_INFORMATION DirObjInformation, 
-                               IN ULONG                BufferLength, 
-                               IN BOOLEAN              GetNextIndex, 
-                               IN BOOLEAN              IgnoreInputIndex, 
-                               IN OUT PULONG           ObjectIndex,
-                               OUT PULONG              DataWritten OPTIONAL);
-
-/*
- * FUNCTION: Returns information about an open file
- * ARGUMENTS:
- *        FileHandle = Handle of the file to be queried
- *        IoStatusBlock (OUT) = Caller supplied storage for the result
- *        FileInformation (OUT) = Caller supplied storage for the file
- *                                information
- *        Length = Length in bytes of the buffer for file information
- *        FileInformationClass = Type of information to be returned
- * RETURNS: Status
- */
-NTSTATUS ZwQueryInformationFile(HANDLE FileHandle,
-                               PIO_STATUS_BLOCK IoStatusBlock,
-                               PVOID FileInformation,
-                               ULONG Length,
-                               FILE_INFORMATION_CLASS FileInformationClass);
-
-
-
-NTSTATUS ZwReadFile(HANDLE FileHandle,
-                    HANDLE EventHandle,
-                   PIO_APC_ROUTINE ApcRoutine,
-                   PVOID ApcContext,
-                   PIO_STATUS_BLOCK IoStatusBlock,
-                   PVOID Buffer,
-                   ULONG Length,
-                   PLARGE_INTEGER ByteOffset,
-                   PULONG Key);
-
-
-   
-
-
-#define NtCurrentProcess() ( (HANDLE) 0xFFFFFFFF )
-#define NtCurrentThread() ( (HANDLE) 0xFFFFFFFE )
-
-
-
-// event access mask
-
-#define EVENT_READ_ACCESS                      1
-#define EVENT_WRITE_ACCESS                     2
-
-
-// file creation flags 
-
-#define FILE_DIRECTORY_FILE                     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
-
-#define FILE_COMPLETE_IF_OPLOCKED               0x00000100
-#define FILE_NO_EA_KNOWLEDGE                    0x00000200
-
-#define FILE_RANDOM_ACCESS                      0x00000800
-
-#define FILE_DELETE_ON_CLOSE                    0x00001000
-#define FILE_OPEN_BY_FILE_ID                    0x00002000
-#define FILE_OPEN_FOR_BACKUP_INTENT             0x00004000
-#define FILE_NO_COMPRESSION                     0x00008000
-
-#define FILE_RESERVE_OPFILTER                   0x00100000
-#define FILE_TRANSACTED_MODE                    0x00200000
-#define FILE_OPEN_OFFLINE_FILE                  0x00400000
-
-#define FILE_VALID_OPTION_FLAGS                 0x007fffff
-#define FILE_VALID_PIPE_OPTION_FLAGS            0x00000032
-#define FILE_VALID_MAILSLOT_OPTION_FLAGS        0x00000032
-#define FILE_VALID_SET_FLAGS                    0x00001036
-
-
-// file disposition values
-
-
-#define FILE_SUPERSEDE                  0x0000
-#define FILE_OPEN                       0x0001
-#define FILE_CREATE                     0x0002
-#define FILE_OPEN_IF                    0x0003
-#define FILE_OVERWRITE                  0x0004
-#define FILE_OVERWRITE_IF               0x0005
-#define FILE_MAXIMUM_DISPOSITION        0x0005
-
-
-
-
-//process query / set information class
-
-#define        ProcessBasicInformation                 0
-#define        ProcessQuotaLimits                      1
-#define        ProcessIoCounters                       2
-#define ProcessVmCounters                      3
-#define ProcessTimes                           4
-#define ProcessBasePriority                    5
-#define ProcessRaisePriority                   6
-#define ProcessDebugPort                       7
-#define ProcessExceptionPort                   8
-#define ProcessAccessToken                     9
-#define ProcessLdtInformation                  10
-#define ProcessLdtSize                         11
-#define ProcessDefaultHardErrorMode            12
-#define ProcessIoPortHandlers                  13
-#define ProcessPooledUsageAndLimits            14
-#define ProcessWorkingSetWatch                 15
-#define ProcessUserModeIOPL                    16
-#define ProcessEnableAlignmentFaultFixup       17
-#define ProcessPriorityClass                   18
-#define ProcessWx86Information                 19
-#define ProcessHandleCount                     20
-#define ProcessAffinityMask                    21
-#define MaxProcessInfoClass                    22
-
-// thread query / set information class
-#define ThreadBasicInformation                 0
-#define ThreadTimes                            1
-#define ThreadPriority                         2
-#define ThreadBasePriority                     3
-#define ThreadAffinityMask                     4
-#define ThreadImpersonationToken               5
-#define ThreadDescriptorTableEntry             6
-#define ThreadEnableAlignmentFaultFixup                7
-#define ThreadEventPair                                8
-#define ThreadQuerySetWin32StartAddress                9
-#define ThreadZeroTlsCell                      10
-#define ThreadPerformanceCount                 11
-#define ThreadAmILastThread                    12
-#define ThreadIdealProcessor                   13
-#define ThreadPriorityBoost                    14
-#define MaxThreadInfoClass                     15
-
-
-
-// key query information class
-
-#define KeyBasicInformation                    0
-#define KeyNodeInformation                     1
-#define KeyFullInformation                     2
-
-
-// key set information class
-
-#define KeyWriteTimeInformation                        0
-
-// key value information class
-
-#define KeyValueBasicInformation               0
-#define        KeyValueFullInformation                 1
-#define        KeyValuePartialInformation              2
-
-// object handle information
-
-#define ObjectBasicInformation                 0
-#define ObjectNameInformation                  1
-#define ObjectTypeInformation                  2
-#define ObjectAllInformation                   3
-#define        ObjectDataInformation                   4
-
-// semaphore information
-
-#define SemaphoreBasicInformation              0
-
-// event information
-
-#define EventBasicInformation                  0
-
-
-// system information
-
-#define SystemPerformanceInformation            5
-#define SystemCacheInformation                 21
-#define SystemTimeAdjustmentInformation                28
-
-
-// file information
-
-
-#define FileDirectoryInformation               1
-#define FileFullDirectoryInformation           2
-#define FileBothDirectoryInformation           3
-#define FileBasicInformation                   4
-#define FileStandardInformation                        5
-#define FileInternalInformation                        6
-#define FileEaInformation                      7
-#define FileAccessInformation                  8
-#define FileNameInformation                    9
-#define FileRenameInformation                  10
-#define FileLinkInformation                    11
-#define FileNamesInformation                   12
-#define FileDispositionInformation             13
-#define FilePositionInformation                        14
-#define FileFullEaInformation                  15
-#define FileModeInformation                    16
-#define FileAlignmentInformation               17
-#define FileAllInformation                     18
-#define FileAllocationInformation              19
-#define FileEndOfFileInformation               20
-#define FileAlternateNameInformation           21
-#define FileStreamInformation                  22
-#define FilePipeInformation                    23
-#define FilePipeLocalInformation               24
-#define FilePipeRemoteInformation              25
-#define FileMailslotQueryInformation           26
-#define FileMailslotSetInformation             27
-#define FileCompressionInformation             28
-#define FileCopyOnWriteInformation             29
-#define FileCompletionInformation              30
-#define FileMoveClusterInformation             31
-#define FileOleClassIdInformation              32
-#define FileOleStateBitsInformation            33
-#define FileNetworkOpenInformation             34
-#define FileObjectIdInformation                        35
-#define FileOleAllInformation                  36
-#define FileOleDirectoryInformation            37
-#define FileContentIndexInformation            38
-#define FileInheritContentIndexInformation     39
-#define FileOleInformation                     40
-#define FileMaximumInformation                 41
-
-
-
-//file system information class values
-
-
-
-#define FileFsVolumeInformation                1
-#define FileFsLabelInformation                 2
-#define FileFsSizeInformation                  3
-#define FileFsDeviceInformation                        4
-#define FileFsAttributeInformation             5
-#define FileFsControlInformation               6
-#define FileFsQuotaQueryInformation            7
-#define FileFsQuotaSetInformation              8
-#define FileFsMaximumInformation               9
-
-
-// shutdown action
-
-typedef enum SHUTDOWN_ACTION_TAG {
-       ShutdownNoReboot,
-       ShutdownReboot,
-       ShutdownPowerOff
-} SHUTDOWN_ACTION;
-
-
-
-// wait type
-
-#define WaitAll                                        0
-#define WaitAny                                        1
-// key restore flags
-
-#define REG_WHOLE_HIVE_VOLATILE                1   
-#define REG_REFRESH_HIVE                       2   
-
-
-// object type  access rights
-
-#define OBJECT_TYPE_CREATE             0x0001 
-#define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
-
-
-// directory access rights
-
-#define DIRECTORY_QUERY                                0x0001
-#define DIRECTORY_TRAVERSE                     0x0002
-#define DIRECTORY_CREATE_OBJECT                        0x0004
-#define DIRECTORY_CREATE_SUBDIRECTORY          0x0008
-
-#define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF)
-
-// symbolic link access rights
-
-#define SYMBOLIC_LINK_QUERY                    0x0001
-#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
-   
-typedef struct _PROCESS_WS_WATCH_INFORMATION
-{
-       PVOID FaultingPc;
-       PVOID FaultingVa;
-} PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
-
-typedef struct _PROCESS_BASIC_INFORMATION
-{
-       NTSTATUS ExitStatus;
-       PNT_PEB PebBaseAddress;
-       KAFFINITY AffinityMask;
-       KPRIORITY BasePriority;
-       ULONG UniqueProcessId;
-       ULONG InheritedFromUniqueProcessId;
-} PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION;
-
-typedef struct _QUOTA_LIMITS 
-{
-       ULONG PagedPoolLimit;
-       ULONG NonPagedPoolLimit;
-       ULONG MinimumWorkingSetSize;
-       ULONG MaximumWorkingSetSize;
-       ULONG PagefileLimit;
-       TIME TimeLimit;
-} QUOTA_LIMITS, *PQUOTA_LIMITS;
-
-typedef struct _IO_COUNTERS
-{
-       ULONG ReadOperationCount;
-       ULONG WriteOperationCount;
-       ULONG OtherOperationCount;
-       LARGE_INTEGER ReadTransferCount;
-       LARGE_INTEGER WriteTransferCount;
-       LARGE_INTEGER OtherTransferCount;
-} IO_COUNTERS, *PIO_COUNTERS;
-
-
-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 struct _POOLED_USAGE_AND_LIMITS_ 
-{
-       ULONG PeakPagedPoolUsage;
-       ULONG PagedPoolUsage;
-       ULONG PagedPoolLimit;
-       ULONG PeakNonPagedPoolUsage;
-       ULONG NonPagedPoolUsage;
-       ULONG NonPagedPoolLimit;
-       ULONG PeakPagefileUsage;
-       ULONG PagefileUsage;
-       ULONG PagefileLimit;
-} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
-
-
-typedef struct _PROCESS_ACCESS_TOKEN 
-{
-       HANDLE Token;
-       HANDLE Thread;
-} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
-
-typedef struct _KERNEL_USER_TIMES 
-{
-       TIME CreateTime;
-       TIME ExitTime;
-       TIME KernelTime;
-       TIME UserTime;
-} KERNEL_USER_TIMES;
-typedef KERNEL_USER_TIMES *PKERNEL_USER_TIMES;
-
-// thread information
-
-// incompatible with MS NT
-
-typedef struct _THREAD_BASIC_INFORMATION
-{
-       NTSTATUS ExitStatus;
-       PVOID TebBaseAddress;
-       KAFFINITY AffinityMask;
-       KPRIORITY BasePriority;
-       ULONG UniqueThreadId;
-} THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
-
-// object information
-   
-typedef struct _OBJECT_NAME_INFORMATION 
-{               
-    UNICODE_STRING Name;                                
-} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;   
-
-
-
-typedef struct _OBJECT_DATA_INFORMATION 
-{
-       BOOL bInheritHanlde;
-       BOOL bProtectFromClose;
-} OBJECT_DATA_INFORMATION,  *POBJECT_DATA_INFORMATION;
-
-
-typedef struct _OBJECT_TYPE_INFORMATION 
-{
-       UNICODE_STRING  Name;
-       UNICODE_STRING Type;
-       ULONG TotalHandles;
-       ULONG ReferenceCount;
-} OBJECT_TYPE_INFORMATION, *POBJECT_TYPE_INFORMATION;
-
-// system information
-
-typedef struct _SYSTEM_TIME_ADJUSTMENT
-{
-       ULONG TimeAdjustment;   
-       BOOL  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; 
-
-
-typedef struct _SYSTEM_CACHE_INFORMATION {
-       ULONG           CurrentSize;
-       ULONG           PeakSize;
-       ULONG           PageFaultCount;
-       ULONG           MinimumWorkingSet;
-       ULONG           MaximumWorkingSet;
-       ULONG           Unused[4];
-} SYSTEM_CACHE_INFORMATION;
-
-
-
-// file information
-
-typedef struct _FILE_BASIC_INFORMATION 
-{                    
-       TIME CreationTime;                             
-       TIME LastAccessTime;                           
-       TIME LastWriteTime;                            
-       TIME ChangeTime;                               
-       ULONG FileAttributes;                                   
-} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;         
-                                                            
-typedef struct _FILE_STANDARD_INFORMATION 
-{                 
-       LARGE_INTEGER AllocationSize;                           
-       LARGE_INTEGER EndOfFile;                                
-       ULONG NumberOfLinks;                                    
-       BOOLEAN DeletePending;                                  
-       BOOLEAN Directory;                                      
-} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;   
-                                                            
-typedef struct _FILE_POSITION_INFORMATION 
-{                 
-       LARGE_INTEGER CurrentByteOffset;                        
-} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;   
-                                                            
-typedef struct _FILE_ALIGNMENT_INFORMATION 
-{                
-       ULONG AlignmentRequirement;                             
-} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; 
-                                                            
-typedef struct _FILE_DISPOSITION_INFORMATION
-{                  
-       BOOLEAN DeleteFile;                                         
-} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; 
-                                                                
-typedef struct _FILE_END_OF_FILE_INFORMATION
-{                  
-       LARGE_INTEGER EndOfFile;                                    
-} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; 
-                                                                
-typedef struct _FILE_NETWORK_OPEN_INFORMATION {
-       TIME CreationTime;
-       TIME LastAccessTime;
-       TIME LastWriteTime;
-       TIME ChangeTime;
-       LARGE_INTEGER AllocationSize;
-       LARGE_INTEGER EndOfFile;
-       ULONG FileAttributes;
-} FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
-
-typedef struct _FILE_FULL_EA_INFORMATION
-{
-       ULONG NextEntryOffset;
-       UCHAR Flags;
-       UCHAR EaNameLength;
-       USHORT EaValueLength;
-       CHAR *EaName;
-} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
-
-
-typedef struct _FILE_EA_INFORMATION {
-       ULONG EaSize;
-} FILE_EA_INFORMATION, *PFILE_EA_INFORMATION;
-
-
-typedef struct _FILE_GET_EA_INFORMATION {
-       ULONG NextEntryOffset;
-       UCHAR EaNameLength;
-       CHAR EaName[0];
-} FILE_GET_EA_INFORMATION, *PFILE_GET_EA_INFORMATION;
-
-typedef struct _FILE_STREAM_INFORMATION {
-        ULONG NextEntryOffset;
-        ULONG StreamNameLength;
-        LARGE_INTEGER StreamSize;
-        LARGE_INTEGER StreamAllocationSize;
-        WCHAR StreamName[0];
-} FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION;
-
-typedef struct _FILE_ALLOCATION_INFORMATION {
-       LARGE_INTEGER AllocationSize;
-} FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION;
-
-typedef struct _FILE_NAME_INFORMATION {
-       ULONG FileNameLength;
-       WCHAR FileName[0];
-} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
-
-typedef struct _FILE_NAMES_INFORMATION {
-       ULONG NextEntryOffset;
-       ULONG FileIndex;
-       ULONG FileNameLength;
-       WCHAR FileName[0];
-} FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION;
-
-
-typedef struct _FILE_RENAME_INFORMATION {
-       BOOLEAN Replace;
-       HANDLE RootDir;
-        ULONG FileNameLength;
-       WCHAR FileName[0];
-} FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;
-
-
-typedef struct _FILE_INTERNAL_INFORMATION {
-       LARGE_INTEGER IndexNumber;
-} FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION;
-
-typedef struct _FILE_ACCESS_INFORMATION {
-       ACCESS_MASK AccessFlags;
-} FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION;
-
-
-typedef struct _FILE_MODE_INFORMATION {
-       ULONG Mode;
-} FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION;
-
-typedef struct _FILE_COMPRESSION_INFORMATION {
-       LARGE_INTEGER CompressedFileSize;
-       USHORT CompressionFormat;
-       UCHAR CompressionUnitShift;
-       UCHAR ChunkShift;
-       UCHAR ClusterShift;
-       UCHAR Reserved[3];
-} FILE_COMPRESSION_INFORMATION, *PFILE_COMPRESSION_INFORMATION;
-
-typedef struct _FILE_ALL_INFORMATION {
-       FILE_BASIC_INFORMATION BasicInformation;
-       FILE_STANDARD_INFORMATION StandardInformation;
-       FILE_INTERNAL_INFORMATION InternalInformation;
-       FILE_EA_INFORMATION EaInformation;
-       FILE_ACCESS_INFORMATION AccessInformation;
-       FILE_POSITION_INFORMATION PositionInformation;
-       FILE_MODE_INFORMATION ModeInformation;
-       FILE_ALIGNMENT_INFORMATION AlignmentInformation;
-       FILE_NAME_INFORMATION NameInformation;
-} FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION;
-
-// file system information structures
-
-typedef struct _FILE_FS_DEVICE_INFORMATION {                    
-       DEVICE_TYPE DeviceType;                                     
-       ULONG Characteristics;                                      
-} FILE_FS_DEVICE_INFORMATION,  *PFILE_FS_DEVICE_INFORMATION;
-
-
-/*     device type can be one of the following values:
-
-       FILE_DEVICE_BEEP                0x00000001
-       FILE_DEVICE_CD_ROM              0x00000002
-       FILE_DEVICE_CD_ROM_FILE_SYSTEM  0x00000003
-       FILE_DEVICE_CONTROLLER          0x00000004
-       FILE_DEVICE_DATALINK            0x00000005
-       FILE_DEVICE_DFS                 0x00000006
-       FILE_DEVICE_DISK                0x00000007
-       FILE_DEVICE_DISK_FILE_SYSTEM    0x00000008
-       FILE_DEVICE_FILE_SYSTEM         0x00000009
-       FILE_DEVICE_INPORT_PORT         0x0000000a
-       FILE_DEVICE_KEYBOARD            0x0000000b
-       FILE_DEVICE_MAILSLOT            0x0000000c
-       FILE_DEVICE_MIDI_IN             0x0000000d
-       FILE_DEVICE_MIDI_OUT            0x0000000e
-       FILE_DEVICE_MOUSE               0x0000000f
-       FILE_DEVICE_MULTI_UNC_PROVIDER  0x00000010
-       FILE_DEVICE_NAMED_PIPE          0x00000011
-       FILE_DEVICE_NETWORK             0x00000012
-       FILE_DEVICE_NETWORK_BROWSER     0x00000013
-       FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
-       FILE_DEVICE_NULL                0x00000015
-       FILE_DEVICE_PARALLEL_PORT       0x00000016
-       FILE_DEVICE_PHYSICAL_NETCARD    0x00000017
-       FILE_DEVICE_PRINTER             0x00000018
-       FILE_DEVICE_SCANNER             0x00000019
-       FILE_DEVICE_SERIAL_MOUSE_PORT   0x0000001a
-       FILE_DEVICE_SERIAL_PORT         0x0000001b
-       FILE_DEVICE_SCREEN              0x0000001c
-       FILE_DEVICE_SOUND               0x0000001d
-       FILE_DEVICE_STREAMS             0x0000001e
-       FILE_DEVICE_TAPE                0x0000001f
-       FILE_DEVICE_TAPE_FILE_SYSTEM    0x00000020
-       FILE_DEVICE_TRANSPORT           0x00000021
-       FILE_DEVICE_UNKNOWN             0x00000022
-       FILE_DEVICE_VIDEO               0x00000023
-       FILE_DEVICE_VIRTUAL_DISK        0x00000024
-       FILE_DEVICE_WAVE_IN             0x00000025
-       FILE_DEVICE_WAVE_OUT            0x00000026
-       FILE_DEVICE_8042_PORT           0x00000027
-       FILE_DEVICE_NETWORK_REDIRECTOR  0x00000028
-       FILE_DEVICE_BATTERY             0x00000029
-       FILE_DEVICE_BUS_EXTENDER        0x0000002a
-       FILE_DEVICE_MODEM               0x0000002b
-       FILE_DEVICE_VDM                 0x0000002c
- */
-
-/* 
-       characteristics  is one of the following values:
-
-       FILE_REMOVABLE_MEDIA            0x00000001
-        FILE_READ_ONLY_DEVICE           0x00000002
-        FILE_FLOPPY_DISKETTE            0x00000004
-        FILE_WRITE_ONCE_MEDIA           0x00000008
-        FILE_REMOTE_DEVICE              0x00000010
-        FILE_DEVICE_IS_MOUNTED          0x00000020
-        FILE_VIRTUAL_VOLUME             0x00000040
-*/  
-
-typedef struct _FILE_FS_VOLUME_INFORMATION {
-       TIME VolumeCreationTime;
-       ULONG VolumeSerialNumber;
-       ULONG VolumeLabelLength;
-       BOOLEAN SupportsObjects;
-       WCHAR VolumeLabel[0];
-} FILE_FS_VOLUME_INFORMATION;
-
-typedef struct _FILE_FS_SIZE_INFORMATION {
-       LARGE_INTEGER TotalAllocationUnits;
-       LARGE_INTEGER AvailableAllocationUnits;
-       ULONG SectorsPerAllocationUnit;
-       ULONG BytesPerSector;
-} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
-
-typedef struct _FILE_FS_ATTRIBUTE_INFORMATION {
-       ULONG FileSystemAttributes;
-       LONG MaximumComponentNameLength;
-       ULONG FileSystemNameLength;
-       WCHAR FileSystemName[0]; 
-} FILE_FS_ATTRIBUTE_INFORMATION;
-
-/*
-       FileSystemAttributes is one of the following values:
-
-       FILE_CASE_SENSITIVE_SEARCH      0x00000001
-        FILE_CASE_PRESERVED_NAMES       0x00000002
-        FILE_UNICODE_ON_DISK            0x00000004
-        FILE_PERSISTENT_ACLS            0x00000008
-        FILE_FILE_COMPRESSION           0x00000010
-        FILE_VOLUME_QUOTAS              0x00000020
-        FILE_VOLUME_IS_COMPRESSED       0x00008000
-*/
-typedef struct _FILE_FS_LABEL_INFORMATION {
-       ULONG VolumeLabelLength;
-       WCHAR VolumeLabel[0];
-} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
-
-// read file scatter / write file scatter
-//FIXME I am a win32 struct aswell
-
-typedef union _FILE_SEGMENT_ELEMENT {     
-       PVOID Buffer; 
-       ULONG Alignment; 
-}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT; 
-
-// directory information
-
-
-typedef struct _FILE_DIRECTORY_INFORMATION {
-       ULONG   NextEntryOffset;
-       ULONG   FileIndex;
-       TIME CreationTime;
-       TIME LastAccessTime;
-       TIME LastWriteTime;
-       TIME ChangeTime;
-       LARGE_INTEGER EndOfFile;
-       LARGE_INTEGER AllocationSize;
-       ULONG FileAttributes;
-       ULONG FileNameLength;
-       WCHAR FileName[0];
-} FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION;
-
-typedef struct _FILE_FULL_DIRECTORY_INFORMATION {
-       ULONG   NextEntryOffset;
-       ULONG   FileIndex;
-       TIME CreationTime;
-       TIME LastAccessTime;
-       TIME LastWriteTime;
-       TIME ChangeTime;
-       LARGE_INTEGER EndOfFile;
-       LARGE_INTEGER AllocationSize;
-       ULONG FileAttributes;
-       ULONG FileNameLength;
-       ULONG EaSize;
-       WCHAR FileName[0];
-} FILE_FULL_DIRECTORY_INFORMATION, *PFILE_FULL_DIRECTORY_INFORMATION;
-
-
-typedef struct _FILE_BOTH_DIRECTORY_INFORMATION {
-       ULONG           NextEntryOffset;
-       ULONG           FileIndex;
-       TIME            CreationTime;
-       TIME            LastAccessTime;
-       TIME            LastWriteTime;
-       TIME            ChangeTime;
-       LARGE_INTEGER   EndOfFile;
-       LARGE_INTEGER   AllocationSize;
-       ULONG           FileAttributes;
-       ULONG           FileNameLength;
-       ULONG           EaSize;
-       CHAR            ShortNameLength;
-       WCHAR           ShortName[12]; // 8.3 name
-       WCHAR           FileName[0];
-} FILE_BOTH_DIRECTORY_INFORMATION, *PFILE_BOTH_DIRECTORY_INFORMATION;
-
-
-/*
-       NotifyFilter / CompletionFilter:
-
-       FILE_NOTIFY_CHANGE_FILE_NAME        0x00000001
-       FILE_NOTIFY_CHANGE_DIR_NAME         0x00000002
-       FILE_NOTIFY_CHANGE_NAME             0x00000003
-       FILE_NOTIFY_CHANGE_ATTRIBUTES       0x00000004
-       FILE_NOTIFY_CHANGE_SIZE             0x00000008
-       FILE_NOTIFY_CHANGE_LAST_WRITE       0x00000010
-       FILE_NOTIFY_CHANGE_LAST_ACCESS      0x00000020
-       FILE_NOTIFY_CHANGE_CREATION         0x00000040
-       FILE_NOTIFY_CHANGE_EA               0x00000080
-       FILE_NOTIFY_CHANGE_SECURITY         0x00000100
-       FILE_NOTIFY_CHANGE_STREAM_NAME      0x00000200
-       FILE_NOTIFY_CHANGE_STREAM_SIZE      0x00000400
-       FILE_NOTIFY_CHANGE_STREAM_WRITE     0x00000800
-*/
-
-typedef struct _FILE_NOTIFY_INFORMATION {
-       ULONG NextEntryOffset;
-       ULONG Action;
-       ULONG FileNameLength;
-       WCHAR FileName[0]; 
-} FILE_NOTIFY_INFORMATION;
-
-
-/*
-        Action is one of the following values:
-
-       FILE_ACTION_ADDED               0x00000001
-       FILE_ACTION_REMOVED             0x00000002
-       FILE_ACTION_MODIFIED            0x00000003
-       FILE_ACTION_RENAMED_OLD_NAME    0x00000004
-       FILE_ACTION_RENAMED_NEW_NAME    0x00000005
-       FILE_ACTION_ADDED_STREAM        0x00000006
-       FILE_ACTION_REMOVED_STREAM      0x00000007
-       FILE_ACTION_MODIFIED_STREAM     0x00000008
-
-*/
-
-
-//FIXME: I am a win32 object 
-typedef 
-VOID 
-(*PTIMERAPCROUTINE)( 
-       LPVOID lpArgToCompletionRoutine, 
-       DWORD dwTimerLowValue, 
-       DWORD dwTimerHighValue 
-       ); 
-
-// NtProcessStartup parameters
-
-typedef struct _ENVIRONMENT_INFORMATION {
-       ULONG            Unknown[21];     
-       UNICODE_STRING   CommandLine;
-       UNICODE_STRING   ImageFile;
-} ENVIRONMENT_INFORMATION, *PENVIRONMENT_INFORMATION;
-
-
-typedef struct _STARTUP_ARGUMENT {
-       ULONG                     Unknown[3];
-       PENVIRONMENT_INFORMATION  Environment;
-} STARTUP_ARGUMENT, *PSTARTUP_ARGUMENT;
-
-
-// File System Control commands ( related to defragging )
-
-#define        FSCTL_READ_MFT_RECORD                   0x90068 // NTFS only
-#define FSCTL_GET_VOLUME_BITMAP                        0x9006F
-#define FSCTL_GET_RETRIEVAL_POINTERS           0x90073
-#define FSCTL_MOVE_FILE                                0x90074
-
-typedef struct _MAPPING_PAIR 
-{
-       ULONGLONG       Vcn;
-       ULONGLONG       Lcn;
-} MAPPING_PAIR, *PMAPPING_PAIR;
-
-typedef struct _GET_RETRIEVAL_DESCRIPTOR
-{
-       ULONG           NumberOfPairs;
-       ULONGLONG       StartVcn;
-       MAPPING_PAIR    Pair[0];
-} GET_RETRIEVAL_DESCRIPTOR, *PGET_RETRIEVAL_DESCRIPTOR;
-
-typedef struct _BITMAP_DESCRIPTOR
-{
-       ULONGLONG       StartLcn;
-       ULONGLONG       ClustersToEndOfVol;
-       BYTE            Map[0];
-} BITMAP_DESCRIPTOR, *PBITMAP_DESCRIPTOR; 
-
-typedef struct _MOVEFILE_DESCRIPTOR
-{
-       HANDLE            FileHandle; 
-       ULONG             Reserved;   
-       LARGE_INTEGER     StartVcn; 
-       LARGE_INTEGER     TargetLcn;
-       ULONG             NumVcns; 
-       ULONG             Reserved1;    
-} MOVEFILE_DESCRIPTOR, *PMOVEFILE_DESCRIPTOR;
-
-
-// semaphore information
-
-typedef struct _SEMAPHORE_BASIC_INFORMATION
-{
-       ULONG CurrentCount;
-       ULONG MaximumCount;
-} SEMAPHORE_BASIC_INFORMATION, *PSEMAPHORE_BASIC_INFORMATION;
-
-// event information
-
-typedef struct _EVENT_BASIC_INFORMATION 
-{
-       BOOL AutomaticReset;
-       BOOL Signaled;
-} EVENT_BASIC_INFORMATION, *PEVENT_INFORMATION;
-
-
-
+NTSTATUS
+STDCALL
+NtAccessCheck(
+       IN PSECURITY_DESCRIPTOR SecurityDescriptor,
+       IN HANDLE ClientToken,
+       IN ULONG DesiredAcces,
+       IN PGENERIC_MAPPING GenericMapping,
+       OUT PRIVILEGE_SET PrivilegeSet,
+       OUT PULONG ReturnLength,
+       OUT PULONG GrantedAccess,
+       OUT PULONG AccessStatus
+       );
+NTSTATUS
+STDCALL
+ZwAccessCheck(
+       IN PSECURITY_DESCRIPTOR SecurityDescriptor,
+       IN HANDLE ClientToken,
+       IN ULONG DesiredAcces,
+       IN PGENERIC_MAPPING GenericMapping,
+       OUT PRIVILEGE_SET PrivilegeSet,
+       OUT PULONG ReturnLength,
+       OUT PULONG GrantedAccess,
+       OUT PULONG AccessStatus
+       );
 
 /*
  * FUNCTION: Adds an atom to the global atom table
  * ARGUMENTS: 
        Atom (OUT) = Caller supplies storage for the resulting atom.
*       Atom (OUT) = Caller supplies storage for the resulting atom.
  *        AtomString = The string to add to the atom table.
  * REMARKS: The arguments map to the win32 add GlobalAddAtom. 
  * RETURNS: Status
@@ -1070,6 +56,14 @@ NtAddAtom(
        OUT ATOM *Atom,
        IN PUNICODE_STRING AtomString
        );
+
+
+NTSTATUS
+STDCALL
+ZwAddAtom(
+       OUT ATOM *Atom,
+       IN PUNICODE_STRING AtomString
+       );
 /*
  * FUNCTION: Decrements a thread's suspend count and places it in an alerted 
  *           state.
@@ -1087,6 +81,13 @@ NtAlertResumeThread(
        OUT PULONG SuspendCount
        );
 
+NTSTATUS
+STDCALL
+ZwAlertResumeThread(
+       IN HANDLE ThreadHandle,
+       OUT PULONG SuspendCount
+       );
+
 /*
  * FUNCTION: Puts the thread in a alerted state
  * ARGUMENTS: 
@@ -1099,6 +100,13 @@ NtAlertThread(
        IN HANDLE ThreadHandle
        );
 
+NTSTATUS
+STDCALL
+ZwAlertThread(
+       IN HANDLE ThreadHandle
+       );
+
+
 /*
  * FUNCTION: Allocates a locally unique id
  * ARGUMENTS: 
@@ -1111,6 +119,13 @@ NtAllocateLocallyUniqueId(
        OUT PVOID LocallyUniqueId
        );
 
+NTSTATUS
+STDCALL
+ZwAllocateLocallyUniqueId(
+       OUT PVOID LocallyUniqueId
+       );
+
+
 /*
  * FUNCTION: Allocates a block of virtual memory in the process address space
  * ARGUMENTS:
@@ -1144,6 +159,34 @@ NtAllocateVirtualMemory(
        IN ULONG  Protect
        );
 
+NTSTATUS
+STDCALL
+ZwAllocateVirtualMemory( 
+       IN HANDLE ProcessHandle,
+       OUT PVOID *BaseAddress,
+       IN ULONG  ZeroBits,
+       IN ULONG  RegionSize,
+       IN ULONG  AllocationType, 
+       IN ULONG  Protect
+       );
+/*
+ * FUNCTION: Returns from a callback into user mode
+ * ARGUMENTS:
+ * RETURN Status
+ */
+//FIXME: this function might need 3 parameters
+NTSTATUS
+STDCALL
+NtCallbackReturn(
+               VOID
+       );
+
+NTSTATUS
+STDCALL
+ZwCallbackReturn(
+               VOID
+       );
+
 /*
  * FUNCTION: Cancels a IO request
  * ARGUMENTS: 
@@ -1160,18 +203,32 @@ NtCancelIoFile(
        IN HANDLE FileHandle,
        OUT PIO_STATUS_BLOCK IoStatusBlock   
        );
+
+NTSTATUS
+STDCALL
+ZwCancelIoFile(
+       IN HANDLE FileHandle,
+       OUT PIO_STATUS_BLOCK IoStatusBlock   
+       );
 /*
  * FUNCTION: Cancels a timer
  * ARGUMENTS: 
  *        TimerHandle = Handle to the timer
         ElapsedTime = Specifies the elapsed time the timer has run so far.
*        CurrentState = Specifies the state of the timer when cancelled.
  * REMARKS:
         The arguments to this function map to the function CancelWaitableTimer. 
*        The arguments to this function map to the function CancelWaitableTimer. 
  * RETURNS: Status
  */
 NTSTATUS
 STDCALL
 NtCancelTimer(
+       IN HANDLE TimerHandle,
+       OUT PBOOLEAN CurrentState OPTIONAL
+       );
+
+NTSTATUS
+STDCALL
+ZwCancelTimer(
        IN HANDLE TimerHandle,
        OUT ULONG ElapsedTime
        );
@@ -1190,6 +247,12 @@ NtClearEvent(
        IN HANDLE  EventHandle 
        );
 
+NTSTATUS
+STDCALL
+ZwClearEvent( 
+       IN HANDLE  EventHandle 
+       );
+
 /*
  * FUNCTION: Closes an object handle
  * ARGUMENTS:
@@ -1205,22 +268,40 @@ NtClose(
        IN HANDLE Handle
        );
 
+NTSTATUS
+STDCALL
+ZwClose(
+       IN HANDLE Handle
+       );
+
 
 /*
  * FUNCTION: Continues a thread with the specified context
  * ARGUMENTS: 
  *        Context = Specifies the processor context
+ *       IrqLevel = Specifies the Interupt Request Level to continue with. Can
+ *                     be PASSIVE_LEVEL or APC_LEVEL
  * REMARKS
- *        NtContinue can be used to continue after a exception.
+ *        NtContinue can be used to continue after an exception or apc.
  * RETURNS: Status
  */
 //FIXME This function might need another parameter
+
 NTSTATUS
 STDCALL
 NtContinue(
-       IN PCONTEXT Context
+       IN PCONTEXT Context,
+       IN CINT IrqLevel
+       );
+
+NTSTATUS
+STDCALL
+ZwContinue(
+       IN PCONTEXT Context,
+       IN CINT IrqLevel
        );
 
+
 /*
  * FUNCTION: Creates a directory object
  * ARGUMENTS:
@@ -1231,6 +312,7 @@ NtContinue(
  *          handle, a access mask and a OBJECT_ATTRIBUTES structure to map the path name and the SECURITY_ATTRIBUTES.
  * RETURNS: Status
  */
+
 NTSTATUS
 STDCALL
 NtCreateDirectoryObject(
@@ -1238,6 +320,15 @@ NtCreateDirectoryObject(
        IN ACCESS_MASK DesiredAccess,
        IN POBJECT_ATTRIBUTES ObjectAttributes
        );
+
+NTSTATUS
+STDCALL
+ZwCreateDirectoryObject(
+       OUT PHANDLE DirectoryHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes
+       );
+
 /*
  * FUNCTION: Creates an event object
  * ARGUMENTS:
@@ -1245,22 +336,33 @@ NtCreateDirectoryObject(
  *        DesiredAccess = Specifies access to the event
  *        ObjectAttribute = Initialized attributes for the object
  *        ManualReset = manual-reset or auto-reset if true you have to reset the state of the event manually
-                        using NtResetEvent/NtClearEvent. if false the system will reset the event to a non-signalled state
-                        automatically after the system has rescheduled a thread waiting on the event.
*                       using NtResetEvent/NtClearEvent. if false the system will reset the event to a non-signalled state
*                       automatically after the system has rescheduled a thread waiting on the event.
  *        InitialState = specifies the initial state of the event to be signaled ( TRUE ) or non-signalled (FALSE).
  * REMARKS: This function maps to the win32 CreateEvent. Demanding a out variable  of type HANDLE,
  *          a access mask and a OBJECT_ATTRIBUTES structure mapping to the SECURITY_ATTRIBUTES. ManualReset and InitialState are
  *          both parameters aswell ( possibly the order is reversed ).
  * RETURNS: Status
  */
+
 NTSTATUS
 STDCALL
 NtCreateEvent(
        OUT PHANDLE FileHandle,
        IN ACCESS_MASK DesiredAccess,
        IN POBJECT_ATTRIBUTES ObjectAttributes,
-       IN BOOL ManualReset,
-       IN BOOL InitialState
+       IN BOOLEAN ManualReset,
+       IN BOOLEAN InitialState
+       );
+
+NTSTATUS
+STDCALL
+ZwCreateEvent(
+       OUT PHANDLE FileHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes,
+       IN BOOLEAN ManualReset,
+       IN BOOLEAN InitialState
        );
 
 /*
@@ -1279,6 +381,14 @@ NtCreateEventPair(
        IN POBJECT_ATTRIBUTES ObjectAttributes
        );
 
+NTSTATUS
+STDCALL
+ZwCreateEventPair(
+       OUT PHANDLE FileHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes
+       );
+
 
 /*
  * FUNCTION: Creates or opens a file, directory or device object.
@@ -1297,7 +407,8 @@ NtCreateEventPair(
  *        EaLength = Extended Attributes buffer size,  applies only to files and directories.
  * REMARKS: This function maps to the win32 CreateFile. 
  * RETURNS: Status
- */                                        
+ */
+                                        
 NTSTATUS                                        
 STDCALL                                           
 NtCreateFile(                                   
@@ -1313,6 +424,23 @@ NtCreateFile(
        IN PVOID EaBuffer OPTIONAL,                 
        IN ULONG EaLength                           
        );                                          
+
+NTSTATUS                                        
+STDCALL                                           
+ZwCreateFile(                                   
+       OUT PHANDLE FileHandle,                     
+       IN ACCESS_MASK DesiredAccess,               
+       IN POBJECT_ATTRIBUTES ObjectAttributes,     
+       OUT PIO_STATUS_BLOCK IoStatusBlock,         
+       IN PLARGE_INTEGER AllocationSize OPTIONAL,  
+       IN ULONG FileAttributes,                    
+       IN ULONG ShareAccess,                       
+       IN ULONG CreateDisposition,                 
+       IN ULONG CreateOptions,                     
+       IN PVOID EaBuffer OPTIONAL,                 
+       IN ULONG EaLength                           
+       );          
+
 /*
  * FUNCTION: Creates or opens a file, directory or device object.
  * ARGUMENTS:
@@ -1324,6 +452,7 @@ NtCreateFile(
  * RETURNS:
  *     Status
  */
+
 NTSTATUS
 STDCALL
 NtCreateIoCompletion(
@@ -1332,6 +461,16 @@ NtCreateIoCompletion(
        OUT PIO_STATUS_BLOCK IoStatusBlock,
        IN ULONG NumberOfConcurrentThreads 
        );
+
+NTSTATUS
+STDCALL
+ZwCreateIoCompletion(
+       OUT PHANDLE CompletionPort,
+       IN ACCESS_MASK DesiredAccess,
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
+       IN ULONG NumberOfConcurrentThreads 
+       );
+
 /*
  * FUNCTION: Creates a registry key
  * ARGUMENTS:
@@ -1347,9 +486,9 @@ NtCreateIoCompletion(
  *                     KEY_NOTIFY      
  *                     KEY_CREATE_LINK A symbolic link to the key can be created. 
  *        ObjectAttributes = The name of the key may be specified directly in the name field 
- *                             of object attributes or relative
- *                             to a key in rootdirectory.
- *       Class = Specifies the kind of data.
+ *                             of object attributes or relative to a key in rootdirectory.
+ *        TitleIndex = Might specify the position in the sequential order of subkeys. 
+ *       Class = Specifies the kind of data, for example REG_SZ for string data. [ ??? ]
  *        CreateOptions = Specifies additional options with which the key is created
  *                     REG_OPTION_VOLATILE             The key is not preserved across boots.
  *                     REG_OPTION_NON_VOLATILE         The key is preserved accross boots.
@@ -1360,6 +499,7 @@ NtCreateIoCompletion(
  * RETURNS:
  *     Status
  */
+
 NTSTATUS
 STDCALL
 NtCreateKey(
@@ -1372,6 +512,18 @@ NtCreateKey(
        IN PULONG Disposition OPTIONAL
        );
 
+NTSTATUS
+STDCALL
+ZwCreateKey(
+       OUT PHANDLE KeyHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes,
+       IN ULONG TitleIndex,
+       IN PUNICODE_STRING Class OPTIONAL,
+       IN ULONG CreateOptions,
+       IN PULONG Disposition OPTIONAL
+       );
+
 
 //NtCreateMailslotFile
 
@@ -1393,7 +545,16 @@ NtCreateMutant(
        OUT PHANDLE MutantHandle,
        IN ACCESS_MASK DesiredAccess,
        IN OBJECT_ATTRIBUTES ObjectAttributes,
-       IN BOOL InitialOwner
+       IN BOOLEAN InitialOwner
+       );
+
+NTSTATUS
+STDCALL
+ZwCreateMutant(
+       OUT PHANDLE MutantHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN OBJECT_ATTRIBUTES ObjectAttributes,
+       IN BOOLEAN InitialOwner
        );
 
 //NtCreateNamedPipeFile
@@ -1404,9 +565,10 @@ NtCreateMutant(
  *        PageFileName  = Name of the pagefile
  *        MinimumSize = Specifies the minimum size
  *        MaximumSize = Specifies the maximum size
- *        ActualSize  = Specifies the actual size 
+ *        ActualSize(OUT)  = Specifies the actual size 
  * RETURNS: Status
-*/
+ */
+
 NTSTATUS 
 STDCALL 
 NtCreatePagingFile(
@@ -1415,6 +577,16 @@ NtCreatePagingFile(
        IN ULONG MaxiumSize,
        OUT PULONG ActualSize 
        );
+
+NTSTATUS 
+STDCALL 
+ZwCreatePagingFile(
+       IN PUNICODE_STRING PageFileName,
+       IN ULONG MiniumSize,
+       IN ULONG MaxiumSize,
+       OUT PULONG ActualSize 
+       );
+
 /*
  * FUNCTION: Creates a process.
  * ARGUMENTS:
@@ -1443,6 +615,20 @@ NtCreateProcess(
         IN HANDLE DebugPort OPTIONAL,
         IN HANDLE ExceptionPort OPTIONAL
        );
+
+NTSTATUS 
+STDCALL 
+ZwCreateProcess(
+       OUT PHANDLE ProcessHandle,
+        IN ACCESS_MASK DesiredAccess,
+        IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
+        IN HANDLE ParentProcess,
+        IN BOOLEAN InheritObjectTable,
+        IN HANDLE SectionHandle OPTIONAL,
+        IN HANDLE DebugPort OPTIONAL,
+        IN HANDLE ExceptionPort OPTIONAL
+       );
+
 /*
  * FUNCTION: Creates a section object.
  * ARGUMENTS:
@@ -1457,9 +643,22 @@ NtCreateProcess(
  *        FileHanlde = Handle to a file to create a section mapped to a file instead of a memory backed section.
  * RETURNS: Status
  */
+
+NTSTATUS
+STDCALL
+NtCreateSection( 
+       OUT PHANDLE SectionHandle, 
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,  
+       IN PLARGE_INTEGER MaximumSize OPTIONAL,  
+       IN ULONG SectionPageProtection OPTIONAL,
+       IN ULONG AllocationAttributes,
+       IN HANDLE FileHandle OPTIONAL
+       );
+
 NTSTATUS
 STDCALL
-NtCreateSection( 
+ZwCreateSection( 
        OUT PHANDLE SectionHandle, 
        IN ACCESS_MASK DesiredAccess,
        IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,  
@@ -1468,6 +667,7 @@ NtCreateSection(
        IN ULONG AllocationAttributes,
        IN HANDLE FileHandle OPTIONAL
        );
+
 /*
  * FUNCTION: Creates a semaphore object for interprocess synchronization.
  * ARGUMENTS:
@@ -1491,15 +691,24 @@ NtCreateSemaphore(
        IN ULONG InitialCount,
        IN ULONG MaximumCount
        );
+
+NTSTATUS
+STDCALL
+ZwCreateSemaphore(
+       OUT PHANDLE SemaphoreHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
+       IN ULONG InitialCount,
+       IN ULONG MaximumCount
+       );
+
 /*
  * FUNCTION: Creates a symbolic link object
  * ARGUMENTS:
  *        SymbolicLinkHandle (OUT) = Caller supplied storage for the resulting handle
  *        DesiredAccess = Specifies the allowed or desired access to the thread. 
  *        ObjectAttributes = Initialized attributes for the object.
- *        Name = 
- * REMARKS:
- *        This function map to the win32 function CreateThread. 
+ *        Name = Target name of the symbolic link  
  * RETURNS: Status
  */
 NTSTATUS
@@ -1510,6 +719,16 @@ NtCreateSymbolicLinkObject(
        IN POBJECT_ATTRIBUTES ObjectAttributes,
        IN PUNICODE_STRING Name
        );
+
+NTSTATUS
+STDCALL
+ZwCreateSymbolicLinkObject(
+       OUT PHANDLE SymbolicLinkHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes,
+       IN PUNICODE_STRING Name
+       );
+
 /*
  * FUNCTION: Creates a user mode thread
  * ARGUMENTS:
@@ -1519,10 +738,10 @@ NtCreateSymbolicLinkObject(
  *        ProcessHandle = Handle to the threads parent process.
  *        ClientId (OUT) = Caller supplies storage for returned process id and thread id.
  *        ThreadContext = Initial processor context for the thread.
- *        InitialTeb = Initial Thread Environment Block for the Thread.
+ *        InitialTeb = Initial user mode stack context for the thread.
  *        CreateSuspended = Specifies if the thread is ready for scheduling
  * REMARKS:
- *        This function maps to the win32 function CreateThread.  The exact arguments are from the usenet. [<6f7cqj$tq9$1@nnrp1.dejanews.com>] 
+ *        This function maps to the win32 function CreateThread.  
  * RETURNS: Status
  */
 NTSTATUS
@@ -1537,13 +756,26 @@ NtCreateThread(
        IN PINITIAL_TEB InitialTeb,
        IN BOOLEAN CreateSuspended
        );
+
+NTSTATUS
+STDCALL 
+ZwCreateThread(
+       OUT PHANDLE ThreadHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
+       IN HANDLE ProcessHandle,
+       OUT PCLIENT_ID ClientId,
+       IN PCONTEXT ThreadContext,
+       IN PINITIAL_TEB InitialTeb,
+       IN BOOLEAN CreateSuspended
+       );
 /*
  * FUNCTION: Creates a waitable timer.
  * ARGUMENTS:
  *        TimerHandle (OUT) = Caller supplied storage for the resulting handle
  *        DesiredAccess = Specifies the allowed or desired access to the timer. 
  *        ObjectAttributes = Initialized attributes for the object.
- *        ManualReset = Specifies if the timer should be reset manually.
+ *        TimerType = Specifies if the timer should be reset manually.
  * REMARKS:
  *       This function maps to the win32  CreateWaitableTimer. lpTimerAttributes and lpTimerName map to
  *       corresponding fields in OBJECT_ATTRIBUTES structure. 
@@ -1556,18 +788,26 @@ NtCreateTimer(
        OUT PHANDLE TimerHandle,
        IN ACCESS_MASK DesiredAccess,
        IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
-       IN BOOL ManualReset 
+       IN CINT TimerType
+       );
+
+NTSTATUS
+STDCALL 
+ZwCreateTimer(
+       OUT PHANDLE TimerHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
+       IN CINT TimerType
        );
+
+
 /*
  * FUNCTION: Returns the callers thread TEB.
- * ARGUMENTS:
- *        Teb (OUT) = Caller supplied storage for the resulting TEB.
- * RETURNS: Status
+ * RETURNS: The resulting teb.
  */
-NTSTATUS
+NT_TEB *
 STDCALL 
-NtCurrentTeb(
-       NT_TEB *CurrentTeb
+NtCurrentTeb(VOID
        );
 
 /*
@@ -1580,16 +820,24 @@ NtCurrentTeb(
 NTSTATUS
 STDCALL
 NtDelayExecution(
-       IN BOOL Alertable,
-       IN PLARGE_INTEGER Interval
+       IN BOOLEAN Alertable,
+       IN TIME *Interval
+       );
+
+NTSTATUS
+STDCALL
+ZwDelayExecution(
+       IN BOOLEAN Alertable,
+       IN TIME *Interval
        );
 
+
 /*
  * FUNCTION: Deletes an atom from the global atom table
  * ARGUMENTS:
- *        Atom = Atom to delete
+ *        Atom = Identifies the atom to delete
  * REMARKS:
       The function maps to the win32 GlobalDeleteAtom
*      The function maps to the win32 GlobalDeleteAtom
  * RETURNS: Status
  */
 NTSTATUS
@@ -1598,13 +846,19 @@ NtDeleteAtom(
        IN ATOM Atom
        );
 
+NTSTATUS
+STDCALL
+ZwDeleteAtom(
+       IN ATOM Atom
+       );
+
 /*
  * FUNCTION: Deletes a file
  * ARGUMENTS:
- *        ObjectAttributes = Handle to the file which should be deleted
+ *        ObjectAttributes = Name of the file which should be deleted
  * REMARKS:
       This system call is functionally equivalent to NtSetInformationFile
       setting the disposition information.
*      This system call is functionally equivalent to NtSetInformationFile
*      setting the disposition information.
  *      The function maps to the win32 DeleteFile. 
  * RETURNS: Status
  */
@@ -1614,6 +868,12 @@ NtDeleteFile(
        IN POBJECT_ATTRIBUTES ObjectAttributes
        );
 
+NTSTATUS
+STDCALL
+ZwDeleteFile(
+       IN POBJECT_ATTRIBUTES ObjectAttributes
+       );
+
 /*
  * FUNCTION: Deletes a registry key
  * ARGUMENTS:
@@ -1625,6 +885,12 @@ STDCALL
 NtDeleteKey(
        IN HANDLE KeyHandle
        );
+NTSTATUS
+STDCALL
+ZwDeleteKey(
+       IN HANDLE KeyHandle
+       );
+
 /*
  * FUNCTION: Deletes a value from a registry key
  * ARGUMENTS:
@@ -1639,14 +905,21 @@ NtDeleteValueKey(
        IN HANDLE KeyHandle,
        IN PUNICODE_STRING ValueName
        );
+
+NTSTATUS
+STDCALL
+ZwDeleteValueKey(
+       IN HANDLE KeyHandle,
+       IN PUNICODE_STRING ValueName
+       );
 /*
  * FUNCTION: Sends IOCTL to the io sub system
  * ARGUMENTS:
  *        DeviceHandle = Points to the handle that is created by NtCreateFile
  *        Event = Event to synchronize on STATUS_PENDING
- *        ApcRoutine = 
- *       ApcContext =
- *       IoStatusBlock = Caller should supply storage for 
+ *        ApcRoutine = Asynchroneous procedure callback
+ *       ApcContext = Callback context.
+ *       IoStatusBlock = Caller should supply storage for extra information.. 
  *        IoControlCode = Contains the IO Control command. This is an 
  *                     index to the structures in InputBuffer and OutputBuffer.
  *       InputBuffer = Caller should supply storage for input buffer if IOTL expects one.
@@ -1670,6 +943,21 @@ NtDeviceIoControlFile(
        OUT PVOID OutputBuffer,
        IN ULONG OutputBufferSize
        );
+
+NTSTATUS
+STDCALL
+ZwDeviceIoControlFile(
+       IN HANDLE DeviceHandle,
+       IN HANDLE Event OPTIONAL, 
+       IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL, 
+       IN PVOID UserApcContext OPTIONAL, 
+       OUT PIO_STATUS_BLOCK IoStatusBlock, 
+       IN ULONG IoControlCode,
+       IN PVOID InputBuffer, 
+       IN ULONG InputBufferSize,
+       OUT PVOID OutputBuffer,
+       IN ULONG OutputBufferSize
+       );
 /*
  * FUNCTION: Displays a string on the blue screen
  * ARGUMENTS:
@@ -1682,16 +970,31 @@ STDCALL
 NtDisplayString(
        IN PUNICODE_STRING DisplayString
        );
+
+NTSTATUS
+STDCALL
+ZwDisplayString(
+       IN PUNICODE_STRING DisplayString
+       );
+
 /*
- * FUNCTION: Displays a string on the blue screen
+ * FUNCTION: Copies a handle from one process space to another
  * ARGUMENTS:
- *         SourceProcessHandle = The string to display
-          SourceHandle =
-          TargetProcessHandle =
-          TargetHandle = 
-          DesiredAccess = 
-          InheritHandle = 
+ *         SourceProcessHandle = The source process owning the handle. The source process should have opened
+ *                     the SourceHandle with PROCESS_DUP_HANDLE access.
+ *        SourceHandle = The handle to the object.
+ *        TargetProcessHandle = The destination process owning the handle 
+ *        TargetHandle (OUT) = Caller should supply storage for the duplicated handle. 
+ *        DesiredAccess = The desired access to the handle.
+ *        InheritHandle = Indicates wheter the new handle will be inheritable or not.
+ *        Options = Specifies special actions upon duplicating the handle. Can be
+ *                     one of the values DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS.
+ *                     DUPLICATE_CLOSE_SOURCE specifies that the source handle should be
+ *                     closed after duplicating. DUPLICATE_SAME_ACCESS specifies to ignore
+ *                     the DesiredAccess paramter and just grant the same access to the new
+ *                     handle.
  * RETURNS: Status
+ * REMARKS: This function maps to the win32 DuplicateHandle.
  */
 
 NTSTATUS
@@ -1701,8 +1004,21 @@ NtDuplicateObject(
        IN PHANDLE SourceHandle,
        IN HANDLE TargetProcessHandle,
        OUT PHANDLE TargetHandle,
-       IN ULONG DesiredAccess,
-       IN BOOL InheritHandle
+       IN ACCESS_MASK DesiredAccess,
+       IN BOOLEAN InheritHandle,
+       ULONG Options
+       );
+
+NTSTATUS
+STDCALL
+ZwDuplicateObject(
+       IN HANDLE SourceProcessHandle,
+       IN PHANDLE SourceHandle,
+       IN HANDLE TargetProcessHandle,
+       OUT PHANDLE TargetHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN BOOLEAN InheritHandle,
+       ULONG Options
        );
 /*
  * FUNCTION: Returns information about the subkeys of an open key
@@ -1724,7 +1040,18 @@ STDCALL
 NtEnumerateKey(
        IN HANDLE KeyHandle,
        IN ULONG Index,
-       IN CINT KeyInformationClass,
+       IN KEY_INFORMATION_CLASS KeyInformationClass,
+       OUT PVOID KeyInformation,
+       IN ULONG Length,
+       OUT PULONG ResultLength
+       );
+
+NTSTATUS
+STDCALL
+ZwEnumerateKey(
+       IN HANDLE KeyHandle,
+       IN ULONG Index,
+       IN KEY_INFORMATION_CLASS KeyInformationClass,
        OUT PVOID KeyInformation,
        IN ULONG Length,
        OUT PULONG ResultLength
@@ -1749,7 +1076,18 @@ STDCALL
 NtEnumerateValueKey(
        IN HANDLE KeyHandle,
        IN ULONG Index,
-       IN CINT KeyValueInformationClass,
+       IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
+       OUT PVOID KeyValueInformation,
+       IN ULONG Length,
+       OUT PULONG ResultLength
+       );
+
+NTSTATUS
+STDCALL
+ZwEnumerateValueKey(
+       IN HANDLE KeyHandle,
+       IN ULONG Index,
+       IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
        OUT PVOID KeyValueInformation,
        IN ULONG Length,
        OUT PULONG ResultLength
@@ -1767,6 +1105,13 @@ NtExtendSection(
        IN HANDLE SectionHandle,
        IN ULONG NewMaximumSize
        );
+NTSTATUS
+STDCALL
+ZwExtendSection(
+       IN HANDLE SectionHandle,
+       IN ULONG NewMaximumSize
+       );
+
 /*
  * FUNCTION: Finds a atom
  * ARGUMENTS:
@@ -1774,7 +1119,7 @@ NtExtendSection(
  *      AtomString = String to search for.
  * RETURNS: Status 
  * REMARKS:
      This funciton maps to the win32 GlobalFindAtom
*     This funciton maps to the win32 GlobalFindAtom
  */
 NTSTATUS
 STDCALL
@@ -1782,16 +1127,23 @@ NtFindAtom(
        OUT ATOM *Atom,
        IN PUNICODE_STRING AtomString
        );
+
+NTSTATUS
+STDCALL
+ZwFindAtom(
+       OUT ATOM *Atom,
+       IN PUNICODE_STRING AtomString
+       );
 /*
  * FUNCTION: Flushes chached file data to disk
  * ARGUMENTS:
  *       FileHandle = Points to the file
       IoStatusBlock = Caller must supply storage to receive the result of the flush
              buffers operation. The information field is set to number of bytes
              flushed to disk.
*      IoStatusBlock = Caller must supply storage to receive the result of the flush
*             buffers operation. The information field is set to number of bytes
*             flushed to disk.
  * RETURNS: Status 
  * REMARKS:
      This funciton maps to the win32 FlushFileBuffers
*     This funciton maps to the win32 FlushFileBuffers
  */
 NTSTATUS
 STDCALL
@@ -1799,15 +1151,22 @@ NtFlushBuffersFile(
        IN HANDLE FileHandle,
        OUT PIO_STATUS_BLOCK IoStatusBlock
        );
+
+NTSTATUS
+STDCALL
+ZwFlushBuffersFile(
+       IN HANDLE FileHandle,
+       OUT PIO_STATUS_BLOCK IoStatusBlock
+       );
 /*
  * FUNCTION: Flushes a the processors instruction cache
  * ARGUMENTS:
  *       ProcessHandle = Points to the process owning the cache
       BaseAddress = // might this be a image address ????
       NumberOfBytesToFlush = 
*      BaseAddress = // might this be a image address ????
*      NumberOfBytesToFlush = 
  * RETURNS: Status 
  * REMARKS:
      This funciton is used by debuggers
*     This funciton is used by debuggers
  */
 NTSTATUS
 STDCALL
@@ -1816,13 +1175,20 @@ NtFlushInstructionCache(
        IN PVOID BaseAddress,
        IN UINT NumberOfBytesToFlush
        );
+NTSTATUS
+STDCALL
+ZwFlushInstructionCache(
+       IN HANDLE ProcessHandle,
+       IN PVOID BaseAddress,
+       IN UINT NumberOfBytesToFlush
+       );
 /*
  * FUNCTION: Flushes a registry key to disk
  * ARGUMENTS:
  *       KeyHandle = Points to the registry key handle
  * RETURNS: Status 
  * REMARKS:
      This funciton maps to the win32 RegFlushKey.
*     This funciton maps to the win32 RegFlushKey.
  */
 NTSTATUS
 STDCALL
@@ -1830,6 +1196,12 @@ NtFlushKey(
        IN HANDLE KeyHandle
        );
 
+NTSTATUS
+STDCALL
+ZwFlushKey(
+       IN HANDLE KeyHandle
+       );
+
 /*
  * FUNCTION: Flushes virtual memory to file
  * ARGUMENTS:
@@ -1839,7 +1211,7 @@ NtFlushKey(
  *        NumberOfBytesFlushed = Actual number of bytes flushed
  * RETURNS: Status 
  * REMARKS:
        Check return status on STATUS_NOT_MAPPED_DATA 
*       Check return status on STATUS_NOT_MAPPED_DATA 
  */
 NTSTATUS
 STDCALL
@@ -1849,22 +1221,28 @@ NtFlushVirtualMemory(
        IN ULONG NumberOfBytesToFlush,
        OUT PULONG NumberOfBytesFlushed OPTIONAL
        );
+NTSTATUS
+STDCALL
+ZwFlushVirtualMemory(
+       IN HANDLE ProcessHandle,
+       IN PVOID BaseAddress,
+       IN ULONG NumberOfBytesToFlush,
+       OUT PULONG NumberOfBytesFlushed OPTIONAL
+       );
 /*
- * FUNCTION: Flushes virtual memory to file
- * ARGUMENTS:
- *        ProcessHandle = Points to the process that allocated the virtual memory
- *        BaseAddress = Points to the memory address
- *        NumberOfBytesToFlush = Limits the range to flush,
- *        NumberOfBytesFlushed = Actual number of bytes flushed
+ * FUNCTION: Flushes the dirty pages to file
  * RETURNS: Status 
- * REMARKS:
-         Check return status on STATUS_NOT_MAPPED_DATA 
  */
-VOID
+NTSTATUS
 STDCALL                                            
 NtFlushWriteBuffer (                            
        VOID                                        
-       );              
+       );
+NTSTATUS
+STDCALL                                            
+ZwFlushWriteBuffer (                            
+       VOID                                        
+       );                      
 /*
  * FUNCTION: Frees a range of virtual memory
  * ARGUMENTS:
@@ -1878,11 +1256,20 @@ NtFlushWriteBuffer (
 NTSTATUS
 STDCALL
 NtFreeVirtualMemory(
-       IN PHANDLE ProcessHandle,
+       IN HANDLE ProcessHandle,
        IN PVOID  *BaseAddress, 
        IN ULONG  RegionSize,   
        IN ULONG  FreeType
-       ); 
+       );
+
+NTSTATUS
+STDCALL
+ZwFreeVirtualMemory(
+       IN HANDLE ProcessHandle,
+       IN PVOID  *BaseAddress, 
+       IN ULONG  RegionSize,   
+       IN ULONG  FreeType
+       );  
 
 /*
  * FUNCTION: Sends FSCTL to the filesystem
@@ -1893,17 +1280,18 @@ NtFreeVirtualMemory(
  *       ApcContext =
  *       IoStatusBlock = Caller should supply storage for 
  *        IoControlCode = Contains the File System Control command. This is an 
                      index to the structures in InputBuffer and OutputBuffer.
              FSCTL_GET_RETRIEVAL_POINTERS    MAPPING_PAIR
              FSCTL_GET_RETRIEVAL_POINTERS    GET_RETRIEVAL_DESCRIPTOR
              FSCTL_GET_VOLUME_BITMAP         BITMAP_DESCRIPTOR
              FSCTL_MOVE_FILE                 MOVEFILE_DESCRIPTOR
-
*                     index to the structures in InputBuffer and OutputBuffer.
*             FSCTL_GET_RETRIEVAL_POINTERS    MAPPING_PAIR
*             FSCTL_GET_RETRIEVAL_POINTERS    GET_RETRIEVAL_DESCRIPTOR
*             FSCTL_GET_VOLUME_BITMAP         BITMAP_DESCRIPTOR
*             FSCTL_MOVE_FILE                 MOVEFILE_DESCRIPTOR
+ *
  *       InputBuffer = Caller should supply storage for input buffer if FCTL expects one.
  *       InputBufferSize = Size of the input bufffer
  *        OutputBuffer = Caller should supply storage for output buffer if FCTL expects one.
  *        OutputBufferSize  = Size of the input bufffer
- * RETURNS: Status 
+ * RETURNS: Status [ STATUS_SUCCESS | STATUS_PENDING | STATUS_ACCESS_DENIED | STATUS_INSUFFICIENT_RESOURCES |
+ *             STATUS_INVALID_PARAMETER | STATUS_INVALID_DEVICE_REQUEST ]
  */
 NTSTATUS
 STDCALL
@@ -1920,6 +1308,21 @@ NtFsControlFile(
        IN ULONG OutputBufferSize
        );
 
+NTSTATUS
+STDCALL
+ZwFsControlFile(
+       IN HANDLE DeviceHandle,
+       IN HANDLE Event OPTIONAL, 
+       IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, 
+       IN PVOID ApcContext OPTIONAL, 
+       OUT PIO_STATUS_BLOCK IoStatusBlock, 
+       IN ULONG IoControlCode,
+       IN PVOID InputBuffer, 
+       IN ULONG InputBufferSize,
+       OUT PVOID OutputBuffer,
+       IN ULONG OutputBufferSize
+       );
+
 /*
  * FUNCTION: Retrieves the processor context of a thread
  * ARGUMENTS:
@@ -1934,6 +1337,13 @@ NtGetContextThread(
        IN HANDLE ThreadHandle, 
        OUT PCONTEXT Context
        );
+
+NTSTATUS
+STDCALL 
+ZwGetContextThread(
+       IN HANDLE ThreadHandle, 
+       OUT PCONTEXT Context
+       );
 /*
  * FUNCTION: Retrieves the uptime of the system
  * ARGUMENTS:
@@ -1946,6 +1356,12 @@ NtGetTickCount(
        PULONG UpTime
        );
 
+NTSTATUS
+STDCALL 
+ZwGetTickCount(
+       PULONG UpTime
+       );
+
 //-- NtImpersonateThread
 
 /*
@@ -1957,8 +1373,14 @@ NtGetTickCount(
 NTSTATUS
 STDCALL 
 NtInitializeRegistry(
-       BOOL SetUpBoot
+       BOOLEAN SetUpBoot
+       );
+NTSTATUS
+STDCALL 
+ZwInitializeRegistry(
+       BOOLEAN SetUpBoot
        );
+
 /*
  * FUNCTION: Loads a driver. 
  * ARGUMENTS: 
@@ -1971,6 +1393,12 @@ NtLoadDriver(
        IN PUNICODE_STRING DriverServiceName
        );
 
+NTSTATUS
+STDCALL 
+ZwLoadDriver(
+       IN PUNICODE_STRING DriverServiceName
+       );
+
 //-- NtLoadKey2
 /*
  * FUNCTION: Loads a registry key. 
@@ -1987,6 +1415,12 @@ NtLoadKey(
        PHANDLE KeyHandle,
        OBJECT_ATTRIBUTES ObjectAttributes
        );
+NTSTATUS
+STDCALL 
+ZwLoadKey(
+       PHANDLE KeyHandle,
+       OBJECT_ATTRIBUTES ObjectAttributes
+       );
 /*
  * FUNCTION: Locks a range of bytes in a file. 
  * ARGUMENTS: 
@@ -1998,27 +1432,46 @@ NtLoadKey(
  *                      the completion status and information about the requested lock operation.
  *       ByteOffset = Offset 
  *       Length = Number of bytes to lock.
- *       Key  = 
- *       FailImmediatedly =
- *       ExclusiveLock =
+ *       Key  = Special value to give other threads the possibility to unlock the file
+               by supplying the key in a call to NtUnlockFile.
+ *       FailImmediatedly = If false the request will block untill the lock is obtained. 
+ *       ExclusiveLock = Specifies whether a exclusive or a shared lock is obtained.
  * REMARK:
-       This procedure maps to the win32 procedure LockFileEx 
- * RETURNS: Status
+       This procedure maps to the win32 procedure LockFileEx. STATUS_PENDING is returned if the lock could
+       not be obtained immediately, the device queue is busy and the IRP is queued.
+ * RETURNS: Status [ STATUS_SUCCESS | STATUS_PENDING | STATUS_ACCESS_DENIED | STATUS_INSUFFICIENT_RESOURCES |
+               STATUS_INVALID_PARAMETER | STATUS_INVALID_DEVICE_REQUEST | STATUS_LOCK_NOT_GRANTED ]
+
  */    
 NTSTATUS 
 STDCALL
 NtLockFile(
-  IN  HANDLE FileHandle,
-  IN  HANDLE Event OPTIONAL,
-  IN  PIO_APC_ROUTINE ApcRoutine OPTIONAL,
-  IN  PVOID ApcContext OPTIONAL,
-  OUT PIO_STATUS_BLOCK IoStatusBlock,
-  IN  PLARGE_INTEGER ByteOffset,
-  IN  PLARGE_INTEGER Length,
-  IN  ULONG Key,
-  IN  BOOLEAN FailImmediatedly,
-  IN  BOOLEAN ExclusiveLock
-  );
+       IN  HANDLE FileHandle,
+       IN  HANDLE Event OPTIONAL,
+       IN  PIO_APC_ROUTINE ApcRoutine OPTIONAL,
+       IN  PVOID ApcContext OPTIONAL,
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
+       IN  PLARGE_INTEGER ByteOffset,
+       IN  PLARGE_INTEGER Length,
+       IN  PULONG Key,
+       IN  BOOLEAN FailImmediatedly,
+       IN  BOOLEAN ExclusiveLock
+       );
+
+NTSTATUS 
+STDCALL
+ZwLockFile(
+       IN  HANDLE FileHandle,
+       IN  HANDLE Event OPTIONAL,
+       IN  PIO_APC_ROUTINE ApcRoutine OPTIONAL,
+       IN  PVOID ApcContext OPTIONAL,
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
+       IN  PLARGE_INTEGER ByteOffset,
+       IN  PLARGE_INTEGER Length,
+       IN  PULONG Key,
+       IN  BOOLEAN FailImmediatedly,
+       IN  BOOLEAN ExclusiveLock
+       );
 /*
  * FUNCTION: Locks a range of virtual memory. 
  * ARGUMENTS: 
@@ -2028,7 +1481,7 @@ NtLockFile(
  *       NumberOfBytesLocked (OUT) = Number of bytes actually locked.
  * REMARK:
        This procedure maps to the win32 procedure VirtualLock 
- * RETURNS: Status
+ * RETURNS: Status [STATUS_SUCCESS | STATUS_WAS_LOCKED ]
  */    
 NTSTATUS
 STDCALL 
@@ -2038,6 +1491,14 @@ NtLockVirtualMemory(
        ULONG NumberOfBytesToLock,
        PULONG NumberOfBytesLocked
        );
+NTSTATUS
+STDCALL 
+ZwLockVirtualMemory(
+       HANDLE ProcessHandle,
+       PVOID BaseAddress,
+       ULONG NumberOfBytesToLock,
+       PULONG NumberOfBytesLocked
+       );
 /*
  * FUNCTION: Makes temporary object that will be removed at next boot.
  * ARGUMENTS: 
@@ -2050,6 +1511,12 @@ STDCALL
 NtMakeTemporaryObject(
        IN HANDLE Handle 
        );
+
+NTSTATUS
+STDCALL
+ZwMakeTemporaryObject(
+       IN HANDLE Handle 
+       );
 /*
  * FUNCTION: Maps a view of a section into the virtual address space of a 
  *           process
@@ -2071,18 +1538,34 @@ NtMakeTemporaryObject(
  *        Protect = Protection for the committed region of the view
  * RETURNS: Status
  */
-NTSTATUS STDCALL
+NTSTATUS 
+STDCALL
 NtMapViewOfSection(
-     IN HANDLE SectionHandle,
-     IN HANDLE ProcessHandle,
-     IN OUT PVOID *BaseAddress,
-     IN ULONG ZeroBits,
-     IN ULONG CommitSize,
-     IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
-     IN OUT PULONG ViewSize,
-     IN SECTION_INHERIT InheritDisposition,
-     IN ULONG AllocationType,
-     IN ULONG AccessProtection
+       IN HANDLE SectionHandle,
+       IN HANDLE ProcessHandle,
+       IN OUT PVOID *BaseAddress,
+       IN ULONG ZeroBits,
+       IN ULONG CommitSize,
+       IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
+       IN OUT PULONG ViewSize,
+       IN SECTION_INHERIT InheritDisposition,
+       IN ULONG AllocationType,
+       IN ULONG AccessProtection
+    );
+
+NTSTATUS 
+STDCALL
+ZwMapViewOfSection(
+       IN HANDLE SectionHandle,
+       IN HANDLE ProcessHandle,
+       IN OUT PVOID *BaseAddress,
+       IN ULONG ZeroBits,
+       IN ULONG CommitSize,
+       IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
+       IN OUT PULONG ViewSize,
+       IN SECTION_INHERIT InheritDisposition,
+       IN ULONG AllocationType,
+       IN ULONG AccessProtection
     );
 
 /*
@@ -2127,8 +1610,50 @@ NtNotifyChangeDirectoryFile(
        OUT PVOID Buffer,
        IN ULONG BufferSize,
        IN ULONG CompletionFilter,
-       IN BOOL WatchTree
+       IN BOOLEAN WatchTree
+       );
+
+NTSTATUS
+STDCALL
+ZwNotifyChangeDirectoryFile(
+       IN HANDLE FileHandle,
+       IN HANDLE Event OPTIONAL, 
+       IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, 
+       IN PVOID ApcContext OPTIONAL, 
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
+       OUT PVOID Buffer,
+       IN ULONG BufferSize,
+       IN ULONG CompletionFilter,
+       IN BOOLEAN WatchTree
        );
+
+/*
+ * FUNCTION: Installs a notfication callback on registry changes
+ * ARGUMENTS:
+       KeyHandle = Handle to the registry key
+       Event = Event that should be signalled on modification of the key
+       ApcRoutine = Routine that should be called on modification of the key
+       ApcContext = Argument to the ApcRoutine
+       IoStatusBlock = ???
+       CompletionFilter = Specifies the kind of notification the caller likes to receive.
+                       Can be a combination of the following values:
+
+                       REG_NOTIFY_CHANGE_NAME
+                       REG_NOTIFY_CHANGE_ATTRIBUTES
+                       REG_NOTIFY_CHANGE_LAST_SET
+                       REG_NOTIFY_CHANGE_SECURITY
+                               
+                               
+       Asynchroneous = If TRUE the changes are reported by signalling an event if false
+                       the function will not return before a change occurs.
+       ChangeBuffer =  Will return the old value
+       Length = Size of the change buffer
+       WatchSubtree =  Indicates if the caller likes to receive a notification of changes in
+                       sub keys or not.
+ * REMARKS: If the key is closed the event is signalled aswell.
+ * RETURNS: Status
+ */
+
 NTSTATUS
 STDCALL
 NtNotifyChangeKey(
@@ -2144,6 +1669,21 @@ NtNotifyChangeKey(
        IN BOOLEAN WatchSubtree
        );
 
+NTSTATUS
+STDCALL
+ZwNotifyChangeKey(
+       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
+       );
+
 /*
  * FUNCTION: Opens an existing directory object
  * ARGUMENTS:
@@ -2160,6 +1700,14 @@ NtOpenDirectoryObject(
        IN ACCESS_MASK DesiredAccess,
        IN POBJECT_ATTRIBUTES ObjectAttributes
        );
+NTSTATUS
+STDCALL
+ZwOpenDirectoryObject(
+       OUT PHANDLE FileHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes
+       );
+
 /*
  * FUNCTION: Opens an existing event
  * ARGUMENTS:
@@ -2175,6 +1723,14 @@ NtOpenEvent(
         IN ACCESS_MASK DesiredAccess,
        IN POBJECT_ATTRIBUTES ObjectAttributes
        );
+
+NTSTATUS
+STDCALL
+ZwOpenEvent(   
+       OUT PHANDLE EventHandle,
+        IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes
+       );
 /*
  * FUNCTION: Opens an existing file
  * ARGUMENTS:
@@ -2197,6 +1753,17 @@ NtOpenFile(
        IN ULONG OpenOptions                                                                    
        );
 
+NTSTATUS
+STDCALL
+ZwOpenFile(
+       OUT PHANDLE FileHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes,
+       OUT PIO_STATUS_BLOCK IoStatusBlock,   
+       IN ULONG ShareAccess,         
+       IN ULONG OpenOptions                                                                    
+       );
+
 /*
  * FUNCTION: Opens an existing io completion object
  * ARGUMENTS:
@@ -2213,6 +1780,14 @@ NtOpenIoCompletion(
        IN ACCESS_MASK DesiredAccess,
        IN POBJECT_ATTRIBUTES ObjectAttributes
        );
+
+NTSTATUS
+STDCALL
+ZwOpenIoCompletion(
+       OUT PHANDLE CompetionPort,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes
+       );
        
 /*
  * FUNCTION: Opens an existing key in the registry
@@ -2229,6 +1804,14 @@ NtOpenKey(
        IN ACCESS_MASK DesiredAccess,
        IN POBJECT_ATTRIBUTES ObjectAttributes
        );
+
+NTSTATUS
+STDCALL
+ZwOpenKey(
+       OUT PHANDLE KeyHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes
+       );
 /*
  * FUNCTION: Opens an existing key in the registry
  * ARGUMENTS:
@@ -2244,6 +1827,13 @@ NtOpenMutant(
        IN ACCESS_MASK DesiredAccess,
        IN POBJECT_ATTRIBUTES ObjectAttributes
        );
+NTSTATUS
+STDCALL
+ZwOpenMutant(
+       OUT PHANDLE MutantHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes
+       );
        
 /*
  * FUNCTION: Opens an existing process
@@ -2262,6 +1852,14 @@ NtOpenProcess (
        IN POBJECT_ATTRIBUTES ObjectAttributes,
        IN PCLIENT_ID ClientId
        ); 
+NTSTATUS 
+STDCALL
+ZwOpenProcess (
+       OUT PHANDLE ProcessHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes,
+       IN PCLIENT_ID ClientId
+       ); 
 /*
  * FUNCTION: Opens an existing section object
  * ARGUMENTS:
@@ -2277,6 +1875,13 @@ NtOpenSection(
        IN ACCESS_MASK DesiredAccess,
        IN POBJECT_ATTRIBUTES ObjectAttributes
        );
+NTSTATUS
+STDCALL
+ZwOpenSection(
+       OUT PHANDLE SectionHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes
+       );
 /*
  * FUNCTION: Opens an existing semaphore
  * ARGUMENTS:
@@ -2292,6 +1897,13 @@ NtOpenSemaphore(
        IN ACCESS_MASK DesiredAcces,
        IN POBJECT_ATTRIBUTES ObjectAttributes
        );
+NTSTATUS
+STDCALL
+ZwOpenSemaphore(
+       IN HANDLE SemaphoreHandle,
+       IN ACCESS_MASK DesiredAcces,
+       IN POBJECT_ATTRIBUTES ObjectAttributes
+       );
 /*
  * FUNCTION: Opens an existing symbolic link
  * ARGUMENTS:
@@ -2307,6 +1919,13 @@ NtOpenSymbolicLinkObject(
        IN ACCESS_MASK DesiredAccess,
        IN POBJECT_ATTRIBUTES ObjectAttributes
        );
+NTSTATUS
+STDCALL
+ZwOpenSymbolicLinkObject(
+       OUT PHANDLE SymbolicLinkHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes
+       );
 /*
  * FUNCTION: Opens an existing thread
  * ARGUMENTS:
@@ -2324,6 +1943,14 @@ NtOpenThread(
        IN POBJECT_ATTRIBUTES ObjectAttributes,
        IN PCLIENT_ID ClientId
        );
+NTSTATUS
+STDCALL
+ZwOpenThread(
+       OUT PHANDLE ThreadHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes,
+       IN PCLIENT_ID ClientId
+       );
 /*
  * FUNCTION: Opens an existing timer
  * ARGUMENTS:
@@ -2339,12 +1966,19 @@ NtOpenTimer(
        IN ACCESS_MASK DesiredAccess,
        IN POBJECT_ATTRIBUTES ObjectAttributes
        );
+NTSTATUS
+STDCALL
+ZwOpenTimer(
+       OUT PHANDLE TimerHandle,
+       IN ACCESS_MASK DesiredAccess,
+       IN POBJECT_ATTRIBUTES ObjectAttributes
+       );
 /*
  * FUNCTION: Entry point for native applications
  * ARGUMENTS:
  *     Argument = Arguments passed to the application by the system [ at boot time ]
  * REMARKS:
- *      Native applications should use this function instead of a main.
+ *      Native applications should use this function instead of a main. Calling proces should terminate itself.
  * RETURNS: Status
  */    
 void NtProcessStartup( 
@@ -2375,12 +2009,22 @@ NtProtectVirtualMemory(
        IN ULONG NewAccessProtection,
        OUT PULONG OldAccessProtection 
        );
+NTSTATUS
+STDCALL
+ZwProtectVirtualMemory(
+       IN HANDLE ProcessHandle,
+       IN PVOID BaseAddress,
+       IN ULONG NumberOfBytesToProtect,
+       IN ULONG NewAccessProtection,
+       OUT PULONG OldAccessProtection 
+       );
+
 
 /*
  * FUNCTION: Signals an event and resets it afterwards.
  * ARGUMENTS:
  *        EventHandle  = Handle to the event
- *        PulseCount = Number of times the action should be repeated
+ *        PulseCount = Number of times the action is repeated
  * RETURNS: Status
  */
 NTSTATUS 
@@ -2390,9 +2034,60 @@ NtPulseEvent(
        IN PULONG PulseCount OPTIONAL
        );
 
-//-- NtQueryAttributesFile
+NTSTATUS 
+STDCALL 
+ZwPulseEvent(
+       IN HANDLE EventHandle,
+       IN PULONG PulseCount OPTIONAL
+       );
+
+/*
+ * FUNCTION: Queries the attributes of a file
+ * ARGUMENTS:
+ *        FileHandle  = Handle to the file
+ *        Buffer = Caller supplies storage for the attributes
+ * RETURNS: Status
+ */
+
+NTSTATUS 
+STDCALL 
+NtQueryAttributesFile(
+       IN HANDLE FileHandle,
+       IN PVOID Buffer
+       );
+
+NTSTATUS 
+STDCALL 
+ZwQueryAttributesFile(
+       IN HANDLE FileHandle,
+       IN PVOID Buffer
+       );
+
 
-// FileNameInformation - FILE_NAMES_INFORMATION
+/*
+ * FUNCTION: Queries a directory file.
+ * ARGUMENTS:
+ *       FileHandle = Handle to a directory file
+ *        EventHandle  = Handle to the event signaled on completion
+ *       ApcRoutine = Asynchroneous procedure callback, called on completion
+ *       ApcContext = Argument to the apc.
+ *       IoStatusBlock = Caller supplies storage for extended status information.
+ *       FileInformation = Caller supplies storage for the resulting information.
+ *
+ *             FileNameInformation             FILE_NAMES_INFORMATION
+ *             FileDirectoryInformation        FILE_DIRECTORY_INFORMATION
+ *             FileFullDirectoryInformation    FILE_FULL_DIRECTORY_INFORMATION
+ *             FileBothDirectoryInformation    FILE_BOTH_DIR_INFORMATION
+ *
+ *       Length = Size of the storage supplied
+ *       FileInformationClass = Indicates the type of information requested.  
+ *       ReturnSingleEntry = Specify true if caller only requests the first directory found.
+ *       FileName = Initial directory name to query, that may contain wild cards.
+ *        RestartScan = Number of times the action should be repeated
+ * RETURNS: Status [ STATUS_SUCCESS, STATUS_ACCESS_DENIED, STATUS_INSUFFICIENT_RESOURCES,
+ *                  STATUS_INVALID_PARAMETER, STATUS_INVALID_DEVICE_REQUEST, STATUS_BUFFER_OVERFLOW,
+ *                  STATUS_INVALID_INFO_CLASS, STATUS_NO_SUCH_FILE, STATUS_NO_MORE_FILES ]
+ */
 
 NTSTATUS 
 STDCALL 
@@ -2409,6 +2104,22 @@ NtQueryDirectoryFile(
        IN PUNICODE_STRING FileName OPTIONAL,
        IN BOOLEAN RestartScan
        );
+
+NTSTATUS 
+STDCALL 
+ZwQueryDirectoryFile(
+       IN HANDLE FileHandle,
+       IN HANDLE Event OPTIONAL,
+       IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
+       IN PVOID ApcContext OPTIONAL,
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
+       OUT PVOID FileInformation,
+       IN ULONG Length,
+       IN FILE_INFORMATION_CLASS FileInformationClass,
+       IN BOOLEAN ReturnSingleEntry,
+       IN PUNICODE_STRING FileName OPTIONAL,
+       IN BOOLEAN RestartScan
+       );
        
 /*
  * FUNCTION: Query information about the content of a directory object
@@ -2434,6 +2145,33 @@ NtQueryDirectoryObject(
        OUT PULONG              DataWritten OPTIONAL
        ); 
 
+NTSTATUS 
+STDCALL 
+ZwQueryDirectoryObject(
+       IN HANDLE DirObjHandle,
+       OUT POBJDIR_INFORMATION DirObjInformation, 
+       IN ULONG                BufferLength, 
+       IN BOOLEAN              GetNextIndex, 
+       IN BOOLEAN              IgnoreInputIndex, 
+       IN OUT PULONG           ObjectIndex,
+       OUT PULONG              DataWritten OPTIONAL
+       ); 
+
+/*
+ * FUNCTION: Queries the extended attributes of a file
+ * ARGUMENTS:
+ *        FileHandle  = Handle to the event
+ *        IoStatusBlock = Number of times the action is repeated
+ *        Buffer
+ *        Length
+ *        ReturnSingleEntry
+ *        EaList
+ *        EaListLength
+ *        EaIndex
+ *        RestartScan
+ * RETURNS: Status
+ */
+
 NTSTATUS
 STDCALL
 NtQueryEaFile(
@@ -2447,6 +2185,20 @@ NtQueryEaFile(
        IN PULONG EaIndex OPTIONAL,
        IN BOOLEAN RestartScan
        );
+
+NTSTATUS
+STDCALL
+ZwQueryEaFile(
+       IN HANDLE FileHandle,
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
+       OUT PVOID Buffer,
+       IN ULONG Length,
+       IN BOOLEAN ReturnSingleEntry,
+       IN PVOID EaList OPTIONAL,
+       IN ULONG EaListLength,
+       IN PULONG EaIndex OPTIONAL,
+       IN BOOLEAN RestartScan
+       );
 /*
  * FUNCTION: Queries an event
  * ARGUMENTS:
@@ -2471,8 +2223,47 @@ NtQueryEvent(
        IN ULONG EventInformationLength,
        OUT PULONG ReturnLength
        ); 
-//-- NtQueryFullAttributesFile
-//-- NtQueryInformationAtom
+
+NTSTATUS
+STDCALL
+ZwQueryEvent(
+       IN HANDLE EventHandle,
+       IN CINT EventInformationClass,
+       OUT PVOID EventInformation,
+       IN ULONG EventInformationLength,
+       OUT PULONG ReturnLength
+       );
+NTSTATUS
+STDCALL 
+NtQueryFullAttributesFile(
+       IN HANDLE FileHandle,
+       IN PVOID Attributes
+       );
+NTSTATUS
+STDCALL 
+ZwQueryFullAttributesFile(
+       IN HANDLE FileHandle,
+       IN PVOID Attributes
+       );
+
+NTSTATUS
+STDCALL
+NtQueryInformationAtom(
+       IN HANDLE AtomHandle,
+       IN CINT AtomInformationClass,
+       OUT PVOID AtomInformation,
+       IN ULONG AtomInformationLength,
+       OUT PULONG ReturnLength
+       ); 
+NTSTATUS
+STDCALL
+NtQueryInformationAtom(
+       IN HANDLE AtomHandle,
+       IN CINT AtomInformationClass,
+       OUT PVOID AtomInformation,
+       IN ULONG AtomInformationLength,
+       OUT PULONG ReturnLength
+       ); 
 
 
 
@@ -2540,9 +2331,15 @@ NtQueryInformationFile(
        OUT PIO_STATUS_BLOCK IoStatusBlock,
        OUT PVOID FileInformation,
        IN ULONG Length,
-       IN CINT FileInformationClass
+       IN FILE_INFORMATION_CLASS FileInformationClass
     );
 
+NTSTATUS ZwQueryInformationFile(HANDLE FileHandle,
+                               PIO_STATUS_BLOCK IoStatusBlock,
+                               PVOID FileInformation,
+                               ULONG Length,
+                               FILE_INFORMATION_CLASS FileInformationClass);
+  
 /*
  * FUNCTION: Queries the information of a process object.
  * ARGUMENTS: 
@@ -2560,7 +2357,7 @@ NtQueryInformationFile(
                ProcessExceptionPort             HANDLE 
                ProcessAccessToken               PROCESS_ACCESS_TOKEN
                ProcessLdtInformation            LDT_ENTRY ??
-               ProcessLdtSize                   ??
+               ProcessLdtSize                   ULONG
                ProcessDefaultHardErrorMode      ULONG
                ProcessIoPortHandlers            // kernel mode only
                ProcessPooledUsageAndLimits      POOLED_USAGE_AND_LIMITS
@@ -2572,7 +2369,7 @@ NtQueryInformationFile(
                ProcessHandleCount               ULONG
                ProcessAffinityMask              ULONG  
                ProcessPooledQuotaLimits         QUOTA_LIMITS
-               MaxProcessInfoClass              ??
+               MaxProcessInfoClass              
 
  *        ProcessInformation = Caller supplies storage for the process information structure
  *       ProcessInformationLength = Size of the process information structure
@@ -2598,6 +2395,16 @@ NtQueryInformationProcess(
        OUT PULONG ReturnLength 
        );
 
+NTSTATUS
+STDCALL
+ZwQueryInformationProcess(
+       IN HANDLE ProcessHandle,
+       IN CINT ProcessInformationClass,
+       OUT PVOID ProcessInformation,
+       IN ULONG ProcessInformationLength,
+       OUT PULONG ReturnLength 
+       );
+
 
 
 /*
@@ -2606,11 +2413,11 @@ NtQueryInformationProcess(
  *        ThreadHandle = Handle to the thread object
  *        ThreadInformationClass = Index to a certain information structure
 
-               ThreadBasicInformation          THREAD_BASIC_INFORMATION        
-               ThreadTimes                     KERNEL_USER_TIMES
-               ThreadPriority                  KPRIORITY       
-               ThreadBasePriority              KPRIORITY       
-               ThreadAffinityMask              KAFFINITY       
+               ThreadBasicInformation                  THREAD_BASIC_INFORMATION        
+               ThreadTimes                             KERNEL_USER_TIMES
+               ThreadPriority                          KPRIORITY       
+               ThreadBasePriority                      KPRIORITY       
+               ThreadAffinityMask                      KAFFINITY       
                ThreadImpersonationToken                
                ThreadDescriptorTableEntry              
                ThreadEnableAlignmentFaultFixup         
@@ -2639,7 +2446,7 @@ NTSTATUS
 STDCALL
 NtQueryInformationThread(
        IN HANDLE ThreadHandle,
-       IN CINT ThreadInformationClass,
+       IN THREADINFOCLASS ThreadInformationClass,
        OUT PVOID ThreadInformation,
        IN ULONG ThreadInformationLength,
        OUT PULONG ReturnLength 
@@ -2647,7 +2454,7 @@ NtQueryInformationThread(
 
 NTSTATUS
 STDCALL
-NtQueryIoCompletion(
+ZwQueryIoCompletion(
        IN HANDLE CompletionPort,
        IN CINT CompletionInformationClass,
        OUT PVOID CompletionInformation,
@@ -2669,19 +2476,39 @@ NTSTATUS
 STDCALL
 NtQueryKey(
        IN HANDLE KeyHandle,
-       IN CINT KeyInformationClass,
+       IN KEY_INFORMATION_CLASS KeyInformationClass,
+       OUT PVOID KeyInformation,
+       IN ULONG Length,
+       OUT PULONG ResultLength 
+       );
+
+NTSTATUS
+STDCALL
+ZwQueryKey(
+       IN HANDLE KeyHandle,
+       IN KEY_INFORMATION_CLASS KeyInformationClass,
        OUT PVOID KeyInformation,
        IN ULONG Length,
        OUT PULONG ResultLength 
        );
 
 
+// draft
 
-// preliminary guess
+NTSTATUS
+STDCALL
+NtQueryMultipleValueKey(
+   HANDLE KeyHandle,   
+   PVALENT ListOfValuesToQuery,        
+   ULONG NumberOfItems,        
+   PVOID MultipleValueInformation,             
+   ULONG Length,
+   PULONG  ReturnLength
+);     
 
 NTSTATUS
 STDCALL
-NtQueryMultipleValueKey(
+ZwQueryMultipleValueKey(
    HANDLE KeyHandle,   
    PVALENT ListOfValuesToQuery,        
    ULONG NumberOfItems,        
@@ -2708,7 +2535,16 @@ NtQueryMutant(
        IN ULONG Length,
        OUT PULONG ResultLength 
        );
-       
+
+NTSTATUS
+STDCALL
+ZwQueryMutant(
+       IN HANDLE MutantHandle,
+       IN CINT MutantInformationClass,
+       OUT PVOID MutantInformation,
+       IN ULONG Length,
+       OUT PULONG ResultLength 
+       );
 /*
  * FUNCTION: Queries the information of a  object.
  * ARGUMENTS: 
@@ -2734,6 +2570,15 @@ NtQueryObject(
        IN ULONG Length,
        OUT PULONG ResultLength
        );
+NTSTATUS
+STDCALL
+ZwQueryObject(
+       IN HANDLE ObjectHandle,
+       IN CINT ObjectInformationClass,
+       OUT PVOID ObjectInformation,
+       IN ULONG Length,
+       OUT PULONG ResultLength
+       );
 
 /*
  * FUNCTION: Queries the system ( high-resolution ) performance counter.
@@ -2752,6 +2597,13 @@ NtQueryPerformanceCounter(
        IN PLARGE_INTEGER Counter,
        IN PLARGE_INTEGER Frequency
        );
+
+NTSTATUS
+STDCALL
+ZwQueryPerformanceCounter(
+       IN PLARGE_INTEGER Counter,
+       IN PLARGE_INTEGER Frequency
+       );
 /*
  * FUNCTION: Queries the information of a section object.
  * ARGUMENTS: 
@@ -2772,6 +2624,15 @@ NtQuerySection(
        IN ULONG Length, 
        OUT PULONG ResultLength 
        );
+NTSTATUS
+STDCALL
+ZwQuerySection(
+       IN HANDLE SectionHandle,
+       IN CINT SectionInformationClass,
+       OUT PVOID SectionInformation,
+       IN ULONG Length, 
+       OUT PULONG ResultLength 
+       );
 
 
 /*
@@ -2795,12 +2656,21 @@ NtQuerySemaphore(
        ULONG Length,
        PULONG ReturnLength
        );
+NTSTATUS
+STDCALL
+ZwQuerySemaphore(
+       HANDLE SemaphoreHandle,
+       CINT SemaphoreInformationClass,
+       OUT PVOID SemaphoreInformation,
+       ULONG Length,
+       PULONG ReturnLength
+       );
 
 /*
  * FUNCTION: Queries the information of a symbolic link object.
  * ARGUMENTS: 
  *        SymbolicLinkHandle = Handle to the symbolic link object
- *       LinkName = resolved name of link
+ *       LinkTarget = resolved name of link
  *        DataWritten = size of the LinkName.
  * RETURNS: Status
  *
@@ -2808,11 +2678,46 @@ NtQuerySemaphore(
 NTSTATUS
 STDCALL 
 NtQuerySymbolicLinkObject(
+       IN HANDLE               SymLinkObjHandle,
+       OUT PUNICODE_STRING     LinkTarget,    
+       OUT PULONG              DataWritten OPTIONAL
+       ); 
+
+NTSTATUS
+STDCALL 
+ZwQuerySymbolicLinkObject(
        IN HANDLE               SymLinkObjHandle,
        OUT PUNICODE_STRING     LinkName,    
        OUT PULONG              DataWritten OPTIONAL
        ); 
-//-- NtQuerySystemEnvironmentValue
+
+
+/*
+ * FUNCTION: Queries a system environment variable.
+ * ARGUMENTS: 
+ *        Name = Name of the variable
+ *       Value (OUT) = value of the variable
+ *        Length = size of the buffer
+ *        ReturnLength = data written
+ * RETURNS: Status
+ *
+*/      
+NTSTATUS
+STDCALL 
+NtQuerySystemEnvironmentValue(
+       IN PUNICODE_STRING Name,
+       OUT PVOID Value,
+       ULONG Length,
+       PULONG ReturnLength
+       );
+NTSTATUS
+STDCALL 
+ZwQuerySystemEnvironmentValue(
+       IN PUNICODE_STRING Name,
+       OUT PVOID Value,
+       ULONG Length,
+       PULONG ReturnLength
+       );
 
 
 /*
@@ -2822,6 +2727,7 @@ NtQuerySymbolicLinkObject(
 
          SystemTimeAdjustmentInformation       SYSTEM_TIME_ADJUSTMENT
          SystemCacheInformation                SYSTEM_CACHE_INFORMATION
+         SystemConfigurationInformation        CONFIGURATION_INFORMATION
 
  *       SystemInformation = caller supplies storage for the information structure
  *        Length = size of the structure
@@ -2837,6 +2743,14 @@ NtQuerySystemInformation(
        IN ULONG Length,
        OUT PULONG ResultLength
        );
+NTSTATUS
+STDCALL
+ZwQuerySystemInformation(
+       IN CINT SystemInformationClass,
+       OUT PVOID SystemInformation,
+       IN ULONG Length,
+       OUT PULONG ResultLength
+       );
 
 /*
  * FUNCTION: Retrieves the system time
@@ -2849,9 +2763,44 @@ NtQuerySystemInformation(
 NTSTATUS
 STDCALL
 NtQuerySystemTime (
-       OUT PLARGE_INTEGER CurrentTime
+       OUT TIME *CurrentTime
+       );
+
+NTSTATUS
+STDCALL
+ZwQuerySystemTime (
+       OUT TIME *CurrentTime
+       );
+
+/*
+ * FUNCTION: Queries information about a timer
+ * ARGUMENTS: 
+ *        TimerHandle  = Handle to the timer
+         TimerValueInformationClass = Index to a certain information structure
+         TimerValueInformation = Caller supplies storage for the information structure
+         Length = Size of the information structure
+         ResultLength = Data written
+ * RETURNS: Status
+ *
+*/       
+NTSTATUS
+STDCALL
+NtQueryTimer(
+       IN HANDLE TimerHandle,
+       IN CINT TimerInformationClass,
+       OUT PVOID TimerInformation,
+       IN ULONG Length,
+       OUT PULONG ResultLength
+       );
+NTSTATUS
+STDCALL
+ZwQueryTimer(
+       IN HANDLE TimerHandle,
+       IN CINT TimerInformationClass,
+       OUT PVOID TimerInformation,
+       IN ULONG Length,
+       OUT PULONG ResultLength
        );
-//-- NtQueryTimer
 
 /*
  * FUNCTION: Queries the timer resolution
@@ -2864,13 +2813,22 @@ NtQuerySystemTime (
 */        
 
 
-NTSTATUS 
+NTSTATUS
+STDCALL 
 NtQueryTimerResolution ( 
        OUT PULONG MinimumResolution,
        OUT PULONG MaximumResolution, 
        OUT PULONG ActualResolution 
        ); 
 
+NTSTATUS
+STDCALL 
+ZwQueryTimerResolution ( 
+       OUT PULONG MinimumResolution,
+       OUT PULONG MaximumResolution, 
+       OUT PULONG ActualResolution 
+       ); 
+
 /*
  * FUNCTION: Queries a registry key value
  * ARGUMENTS: 
@@ -2893,7 +2851,18 @@ STDCALL
 NtQueryValueKey(
        IN HANDLE KeyHandle,
        IN PUNICODE_STRING ValueName,
-       IN CINT KeyValueInformationClass,
+       IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
+       OUT PVOID KeyValueInformation,
+       IN ULONG Length,
+       OUT PULONG ResultLength
+       );
+
+NTSTATUS
+STDCALL
+ZwQueryValueKey(
+       IN HANDLE KeyHandle,
+       IN PUNICODE_STRING ValueName,
+       IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
        OUT PVOID KeyValueInformation,
        IN ULONG Length,
        OUT PULONG ResultLength
@@ -2901,6 +2870,7 @@ NtQueryValueKey(
 
 
 
+
 /*
  * FUNCTION: Queries the virtual memory information.
  * ARGUMENTS: 
@@ -2927,10 +2897,21 @@ NtQueryVirtualMemory(
        IN ULONG Length,
        OUT PULONG ResultLength
        );
+NTSTATUS
+STDCALL
+ZwQueryVirtualMemory(
+       IN HANDLE ProcessHandle,
+       IN PVOID Address,
+       IN IN CINT VirtualMemoryInformationClass,
+       OUT PVOID VirtualMemoryInformation,
+       IN ULONG Length,
+       OUT PULONG ResultLength
+       );
+
 /*
  * FUNCTION: Queries the volume information
  * ARGUMENTS: 
- *        FileHandle  = 
+ *        FileHandle  = Handle to a file object on the target volume
          ReturnLength = DataWritten
          FSInformation = Caller should supply storage for the information structure.
          Length = Size of the information structure
@@ -2946,7 +2927,8 @@ NtQueryVirtualMemory(
                FileFsQuotaSetInformation       --
                FileFsMaximumInformation        
 
- * RETURNS: Status
+ * RETURNS: Status [ STATUS_SUCCESS | STATUS_INSUFFICIENT_RESOURCES | STATUS_INVALID_PARAMETER |
+                STATUS_INVALID_DEVICE_REQUEST | STATUS_BUFFER_OVERFLOW ]
  *
 */     
 NTSTATUS
@@ -2958,7 +2940,48 @@ NtQueryVolumeInformationFile(
        IN ULONG Length,
        IN CINT FSInformationClass 
     );
-// NtQueueApcThread
+
+NTSTATUS
+STDCALL
+ZwQueryVolumeInformationFile(
+       IN HANDLE FileHandle,
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
+       OUT PVOID FSInformation,
+       IN ULONG Length,
+       IN CINT FSInformationClass 
+    );
+// draft
+// FIXME: Should I specify if the apc is user or kernel mode somewhere ??
+/*
+ * FUNCTION: Queues a (user) apc to a thread.
+ * ARGUMENTS: 
+         ThreadHandle = Thread to which the apc is queued.
+         ApcRoutine = Points to the apc routine
+         NormalContext = Argument to Apc Routine
+ *        SystemArgument1 = Argument of the Apc Routine
+         SystemArgument2 = Argument of the Apc Routine
+ * REMARK: If the apc is queued against a thread of a different process than the calling thread
+               the apc routine should be specified in the address space of the queued thread's process.
+ * RETURNS: Status
+*/
+
+NTSTATUS
+STDCALL
+NtQueueApcThread(
+       HANDLE ThreadHandle,
+       PKNORMAL_ROUTINE ApcRoutine,
+       PVOID NormalContext,
+       PVOID SystemArgument1,
+       PVOID SystemArgument2);
+
+NTSTATUS
+STDCALL
+ZwQueueApcThread(
+       HANDLE ThreadHandle,
+       PKNORMAL_ROUTINE ApcRoutine,
+       PVOID NormalContext,
+       PVOID SystemArgument1,
+       PVOID SystemArgument2);
 /*
  * FUNCTION: Raises an exception
  * ARGUMENTS: 
@@ -2978,6 +3001,14 @@ NtRaiseException(
        IN BOOL IsDebugger OPTIONAL
        );
 
+NTSTATUS
+STDCALL
+ZwRaiseException(
+       IN PEXCEPTION_RECORD ExceptionRecord,
+       IN PCONTEXT Context,
+       IN BOOL IsDebugger OPTIONAL
+       );
+
 //NtRaiseHardError
 /*
  * FUNCTION: Read a file
@@ -2990,7 +3021,7 @@ NtRaiseException(
          Buffer = Caller should supply storage to receive the information
          BufferLength = Size of the buffer
          ByteOffset = Offset to start reading the file
-         Key =  unused
+         Key = If a range is lock a matching key will allow the read to continue.
  * RETURNS: Status
  *
 */       
@@ -3009,6 +3040,20 @@ NtReadFile(
        IN PLARGE_INTEGER ByteOffset OPTIONAL,
        IN PULONG Key OPTIONAL  
        );
+
+NTSTATUS
+STDCALL
+ZwReadFile(
+       IN HANDLE FileHandle,
+       IN HANDLE Event OPTIONAL,
+       IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
+       IN PVOID UserApcContext OPTIONAL,
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
+       OUT PVOID Buffer,
+       IN ULONG BufferLength,
+       IN PLARGE_INTEGER ByteOffset OPTIONAL,
+       IN PULONG Key OPTIONAL  
+       );
 /*
  * FUNCTION: Read a file using scattered io
  * ARGUMENTS: 
@@ -3020,7 +3065,7 @@ NtReadFile(
          BufferDescription = Caller should supply storage to receive the information
          BufferLength = Size of the buffer
          ByteOffset = Offset to start reading the file
-         Key =  unused
+         Key =  Key = If a range is lock a matching key will allow the read to continue.
  * RETURNS: Status
  *
 */       
@@ -3037,6 +3082,20 @@ NtReadFileScatter(
        IN PLARGE_INTEGER ByteOffset, 
        IN PULONG Key OPTIONAL  
        ); 
+
+NTSTATUS
+STDCALL
+ZwReadFileScatter( 
+       IN HANDLE FileHandle, 
+       IN HANDLE Event OPTIONAL, 
+       IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL, 
+       IN  PVOID UserApcContext OPTIONAL, 
+       OUT PIO_STATUS_BLOCK UserIoStatusBlock, 
+       IN FILE_SEGMENT_ELEMENT BufferDescription[], 
+       IN ULONG BufferLength, 
+       IN PLARGE_INTEGER ByteOffset, 
+       IN PULONG Key OPTIONAL  
+       ); 
 /*
  * FUNCTION: Copies a range of virtual memory to a buffer
  * ARGUMENTS: 
@@ -3051,29 +3110,44 @@ NtReadFileScatter(
 NTSTATUS
 STDCALL
 NtReadVirtualMemory( 
+       IN HANDLE ProcessHandle,
+       IN PVOID BaseAddress,
+       OUT PVOID Buffer,
+       IN ULONG  NumberOfBytesToRead,
+       OUT PULONG NumberOfBytesRead
+       ); 
+NTSTATUS
+STDCALL
+ZwReadVirtualMemory( 
        IN HANDLE ProcessHandle,
        IN PVOID BaseAddress,
        OUT PVOID Buffer,
        IN ULONG  NumberOfBytesToRead,
        OUT PULONG NumberOfBytesRead
        );      
-//FIXME: Is the parameters correctly named ? ThreadHandle might be a TerminationPort
+       
+
 /*
  * FUNCTION: Debugger can register for thread termination
  * ARGUMENTS: 
- *       ThreadHandle = 
+ *       TerminationPort = Port on which the debugger likes to be notified.
  * RETURNS: Status
  */
 
 NTSTATUS
 STDCALL        
 NtRegisterThreadTerminatePort(
-       HANDLE ThreadHandle
+       HANDLE TerminationPort
+       );
+NTSTATUS
+STDCALL        
+ZwRegisterThreadTerminatePort(
+       HANDLE TerminationPort
        );
 /*
  * FUNCTION: Releases a mutant
  * ARGUMENTS: 
- *       MutantHandle = 
+ *       MutantHandle = Handle to the mutant
  *       ReleaseCount = 
  * RETURNS: Status
  */
@@ -3083,12 +3157,19 @@ NtReleaseMutant(
        IN HANDLE MutantHandle,
        IN PULONG ReleaseCount OPTIONAL 
        );
+
+NTSTATUS
+STDCALL        
+ZwReleaseMutant(
+       IN HANDLE MutantHandle,
+       IN PULONG ReleaseCount OPTIONAL 
+       );
 /*
  * FUNCTION: Releases a semaphore 
  * ARGUMENTS: 
  *       SemaphoreHandle = Handle to the semaphore object
- *       ReleaseCount =
- *       PreviousCount =  
+ *       ReleaseCount = Number to decrease the semaphore count
+ *       PreviousCount = Previous semaphore count
  * RETURNS: Status
  */
 NTSTATUS
@@ -3098,15 +3179,22 @@ NtReleaseSemaphore(
        IN ULONG ReleaseCount,
        IN PULONG PreviousCount
        );
+
+NTSTATUS
+STDCALL
+ZwReleaseSemaphore( 
+       IN HANDLE SemaphoreHandle,
+       IN ULONG ReleaseCount,
+       IN PULONG PreviousCount
+       );
 /*
  * FUNCTION: Removes an io completion
  * ARGUMENTS:
  *        CompletionPort (OUT) = Caller supplied storage for the resulting handle
  *        CompletionKey = Requested access to the key
- *        IoStatusBlock =
- *        ObjectAttribute = Initialized attributes for the object
- *        CompletionStatus =
- *        WaitTime =
+ *        IoStatusBlock = Caller provides storage for extended status information
+ *        CompletionStatus = Current status of the io operation.
+ *        WaitTime = Time to wait if ..
  * RETURNS: Status
  */
 NTSTATUS
@@ -3118,6 +3206,16 @@ NtRemoveIoCompletion(
        OUT PULONG CompletionStatus,
        ULONG WaitTime 
        );
+
+NTSTATUS
+STDCALL
+ZwRemoveIoCompletion(
+       IN HANDLE CompletionPort,
+       OUT PULONG CompletionKey,
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
+       OUT PULONG CompletionStatus,
+       ULONG WaitTime 
+       );
 /*
  * FUNCTION: Replaces one registry key with another
  * ARGUMENTS: 
@@ -3133,6 +3231,14 @@ NtReplaceKey(
        IN HANDLE Key,
        IN POBJECT_ATTRIBUTES ReplacedObjectAttributes 
        );
+NTSTATUS
+STDCALL
+ZwReplaceKey(
+       IN POBJECT_ATTRIBUTES ObjectAttributes, 
+       IN HANDLE Key,
+       IN POBJECT_ATTRIBUTES ReplacedObjectAttributes 
+       );
+
 /*
  * FUNCTION: Resets a event to a non signaled state 
  * ARGUMENTS: 
@@ -3146,7 +3252,13 @@ NtResetEvent(
        HANDLE EventHandle,
        PULONG NumberOfWaitingThreads OPTIONAL
        );
-//Preliminary guess
+NTSTATUS
+STDCALL
+ZwResetEvent(
+       HANDLE EventHandle,
+       PULONG NumberOfWaitingThreads OPTIONAL
+       );
+//draft
 NTSTATUS
 STDCALL
 NtRestoreKey(
@@ -3154,6 +3266,14 @@ NtRestoreKey(
        HANDLE FileHandle,
        ULONG RestoreFlags
        );
+
+NTSTATUS
+STDCALL
+ZwRestoreKey(
+       HANDLE KeyHandle,
+       HANDLE FileHandle,
+       ULONG RestoreFlags
+       );
 /*
  * FUNCTION: Decrements a thread's resume count
  * ARGUMENTS: 
@@ -3170,6 +3290,12 @@ NtResumeThread(
        IN HANDLE ThreadHandle,
        IN PULONG SuspendCount
        );
+NTSTATUS
+STDCALL
+ZwResumeThread(
+       IN HANDLE ThreadHandle,
+       IN PULONG SuspendCount
+       );
 /*
  * FUNCTION: Writes the content of a registry key to ascii file
  * ARGUMENTS: 
@@ -3186,6 +3312,12 @@ NtSaveKey(
        IN HANDLE KeyHandle,
        IN HANDLE FileHandle
        );
+NTSTATUS
+STDCALL
+ZwSaveKey(
+       IN HANDLE KeyHandle,
+       IN HANDLE FileHandle
+       );
 /*
  * FUNCTION: Sets the context of a specified thread.
  * ARGUMENTS: 
@@ -3200,6 +3332,12 @@ NtSetContextThread(
        IN HANDLE ThreadHandle,
        IN PCONTEXT Context
        );
+NTSTATUS
+STDCALL
+ZwSetContextThread(
+       IN HANDLE ThreadHandle,
+       IN PCONTEXT Context
+       );
 /*
  * FUNCTION: Sets the extended attributes of a file.
  * ARGUMENTS: 
@@ -3212,20 +3350,28 @@ NtSetContextThread(
  */
 NTSTATUS
 STDCALL
-NtSetEaFile(
+NtSetEaFile(
+       IN HANDLE FileHandle,
+       IN PIO_STATUS_BLOCK IoStatusBlock,      
+       PVOID EaBuffer, 
+       ULONG EaBufferSize
+       );
+NTSTATUS
+STDCALL
+ZwSetEaFile(
        IN HANDLE FileHandle,
        IN PIO_STATUS_BLOCK IoStatusBlock,      
        PVOID EaBuffer, 
        ULONG EaBufferSize
        );
 
-//FIXME Shoud I have input EVENT_BASIC_INFORMATION ??
+//FIXME: should I return the event state ?
 
 /*
- * FUNCTION: Sets the attributes of an event.
+ * FUNCTION: Sets the  event to a signalled state.
  * ARGUMENTS: 
  *        EventHandle = Handle to the event
- *        Count =  The resulting count.
+ *        NumberOfThreadsReleased =  The number of threads released
  * REMARK:
  *       This procedure maps to the win32 SetEvent function. 
  * RETURNS: Status
@@ -3235,7 +3381,14 @@ NTSTATUS
 STDCALL
 NtSetEvent(
        IN HANDLE EventHandle,
-       PULONG Count
+       PULONG NumberOfThreadsReleased
+       );
+
+NTSTATUS
+STDCALL
+ZwSetEvent(
+       IN HANDLE EventHandle,
+       PULONG NumberOfThreadsReleased
        );
 
 /*
@@ -3251,6 +3404,11 @@ NtSetHighEventPair(
        IN HANDLE EventPair
        );
 
+NTSTATUS
+STDCALL
+ZwSetHighEventPair(
+       IN HANDLE EventPair
+       );
 /*
  * FUNCTION: Sets the high part of an event pair and wait for the low part
  * ARGUMENTS: 
@@ -3262,6 +3420,11 @@ STDCALL
 NtSetHighWaitLowEventPair(
        IN HANDLE EventPair
        );
+NTSTATUS
+STDCALL
+ZwSetHighWaitLowEventPair(
+       IN HANDLE EventPair
+       );
 
 /*
  * FUNCTION: Sets the information of a file object.
@@ -3292,10 +3455,20 @@ NtSetInformationFile(
        IN PIO_STATUS_BLOCK IoStatusBlock,
        IN PVOID FileInformation,
        IN ULONG Length,
-       IN CINT FileInformationClass
+       IN FILE_INFORMATION_CLASS FileInformationClass
+       );
+NTSTATUS
+STDCALL
+ZwSetInformationFile(
+       IN HANDLE FileHandle,
+       IN PIO_STATUS_BLOCK IoStatusBlock,
+       IN PVOID FileInformation,
+       IN ULONG Length,
+       IN FILE_INFORMATION_CLASS FileInformationClass
        );
 
 
+
 /*
  * FUNCTION: Sets the information of a registry key.
  * ARGUMENTS: 
@@ -3318,6 +3491,15 @@ NtSetInformationKey(
        IN PVOID KeyInformation,
        IN ULONG KeyInformationLength
        );
+
+NTSTATUS
+STDCALL
+ZwSetInformationKey(
+       IN HANDLE KeyHandle,
+       IN CINT KeyInformationClass,
+       IN PVOID KeyInformation,
+       IN ULONG KeyInformationLength
+       );
 /*
  * FUNCTION: Changes a set of object specific parameters
  * ARGUMENTS: 
@@ -3345,6 +3527,15 @@ NtSetInformationObject(
        IN ULONG Length 
        );
 
+NTSTATUS
+STDCALL
+ZwSetInformationObject(
+       IN HANDLE ObjectHandle,
+       IN CINT ObjectInformationClass,
+       IN PVOID ObjectInformation,
+       IN ULONG Length 
+       );
+
 /*
  * FUNCTION: Changes a set of process specific parameters
  * ARGUMENTS: 
@@ -3374,6 +3565,14 @@ NtSetInformationProcess(
        IN PVOID ProcessInformation,
        IN ULONG ProcessInformationLength
        );
+NTSTATUS
+STDCALL
+ZwSetInformationProcess(
+       IN HANDLE ProcessHandle,
+       IN CINT ProcessInformationClass,
+       IN PVOID ProcessInformation,
+       IN ULONG ProcessInformationLength
+       );
 /*
  * FUNCTION: Changes a set of thread specific parameters
  * ARGUMENTS: 
@@ -3397,11 +3596,20 @@ NTSTATUS
 STDCALL
 NtSetInformationThread(
        IN HANDLE ThreadHandle,
-       IN CINT ThreadInformationClass,
+       IN THREADINFOCLASS ThreadInformationClass,
        IN PVOID ThreadInformation,
        IN ULONG ThreadInformationLength
        );
-//FIXME: Are the arguments correct
+NTSTATUS
+STDCALL
+ZwSetInformationThread(
+       IN HANDLE ThreadHandle,
+       IN THREADINFOCLASS ThreadInformationClass,
+       IN PVOID ThreadInformation,
+       IN ULONG ThreadInformationLength
+       );
+
+ //FIXME: Are the arguments correct
 // Might be a ordinary set function
 /*
  * FUNCTION: Sets an io completion
@@ -3422,6 +3630,15 @@ NtSetIoCompletion(
        IN ULONG NumberOfBytesToTransfer, 
        OUT PULONG NumberOfBytesTransferred
        );
+NTSTATUS
+STDCALL
+ZwSetIoCompletion(
+       IN HANDLE CompletionPort,
+       IN ULONG CompletionKey,
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
+       IN ULONG NumberOfBytesToTransfer, 
+       OUT PULONG NumberOfBytesTransferred
+       );
 //FIXME: Should I have more parameters ?
 /*
  * FUNCTION: Initializes the Local Descriptor Table
@@ -3430,12 +3647,12 @@ NtSetIoCompletion(
        LdtEntry =
  * RETURNS: Status
 */
-NTSTATUS
-STDCALL
-NtSetLdtEntries(
-       HANDLE ProcessHandle,
-       PVOID LdtEntry // LDT_ENTR
-       );
+//NTSTATUS
+//STDCALL
+//NtSetLdtEntries(
+//     HANDLE ProcessHandle,
+//     PVOID LdtEntry // LDT_ENTR
+//     );
 
 /*
  * FUNCTION: Sets the low part of an event pair
@@ -3449,7 +3666,11 @@ STDCALL
 NtSetLowEventPair(
        HANDLE EventPair
        );
-
+NTSTATUS
+STDCALL
+ZwSetLowEventPair(
+       HANDLE EventPair
+       );
 /*
  * FUNCTION: Sets the low part of an event pair and wait for the high part
  * ARGUMENTS: 
@@ -3461,6 +3682,11 @@ STDCALL
 NtSetLowWaitHighEventPair(
        HANDLE EventPair
        );
+NTSTATUS
+STDCALL
+ZwSetLowWaitHighEventPair(
+       HANDLE EventPair
+       );
 
 //FIXME: Should Value be a void pointer or a pointer to a unicode string ?
 /*
@@ -3473,10 +3699,15 @@ NtSetLowWaitHighEventPair(
 NTSTATUS
 STDCALL
 NtSetSystemEnvironmentValue(
-       IN PUNICODE_STRING ValueName,
-       IN PVOID Value
+       IN PUNICODE_STRING VariableName,
+       IN PUNICODE_STRING Value
+       );
+NTSTATUS
+STDCALL
+ZwSetSystemEnvironmentValue(
+       IN PUNICODE_STRING VariableName,
+       IN PUNICODE_STRING Value
        );
-
 /*
  * FUNCTION: Sets system parameters
  * ARGUMENTS: 
@@ -3497,6 +3728,14 @@ NtSetSystemInformation(
        IN ULONG SystemInformationLength
        );
 
+NTSTATUS
+STDCALL
+ZwSetSystemInformation(
+       IN CINT SystemInformationClass,
+       IN PVOID SystemInformation,
+       IN ULONG SystemInformationLength
+       );
+
 /*
  * FUNCTION: Sets the system time
  * ARGUMENTS: 
@@ -3510,15 +3749,22 @@ NtSetSystemTime(
        IN PLARGE_INTEGER SystemTime,
        IN PLARGE_INTEGER NewSystemTime OPTIONAL
        );
+NTSTATUS
+STDCALL
+ZwSetSystemTime(
+       IN PLARGE_INTEGER SystemTime,
+       IN PLARGE_INTEGER NewSystemTime OPTIONAL
+       );
 /*
  * FUNCTION: Sets the characteristics of a timer
  * ARGUMENTS: 
- *      TimerHandle = 
- *     DueTime = 
- *      CompletionRoutine = 
- *      ArgToCompletionRoutine =
- *      Resume = 
- *      Period = 
+ *      TimerHandle = Handle to the timer
+ *     DueTime = Time before the timer becomes signalled for the first time.
+ *      TimerApcRoutine = Completion routine can be called on time completion
+ *      TimerContext = Argument to the completion routine
+ *      Resume = Specifies if the timer should repeated after completing one cycle
+ *      Period = Cycle of the timer
+ * REMARKS: This routine maps to the win32 SetWaitableTimer.
  * RETURNS: Status
 */
 NTSTATUS
@@ -3526,10 +3772,22 @@ STDCALL
 NtSetTimer(
        IN HANDLE TimerHandle,
        IN PLARGE_INTEGER DueTime,
-       IN PTIMERAPCROUTINE CompletionRoutine,
-       IN PVOID ArgToCompletionRoutine,
-       IN BOOL Resume,
-       IN ULONG Period
+       IN PTIMERAPCROUTINE TimerApcRoutine,
+       IN PVOID TimerContext,
+       IN BOOL WakeTimer,
+       IN ULONG Period OPTIONAL,
+       OUT PBOOLEAN PreviousState OPTIONAL
+       );
+NTSTATUS
+STDCALL
+ZwSetTimer(
+       IN HANDLE TimerHandle,
+       IN PLARGE_INTEGER DueTime,
+       IN PTIMERAPCROUTINE TimerApcRoutine,
+       IN PVOID TimerContext,
+       IN BOOL WakeTimer,
+       IN ULONG Period OPTIONAL,
+       OUT PBOOLEAN PreviousState OPTIONAL
        );
 /*
  * FUNCTION: Sets the frequency of the system timer
@@ -3546,6 +3804,13 @@ NtSetTimerResolution(
        IN BOOL SetOrUnset,
        OUT PULONG ActualResolution
        );
+NTSTATUS
+STDCALL
+ZwSetTimerResolution(
+       IN ULONG RequestedResolution,
+       IN BOOL SetOrUnset,
+       OUT PULONG ActualResolution
+       );
 /*
  * FUNCTION: Sets the value of a registry key
  * ARGUMENTS: 
@@ -3553,7 +3818,7 @@ NtSetTimerResolution(
  *     ValueName = Name of the value entry to change
  *     TitleIndex = pointer to a structure containing the new volume information
  *      Type = Type of the registry key. Can be one of the values:
- *             REG_BINARY              
+ *             REG_BINARY                      Unspecified binary data
  *             REG_DWORD                       A 32 bit value
  *             REG_DWORD_LITTLE_ENDIAN         Same as REG_DWORD
  *             REG_DWORD_BIG_ENDIAN            A 32 bit value whose least significant byte is at the highest address
@@ -3579,6 +3844,16 @@ NtSetValueKey(
        IN PVOID Data,
        IN ULONG DataSize
        );
+NTSTATUS
+STDCALL
+ZwSetValueKey(
+       IN HANDLE KeyHandle,
+       IN PUNICODE_STRING ValueName,
+       IN ULONG TitleIndex OPTIONAL,
+       IN ULONG Type,
+       IN PVOID Data,
+       IN ULONG DataSize
+       );
 /*
  * FUNCTION: Sets the volume information of a file. 
  * ARGUMENTS: 
@@ -3596,10 +3871,20 @@ NtSetVolumeInformationFile(
        PVOID VolumeInformation,
        ULONG Length
        );
+
+NTSTATUS
+STDCALL
+ZwSetVolumeInformationFile(
+       IN HANDLE FileHandle,
+       IN CINT VolumeInformationClass,
+       PVOID VolumeInformation,
+       ULONG Length
+       );
 /*
  * FUNCTION: Shuts the system down
  * ARGUMENTS: 
- *        Action: 
+ *        Action: Specifies the type of shutdown, it can be one of the following values:
+                       ShutdownNoReboot, ShutdownReboot, ShutdownPowerOff
  * RETURNS: Status
  */ 
 NTSTATUS 
@@ -3607,6 +3892,12 @@ STDCALL
 NtShutdownSystem(
        IN SHUTDOWN_ACTION Action
        );
+
+NTSTATUS 
+STDCALL 
+ZwShutdownSystem(
+       IN SHUTDOWN_ACTION Action
+       );
 /*
  * FUNCTION: Signals an event and wait for it to be signaled again.
  * ARGUMENTS: 
@@ -3625,6 +3916,15 @@ NtSignalAndWaitForSingleObject(
        IN PLARGE_INTEGER Time,
        PULONG NumberOfWaitingThreads OPTIONAL 
        );
+
+NTSTATUS 
+STDCALL 
+ZwSignalAndWaitForSingleObject(
+        IN HANDLE EventHandle,
+       IN BOOLEAN Alertable,
+       IN PLARGE_INTEGER Time,
+       PULONG NumberOfWaitingThreads OPTIONAL 
+       );
 /*
  * FUNCTION: Increments a thread's resume count
  * ARGUMENTS: 
@@ -3642,6 +3942,12 @@ NtSuspendThread(
        IN HANDLE ThreadHandle,
        IN PULONG PreviousSuspendCount 
        );
+NTSTATUS 
+STDCALL 
+ZwSuspendThread(
+       IN HANDLE ThreadHandle,
+       IN PULONG PreviousSuspendCount 
+       );
 
 //--NtSystemDebugControl
 /*
@@ -3659,6 +3965,12 @@ NtTerminateProcess(
        IN HANDLE ProcessHandle ,
        IN NTSTATUS ExitStatus
        );
+NTSTATUS 
+STDCALL 
+ZwTerminateProcess(
+       IN HANDLE ProcessHandle ,
+       IN NTSTATUS ExitStatus
+       );
 /*
  * FUNCTION: Terminates the execution of a thread. 
  * ARGUMENTS: 
@@ -3672,8 +3984,14 @@ NtTerminateThread(
        IN HANDLE ThreadHandle ,
        IN NTSTATUS ExitStatus
        );
+NTSTATUS 
+STDCALL 
+ZwTerminateThread(
+       IN HANDLE ThreadHandle ,
+       IN NTSTATUS ExitStatus
+       );
 /*
- * FUNCTION: Test to see if there are any pending alerts for the calling thread 
+ * FUNCTION: Tests to see if there are any pending alerts for the calling thread 
  * RETURNS: Status
  */    
 NTSTATUS 
@@ -3681,6 +3999,11 @@ STDCALL
 NtTestAlert(
        VOID 
        );
+NTSTATUS 
+STDCALL 
+ZwTestAlert(
+       VOID 
+       );
 /*
  * FUNCTION: Unloads a driver. 
  * ARGUMENTS: 
@@ -3692,10 +4015,15 @@ STDCALL
 NtUnloadDriver(
        IN PUNICODE_STRING DriverServiceName
        );
+NTSTATUS 
+STDCALL
+ZwUnloadDriver(
+       IN PUNICODE_STRING DriverServiceName
+       );
 
 //FIXME: NtUnloadKey needs more arguments
 /*
- * FUNCTION: Unload a registry key. 
+ * FUNCTION: Unloads a registry key. 
  * ARGUMENTS: 
  *       KeyHandle = Handle to the registry key
  * REMARK:
@@ -3707,6 +4035,11 @@ STDCALL
 NtUnloadKey(
        HANDLE KeyHandle
        );
+NTSTATUS 
+STDCALL
+ZwUnloadKey(
+       HANDLE KeyHandle
+       );
 
 /*
  * FUNCTION: Unlocks a range of bytes in a file. 
@@ -3717,16 +4050,29 @@ NtUnloadKey(
                        The information field is set to the number of bytes unlocked.
  *       ByteOffset = Offset to start the range of bytes to unlock 
  *       Length = Number of bytes to unlock.
- *       Key = 
+ *       Key = Special value to enable other threads to unlock a file than the
+               thread that locked the file. The key supplied must match with the one obtained
+               in a previous call to NtLockFile.
  * REMARK:
-       This procedure maps to the win32 procedure UnlockFileEx 
- * RETURNS: Status
+       This procedure maps to the win32 procedure UnlockFileEx. STATUS_PENDING is returned if the lock could
+       not be obtained immediately, the device queue is busy and the IRP is queued.
+ * RETURNS: Status [ STATUS_SUCCESS | STATUS_PENDING | STATUS_ACCESS_DENIED | STATUS_INSUFFICIENT_RESOURCES |
+       STATUS_INVALID_PARAMETER | STATUS_INVALID_DEVICE_REQUEST | STATUS_RANGE_NOT_LOCKED ]
  */    
 NTSTATUS 
 STDCALL
 NtUnlockFile(
        IN HANDLE FileHandle,
-       OUT IO_STATUS_BLOCK IoStatusBlock,
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
+       IN LARGE_INTEGER ByteOffset,
+       IN LARGE_INTEGER Lenght,
+       OUT PULONG Key OPTIONAL
+       );
+NTSTATUS 
+STDCALL
+ZwUnlockFile(
+       IN HANDLE FileHandle,
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
        IN LARGE_INTEGER ByteOffset,
        IN LARGE_INTEGER Lenght,
        OUT PULONG Key OPTIONAL
@@ -3741,7 +4087,7 @@ NtUnlockFile(
  *       NumberOfBytesUnlocked (OUT) = Number of bytes actually unlocked.
  * REMARK:
        This procedure maps to the win32 procedure VirtualUnlock 
- * RETURNS: Status
+ * RETURNS: Status [ STATUS_SUCCESS | STATUS_PAGE_WAS_ULOCKED ]
  */    
 NTSTATUS 
 STDCALL
@@ -3751,6 +4097,15 @@ NtUnlockVirtualMemory(
        ULONG  NumberOfBytesToUnlock,
        PULONG NumberOfBytesUnlocked OPTIONAL
        );
+
+NTSTATUS 
+STDCALL
+ZwUnlockVirtualMemory(
+       HANDLE ProcessHandle,
+       PVOID BaseAddress,
+       ULONG  NumberOfBytesToUnlock,
+       PULONG NumberOfBytesUnlocked OPTIONAL
+       );
 /*
  * FUNCTION: Unmaps a piece of virtual memory backed by a file. 
  * ARGUMENTS: 
@@ -3766,12 +4121,18 @@ NtUnmapViewOfSection(
        IN HANDLE ProcessHandle,
        IN PVOID BaseAddress
        );
+NTSTATUS
+STDCALL
+ZwUnmapViewOfSection(
+       IN HANDLE ProcessHandle,
+       IN PVOID BaseAddress
+       );
 /*
  * FUNCTION: Waits for multiple objects to become signalled. 
  * ARGUMENTS: 
  *       Count = The number of objects
  *       Object = The array of object handles
- *       WaitType = 
+ *       WaitType = Can be one of the values UserMode or KernelMode
  *       Alertable = If true the wait is alertable.
  *       Time = The maximum wait time. 
  * REMARKS:
@@ -3782,7 +4143,17 @@ NTSTATUS
 STDCALL
 NtWaitForMultipleObjects (
        IN ULONG Count,
-       IN PHANDLE Object[0],
+       IN PHANDLE Object[],
+       IN CINT WaitType,
+       IN BOOLEAN Alertable,
+       IN PLARGE_INTEGER Time 
+       );
+
+NTSTATUS
+STDCALL
+ZwWaitForMultipleObjects (
+       IN ULONG Count,
+       IN PHANDLE Object[],
        IN CINT WaitType,
        IN BOOLEAN Alertable,
        IN PLARGE_INTEGER Time 
@@ -3804,11 +4175,31 @@ NtWaitForSingleObject (
        IN BOOLEAN Alertable,
        IN PLARGE_INTEGER Time 
        );
+
+NTSTATUS
+STDCALL
+ZwWaitForSingleObject (
+       IN PHANDLE Object,
+       IN BOOLEAN Alertable,
+       IN PLARGE_INTEGER Time 
+       );
+
+NTSTATUS
+STDCALL
+NtWaitLowEventPair(
+       IN HANDLE EventHandle
+       );
+
+NTSTATUS
+STDCALL
+ZwWaitLowEventPair(
+       IN HANDLE EventHandle
+       );
 /*
  * FUNCTION: Writes data to a file
  * ARGUMENTS: 
  *       FileHandle = The handle a file ( from NtCreateFile )
- *       Event  = 
+ *       Event  = Specifies a event that will become signalled when the write operation completes.
  *       ApcRoutine = Asynchroneous Procedure Callback [ Should not be used by device drivers ]
  *       ApcContext = Argument to the Apc Routine 
  *       IoStatusBlock = Caller should supply storage for a structure containing the completion status and information about the requested write operation.
@@ -3822,11 +4213,26 @@ NtWaitForSingleObject (
  * REMARKS:
  *      This function maps to the win32 WriteFile. 
  *      Callers to NtWriteFile should run at IRQL PASSIVE_LEVEL.
- * RETURNS: Status
+ * RETURNS: Status [ STATUS_SUCCESS | STATUS_PENDING | STATUS_ACCESS_DENIED | STATUS_INSUFFICIENT_RESOURCES
+       STATUS_INVALID_PARAMETER | STATUS_INVALID_DEVICE_REQUEST | STATUS_FILE_LOCK_CONFLICT ]
  */
 NTSTATUS
 STDCALL
 NtWriteFile(
+       IN HANDLE FileHandle,
+       IN HANDLE Event OPTIONAL,
+       IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
+       IN PVOID ApcContext OPTIONAL,
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
+       IN PVOID Buffer,
+       IN ULONG Length,
+       IN PLARGE_INTEGER ByteOffset,
+       IN PULONG Key OPTIONAL
+    );
+
+NTSTATUS
+STDCALL
+ZwWriteFile(
        IN HANDLE FileHandle,
        IN HANDLE Event OPTIONAL,
        IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
@@ -3851,16 +4257,32 @@ NtWriteFile(
  *       ByteOffset = Points to a file offset. If a combination of Length and BytesOfSet is past the end-of-file mark the file will be enlarged.
  *                   BytesOffset is ignored if the file is created with FILE_APPEND_DATA in the DesiredAccess. BytesOffset is also ignored if
  *                    the file is created with CreateOptions flags FILE_SYNCHRONOUS_IO_ALERT or FILE_SYNCHRONOUS_IO_NONALERT set, in that case a offset
- *                    should be created by specifying FILE_USE_FILE_POINTER_POSITION.
- *       Key =  Unused
+ *                    should be created by specifying FILE_USE_FILE_POINTER_POSITION. Use FILE_WRITE_TO_END_OF_FILE to write to the EOF.
+ *       Key = If a matching key [ a key provided at NtLockFile ] is provided the write operation will continue even if a byte range is locked.
  * REMARKS:
  *      This function maps to the win32 WriteFile. 
  *      Callers to NtWriteFile should run at IRQL PASSIVE_LEVEL.
- * RETURNS: Status
+ * RETURNS: Status [ STATUS_SUCCESS | STATUS_PENDING | STATUS_ACCESS_DENIED | STATUS_INSUFFICIENT_RESOURCES
+               STATUS_INVALID_PARAMETER | STATUS_INVALID_DEVICE_REQUEST | STATUS_FILE_LOCK_CONFLICT ]
  */
 
 NTSTATUS
-STDCALL NtWriteFileScatter( 
+STDCALL 
+NtWriteFileGather( 
+       IN HANDLE FileHandle, 
+       IN HANDLE Event OPTIONAL, 
+       IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, 
+       IN PVOID ApcContext OPTIONAL, 
+       OUT PIO_STATUS_BLOCK IoStatusBlock,
+       IN FILE_SEGMENT_ELEMENT BufferDescription[], 
+       IN ULONG BufferLength, 
+       IN PLARGE_INTEGER ByteOffset, 
+       IN PULONG Key OPTIONAL
+       ); 
+
+NTSTATUS
+STDCALL 
+ZwWriteFileGather( 
        IN HANDLE FileHandle, 
        IN HANDLE Event OPTIONAL, 
        IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, 
@@ -3872,6 +4294,7 @@ STDCALL NtWriteFileScatter(
        IN PULONG Key OPTIONAL
        ); 
 
+
 /*
  * FUNCTION: Writes a range of virtual memory
  * ARGUMENTS: 
@@ -3893,6 +4316,16 @@ NtWriteVirtualMemory(
        IN ULONG NumberOfBytesToWrite,
        OUT PULONG NumberOfBytesWritten
        );
+
+NTSTATUS
+STDCALL 
+ZwWriteVirtualMemory(
+       IN HANDLE ProcessHandle,
+       IN PVOID  BaseAddress,
+       IN PVOID Buffer,
+       IN ULONG NumberOfBytesToWrite,
+       OUT PULONG NumberOfBytesWritten
+       );
 /*
  * FUNCTION: Yields the callers thread.
  * RETURNS: Status
@@ -3903,6 +4336,77 @@ NtYieldExecution(
        VOID
        );
 
+NTSTATUS
+STDCALL 
+ZwYieldExecution(
+       VOID
+       );
 
 
+/*
+ * These prototypes are unknown as yet
+ */
+NTSTATUS STDCALL NtAcceptConnectPort(VOID);
+NTSTATUS STDCALL NtAccessCheckAndAuditAlarm(VOID);
+NTSTATUS STDCALL NtAdjustGroupsToken(VOID);
+NTSTATUS STDCALL NtAdjustPrivilegesToken(VOID);
+NTSTATUS STDCALL NtAllocateUuids(VOID);
+NTSTATUS STDCALL NtCloseObjectAuditAlarm(VOID);
+NTSTATUS STDCALL NtCompleteConnectPort(VOID);
+NTSTATUS STDCALL NtConnectPort(VOID);
+NTSTATUS STDCALL NtCreateMailslotFile(VOID);
+NTSTATUS STDCALL NtCreateNamedPipeFile(VOID);
+NTSTATUS STDCALL NtCreatePort(VOID);
+NTSTATUS STDCALL NtCreateProfile(VOID);
+NTSTATUS STDCALL NtCreateToken(VOID);
+NTSTATUS STDCALL NtDeleteObjectAuditAlarm(VOID);
+NTSTATUS STDCALL NtDuplicateToken(VOID);
+NTSTATUS STDCALL NtGetPlugPlayEvent(VOID);
+NTSTATUS STDCALL NtImpersonateClientOfPort(VOID);
+NTSTATUS STDCALL NtImpersonateThread(VOID);
+NTSTATUS STDCALL NtListenPort(VOID);
+NTSTATUS STDCALL NtLoadKey2(VOID);
+NTSTATUS STDCALL NtOpenEventPair(VOID);
+NTSTATUS STDCALL NtOpenObjectAuditAlarm(VOID);
+NTSTATUS STDCALL NtOpenProcessToken(VOID);
+NTSTATUS STDCALL NtOpenThreadToken(VOID);
+NTSTATUS STDCALL NtPlugPlayControl(VOID);
+NTSTATUS STDCALL NtPrivilegeCheck(VOID);
+NTSTATUS STDCALL NtPrivilegedServiceAuditAlarm(VOID);
+NTSTATUS STDCALL NtPrivilegeObjectAuditAlarm(VOID);
+NTSTATUS STDCALL NtQueryDefaultLocale(VOID);
+NTSTATUS STDCALL NtQueryIoCompletion(VOID);
+NTSTATUS STDCALL NtQueryInformationPort(VOID);
+NTSTATUS STDCALL NtQueryInformationToken(VOID);
+NTSTATUS STDCALL NtQueryIntervalProfile(VOID);
+NTSTATUS STDCALL NtQueryOleDirectoryFile(VOID);
+NTSTATUS STDCALL NtQuerySecurityObject(VOID);
+NTSTATUS STDCALL NtRaiseHardError(VOID);
+NTSTATUS STDCALL NtReadRequestData(VOID);
+NTSTATUS STDCALL NtReplyPort(VOID);
+NTSTATUS STDCALL NtReplyWaitReceivePort(VOID);
+NTSTATUS STDCALL NtReplyWaitReplyPort(VOID);
+NTSTATUS STDCALL NtRequestPort(VOID);
+NTSTATUS STDCALL NtSetDefaultHardErrorPort(VOID);
+NTSTATUS STDCALL NtSetDefaultLocale(VOID);
+NTSTATUS STDCALL NtSetInformationToken(VOID);
+NTSTATUS STDCALL NtSetIntervalProfile(VOID);
+NTSTATUS STDCALL NtSetLdtEntries(VOID);
+NTSTATUS STDCALL NtSetSecurityObject(VOID);
+NTSTATUS STDCALL NtSetSystemPowerState(VOID);
+NTSTATUS STDCALL NtStartProfile(VOID);
+NTSTATUS STDCALL NtStopProfile(VOID);
+NTSTATUS STDCALL NtSystemDebugControl(VOID);
+NTSTATUS STDCALL NtVdmControl(VOID);
+NTSTATUS STDCALL NtWaitHighEventPair(VOID);
+NTSTATUS STDCALL NtWriteRequestData(VOID);
+NTSTATUS STDCALL NtW32Call(VOID);
+NTSTATUS STDCALL NtCreateChannel(VOID);
+NTSTATUS STDCALL NtListenChannel(VOID);
+NTSTATUS STDCALL NtOpenChannel(VOID);
+NTSTATUS STDCALL NtReplyWaitSendChannel(VOID);
+NTSTATUS STDCALL NtSendWaitReplyChannel(VOID);
+NTSTATUS STDCALL NtSetContextChannel(VOID);
+NTSTATUS STDCALL NtRequestWaitReplyPort(VOID); 
 #endif /* __DDK_ZW_H */
index 1cd80df..26ece09 100644 (file)
 #ifndef _GNU_H_WINDOWS32_DEFINES
 #define _GNU_H_WINDOWS32_DEFINES
 
+#define WINBASEAPI
+
+#define EXCEPTION_MAXIMUM_PARAMETERS   (15)
+#define ANYSIZE_ARRAY  (1)
+
+#define STATUS_WAIT_0                  (0x00000000L)
+#define STATUS_ABANDONED_WAIT_0        (0x00000080L)
+#define STATUS_USER_APC                (0x000000C0L)
+#define STATUS_TIMEOUT                 (0x00000102L)
+#define STATUS_PENDING                 (0x00000103L)
+#define STATUS_GUARD_PAGE_VIOLATION    (0x80000001L)
+#define STATUS_DATATYPE_MISALIGNMENT   (0x80000002L)
+#define STATUS_BREAKPOINT              (0x80000003L)
+#define STATUS_SINGLE_STEP             (0x80000004L)
+#define STATUS_IN_PAGE_ERROR           (0xC0000006L)
+#define STATUS_INVALID_HANDLE          (0xC0000008L)
+#define STATUS_ILLEGAL_INSTRUCTION     (0xC000001DL)
+#define STATUS_NONCONTINUABLE_EXCEPTION (0xC0000025L)
+#define STATUS_INVALID_DISPOSITION     (0xC0000026L)
+#define STATUS_ARRAY_BOUNDS_EXCEEDED   (0xC000008CL)
+#define STATUS_FLOAT_DENORMAL_OPERAND  (0xC000008DL)
+#define STATUS_FLOAT_DIVIDE_BY_ZERO    (0xC000008EL)
+#define STATUS_FLOAT_INEXACT_RESULT    (0xC000008FL)
+#define STATUS_FLOAT_INVALID_OPERATION         (0xC0000090L)
+#define STATUS_FLOAT_OVERFLOW          (0xC0000091L)
+#define STATUS_FLOAT_STACK_CHECK       (0xC0000092L)
+#define STATUS_FLOAT_UNDERFLOW         (0xC0000093L)
+#define STATUS_INTEGER_DIVIDE_BY_ZERO  (0xC0000094L)
+#define STATUS_INTEGER_OVERFLOW        (0xC0000095L)
+#define STATUS_PRIVILEGED_INSTRUCTION  (0xC0000096L)
+#define STATUS_STACK_OVERFLOW          (0xC00000FDL)
+#define STATUS_CONTROL_C_EXIT          (0xC000013AL)
+
+#define SEC_COMMIT     (134217728)
+#define SEC_IMAGE      (16777216)
+#define SEC_NOCACHE    (268435456)
+#define SEC_RESERVE    (67108864)
+#define PAGE_READONLY  (2)
+#define PAGE_READWRITE (4)
+#define PAGE_WRITECOPY (8)
+#define PAGE_EXECUTE   (16)
+#define PAGE_EXECUTE_READ      (32)
+#define PAGE_EXECUTE_READWRITE (64)
+#define PAGE_EXECUTE_WRITECOPY (128)
+#define PAGE_GUARD     (256)
+#define PAGE_NOACCESS  (1)
+#define PAGE_NOCACHE   (512)
+#define MEM_COMMIT     (4096)
+#define MEM_FREE       (65536)
+#define MEM_RESERVE    (8192)
+#define MEM_IMAGE      (16777216)
+#define MEM_MAPPED     (262144)
+#define MEM_PRIVATE    (131072)
+#define MEM_DECOMMIT   (16384)
+#define MEM_RELEASE    (32768)
+#define MEM_TOP_DOWN   (1048576)
+#define EXCEPTION_GUARD_PAGE   (0x80000001L)
+#define SECTION_EXTEND_SIZE    (0x10)
+#define SECTION_MAP_READ       (0x4)
+#define SECTION_MAP_WRITE      (0x2)
+#define SECTION_QUERY  (0x1)
+#define SECTION_ALL_ACCESS     (0xf001fL)
+
+
+/* DuplicateHandle, MapViewOfFile */
+#define DUPLICATE_CLOSE_SOURCE (1)
+#define DUPLICATE_SAME_ACCESS  (2)
+#define FILE_MAP_ALL_ACCESS    (0xf001fL)
+#define FILE_MAP_READ  (4)
+#define FILE_MAP_WRITE (2)
+#define FILE_MAP_COPY  (1)
+#define MUTEX_ALL_ACCESS       (0x1f0001L)
+#define MUTEX_MODIFY_STATE     (1)
+#define SYNCHRONIZE    (0x100000L)
+#define SEMAPHORE_ALL_ACCESS   (0x1f0003L)
+#define SEMAPHORE_MODIFY_STATE (2)
+#define EVENT_ALL_ACCESS       (0x1f0003L)
+#define EVENT_MODIFY_STATE     (2)
+#define KEY_ALL_ACCESS (0xf003fL)
+#define KEY_CREATE_LINK        (32)
+#define KEY_CREATE_SUB_KEY     (4)
+#define KEY_ENUMERATE_SUB_KEYS (8)
+#define KEY_EXECUTE    (0x20019L)
+#define KEY_NOTIFY     (16)
+#define KEY_QUERY_VALUE        (1)
+#define KEY_READ       (0x20019L)
+#define KEY_SET_VALUE  (2)
+#define KEY_WRITE      (0x20006L)
+#define PROCESS_ALL_ACCESS     (0x1f0fffL)
+#define PROCESS_CREATE_PROCESS (128)
+#define PROCESS_CREATE_THREAD  (2)
+#define PROCESS_DUP_HANDLE     (64)
+#define PROCESS_QUERY_INFORMATION      (1024)
+#define PROCESS_SET_INFORMATION        (512)
+#define PROCESS_TERMINATE      (1)
+#define PROCESS_VM_OPERATION   (8)
+#define PROCESS_VM_READ        (16)
+#define PROCESS_VM_WRITE       (32)
+#define THREAD_ALL_ACCESS      (0x1f03ffL)
+#define THREAD_DIRECT_IMPERSONATION    (512)
+#define THREAD_GET_CONTEXT     (8)
+#define THREAD_IMPERSONATE     (256)
+#define THREAD_QUERY_INFORMATION       (64)
+#define THREAD_SET_CONTEXT     (16)
+#define THREAD_SET_INFORMATION (32)
+#define THREAD_SET_THREAD_TOKEN        (128)
+#define THREAD_SUSPEND_RESUME  (2)
+#define THREAD_TERMINATE       (1)
+
+#define PACKED __attribute__((packed))
+
+#define THREAD_PRIORITY_ABOVE_NORMAL   (1)
+#define THREAD_PRIORITY_BELOW_NORMAL   (-1)
+#define THREAD_PRIORITY_HIGHEST        (2)
+#define THREAD_PRIORITY_IDLE   (-15)
+#define THREAD_PRIORITY_LOWEST (-2)
+#define THREAD_PRIORITY_NORMAL (0)
+#define THREAD_PRIORITY_TIME_CRITICAL  (15)
+#define THREAD_PRIORITY_ERROR_RETURN   (2147483647)
+
+/* CreateFile, GetFileAttributes, SetFileAttributes */
+#define GENERIC_READ   (0x80000000L)
+#define GENERIC_WRITE  (0x40000000L)
+#define FILE_READ_DATA            ( 0x0001 )    /* file & pipe */
+#define FILE_LIST_DIRECTORY       ( 0x0001 )    /* directory */
+
+#define FILE_WRITE_DATA           ( 0x0002 )    /* file & pipe */
+#define FILE_ADD_FILE             ( 0x0002 )    /* directory */
+
+#define FILE_APPEND_DATA          ( 0x0004 )    /* file */
+#define FILE_ADD_SUBDIRECTORY     ( 0x0004 )    /* directory */
+#define FILE_CREATE_PIPE_INSTANCE ( 0x0004 )    /* named pipe */
+
+#define FILE_READ_EA              ( 0x0008 )    /* file & directory */
+#define FILE_READ_PROPERTIES      FILE_READ_EA
+
+#define FILE_WRITE_EA             ( 0x0010 )    /* file & directory */
+#define FILE_WRITE_PROPERTIES     FILE_WRITE_EA
+
+#define FILE_EXECUTE              ( 0x0020 )    /* file */
+#define FILE_TRAVERSE             ( 0x0020 )    /* directory */
+
+#define FILE_DELETE_CHILD         ( 0x0040 )    /* directory */
+
+#define FILE_READ_ATTRIBUTES      ( 0x0080 )    /* all */
+
+#define FILE_WRITE_ATTRIBUTES     ( 0x0100 )    /* all */
+
+#define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
+
+#define FILE_GENERIC_READ         (STANDARD_RIGHTS_READ     |\
+                                   FILE_READ_DATA           |\
+                                   FILE_READ_ATTRIBUTES     |\
+                                   FILE_READ_EA             |\
+                                   SYNCHRONIZE)
+
+
+#define FILE_GENERIC_WRITE        (STANDARD_RIGHTS_WRITE    |\
+                                   FILE_WRITE_DATA          |\
+                                   FILE_WRITE_ATTRIBUTES    |\
+                                   FILE_WRITE_EA            |\
+                                   FILE_APPEND_DATA         |\
+                                   SYNCHRONIZE)
+
+
+#define FILE_GENERIC_EXECUTE      (STANDARD_RIGHTS_EXECUTE  |\
+                                   FILE_READ_ATTRIBUTES     |\
+                                   FILE_EXECUTE             |\
+                                   SYNCHRONIZE)
+
+#define FILE_SHARE_DELETE      (4)
+#define FILE_SHARE_READ        (1)
+#define FILE_SHARE_WRITE       (2)
+#define CONSOLE_TEXTMODE_BUFFER        (1)
+#define CREATE_NEW     (1)
+#define CREATE_ALWAYS  (2)
+#define OPEN_EXISTING  (3)
+#define OPEN_ALWAYS    (4)
+#define TRUNCATE_EXISTING      (5)
+#define FILE_ATTRIBUTE_ARCHIVE (32)
+#define FILE_ATTRIBUTE_COMPRESSED      (2048)
+#define FILE_ATTRIBUTE_NORMAL  (128)
+#define FILE_ATTRIBUTE_DIRECTORY       (16)
+#define FILE_ATTRIBUTE_HIDDEN  (2)
+#define FILE_ATTRIBUTE_READONLY        (1)
+#define FILE_ATTRIBUTE_SYSTEM  (4)
+#define FILE_ATTRIBUTE_TEMPORARY       (256)
+#define FILE_FLAG_WRITE_THROUGH        (2147483648)
+#define FILE_FLAG_OVERLAPPED   (1073741824)
+#define FILE_FLAG_NO_BUFFERING (536870912)
+#define FILE_FLAG_RANDOM_ACCESS        (268435456)
+#define FILE_FLAG_SEQUENTIAL_SCAN      (134217728)
+#define FILE_FLAG_DELETE_ON_CLOSE      (67108864)
+#define FILE_FLAG_BACKUP_SEMANTICS     (33554432)
+#define FILE_FLAG_POSIX_SEMANTICS      (16777216)
+#define SECURITY_ANONYMOUS     (0)
+#define SECURITY_IDENTIFICATION        (65536)
+#define SECURITY_IMPERSONATION (131072)
+#define SECURITY_DELEGATION    (196608)
+#define SECURITY_CONTEXT_TRACKING      (262144)
+#define SECURITY_EFFECTIVE_ONLY        (524288)
+#define SECURITY_SQOS_PRESENT  (1048576)
+
+/* Standard rights */
+#define STANDARD_RIGHTS_REQUIRED       (0xf0000L)
+#define STANDARD_RIGHTS_WRITE  (0x20000L)
+#define STANDARD_RIGHTS_READ   (0x20000L)
+#define STANDARD_RIGHTS_EXECUTE        (0x20000L)
+#define STANDARD_RIGHTS_ALL    (0x1f0000L)
+#define SPECIFIC_RIGHTS_ALL    (0xffffL)
+
+/* ACCESS_MASK */
+#define MAXIMUM_ALLOWED        (0x2000000L)
+#define GENERIC_ALL    (0x10000000L)
+
+
+#ifndef WIN32_LEAN_AND_MEAN
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
@@ -45,7 +263,6 @@ extern "C" {
 #define SECURITY_DYNAMIC_TRACKING      (1)
 #define MAX_DEFAULTCHAR        (2)
 #define MAX_LEADBYTES  (12)
-#define EXCEPTION_MAXIMUM_PARAMETERS   (15)
 #define CCHDEVICENAME  (32)
 #define CCHFORMNAME    (32)
 #define MENU_TEXT_LEN  (40)
@@ -54,7 +271,6 @@ extern "C" {
 #define NETBIOS_NAME_LEN       (16)
 #define OFS_MAXPATHNAME        (128)
 #define MAX_TAB_STOPS  (32)
-#define ANYSIZE_ARRAY  (1)
 #define RAS_MaxCallbackNumber  (128)
 #define RAS_MaxDeviceName      (128)
 #define RAS_MaxDeviceType      (16)
@@ -382,119 +598,7 @@ extern "C" {
 #define DIB_PAL_COLORS (1)
 #define DIB_RGB_COLORS (0)
 
-/* CreateFile, GetFileAttributes, SetFileAttributes */
-#define GENERIC_READ   (0x80000000L)
-#define GENERIC_WRITE  (0x40000000L)
-#define FILE_READ_DATA            ( 0x0001 )    /* file & pipe */
-#define FILE_LIST_DIRECTORY       ( 0x0001 )    /* directory */
-
-#define FILE_WRITE_DATA           ( 0x0002 )    /* file & pipe */
-#define FILE_ADD_FILE             ( 0x0002 )    /* directory */
-
-#define FILE_APPEND_DATA          ( 0x0004 )    /* file */
-#define FILE_ADD_SUBDIRECTORY     ( 0x0004 )    /* directory */
-#define FILE_CREATE_PIPE_INSTANCE ( 0x0004 )    /* named pipe */
-
-#define FILE_READ_EA              ( 0x0008 )    /* file & directory */
-#define FILE_READ_PROPERTIES      FILE_READ_EA
-
-#define FILE_WRITE_EA             ( 0x0010 )    /* file & directory */
-#define FILE_WRITE_PROPERTIES     FILE_WRITE_EA
-
-#define FILE_EXECUTE              ( 0x0020 )    /* file */
-#define FILE_TRAVERSE             ( 0x0020 )    /* directory */
-
-#define FILE_DELETE_CHILD         ( 0x0040 )    /* directory */
-
-#define FILE_READ_ATTRIBUTES      ( 0x0080 )    /* all */
-
-#define FILE_WRITE_ATTRIBUTES     ( 0x0100 )    /* all */
-
-#define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
-
-#define FILE_GENERIC_READ         (STANDARD_RIGHTS_READ     |\
-                                   FILE_READ_DATA           |\
-                                   FILE_READ_ATTRIBUTES     |\
-                                   FILE_READ_EA             |\
-                                   SYNCHRONIZE)
-
-
-#define FILE_GENERIC_WRITE        (STANDARD_RIGHTS_WRITE    |\
-                                   FILE_WRITE_DATA          |\
-                                   FILE_WRITE_ATTRIBUTES    |\
-                                   FILE_WRITE_EA            |\
-                                   FILE_APPEND_DATA         |\
-                                   SYNCHRONIZE)
-
-
-#define FILE_GENERIC_EXECUTE      (STANDARD_RIGHTS_EXECUTE  |\
-                                   FILE_READ_ATTRIBUTES     |\
-                                   FILE_EXECUTE             |\
-                                   SYNCHRONIZE)
-
-#define FILE_SHARE_DELETE      (4)
-#define FILE_SHARE_READ        (1)
-#define FILE_SHARE_WRITE       (2)
-#define CONSOLE_TEXTMODE_BUFFER        (1)
-#define CREATE_NEW     (1)
-#define CREATE_ALWAYS  (2)
-#define OPEN_EXISTING  (3)
-#define OPEN_ALWAYS    (4)
-#define TRUNCATE_EXISTING      (5)
-#define FILE_ATTRIBUTE_ARCHIVE (32)
-#define FILE_ATTRIBUTE_COMPRESSED      (2048)
-#define FILE_ATTRIBUTE_NORMAL  (128)
-#define FILE_ATTRIBUTE_DIRECTORY       (16)
-#define FILE_ATTRIBUTE_HIDDEN  (2)
-#define FILE_ATTRIBUTE_READONLY        (1)
-#define FILE_ATTRIBUTE_SYSTEM  (4)
-#define FILE_ATTRIBUTE_TEMPORARY       (256)
-#define FILE_FLAG_WRITE_THROUGH        (2147483648)
-#define FILE_FLAG_OVERLAPPED   (1073741824)
-#define FILE_FLAG_NO_BUFFERING (536870912)
-#define FILE_FLAG_RANDOM_ACCESS        (268435456)
-#define FILE_FLAG_SEQUENTIAL_SCAN      (134217728)
-#define FILE_FLAG_DELETE_ON_CLOSE      (67108864)
-#define FILE_FLAG_BACKUP_SEMANTICS     (33554432)
-#define FILE_FLAG_POSIX_SEMANTICS      (16777216)
-#define SECURITY_ANONYMOUS     (0)
-#define SECURITY_IDENTIFICATION        (65536)
-#define SECURITY_IMPERSONATION (131072)
-#define SECURITY_DELEGATION    (196608)
-#define SECURITY_CONTEXT_TRACKING      (262144)
-#define SECURITY_EFFECTIVE_ONLY        (524288)
-#define SECURITY_SQOS_PRESENT  (1048576)
-
 /* CreateFileMapping, VirtualAlloc, VirtualFree, VirtualProtect */
-#define SEC_COMMIT     (134217728)
-#define SEC_IMAGE      (16777216)
-#define SEC_NOCACHE    (268435456)
-#define SEC_RESERVE    (67108864)
-#define PAGE_READONLY  (2)
-#define PAGE_READWRITE (4)
-#define PAGE_WRITECOPY (8)
-#define PAGE_EXECUTE   (16)
-#define PAGE_EXECUTE_READ      (32)
-#define PAGE_EXECUTE_READWRITE (64)
-#define PAGE_EXECUTE_WRITECOPY (128)
-#define PAGE_GUARD     (256)
-#define PAGE_NOACCESS  (1)
-#define PAGE_NOCACHE   (512)
-#define MEM_COMMIT     (4096)
-#define MEM_FREE       (65536)
-#define MEM_RESERVE    (8192)
-#define MEM_IMAGE      (16777216)
-#define MEM_MAPPED     (262144)
-#define MEM_PRIVATE    (131072)
-#define MEM_DECOMMIT   (16384)
-#define MEM_RELEASE    (32768)
-#define MEM_TOP_DOWN   (1048576)
-#define EXCEPTION_GUARD_PAGE   (0x80000001L)
-#define SECTION_EXTEND_SIZE    (0x10)
-#define SECTION_MAP_READ       (0x4)
-#define SECTION_MAP_WRITE      (0x2)
-#define SECTION_QUERY  (0x1)
-#define SECTION_ALL_ACCESS     (0xf001fL)
 
 /* CreateFont */
 #define FW_DONTCARE    (0)
@@ -1051,50 +1155,6 @@ extern "C" {
 #define DT_WORDBREAK   (16)
 #define DT_INTERNAL    (4096)
 
-/* DuplicateHandle, MapViewOfFile */
-#define DUPLICATE_CLOSE_SOURCE (1)
-#define DUPLICATE_SAME_ACCESS  (2)
-#define FILE_MAP_ALL_ACCESS    (0xf001fL)
-#define FILE_MAP_READ  (4)
-#define FILE_MAP_WRITE (2)
-#define FILE_MAP_COPY  (1)
-#define MUTEX_ALL_ACCESS       (0x1f0001L)
-#define MUTEX_MODIFY_STATE     (1)
-#define SYNCHRONIZE    (0x100000L)
-#define SEMAPHORE_ALL_ACCESS   (0x1f0003L)
-#define SEMAPHORE_MODIFY_STATE (2)
-#define EVENT_ALL_ACCESS       (0x1f0003L)
-#define EVENT_MODIFY_STATE     (2)
-#define KEY_ALL_ACCESS (0xf003fL)
-#define KEY_CREATE_LINK        (32)
-#define KEY_CREATE_SUB_KEY     (4)
-#define KEY_ENUMERATE_SUB_KEYS (8)
-#define KEY_EXECUTE    (0x20019L)
-#define KEY_NOTIFY     (16)
-#define KEY_QUERY_VALUE        (1)
-#define KEY_READ       (0x20019L)
-#define KEY_SET_VALUE  (2)
-#define KEY_WRITE      (0x20006L)
-#define PROCESS_ALL_ACCESS     (0x1f0fffL)
-#define PROCESS_CREATE_PROCESS (128)
-#define PROCESS_CREATE_THREAD  (2)
-#define PROCESS_DUP_HANDLE     (64)
-#define PROCESS_QUERY_INFORMATION      (1024)
-#define PROCESS_SET_INFORMATION        (512)
-#define PROCESS_TERMINATE      (1)
-#define PROCESS_VM_OPERATION   (8)
-#define PROCESS_VM_READ        (16)
-#define PROCESS_VM_WRITE       (32)
-#define THREAD_ALL_ACCESS      (0x1f03ffL)
-#define THREAD_DIRECT_IMPERSONATION    (512)
-#define THREAD_GET_CONTEXT     (8)
-#define THREAD_IMPERSONATE     (256)
-#define THREAD_QUERY_INFORMATION       (64)
-#define THREAD_SET_CONTEXT     (16)
-#define THREAD_SET_INFORMATION (32)
-#define THREAD_SET_THREAD_TOKEN        (128)
-#define THREAD_SUSPEND_RESUME  (2)
-#define THREAD_TERMINATE       (1)
 
 /* EditWordBreakProc */
 #define WB_ISDELIMITER (2)
@@ -1902,14 +1962,6 @@ extern "C" {
 #define VTA_CENTER     (6)
 
 /* GetThreadPriority */
-#define THREAD_PRIORITY_ABOVE_NORMAL   (1)
-#define THREAD_PRIORITY_BELOW_NORMAL   (-1)
-#define THREAD_PRIORITY_HIGHEST        (2)
-#define THREAD_PRIORITY_IDLE   (-15)
-#define THREAD_PRIORITY_LOWEST (-2)
-#define THREAD_PRIORITY_NORMAL (0)
-#define THREAD_PRIORITY_TIME_CRITICAL  (15)
-#define THREAD_PRIORITY_ERROR_RETURN   (2147483647)
 #define TLS_MINIMUM_AVAILABLE  (64)
 
 /* GetTimeFormat */
@@ -4110,17 +4162,6 @@ extern "C" {
 #define TAPE_DRIVE_WRITE_SETMARKS      (-2130706432)
 #define TAPE_DRIVE_WRITE_SHORT_FMKS    (-2080374784)
 
-/* Standard rights */
-#define STANDARD_RIGHTS_REQUIRED       (0xf0000L)
-#define STANDARD_RIGHTS_WRITE  (0x20000L)
-#define STANDARD_RIGHTS_READ   (0x20000L)
-#define STANDARD_RIGHTS_EXECUTE        (0x20000L)
-#define STANDARD_RIGHTS_ALL    (0x1f0000L)
-#define SPECIFIC_RIGHTS_ALL    (0xffffL)
-
-/* ACCESS_MASK */
-#define MAXIMUM_ALLOWED        (0x2000000L)
-#define GENERIC_ALL    (0x10000000L)
 
 /* SID */
 #define SECURITY_NULL_RID      (0L)
@@ -5052,33 +5093,6 @@ extern "C" {
 
 #define POLYFILL_LAST          (2)
 
-#define STATUS_WAIT_0                  (0x00000000L)
-#define STATUS_ABANDONED_WAIT_0        (0x00000080L)
-#define STATUS_USER_APC                (0x000000C0L)
-#define STATUS_TIMEOUT                 (0x00000102L)
-#define STATUS_PENDING                 (0x00000103L)
-#define STATUS_GUARD_PAGE_VIOLATION    (0x80000001L)
-#define STATUS_DATATYPE_MISALIGNMENT   (0x80000002L)
-#define STATUS_BREAKPOINT              (0x80000003L)
-#define STATUS_SINGLE_STEP             (0x80000004L)
-#define STATUS_IN_PAGE_ERROR           (0xC0000006L)
-#define STATUS_INVALID_HANDLE          (0xC0000008L)
-#define STATUS_ILLEGAL_INSTRUCTION     (0xC000001DL)
-#define STATUS_NONCONTINUABLE_EXCEPTION (0xC0000025L)
-#define STATUS_INVALID_DISPOSITION     (0xC0000026L)
-#define STATUS_ARRAY_BOUNDS_EXCEEDED   (0xC000008CL)
-#define STATUS_FLOAT_DENORMAL_OPERAND  (0xC000008DL)
-#define STATUS_FLOAT_DIVIDE_BY_ZERO    (0xC000008EL)
-#define STATUS_FLOAT_INEXACT_RESULT    (0xC000008FL)
-#define STATUS_FLOAT_INVALID_OPERATION         (0xC0000090L)
-#define STATUS_FLOAT_OVERFLOW          (0xC0000091L)
-#define STATUS_FLOAT_STACK_CHECK       (0xC0000092L)
-#define STATUS_FLOAT_UNDERFLOW         (0xC0000093L)
-#define STATUS_INTEGER_DIVIDE_BY_ZERO  (0xC0000094L)
-#define STATUS_INTEGER_OVERFLOW        (0xC0000095L)
-#define STATUS_PRIVILEGED_INSTRUCTION  (0xC0000096L)
-#define STATUS_STACK_OVERFLOW          (0xC00000FDL)
-#define STATUS_CONTROL_C_EXIT          (0xC000013AL)
 
 #define EXCEPTION_CTRL_C
 
@@ -5139,7 +5153,6 @@ DECLARE_HANDLE(HANDLE);
 
 #define ASCIICHAR AsciiChar
 #define FAR
-#define PACKED __attribute__((packed))
 
 #define FILTER_TEMP_DUPLICATE_ACCOUNT       (0x0001)
 #define FILTER_NORMAL_ACCOUNT               (0x0002)
@@ -5164,4 +5177,6 @@ DECLARE_HANDLE(HANDLE);
 }
 #endif /* __cplusplus */
 
+#endif /* WIN32_LEAN_AND_MEAN */                                                              
+                                                              
 #endif /* _GNU_H_WINDOWS32_DEFINES */
index 9c52234..b472084 100644 (file)
@@ -31,6 +31,8 @@
 #ifndef _GNU_H_WINDOWS32_FUNCTIONS
 #define _GNU_H_WINDOWS32_FUNCTIONS
 
+#ifndef WIN32_LEAN_AND_MEAN
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
@@ -7430,6 +7432,9 @@ DWORD STDCALL NetGroupEnum (LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD,
 DWORD STDCALL NetLocalGroupEnum (LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD,
                                LPDWORD, LPDWORD);
 
+
+VOID CopyMemory(PVOID Destination, CONST VOID* Source, DWORD Length);
+
 void WINAPI
 SHAddToRecentDocs (UINT, LPCVOID);
 
@@ -7481,4 +7486,6 @@ SHLoadInProc (REFCLSID);
 }
 #endif /* __cplusplus */
 
+#endif /* WIN32_LEAN_AND_MEAN */
+
 #endif /* _GNU_H_WINDOWS32_FUNCTIONS */
index 4943955..8b36906 100644 (file)
@@ -38,6 +38,11 @@ extern char _ctmp;
 
 #define upalpha ('A' - 'a')
 
+extern inline int isspace(char c)
+{
+   return(c==' '||c=='\t');
+}
+
 extern inline char toupper(char c)
 {
    if ((c>='a') && (c<='z')) return (c+upalpha);
index 21ea94a..113a467 100644 (file)
@@ -51,6 +51,7 @@ typedef struct
    unsigned char io_bitmap[1];
 } hal_thread_state;
 
+
 /*
  * FUNCTION: Probes for a PCI bus
  * RETURNS: True if found
index 09a373a..19d6a5f 100644 (file)
 #include <ddk/ntddk.h>
 #include <internal/ob.h>
 
+extern POBJECT_TYPE IoDeviceType;
+extern POBJECT_TYPE IoFileType;
+extern POBJECT_TYPE IoSymbolicLinkType;
+
 /*
  * FUNCTION: Called to initalize a loaded driver
  * ARGUMENTS: 
@@ -36,5 +40,9 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
                                     PKEVENT UserEvent,
                                     PIO_STATUS_BLOCK IoStatusBlock,
                                     PDEVICE_OBJECT DeviceToMount);
-
+NTSTATUS IoPageRead(PFILE_OBJECT FileObject,
+                   PVOID Address,
+                    PLARGE_INTEGER Offset,
+                    PIO_STATUS_BLOCK StatusBlock);
+VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost);
 #endif
index 7061b11..28fb8b0 100644 (file)
 
 /* INTERNAL KERNEL FUNCTIONS ************************************************/
 
+VOID KeAcquireDispatcherDatabaseLock(BOOLEAN Wait);
+VOID KeReleaseDispatcherDatabaseLock(BOOLEAN Wait);
+VOID KeDispatcherObjectWake(DISPATCHER_HEADER* hdr);
+
 VOID KiInterruptDispatch(ULONG irq);
 VOID KiDispatchInterrupt(ULONG irq);
 VOID KiTimerInterrupt(VOID);
index 2398fca..88b1218 100644 (file)
@@ -5,8 +5,6 @@
 #ifndef __INCLUDE_INTERNAL_MM_H
 #define __INCLUDE_INTERNAL_MM_H
 
-#define PAGE_SYSTEM (0x80000000)
-
 #include <internal/linkage.h>
 #include <internal/ntoskrnl.h>
 #include <windows.h>
 enum
 {
    MEMORY_AREA_INVALID,
-   MEMORY_AREA_SECTION_VIEW,
+   MEMORY_AREA_SECTION_VIEW_COMMIT,
    MEMORY_AREA_CONTINUOUS_MEMORY,
    MEMORY_AREA_NO_CACHE,
    MEMORY_AREA_IO_MAPPING,
    MEMORY_AREA_SYSTEM,
    MEMORY_AREA_MDL_MAPPING,
+   MEMORY_AREA_COMMIT,
+   MEMORY_AREA_RESERVE,
+   MEMORY_AREA_SECTION_VIEW_RESERVE,
 };
 
 typedef struct
 {
    CSHORT Type;
    CSHORT Size;
-   FILE_OBJECT* File;
-} SECTION_OBJECT;
+   LARGE_INTEGER MaximumSize;
+   ULONG SectionPageProtection;
+   ULONG AllocateAttributes;
+   PFILE_OBJECT FileObject;
+} SECTION_OBJECT, *PSECTION_OBJECT;
 
 typedef struct
 {
    ULONG Type;
-   ULONG BaseAddress;
+   PVOID BaseAddress;
    ULONG Length;
    ULONG Attributes;
    LIST_ENTRY Entry;
@@ -47,22 +51,28 @@ typedef struct
             ULONG ViewOffset;
          } SectionData;
      } Data;
-} MEMORY_AREA;
+} MEMORY_AREA, *PMEMORY_AREA;
 
 
 NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
+                           PEPROCESS Process,
                            ULONG Type,
-                           PULONG BaseAddress,
+                           PVOID* BaseAddress,
                            ULONG Length,
                            ULONG Attributes,
                            MEMORY_AREA** Result);
-MEMORY_AREA* MmOpenMemoryAreaByAddress(ULONG Address);
+MEMORY_AREA* MmOpenMemoryAreaByAddress(PEPROCESS Process, PVOID Address);
 NTSTATUS MmInitMemoryAreas(VOID);
 VOID ExInitNonPagedPool(ULONG BaseAddress);
-NTSTATUS MmFreeMemoryArea(PVOID BaseAddress,
+NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
+                         PVOID BaseAddress,
                          ULONG Length,
                          BOOLEAN FreePages);
-VOID MmDumpMemoryAreas(VOID);
+VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead);
+NTSTATUS MmLockMemoryArea(MEMORY_AREA* MemoryArea);
+NTSTATUS MmUnlockMemoryArea(MEMORY_AREA* MemoryArea);
+NTSTATUS MmInitSectionImplementation(VOID);
+
 
 /*
  * FUNCTION: Gets a page with a restricted max physical address (i.e.
@@ -96,4 +106,13 @@ void mark_page_not_writable(unsigned int vaddr);
 
 void VirtualInit(boot_param* bp);
 
+#define MM_LOWEST_USER_ADDRESS (4096)
+
+PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
+                              PMEMORY_AREA OriginalMemoryArea,
+                              PVOID BaseAddress,
+                              ULONG Length,
+                              ULONG NewType,
+                              ULONG NewAttributes);
+
 #endif
index 4d71597..d73b40d 100644 (file)
@@ -44,6 +44,8 @@ enum
    OBJTYP_DEVICE,
    OBJTYP_THREAD,
    OBJTYP_FILE,
+   OBJTYP_PROCESS,
+   OBJTYP_SECTION,
    OBJTYP_MAX,
 };
 
@@ -51,27 +53,23 @@ BOOL ObAddObjectToNameSpace(PUNICODE_STRING path, POBJECT_HEADER Object);
 
 VOID ObRegisterType(CSHORT id, OBJECT_TYPE* type);
 
-VOID ObInitializeObjectHeader(CSHORT id, PWSTR name,
+VOID ObInitializeObjectHeader(POBJECT_TYPE Type, PWSTR name,
                              POBJECT_HEADER obj);
-
-/*
- * FUNCTION: Get the size of an object
- * ARGUMENTS:
- *         Type = Object type
- * RETURNS: The size in bytes
- */
-ULONG ObSizeOf(CSHORT Type);
-HANDLE ObAddHandle(PVOID obj);
+HANDLE ObInsertHandle(PKPROCESS Process, PVOID ObjectBody,
+                     ACCESS_MASK GrantedAccess, BOOLEAN Inherit);
 VOID ObDeleteHandle(HANDLE Handle);
 NTSTATUS ObLookupObject(HANDLE rootdir, PWSTR string, PVOID* Object,
                         PWSTR* UnparsedSection);
-PVOID ObGetObjectByHandle(HANDLE h);
+
 PVOID ObGenericCreateObject(PHANDLE Handle,
                            ACCESS_MASK DesiredAccess,
                            POBJECT_ATTRIBUTES ObjectAttributes,
-                           CSHORT Type);
+                           POBJECT_TYPE Type);
 NTSTATUS ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
                            PVOID* Object, PWSTR* UnparsedSection);
+VOID ObInitializeHandleTable(PKPROCESS Parent, BOOLEAN Inherit,
+                            PKPROCESS Process);
+VOID ObRemoveEntry(POBJECT_HEADER Header);
 
 /*
  * FUNCTION: Creates an entry within a directory
@@ -92,6 +90,18 @@ extern inline PVOID HEADER_TO_BODY(POBJECT_HEADER obj)
    return(((void *)obj)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER));
 }
 
-#define OBJECT_ALLOC_SIZE(type) (ObSizeOf(type)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER))
+#define OBJECT_ALLOC_SIZE(type) (type->NonpagedPoolCharge+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER))
+
+/*
+ * PURPOSE: Defines a handle
+ */
+typedef struct
+{
+   PVOID ObjectBody;
+   ACCESS_MASK GrantedAccess;
+   BOOLEAN Inherit;
+} HANDLE_REP, *PHANDLE_REP;
+
+PHANDLE_REP ObTranslateHandle(PKPROCESS Process, HANDLE h);
 
 #endif /* __INCLUDE_INTERNAL_OBJMGR_H */
index 0b5fd1a..d517b8b 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <internal/linkage.h>
 
-static PVOID ExAllocatePagedPool(POOL_TYPE Type, ULONG size);
-static PVOID ExAllocateNonPagedPool(POOL_TYPE Type, ULONG size);
+PVOID ExAllocatePagedPoolWithTag(POOL_TYPE Type, ULONG size, ULONG Tag);
+PVOID ExAllocateNonPagedPoolWithTag(POOL_TYPE Type, ULONG size, ULONG Tag);
 
 #endif /* __INTERNAL_POOL_H */
index 6856e30..623c200 100644 (file)
@@ -3,12 +3,16 @@
 
 #include <internal/hal.h>
 
-extern EPROCESS SystemProcess;
+extern PEPROCESS SystemProcess;
 extern HANDLE SystemProcessHandle;
 
+extern POBJECT_TYPE PsThreadType;
+extern POBJECT_TYPE PsProcessType;
+
 void PsInitThreadManagment(void);
 VOID PsInitProcessManagment(VOID);
 VOID PsInitIdleThread(VOID);
+VOID PsDispatchThread(VOID);
 
 /*
  * PURPOSE: Thread states
@@ -45,9 +49,9 @@ enum
  * Functions the HAL must provide
  */
 
-void HalInitFirstTask(PKTHREAD thread);
-BOOLEAN HalInitTask(PKTHREAD thread, PKSTART_ROUTINE fn, 
-                PVOID StartContext);
+void HalInitFirstTask(PETHREAD thread);
+BOOLEAN HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext);
 void HalTaskSwitch(PKTHREAD thread);
+NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context);
 
 #endif
index 56a3d84..bd9f745 100644 (file)
@@ -9,9 +9,9 @@
 #ifndef __VERSION_H
 #define __VERSION_H
 
-#define KERNEL_VERSION   "0.0.11"
+#define KERNEL_VERSION   "0.0.12"
 #define KERNEL_MAJOR_VERSION    0
 #define KERNEL_MINOR_VERSION    0
-#define KERNEL_PATCH_LEVEL      11
+#define KERNEL_PATCH_LEVEL      12
 
 #endif
index 35c8398..7cc17d3 100644 (file)
@@ -105,6 +105,4 @@ typedef struct __HEAP
    HEAP_BLOCK          Start  __attribute__((aligned (8)));
 } HEAP, *PHEAP;
 
-//PHEAP        __ProcessHeap;
-
 #endif /* __INCLUDE_KERNEL32_HEAP_H */
index 10e04ab..0985c0f 100644 (file)
 #ifndef _GNU_H_WINDOWS32_STRUCTURES
 #define _GNU_H_WINDOWS32_STRUCTURES
 
+typedef struct _LARGE_INTEGER { 
+  DWORD LowPart; 
+  LONG  HighPart; 
+} LARGE_INTEGER, *PLARGE_INTEGER; 
+
+typedef struct _LIST_ENTRY { 
+  struct _LIST_ENTRY *Flink; 
+  struct _LIST_ENTRY *Blink; 
+} LIST_ENTRY, *PLIST_ENTRY; 
+
+typedef DWORD ACCESS_MASK; 
+
+
+typedef struct _SID_IDENTIFIER_AUTHORITY { 
+  BYTE Value[6]; 
+} SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY, 
+    *LPSID_IDENTIFIER_AUTHORITY; 
+
+
+typedef struct _ACL {
+  BYTE AclRevision; 
+  BYTE Sbz1; 
+  WORD AclSize; 
+  WORD AceCount; 
+  WORD Sbz2; 
+} ACL, *PACL; 
+
+
+typedef struct _SID {
+   BYTE  Revision;
+   BYTE  SubAuthorityCount;
+   SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
+   DWORD SubAuthority[ANYSIZE_ARRAY];
+} SID, *PSID;
+
+typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
+
+typedef struct _SECURITY_DESCRIPTOR {
+  BYTE  Revision;
+  BYTE  Sbz1;
+  SECURITY_DESCRIPTOR_CONTROL Control;
+  PSID Owner;
+  PSID Group;
+  PACL Sacl;
+  PACL Dacl;
+} SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
+
+typedef struct _SECURITY_QUALITY_OF_SERVICE { 
+  DWORD Length; 
+  SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; 
+  /* SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; */
+  WINBOOL ContextTrackingMode; 
+  BOOLEAN EffectiveOnly; 
+} SECURITY_QUALITY_OF_SERVICE; 
+
+typedef LARGE_INTEGER LUID, *PLUID;
+
+typedef struct _TOKEN_SOURCE {
+  CHAR SourceName[8]; 
+  LUID SourceIdentifier; 
+} TOKEN_SOURCE; 
+
+typedef struct _PARTITION_INFORMATION { 
+  BYTE PartitionType; 
+  BOOLEAN BootIndicator; 
+  BOOLEAN RecognizedPartition; 
+  BOOLEAN RewritePartition; 
+  LARGE_INTEGER StartingOffset; 
+  LARGE_INTEGER PartitionLength; 
+  LARGE_INTEGER HiddenSectors; 
+} PARTITION_INFORMATION ; 
+
+typedef struct _SINGLE_LIST_ENTRY { 
+  struct _SINGLE_LIST_ENTRY *Next; 
+} SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY; 
+
+typedef struct _CRITICAL_SECTION_DEBUG {
+    WORD   Type;
+    WORD   CreatorBackTraceIndex;
+    struct _CRITICAL_SECTION *CriticalSection;
+    LIST_ENTRY ProcessLocksList;
+    DWORD EntryCount;
+    DWORD ContentionCount;
+    DWORD Depth;
+    PVOID OwnerBackTrace[ 5 ];
+} CRITICAL_SECTION_DEBUG, *PCRITICAL_SECTION_DEBUG;
+
+typedef struct _CRITICAL_SECTION {
+    PCRITICAL_SECTION_DEBUG DebugInfo;
+    LONG LockCount;
+    LONG RecursionCount;
+    HANDLE OwningThread;
+    HANDLE LockSemaphore;
+    DWORD Reserved;
+} CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION;
+
+typedef struct _ULARGE_INTEGER { 
+  DWORD LowPart; 
+  DWORD HighPart; 
+} ULARGE_INTEGER, *PULARGE_INTEGER; 
+
+typedef struct _GENERIC_MAPPING { 
+  ACCESS_MASK GenericRead; 
+  ACCESS_MASK GenericWrite; 
+  ACCESS_MASK GenericExecute; 
+  ACCESS_MASK GenericAll; 
+} GENERIC_MAPPING, *PGENERIC_MAPPING; 
+
+typedef struct _LUID_AND_ATTRIBUTES { 
+  LUID  Luid; 
+  DWORD Attributes; 
+} LUID_AND_ATTRIBUTES; 
+
+typedef struct _PRIVILEGE_SET { 
+  DWORD PrivilegeCount; 
+  DWORD Control; 
+  LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY]; 
+} PRIVILEGE_SET, *PPRIVILEGE_SET, *LPPRIVILEGE_SET; 
+
+#ifdef __i386__
+
+typedef struct _FLOATING_SAVE_AREA {
+    DWORD   ControlWord;
+    DWORD   StatusWord;
+    DWORD   TagWord;
+    DWORD   ErrorOffset;
+    DWORD   ErrorSelector;
+    DWORD   DataOffset;
+    DWORD   DataSelector;
+    BYTE    RegisterArea[80];
+    DWORD   Cr0NpxState;
+} FLOATING_SAVE_AREA;
+
+typedef struct _CONTEXT {
+    DWORD ContextFlags;
+
+    DWORD   Dr0;
+    DWORD   Dr1;
+    DWORD   Dr2;
+    DWORD   Dr3;
+    DWORD   Dr6;
+    DWORD   Dr7;
+
+    FLOATING_SAVE_AREA FloatSave;
+
+    DWORD   SegGs;
+    DWORD   SegFs;
+    DWORD   SegEs;
+    DWORD   SegDs;
+
+    DWORD   Edi;
+    DWORD   Esi;
+    DWORD   Ebx;
+    DWORD   Edx;
+    DWORD   Ecx;
+    DWORD   Eax;
+
+    DWORD   Ebp;
+    DWORD   Eip;
+    DWORD   SegCs; 
+    DWORD   EFlags;
+    DWORD   Esp;
+    DWORD   SegSs;
+} CONTEXT, *PCONTEXT, *LPCONTEXT;
+
+#else /* __ppc__ */
+
+typedef struct
+  {
+    /* Floating point registers returned when CONTEXT_FLOATING_POINT is set */
+    double Fpr0;
+    double Fpr1;
+    double Fpr2;
+    double Fpr3;
+    double Fpr4;
+    double Fpr5;
+    double Fpr6;
+    double Fpr7;
+    double Fpr8;
+    double Fpr9;
+    double Fpr10;
+    double Fpr11;
+    double Fpr12;
+    double Fpr13;
+    double Fpr14;
+    double Fpr15;
+    double Fpr16;
+    double Fpr17;
+    double Fpr18;
+    double Fpr19;
+    double Fpr20;
+    double Fpr21;
+    double Fpr22;
+    double Fpr23;
+    double Fpr24;
+    double Fpr25;
+    double Fpr26;
+    double Fpr27;
+    double Fpr28;
+    double Fpr29;
+    double Fpr30;
+    double Fpr31;
+    double Fpscr;
+
+    /* Integer registers returned when CONTEXT_INTEGER is set.  */
+    DWORD Gpr0;
+    DWORD Gpr1;
+    DWORD Gpr2;
+    DWORD Gpr3;
+    DWORD Gpr4;
+    DWORD Gpr5;
+    DWORD Gpr6;
+    DWORD Gpr7;
+    DWORD Gpr8;
+    DWORD Gpr9;
+    DWORD Gpr10;
+    DWORD Gpr11;
+    DWORD Gpr12;
+    DWORD Gpr13;
+    DWORD Gpr14;
+    DWORD Gpr15;
+    DWORD Gpr16;
+    DWORD Gpr17;
+    DWORD Gpr18;
+    DWORD Gpr19;
+    DWORD Gpr20;
+    DWORD Gpr21;
+    DWORD Gpr22;
+    DWORD Gpr23;
+    DWORD Gpr24;
+    DWORD Gpr25;
+    DWORD Gpr26;
+    DWORD Gpr27;
+    DWORD Gpr28;
+    DWORD Gpr29;
+    DWORD Gpr30;
+    DWORD Gpr31;
+
+    DWORD Cr;                  /* Condition register */
+    DWORD Xer;                 /* Fixed point exception register */
+
+    /* The following are set when CONTEXT_CONTROL is set.  */
+    DWORD Msr;                 /* Machine status register */
+    DWORD Iar;                 /* Instruction address register */
+    DWORD Lr;                  /* Link register */
+    DWORD Ctr;                 /* Control register */
+
+    /* Control which context values are returned */
+    DWORD ContextFlags;
+    DWORD Fill[3];
+
+    /* Registers returned if CONTEXT_DEBUG_REGISTERS is set.  */
+    DWORD Dr0;                          /* Breakpoint Register 1 */
+    DWORD Dr1;                          /* Breakpoint Register 2 */
+    DWORD Dr2;                          /* Breakpoint Register 3 */
+    DWORD Dr3;                          /* Breakpoint Register 4 */
+    DWORD Dr4;                          /* Breakpoint Register 5 */
+    DWORD Dr5;                          /* Breakpoint Register 6 */
+    DWORD Dr6;                          /* Debug Status Register */
+    DWORD Dr7;                          /* Debug Control Register */
+} CONTEXT, *PCONTEXT, *LPCONTEXT;
+#endif
+
+
+typedef struct value_ent {
+    LPTSTR   ve_valuename;
+    DWORD ve_valuelen;
+    DWORD ve_valueptr;
+    DWORD ve_type;
+} VALENT, *PVALENT;
+
+
+typedef struct _EXCEPTION_RECORD { 
+  DWORD ExceptionCode; 
+  DWORD ExceptionFlags; 
+  struct _EXCEPTION_RECORD *ExceptionRecord; 
+  PVOID ExceptionAddress; 
+  DWORD NumberParameters; 
+  DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; 
+} EXCEPTION_RECORD, *PEXCEPTION_RECORD, *LPEXCEPTION_RECORD; 
+
+typedef struct _DRIVE_LAYOUT_INFORMATION { 
+  DWORD  PartitionCount; 
+  DWORD  Signature; 
+  PARTITION_INFORMATION  PartitionEntry[1]; 
+} DRIVE_LAYOUT_INFORMATION; 
+
+typedef struct _KEY_EVENT_RECORD { 
+  WINBOOL bKeyDown;             
+  WORD wRepeatCount;         
+  WORD wVirtualKeyCode;      
+  WORD wVirtualScanCode; 
+
+  char AsciiChar;
+  char pad;
+#if 0
+  union { 
+    WCHAR UnicodeChar; 
+    CHAR  AsciiChar; 
+  } uChar;  
+#endif
+  DWORD dwControlKeyState;   
+} KEY_EVENT_RECORD PACKED;
+
+typedef struct _COORD {
+  SHORT X;    
+  SHORT Y;    
+} COORD; 
+
+typedef struct _MOUSE_EVENT_RECORD { 
+  COORD dwMousePosition; 
+  DWORD dwButtonState; 
+  DWORD dwControlKeyState; 
+  DWORD dwEventFlags; 
+} MOUSE_EVENT_RECORD; 
+
+typedef struct _DISK_GEOMETRY { 
+  LARGE_INTEGER  Cylinders; 
+  MEDIA_TYPE  MediaType; 
+  DWORD  TracksPerCylinder; 
+  DWORD  SectorsPerTrack; 
+  DWORD  BytesPerSector; 
+} DISK_GEOMETRY ; 
+
+
+#ifndef WIN32_LEAN_AND_MEAN
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
-
+   
 typedef struct _ABC {
   int     abcA; 
   UINT    abcB; 
@@ -60,7 +388,6 @@ typedef struct _ACE_HEADER {
   WORD AceSize; 
 } ACE_HEADER; 
 
-typedef DWORD ACCESS_MASK; 
 typedef ACCESS_MASK REGSAM;
 
 typedef struct _ACCESS_ALLOWED_ACE {
@@ -81,14 +408,6 @@ typedef struct tagACCESSTIMEOUT {
   DWORD iTimeOutMSec; 
 } ACCESSTIMEOUT; 
 
-typedef struct _ACL {
-  BYTE AclRevision; 
-  BYTE Sbz1; 
-  WORD AclSize; 
-  WORD AceCount; 
-  WORD Sbz2; 
-} ACL, *PACL; 
-
 typedef struct _ACL_REVISION_INFORMATION {    
   DWORD   AclRevision; 
 } ACL_REVISION_INFORMATION; 
@@ -555,276 +874,94 @@ typedef struct _COMM_CONFIG {
   WORD  wReserved;
   DCB   dcb;
   DWORD dwProviderSubType;
-  DWORD dwProviderOffset;
-  DWORD dwProviderSize;
-  WCHAR wcProviderData[1];
-} COMMCONFIG, *LPCOMMCONFIG;
-
-typedef struct _COMMPROP {
-  WORD  wPacketLength;       
-  WORD  wPacketVersion;      
-  DWORD dwServiceMask;       
-  DWORD dwReserved1;         
-  DWORD dwMaxTxQueue;        
-  DWORD dwMaxRxQueue;        
-  DWORD dwMaxBaud;           
-  DWORD dwProvSubType;       
-  DWORD dwProvCapabilities;  
-  DWORD dwSettableParams;    
-  DWORD dwSettableBaud;      
-  WORD  wSettableData;       
-  WORD  wSettableStopParity; 
-  DWORD dwCurrentTxQueue;    
-  DWORD dwCurrentRxQueue;    
-  DWORD dwProvSpec1;         
-  DWORD dwProvSpec2;         
-  WCHAR wcProvChar[1];       
-} COMMPROP, *LPCOMMPROP; 
-
-typedef struct _COMMTIMEOUTS {
-  DWORD ReadIntervalTimeout; 
-  DWORD ReadTotalTimeoutMultiplier; 
-  DWORD ReadTotalTimeoutConstant; 
-  DWORD WriteTotalTimeoutMultiplier; 
-  DWORD WriteTotalTimeoutConstant; 
-} COMMTIMEOUTS,*LPCOMMTIMEOUTS; 
-
-typedef struct tagCOMPAREITEMSTRUCT {
-  UINT  CtlType; 
-  UINT  CtlID; 
-  HWND  hwndItem; 
-  UINT  itemID1; 
-  DWORD itemData1; 
-  UINT  itemID2; 
-  DWORD itemData2; 
-} COMPAREITEMSTRUCT; 
-
-typedef struct {
-  COLORREF crText;        
-  COLORREF crBackground;  
-  DWORD dwEffects;        
-} COMPCOLOR;
-
-typedef struct _tagCOMPOSITIONFORM {
-  DWORD  dwStyle;       
-  POINT  ptCurrentPos;  
-  RECT   rcArea;        
-} COMPOSITIONFORM, *LPCOMPOSITIONFORM;
-
-typedef struct _COMSTAT {
-  DWORD fCtsHold : 1;   
-  DWORD fDsrHold : 1;   
-  DWORD fRlsdHold : 1;  
-  DWORD fXoffHold : 1;  
-  DWORD fXoffSent : 1;  
-  DWORD fEof : 1;       
-  DWORD fTxim : 1;      
-  DWORD fReserved : 25; 
-  DWORD cbInQue;        
-  DWORD cbOutQue;       
-} COMSTAT, *LPCOMSTAT; 
-
-typedef struct _CONSOLE_CURSOR_INFO {
-  DWORD  dwSize; 
-  WINBOOL   bVisible; 
-} CONSOLE_CURSOR_INFO, *PCONSOLE_CURSOR_INFO; 
-
-typedef struct _COORD {
-  SHORT X;    
-  SHORT Y;    
-} COORD; 
-
-typedef struct _SMALL_RECT { 
-  SHORT Left;      
-  SHORT Top;       
-  SHORT Right;     
-  SHORT Bottom;    
-} SMALL_RECT, *PSMALL_RECT; 
-typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
-  COORD      dwSize; 
-  COORD      dwCursorPosition; 
-  WORD       wAttributes; 
-  SMALL_RECT srWindow; 
-  COORD      dwMaximumWindowSize; 
-} CONSOLE_SCREEN_BUFFER_INFO, *PCONSOLE_SCREEN_BUFFER_INFO ; 
-
-#ifdef __i386__
-
-typedef struct _FLOATING_SAVE_AREA {
-    DWORD   ControlWord;
-    DWORD   StatusWord;
-    DWORD   TagWord;
-    DWORD   ErrorOffset;
-    DWORD   ErrorSelector;
-    DWORD   DataOffset;
-    DWORD   DataSelector;
-    BYTE    RegisterArea[80];
-    DWORD   Cr0NpxState;
-} FLOATING_SAVE_AREA;
-
-typedef struct _CONTEXT {
-    DWORD ContextFlags;
-
-    DWORD   Dr0;
-    DWORD   Dr1;
-    DWORD   Dr2;
-    DWORD   Dr3;
-    DWORD   Dr6;
-    DWORD   Dr7;
-
-    FLOATING_SAVE_AREA FloatSave;
-
-    DWORD   SegGs;
-    DWORD   SegFs;
-    DWORD   SegEs;
-    DWORD   SegDs;
-
-    DWORD   Edi;
-    DWORD   Esi;
-    DWORD   Ebx;
-    DWORD   Edx;
-    DWORD   Ecx;
-    DWORD   Eax;
-
-    DWORD   Ebp;
-    DWORD   Eip;
-    DWORD   SegCs; 
-    DWORD   EFlags;
-    DWORD   Esp;
-    DWORD   SegSs;
-} CONTEXT, *PCONTEXT, *LPCONTEXT;
-
-#else /* __ppc__ */
-
-typedef struct
-  {
-    /* Floating point registers returned when CONTEXT_FLOATING_POINT is set */
-    double Fpr0;
-    double Fpr1;
-    double Fpr2;
-    double Fpr3;
-    double Fpr4;
-    double Fpr5;
-    double Fpr6;
-    double Fpr7;
-    double Fpr8;
-    double Fpr9;
-    double Fpr10;
-    double Fpr11;
-    double Fpr12;
-    double Fpr13;
-    double Fpr14;
-    double Fpr15;
-    double Fpr16;
-    double Fpr17;
-    double Fpr18;
-    double Fpr19;
-    double Fpr20;
-    double Fpr21;
-    double Fpr22;
-    double Fpr23;
-    double Fpr24;
-    double Fpr25;
-    double Fpr26;
-    double Fpr27;
-    double Fpr28;
-    double Fpr29;
-    double Fpr30;
-    double Fpr31;
-    double Fpscr;
-
-    /* Integer registers returned when CONTEXT_INTEGER is set.  */
-    DWORD Gpr0;
-    DWORD Gpr1;
-    DWORD Gpr2;
-    DWORD Gpr3;
-    DWORD Gpr4;
-    DWORD Gpr5;
-    DWORD Gpr6;
-    DWORD Gpr7;
-    DWORD Gpr8;
-    DWORD Gpr9;
-    DWORD Gpr10;
-    DWORD Gpr11;
-    DWORD Gpr12;
-    DWORD Gpr13;
-    DWORD Gpr14;
-    DWORD Gpr15;
-    DWORD Gpr16;
-    DWORD Gpr17;
-    DWORD Gpr18;
-    DWORD Gpr19;
-    DWORD Gpr20;
-    DWORD Gpr21;
-    DWORD Gpr22;
-    DWORD Gpr23;
-    DWORD Gpr24;
-    DWORD Gpr25;
-    DWORD Gpr26;
-    DWORD Gpr27;
-    DWORD Gpr28;
-    DWORD Gpr29;
-    DWORD Gpr30;
-    DWORD Gpr31;
+  DWORD dwProviderOffset;
+  DWORD dwProviderSize;
+  WCHAR wcProviderData[1];
+} COMMCONFIG, *LPCOMMCONFIG;
 
-    DWORD Cr;                  /* Condition register */
-    DWORD Xer;                 /* Fixed point exception register */
+typedef struct _COMMPROP {
+  WORD  wPacketLength;       
+  WORD  wPacketVersion;      
+  DWORD dwServiceMask;       
+  DWORD dwReserved1;         
+  DWORD dwMaxTxQueue;        
+  DWORD dwMaxRxQueue;        
+  DWORD dwMaxBaud;           
+  DWORD dwProvSubType;       
+  DWORD dwProvCapabilities;  
+  DWORD dwSettableParams;    
+  DWORD dwSettableBaud;      
+  WORD  wSettableData;       
+  WORD  wSettableStopParity; 
+  DWORD dwCurrentTxQueue;    
+  DWORD dwCurrentRxQueue;    
+  DWORD dwProvSpec1;         
+  DWORD dwProvSpec2;         
+  WCHAR wcProvChar[1];       
+} COMMPROP, *LPCOMMPROP; 
 
-    /* The following are set when CONTEXT_CONTROL is set.  */
-    DWORD Msr;                 /* Machine status register */
-    DWORD Iar;                 /* Instruction address register */
-    DWORD Lr;                  /* Link register */
-    DWORD Ctr;                 /* Control register */
+typedef struct _COMMTIMEOUTS {
+  DWORD ReadIntervalTimeout; 
+  DWORD ReadTotalTimeoutMultiplier; 
+  DWORD ReadTotalTimeoutConstant; 
+  DWORD WriteTotalTimeoutMultiplier; 
+  DWORD WriteTotalTimeoutConstant; 
+} COMMTIMEOUTS,*LPCOMMTIMEOUTS; 
 
-    /* Control which context values are returned */
-    DWORD ContextFlags;
-    DWORD Fill[3];
+typedef struct tagCOMPAREITEMSTRUCT {
+  UINT  CtlType; 
+  UINT  CtlID; 
+  HWND  hwndItem; 
+  UINT  itemID1; 
+  DWORD itemData1; 
+  UINT  itemID2; 
+  DWORD itemData2; 
+} COMPAREITEMSTRUCT; 
 
-    /* Registers returned if CONTEXT_DEBUG_REGISTERS is set.  */
-    DWORD Dr0;                          /* Breakpoint Register 1 */
-    DWORD Dr1;                          /* Breakpoint Register 2 */
-    DWORD Dr2;                          /* Breakpoint Register 3 */
-    DWORD Dr3;                          /* Breakpoint Register 4 */
-    DWORD Dr4;                          /* Breakpoint Register 5 */
-    DWORD Dr5;                          /* Breakpoint Register 6 */
-    DWORD Dr6;                          /* Debug Status Register */
-    DWORD Dr7;                          /* Debug Control Register */
-} CONTEXT, *PCONTEXT, *LPCONTEXT;
-#endif
+typedef struct {
+  COLORREF crText;        
+  COLORREF crBackground;  
+  DWORD dwEffects;        
+} COMPCOLOR;
 
-typedef struct _LIST_ENTRY { 
-  struct _LIST_ENTRY *Flink; 
-  struct _LIST_ENTRY *Blink; 
-} LIST_ENTRY, *PLIST_ENTRY; 
-typedef struct _CRITICAL_SECTION_DEBUG {
-    WORD   Type;
-    WORD   CreatorBackTraceIndex;
-    struct _CRITICAL_SECTION *CriticalSection;
-    LIST_ENTRY ProcessLocksList;
-    DWORD EntryCount;
-    DWORD ContentionCount;
-    DWORD Depth;
-    PVOID OwnerBackTrace[ 5 ];
-} CRITICAL_SECTION_DEBUG, *PCRITICAL_SECTION_DEBUG;
+typedef struct _tagCOMPOSITIONFORM {
+  DWORD  dwStyle;       
+  POINT  ptCurrentPos;  
+  RECT   rcArea;        
+} COMPOSITIONFORM, *LPCOMPOSITIONFORM;
 
-typedef struct _CRITICAL_SECTION {
-    PCRITICAL_SECTION_DEBUG DebugInfo;
-    LONG LockCount;
-    LONG RecursionCount;
-    HANDLE OwningThread;
-    HANDLE LockSemaphore;
-    DWORD Reserved;
-} CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION;
+typedef struct _COMSTAT {
+  DWORD fCtsHold : 1;   
+  DWORD fDsrHold : 1;   
+  DWORD fRlsdHold : 1;  
+  DWORD fXoffHold : 1;  
+  DWORD fXoffSent : 1;  
+  DWORD fEof : 1;       
+  DWORD fTxim : 1;      
+  DWORD fReserved : 25; 
+  DWORD cbInQue;        
+  DWORD cbOutQue;       
+} COMSTAT, *LPCOMSTAT; 
 
-typedef struct _SECURITY_QUALITY_OF_SERVICE { 
-  DWORD Length; 
-  SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; 
-  /* SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; */
-  WINBOOL ContextTrackingMode; 
-  BOOLEAN EffectiveOnly; 
-} SECURITY_QUALITY_OF_SERVICE; 
+typedef struct _CONSOLE_CURSOR_INFO {
+  DWORD  dwSize; 
+  WINBOOL   bVisible; 
+} CONSOLE_CURSOR_INFO, *PCONSOLE_CURSOR_INFO; 
+
+typedef struct _SMALL_RECT { 
+  SHORT Left;      
+  SHORT Top;       
+  SHORT Right;     
+  SHORT Bottom;    
+} SMALL_RECT, *PSMALL_RECT; 
+typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
+  COORD      dwSize; 
+  COORD      dwCursorPosition; 
+  WORD       wAttributes; 
+  SMALL_RECT srWindow; 
+  COORD      dwMaximumWindowSize; 
+} CONSOLE_SCREEN_BUFFER_INFO, *PCONSOLE_SCREEN_BUFFER_INFO ; 
 
 typedef struct tagCONVCONTEXT { 
   UINT  cb; 
@@ -1009,15 +1146,6 @@ typedef struct {
   BYTE rgb[1]; 
 } DDEUP; 
  
-typedef struct _EXCEPTION_RECORD { 
-  DWORD ExceptionCode; 
-  DWORD ExceptionFlags; 
-  struct _EXCEPTION_RECORD *ExceptionRecord; 
-  PVOID ExceptionAddress; 
-  DWORD NumberParameters; 
-  DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; 
-} EXCEPTION_RECORD, *PEXCEPTION_RECORD, *LPEXCEPTION_RECORD; 
 typedef struct _EXCEPTION_DEBUG_INFO {
   EXCEPTION_RECORD ExceptionRecord; 
   DWORD dwFirstChance; 
@@ -1176,20 +1304,7 @@ typedef struct tagDIBSECTION {
   HANDLE              dshSection; 
   DWORD               dsOffset; 
 } DIBSECTION; 
-typedef struct _LARGE_INTEGER { 
-  DWORD LowPart; 
-  LONG  HighPart; 
-} LARGE_INTEGER, *PLARGE_INTEGER; 
-typedef struct _DISK_GEOMETRY { 
-  LARGE_INTEGER  Cylinders; 
-  MEDIA_TYPE  MediaType; 
-  DWORD  TracksPerCylinder; 
-  DWORD  SectorsPerTrack; 
-  DWORD  BytesPerSector; 
-} DISK_GEOMETRY ; 
+   
 typedef struct _DISK_PERFORMANCE { 
   LARGE_INTEGER BytesRead; 
   LARGE_INTEGER BytesWritten; 
@@ -1274,21 +1389,7 @@ typedef struct {
   UINT uiLengthDrawn;  
 } DRAWTEXTPARAMS, *LPDRAWTEXTPARAMS; 
  
-typedef struct _PARTITION_INFORMATION { 
-  BYTE PartitionType; 
-  BOOLEAN BootIndicator; 
-  BOOLEAN RecognizedPartition; 
-  BOOLEAN RewritePartition; 
-  LARGE_INTEGER StartingOffset; 
-  LARGE_INTEGER PartitionLength; 
-  LARGE_INTEGER HiddenSectors; 
-} PARTITION_INFORMATION ; 
  
-typedef struct _DRIVE_LAYOUT_INFORMATION { 
-  DWORD  PartitionCount; 
-  DWORD  Signature; 
-  PARTITION_INFORMATION  PartitionEntry[1]; 
-} DRIVE_LAYOUT_INFORMATION; 
  
 typedef struct _DRIVER_INFO_1 { 
   LPTSTR pName; 
@@ -2255,12 +2356,6 @@ typedef struct tagGCP_RESULTS {
   UINT  nMaxFit;
 } GCP_RESULTS, *LPGCP_RESULTS;
  
-typedef struct _GENERIC_MAPPING { 
-  ACCESS_MASK GenericRead; 
-  ACCESS_MASK GenericWrite; 
-  ACCESS_MASK GenericExecute; 
-  ACCESS_MASK GenericAll; 
-} GENERIC_MAPPING, *PGENERIC_MAPPING; 
  
 typedef struct _GLYPHMETRICS { 
   UINT  gmBlackBoxX; 
@@ -2366,30 +2461,6 @@ typedef struct _IMAGEINFO {
   RECT    rcImage;  
 } IMAGEINFO; 
  
-typedef struct _KEY_EVENT_RECORD { 
-  WINBOOL bKeyDown;             
-  WORD wRepeatCount;         
-  WORD wVirtualKeyCode;      
-  WORD wVirtualScanCode; 
-
-  char AsciiChar;
-  char pad;
-#if 0
-  union { 
-    WCHAR UnicodeChar; 
-    CHAR  AsciiChar; 
-  } uChar;  
-#endif
-  DWORD dwControlKeyState;   
-} KEY_EVENT_RECORD PACKED;
-typedef struct _MOUSE_EVENT_RECORD { 
-  COORD dwMousePosition; 
-  DWORD dwButtonState; 
-  DWORD dwControlKeyState; 
-  DWORD dwEventFlags; 
-} MOUSE_EVENT_RECORD; 
 typedef struct _WINDOW_BUFFER_SIZE_RECORD { 
   COORD dwSize; 
 } WINDOW_BUFFER_SIZE_RECORD; 
@@ -2439,29 +2510,6 @@ typedef struct _JOB_INFO_1 {
   SYSTEMTIME Submitted; 
 } JOB_INFO_1; 
  
-typedef struct _SID_IDENTIFIER_AUTHORITY { 
-  BYTE Value[6]; 
-} SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY, 
-    *LPSID_IDENTIFIER_AUTHORITY; 
-typedef struct _SID {
-   BYTE  Revision;
-   BYTE  SubAuthorityCount;
-   SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
-   DWORD SubAuthority[ANYSIZE_ARRAY];
-} SID, *PSID;
-
-typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
-
-typedef struct _SECURITY_DESCRIPTOR {
-  BYTE  Revision;
-  BYTE  Sbz1;
-  SECURITY_DESCRIPTOR_CONTROL Control;
-  PSID Owner;
-  PSID Group;
-  PACL Sacl;
-  PACL Dacl;
-} SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
  
 typedef struct _JOB_INFO_2 { 
   DWORD      JobId; 
@@ -2541,12 +2589,7 @@ typedef struct _LOCALGROUP_MEMBERS_INFO_3 {
  
 typedef long FXPT16DOT16,  * LPFXPT16DOT16; 
 
-typedef LARGE_INTEGER LUID, *PLUID;
 
-typedef struct _LUID_AND_ATTRIBUTES { 
-  LUID  Luid; 
-  DWORD Attributes; 
-} LUID_AND_ATTRIBUTES; 
  
 typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
 typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
@@ -3472,11 +3515,6 @@ typedef struct _PRINTPROCESSOR_INFO_1 {
   LPTSTR pName; 
 } PRINTPROCESSOR_INFO_1; 
  
-typedef struct _PRIVILEGE_SET { 
-  DWORD PrivilegeCount; 
-  DWORD Control; 
-  LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY]; 
-} PRIVILEGE_SET, *PPRIVILEGE_SET, *LPPRIVILEGE_SET; 
  
 typedef struct _PROCESS_HEAP_ENTRY {  
   PVOID lpData; 
@@ -3839,9 +3877,6 @@ typedef struct _SID_AND_ATTRIBUTES {
 typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
 typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
 
-typedef struct _SINGLE_LIST_ENTRY { 
-  struct _SINGLE_LIST_ENTRY *Next; 
-} SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY; 
  
 typedef struct tagSOUNDSENTRY {  
   UINT cbSize; 
@@ -4083,11 +4118,6 @@ typedef struct tagTOGGLEKEYS {
   DWORD cbSize; 
   DWORD dwFlags; 
 } TOGGLEKEYS; 
-
-typedef struct _TOKEN_SOURCE {
-  CHAR SourceName[8]; 
-  LUID SourceIdentifier; 
-} TOKEN_SOURCE; 
  
 typedef struct _TOKEN_CONTROL { 
   LUID TokenId; 
@@ -4216,12 +4246,7 @@ typedef struct {
   UINT nSec;   
   UINT nInc;   
 } UDACCEL; 
-typedef struct _ULARGE_INTEGER { 
-  DWORD LowPart; 
-  DWORD HighPart; 
-} ULARGE_INTEGER, *PULARGE_INTEGER; 
+  
 typedef struct _UNIVERSAL_NAME_INFO { 
   LPTSTR  lpUniversalName; 
 } UNIVERSAL_NAME_INFO; 
@@ -4232,13 +4257,6 @@ typedef struct tagUSEROBJECTFLAGS {
   DWORD dwFlags; 
 } USEROBJECTFLAGS; 
  
-typedef struct value_ent {
-    LPTSTR   ve_valuename;
-    DWORD ve_valuelen;
-    DWORD ve_valueptr;
-    DWORD ve_type;
-} VALENT, *PVALENT;
-
 typedef struct _VERIFY_INFORMATION { 
   LARGE_INTEGER  StartingOffset; 
   DWORD  Length; 
@@ -4555,5 +4573,7 @@ typedef struct
 }
 #endif /* __cplusplus */
 
+#endif /* WIN32_LEAN_AND_MEAN */
+
 #endif /* _GNU_H_WINDOWS32_STRUCTURES */
 
index fb1899e..20752a4 100644 (file)
@@ -41,7 +41,7 @@
 #include <base.h>
 
 /* WIN32 messages */
-#ifndef _WIN32_LEAN_AND_MEAN
+#ifndef WIN32_LEAN_AND_MEAN
 #include <messages.h>
 #endif
 
 #include <structs.h>
 
 /* WIN32 functions */
-#ifndef _WIN32_LEAN_AND_MEAN
+#ifndef WIN32_LEAN_AND_MEAN
 #include <funcs.h>
 #endif
 
 #endif /* ! defined (RC_INVOKED) */
 
 /* WIN32 error codes */
+#ifndef WIN32_LEAN_AND_MEAN
 #include <errors.h>
+#endif
 
 #ifndef RC_INVOKED
 
 /* Windows sockets specification version 1.1 */
 #ifdef Win32_Winsock
-#ifndef _WIN32_LEAN_AND_MEAN
+#ifndef WIN32_LEAN_AND_MEAN
 #include <sockets.h>
 #endif
 #endif
index 7652dd3..016f6f8 100644 (file)
@@ -36,6 +36,11 @@ extern size_t wcsnlen(const wchar_t * s, size_t count);
 extern int wcsicmp(const wchar_t* cs,const wchar_t * ct);
 extern int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count);
 
+WCHAR wtoupper(WCHAR c);
+WCHAR wtolower(WCHAR c);
+
+   
+   
 #ifdef __cplusplus
 }
 #endif
index 9ba6d5b..9fcb32c 100644 (file)
@@ -1,32 +1,16 @@
-
 /*
  * Win32 File Api functions
  * Author: Boudewijn Dekker
- * to do: many more to add ..
  */
 
-
+#undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
-
-// AnsiOrOemtoUnicode
-// pupose: internal procedure used in file api 
-
-NTSTATUS AnsiOrOemtoUnicode(PUNICODE_STRING DestinationString,PANSI_STRING SourceString, BOOLEAN AllocateDestinationString);
+#include <ddk/ntddk.h>
 
 
 BOOLEAN  bIsFileApiAnsi; // set the file api to ansi or oem
 
 
-NTSTATUS AnsiOrOemtoUnicode(PUNICODE_STRING DestinationString,PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
-{
-       if ( bIsFileApiAnsi ) {
-               return __AnsiStringToUnicodeString(DestinationString, SourceString, AllocateDestinationString);
-       else
-               return __OemStringToUnicodeString(DestinationString, SourceString, AllocateDestinationString);
-
-}
-
-
 WINBASEAPI
 VOID
 WINAPI
@@ -36,7 +20,59 @@ SetFileApisToOEM(VOID)
        return; 
 }
 
-
+HANDLE STDCALL CreateFileA(LPCSTR lpFileName,
+                          DWORD dwDesiredAccess,
+                          DWORD dwShareMode,
+                          LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+                          DWORD dwCreationDisposition,
+                          DWORD dwFlagsAndAttributes,
+                          HANDLE hTemplateFile)
+{
+   HANDLE FileHandle;
+   NTSTATUS Status;
+   WCHAR FileNameW[255];
+   OBJECT_ATTRIBUTES ObjectAttributes;
+   IO_STATUS_BLOCK IoStatusBlock;
+   ULONG i = 0;
+   UNICODE_STRING FileNameString;
+   ULONG Flags = 0;
+   
+   if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED))
+     {
+       Flags = Flags | FILE_SYNCHRONOUS_IO_ALERT;
+     }
+   
+   FileNameString.Length = 0;
+   
+   while ((*lpFileName)!=0)
+     {
+       FileNameW[i] = *lpFileName;
+       lpFileName++;
+       i++;
+       FileNameString.Length++;
+     }
+   FileNameW[i] = 0;
+   FileNameString.Length++;
+   
+   FileNameString.Buffer = &FileNameW;
+   FileNameString.MaximumLength = FileNameString.Length;
+   
+   ObjectAttributes.RootDirectory = NULL;
+   ObjectAttributes.ObjectName = &FileNameString;
+   
+   Status = NtCreateFile(&FileHandle,
+                        dwDesiredAccess,
+                        &ObjectAttributes,
+                        &IoStatusBlock,
+                        NULL,
+                        dwFlagsAndAttributes,
+                        dwShareMode,
+                        dwCreationDisposition,
+                        Flags,
+                        NULL,
+                        0);
+   return(FileHandle);                  
+}
 
 WINBASEAPI
 VOID
@@ -49,10 +85,275 @@ SetFileApisToANSI(VOID)
 
 
 WINBASEAPI
-BOOLEAN
-WINAPI
+WINBOOL
+STDCALL
 AreFileApisANSI(VOID)
 {
        return  bIsFileApiAnsi;
        
 }
+
+
+
+
+BOOL STDCALL WriteFile(HANDLE  hFile,  
+                      LPCVOID lpBuffer,        
+                      DWORD nNumberOfBytesToWrite,
+                      LPDWORD lpNumberOfBytesWritten,  
+                      LPOVERLAPPED lpOverLapped)
+{
+   //FIXME: WriteFile should write to a console if appropriate
+   LARGE_INTEGER Offset;
+   HANDLE hEvent = NULL;
+   NTSTATUS errCode;
+       
+   if (lpOverLapped != NULL ) 
+     {
+       Offset.LowPart = lpOverLapped->Offset;
+       Offset.HighPart = lpOverLapped->OffsetHigh;
+       lpOverLapped->Internal = STATUS_PENDING;
+       hEvent= lpOverLapped->hEvent;
+     }
+   errCode = NtWriteFile(hFile,hEvent,NULL,NULL,
+                        (PIO_STATUS_BLOCK)lpOverLapped,
+                        lpBuffer, 
+                        nNumberOfBytesToWrite,
+                        &Offset,
+                        NULL);
+   if (!NT_SUCCESS(errCode))
+     {
+       SetLastError(RtlNtStatusToDosError(errCode));
+       return FALSE;
+     }
+   
+   return(TRUE);
+}
+
+WINBOOL STDCALL ReadFile(HANDLE hFile,
+                        LPVOID lpBuffer,
+                        DWORD nNumberOfBytesToRead,
+                        LPDWORD lpNumberOfBytesRead,
+                        LPOVERLAPPED lpOverLapped)
+{
+//FIXME ReadFile should write to a console if appropriate
+   HANDLE hEvent = NULL;
+   LARGE_INTEGER Offset;
+   NTSTATUS errCode;
+   PIO_STATUS_BLOCK IoStatusBlock;
+   IO_STATUS_BLOCK IIosb;
+   OVERLAPPED IOverlapped;
+   
+   if ( lpOverLapped != NULL ) 
+     {
+       Offset.LowPart = lpOverLapped->Offset;
+       Offset.HighPart = lpOverLapped->OffsetHigh;
+       lpOverLapped->Internal = STATUS_PENDING;
+       hEvent = lpOverLapped->hEvent;
+       IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped;
+     }
+   else
+     {
+       IoStatusBlock = &IIosb;
+     }
+                                            
+   errCode = NtReadFile(hFile,
+                       hEvent,
+                       NULL,
+                       NULL,
+                       IoStatusBlock,
+                       lpBuffer,
+                       nNumberOfBytesToRead,
+                       &Offset,
+                       NULL);
+   if ( errCode < 0 )  
+     {      
+       SetLastError(RtlNtStatusToDosError(errCode));
+       return FALSE;
+     }
+   return TRUE;  
+}
+
+WINBOOL
+STDCALL
+ReadFileEx(
+          HANDLE hFile,
+          LPVOID lpBuffer,
+          DWORD nNumberOfBytesToRead,
+          LPOVERLAPPED lpOverLapped,
+          LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
+          )
+{
+       HANDLE hEvent = NULL;
+       LARGE_INTEGER Offset;
+       NTSTATUS errCode;
+               
+       if ( lpOverLapped != NULL ) {
+               Offset.LowPart = lpOverLapped->Offset;
+               Offset.HighPart = lpOverLapped->OffsetHigh;
+               lpOverLapped->Internal = STATUS_PENDING;
+               hEvent = lpOverLapped->hEvent;
+       }
+                                
+               
+
+       errCode = NtReadFile(hFile,
+                            hEvent,
+                            (PIO_APC_ROUTINE)lpCompletionRoutine,
+                            NULL,
+                            (PIO_STATUS_BLOCK)lpOverLapped,
+                            lpBuffer,
+                            nNumberOfBytesToRead,
+                            &Offset,
+                            NULL);
+       if ( errCode < 0 )  {
+               SetLastError(RtlNtStatusToDosError(errCode));
+               return FALSE;
+       }
+       return TRUE;  
+}
+
+
+WINBOOL
+STDCALL
+LockFile(
+        HANDLE hFile,
+        DWORD dwFileOffsetLow,
+        DWORD dwFileOffsetHigh,
+        DWORD nNumberOfBytesToLockLow,
+        DWORD nNumberOfBytesToLockHigh
+        )
+{      
+       DWORD dwReserved;
+       OVERLAPPED Overlapped;
+   
+       Overlapped.Offset = dwFileOffsetLow;
+       Overlapped.OffsetHigh = dwFileOffsetHigh;
+       dwReserved = 0;
+
+       return LockFileEx(hFile, LOCKFILE_FAIL_IMMEDIATELY|LOCKFILE_EXCLUSIVE_LOCK,dwReserved,nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, &Overlapped ) ;
+}
+
+WINBOOL
+STDCALL
+LockFileEx(
+          HANDLE hFile,
+          DWORD dwFlags,
+          DWORD dwReserved,
+          DWORD nNumberOfBytesToLockLow,
+          DWORD nNumberOfBytesToLockHigh,
+          LPOVERLAPPED lpOverlapped
+          )
+{
+   LARGE_INTEGER BytesToLock;  
+   BOOL LockImmediate;
+   BOOL LockExclusive;
+   NTSTATUS errCode;
+   LARGE_INTEGER Offset;
+   
+   if(dwReserved != 0) 
+     {      
+       SetLastError(ERROR_INVALID_PARAMETER);
+       return FALSE;
+     }
+   
+   lpOverlapped->Internal = STATUS_PENDING;  
+   
+   Offset.LowPart = lpOverlapped->Offset;
+   Offset.HighPart = lpOverlapped->OffsetHigh;
+   
+   if ( (dwFlags & LOCKFILE_FAIL_IMMEDIATELY) == LOCKFILE_FAIL_IMMEDIATELY )
+     LockImmediate = TRUE;
+   else
+     LockImmediate = FALSE;
+   
+   if ( (dwFlags & LOCKFILE_EXCLUSIVE_LOCK) == LOCKFILE_EXCLUSIVE_LOCK )
+     LockExclusive = TRUE;
+   else
+     LockExclusive = FALSE;
+   
+   BytesToLock.LowPart = nNumberOfBytesToLockLow;
+   BytesToLock.HighPart = nNumberOfBytesToLockHigh;
+   
+   errCode = NtLockFile(hFile,
+                       NULL,
+                       NULL,
+                       NULL,
+                       (PIO_STATUS_BLOCK)lpOverlapped,
+                       &Offset,
+                       &BytesToLock,
+                       NULL,
+                       LockImmediate,
+                       LockExclusive);
+   if ( errCode < 0 ) 
+     {
+      SetLastError(RtlNtStatusToDosError(errCode));
+      return FALSE;
+     }
+   
+   return TRUE;
+                
+}
+
+WINBOOL
+STDCALL
+UnlockFile(
+          HANDLE hFile,
+          DWORD dwFileOffsetLow,
+          DWORD dwFileOffsetHigh,
+          DWORD nNumberOfBytesToUnlockLow,
+          DWORD nNumberOfBytesToUnlockHigh
+          )
+{
+       DWORD dwReserved;
+       OVERLAPPED Overlapped;
+       Overlapped.Offset = dwFileOffsetLow;
+       Overlapped.OffsetHigh = dwFileOffsetHigh;
+       dwReserved = 0;
+       return UnlockFileEx(hFile, dwReserved, nNumberOfBytesToUnlockLow, nNumberOfBytesToUnlockHigh, &Overlapped);
+
+}
+
+
+
+WINBOOL STDCALL UnlockFileEx(HANDLE hFile,
+                            DWORD dwReserved,
+                            DWORD nNumberOfBytesToUnLockLow,
+                            DWORD nNumberOfBytesToUnLockHigh,
+                            LPOVERLAPPED lpOverlapped)
+{
+   LARGE_INTEGER BytesToUnLock;
+   LARGE_INTEGER StartAddress;
+   NTSTATUS errCode;
+   
+   if(dwReserved != 0) 
+     {
+       SetLastError(ERROR_INVALID_PARAMETER);
+       return FALSE;
+     }
+   if ( lpOverlapped == NULL ) 
+     {
+       SetLastError(ERROR_INVALID_PARAMETER);
+       return FALSE;
+     }
+   
+   BytesToUnLock.LowPart = nNumberOfBytesToUnLockLow;
+   BytesToUnLock.HighPart = nNumberOfBytesToUnLockHigh;
+   
+   StartAddress.LowPart = lpOverlapped->Offset;
+   StartAddress.HighPart = lpOverlapped->OffsetHigh;
+   
+   errCode = NtUnlockFile(hFile,
+                         (PIO_STATUS_BLOCK)lpOverlapped,
+                         StartAddress,
+                         BytesToUnLock,
+                         NULL);
+   if ( errCode < 0 ) {
+      SetLastError(RtlNtStatusToDosError(errCode));
+      return FALSE;
+   }
+   
+   return TRUE;
+}
+
+
index 9f61142..4a98c4b 100644 (file)
@@ -5,10 +5,11 @@
 * todo:                check the _lopen for correctness
 */
 
+#undef WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <string.h>
 #include <wstring.h>
-
+#include <fcntl.h>
 
 
 
@@ -26,8 +27,7 @@ long _hread(
 
 }
 
-long 
-_lread(HFILE fd,LPVOID buffer,long count)
+UINT STDCALL _lread(HFILE fd,LPVOID buffer,UINT count)
 {
     return _hread(fd,buffer, count);
 }
@@ -54,14 +54,15 @@ long _hwrite(
 
 }
 
-
-long _lwrite(
-    HFILE  hFile,      
-    LPCSTR  lpBuffer,  
-    long  lBytes       
-   )
+UINT
+STDCALL
+_lwrite(
+       HFILE hFile,
+       LPCSTR lpBuffer,
+       UINT uBytes
+       )
 {
-       return _hwrite(hFile,lpBuffer,lBytes);
+       return _hwrite(hFile,lpBuffer,uBytes);
 }
 
 #define OF_OPENMASK    (OF_READ|OF_READWRITE|OF_WRITE|OF_CREATE)
@@ -123,7 +124,7 @@ int _lclose(
        if ( CloseHandle((HANDLE)hFile) )
                return 0;
        else
-               rerturn -1; 
+               return -1; 
 }
 
 LONG _llseek(
index 669f5d1..349acf0 100644 (file)
@@ -1,9 +1,30 @@
-all: dummy
+all: kernel32.a
 
-OBJECTS = file/file.o file/lfile.o mem/virtual.o mem/local.o mem/global.o
+SYNCH_OBJECTS = synch/critical.o
 
-kernel32_lib: $(OBJECTS)
-       $(LD) --oformat=coff-go32 -Ttext b0000000 $(LDFLAGS) $(OBJECTS) -o kernel32.dll
+#MISC_OBJECTS = misc/atom.o
+MISC_OBJECTS = misc/error.o
+
+#FILE_OBJECTS = file/file.o file/lfile.o
+FILE_OBJECTS = file/file.o file/curdir.o
+
+MEM_OBJECTS = mem/virtual.o mem/heap.o mem/utils.o
+
+#THREAD_OBJECTS = thread/thread.o
+
+PROCESS_OBJECTS = process/proc.o
+
+STRING_OBJECTS = string/lstring.o
+
+INTERNAL_OBJECTS = internal/dprintf.o internal/vsprintf.o
+
+OBJECTS = $(MISC_OBJECTS) $(FILE_OBJECTS) $(THREAD_OBJECTS) \
+          $(PROCESS_OBJECTS) $(STRING_OBJECTS) $(MEM_OBJECTS) \
+         $(INTERNAL_OBJECTS) $(SYNCH_OBJECTS)
+  
+
+kernel32.a: $(OBJECTS)
+       $(AR) vrcs kernel32.a $(OBJECTS) 
 
 dummy:
 
index bb0b853..b310344 100644 (file)
@@ -26,7 +26,9 @@
  * Put the type definitions of the heap in a seperate header. Boudewijn Dekker
  */
 
+#include <kernel32/kernel32.h>
 #include <kernel32/heap.h>
+#include <internal/string.h>
 
 static HEAP_BUCKET __HeapDefaultBuckets[]=
 {
@@ -40,13 +42,14 @@ static HEAP_BUCKET __HeapDefaultBuckets[]=
   { NULL, 256, 15, 4088 },
 };
 
+PHEAP  __ProcessHeap;
 
 static BOOL   __HeapCommit(PHEAP pheap, LPVOID start, LPVOID end);
 static BOOL   __HeapDecommit(PHEAP pheap, LPVOID start, LPVOID end);
 static LPVOID __HeapAlloc(PHEAP pheap, ULONG flags, ULONG size, ULONG tag);
 static VOID   __HeapFreeRest(PHEAP pheap, PHEAP_BLOCK pfree, ULONG allocsize,
                              ULONG newsize);
-static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, ULONG size);
+static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size);
 static BOOL   __HeapFree(PHEAP pheap, ULONG flags, LPVOID pmem);
 static PHEAP_SUBALLOC __HeapAllocSub(PHEAP pheap, PHEAP_BUCKET pbucket);
 static LPVOID __HeapAllocFragment(PHEAP pheap, ULONG flags, ULONG size);
@@ -67,12 +70,14 @@ static BOOL __HeapCommit(PHEAP pheap, LPVOID start, LPVOID end)
 {
    dprintf("__HeapCommit( 0x%lX, 0x%lX, 0x%lX)\n",
            (ULONG) pheap, (ULONG) start, (ULONG) end);
-#ifdef NOT
-   __VirtualDump();
-#endif
+
    if(end >= pheap->LastBlock)
       pheap->LastBlock=end;
-   return __VirtualCommit(start, end-start, PAGE_READWRITE);
+   if (VirtualAlloc(start,end-start,MEM_COMMIT,PAGE_READWRITE)!=start)
+     {
+       return(FALSE);
+     }
+   return(TRUE);
 }
 
 /*********************************************************************
@@ -89,7 +94,8 @@ static BOOL __HeapDecommit(PHEAP pheap, LPVOID start, LPVOID end)
 #endif
    if((end >= pheap->LastBlock)&&(start<= pheap->LastBlock))
       pheap->LastBlock=start;
-   return __VirtualDecommit(start, end-start );
+   
+   return(VirtualFree(start,end-start,MEM_RESERVE));
 }
 
 /*********************************************************************
@@ -106,7 +112,10 @@ static LPVOID __HeapAlloc(PHEAP pheap, ULONG flags, ULONG size, ULONG tag)
    LPVOID      commitend;
    ULONG       freesize;
    ULONG       allocsize;
-
+   
+   dprintf("__HeapAlloc(pheap %x, flags %x, size %d, tag %x)\n",
+          pheap,flags,size,tag);
+   
    pfree=&(pheap->Start);
    allocsize=SIZE_ROUND(size);
    freesize=HEAP_SIZE(pfree);
@@ -154,7 +163,7 @@ static LPVOID __HeapAlloc(PHEAP pheap, ULONG flags, ULONG size, ULONG tag)
    /* update our administration */
    palloc->Size= size | tag;
    if((flags | pheap->Flags)& HEAP_ZERO_MEMORY)
-      memset((LPVOID)palloc+HEAP_ADMIN_SIZE, 0, allocsize);
+      FillMemory((LPVOID)palloc+HEAP_ADMIN_SIZE, allocsize, 0);
    return (LPVOID)palloc+HEAP_ADMIN_SIZE;
 }
 
@@ -236,7 +245,7 @@ static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size)
       /* alloc a new fragment */
       pmem=__HeapAllocFragment(pheap, flags, size);
       if(pmem)
-         memcpy(pmem, pold, size);
+        CopyMemory(pmem, pold, size);
       return pmem;
    }
 #endif
@@ -300,7 +309,7 @@ static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size)
             oldsize=HEAP_SIZE(prealloc);
             pmem=__HeapAlloc(pheap, flags, size, HEAP_NORMAL_TAG);
             if(pmem)
-               memcpy(pmem, pold, oldsize);
+              CopyMemory(pmem, pold, oldsize);
             if((flags|pheap->Flags)&HEAP_ZERO_MEMORY)
                memset(pmem + oldsize, 0, size-oldsize);
             __HeapFree(pheap, flags, pold);
@@ -502,7 +511,7 @@ static LPVOID __HeapReAllocFragment(PHEAP pheap, ULONG flags,
             pmem=__HeapAllocFragment(pheap, flags, size);
 
          if(pmem)
-            memcpy(pmem, pold, size);
+           CopyMemory(pmem, pold, size);
          if((flags|pheap->Flags)&HEAP_ZERO_MEMORY)
             memset(pmem+pfrag->Size, 0, size-pfrag->Size);
 
@@ -580,12 +589,15 @@ static BOOL __HeapFreeFragment(PHEAP pheap, ULONG flags, LPVOID pfree )
 PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize,  ULONG flags)
 {
    PHEAP pheap=(PHEAP) base;
-
+   
+   dprintf("__HeapPrepare(base %x, minsize %d, maxsize %d, flags %x)\n",
+          base,minsize,maxsize,flags);
+   
    pheap->Magic=MAGIC_HEAP;
    pheap->End= ((LPVOID)pheap)+minsize;
    pheap->Flags=flags;
    pheap->LastBlock=(LPVOID)pheap + PAGESIZE;
-   memcpy(pheap->Bucket,__HeapDefaultBuckets,sizeof(__HeapDefaultBuckets));
+   CopyMemory(pheap->Bucket,__HeapDefaultBuckets,sizeof(__HeapDefaultBuckets));
    if(__ProcessHeap)
    {
       pheap->NextHeap=__ProcessHeap->NextHeap;
@@ -611,8 +623,8 @@ PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize,  ULONG flags)
 
 VOID WINAPI __HeapInit(LPVOID base, ULONG minsize, ULONG maxsize)
 {
-   mmap(base, PAGESIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE,
-        __DevZero, 0);
+   VirtualAlloc(base,maxsize,MEM_RESERVE,PAGE_READWRITE);
+   VirtualAlloc(base,PAGESIZE,MEM_COMMIT,PAGE_READWRITE);
    
    __HeapPrepare(base, minsize, maxsize, 0);
 }
@@ -621,16 +633,14 @@ VOID WINAPI __HeapInit(LPVOID base, ULONG minsize, ULONG maxsize)
 /*********************************************************************
 *                     HeapCreate -- KERNEL32                         *
 *********************************************************************/
-
-HANDLE WINAPI HeapCreate(ULONG flags, ULONG minsize, ULONG maxsize)
+HANDLE STDCALL HeapCreate(DWORD flags, DWORD minsize, DWORD maxsize)
 {
    PHEAP pheap;
 
    aprintf("HeapCreate( 0x%lX, 0x%lX, 0x%lX )\n", flags, minsize, maxsize);
 
-   pheap = __VirtualReserve(NULL, minsize, PAGE_READWRITE | MEM_TOP_DOWN);
-   __VirtualCommit(pheap, PAGESIZE, PAGE_READWRITE);
-   __VirtualDump();
+   pheap = VirtualAlloc(NULL, minsize, MEM_TOP_DOWN, PAGE_READWRITE);
+   VirtualAlloc(pheap, PAGESIZE, MEM_COMMIT, PAGE_READWRITE);
    return (HANDLE) __HeapPrepare(pheap, minsize, maxsize, flags);
 }
 
@@ -647,15 +657,15 @@ BOOL WINAPI HeapDestroy(HANDLE hheap)
       return __ErrorReturnFalse(ERROR_INVALID_PARAMETER);
 
    DeleteCriticalSection(&(pheap->Synchronize));
-   __VirtualRelease(pheap);
-
+   VirtualFree(pheap,0,MEM_RELEASE);
+   
    return TRUE;
 }
 
 /*********************************************************************
 *                     HeapAlloc -- KERNEL32                          *
 *********************************************************************/
-LPVOID WINAPI HeapAlloc(HANDLE hheap, ULONG flags, ULONG size)
+LPVOID STDCALL HeapAlloc(HANDLE hheap, DWORD flags, DWORD size)
 {
    PHEAP    pheap=hheap;
    LPVOID   retval;
@@ -684,7 +694,7 @@ LPVOID WINAPI HeapAlloc(HANDLE hheap, ULONG flags, ULONG size)
 /*********************************************************************
 *                     HeapReAlloc -- KERNEL32                        *
 *********************************************************************/
-LPVOID WINAPI HeapReAlloc(HANDLE hheap, ULONG flags, LPVOID ptr, ULONG size)
+LPVOID STDCALL HeapReAlloc(HANDLE hheap, DWORD flags, LPVOID ptr, DWORD size)
 {
    PHEAP            pheap=hheap;
    PHEAP_BLOCK      pfree=((PHEAP_BLOCK)ptr-1);
@@ -714,7 +724,7 @@ LPVOID WINAPI HeapReAlloc(HANDLE hheap, ULONG flags, LPVOID ptr, ULONG size)
 /*********************************************************************
 *                     HeapFree -- KERNEL32                           *
 *********************************************************************/
-BOOL WINAPI HeapFree(HANDLE hheap, ULONG flags, LPVOID ptr)
+WINBOOL STDCALL HeapFree(HANDLE hheap, DWORD flags, LPVOID ptr)
 {
    PHEAP            pheap=hheap;
    PHEAP_BLOCK      pfree=(PHEAP_BLOCK)((LPVOID)ptr-HEAP_ADMIN_SIZE);
index 96532bc..606036c 100644 (file)
@@ -9,11 +9,92 @@
 /* INCLUDES ******************************************************************/
 
 #include <windows.h>
+#include <ddk/ntddk.h>
 
 /* FUNCTIONS *****************************************************************/
 
+LPVOID STDCALL VirtualAllocEx(HANDLE hProcess,
+                             LPVOID lpAddress,
+                             DWORD dwSize,
+                             DWORD flAllocationType,
+                             DWORD flProtect)
+{
+   NTSTATUS Status;
+   
+   Status = ZwAllocateVirtualMemory(hProcess,
+                                   &lpAddress,
+                                   0,
+                                   dwSize,
+                                   flAllocationType,
+                                   flProtect);
+   if (Status != STATUS_SUCCESS)
+     {
+       return(NULL);
+     }
+   return(lpAddress);
+}
+
+LPVOID STDCALL VirtualAlloc(LPVOID lpAddress,
+                           DWORD dwSize,
+                           DWORD flAllocationType,
+                           DWORD flProtect)
+{
+   return(VirtualAllocEx(GetCurrentProcess(),lpAddress,dwSize,flAllocationType,
+                        flProtect));
+}
+
+WINBOOL STDCALL VirtualFreeEx(HANDLE hProcess,
+                             LPVOID lpAddress,
+                             DWORD dwSize,
+                             DWORD dwFreeType)
+{
+   NTSTATUS Status;
+   
+   Status = ZwFreeVirtualMemory(hProcess,
+                               &lpAddress,
+                               dwSize,
+                               dwFreeType);
+   if (Status != STATUS_SUCCESS)
+     {
+       return(FALSE);
+     }
+   return(TRUE);
+}
+
 WINBOOL STDCALL VirtualFree(LPVOID lpAddress, DWORD dwSize, DWORD dwFreeType)
 {
    return(VirtualFreeEx(GetCurrentProcess(),lpAddress,dwSize,dwFreeType));
 }
 
+WINBOOL STDCALL VirtualProtect(LPVOID lpAddress,
+                              DWORD dwSize,
+                              DWORD flNewProtect,
+                              PDWORD lpflOldProtect)
+{
+   return(VirtualProtectEx(GetCurrentProcess(),
+                          lpAddress, 
+                          dwSize, 
+                          flNewProtect, 
+                          lpflOldProtect));
+}
+
+
+WINBOOL STDCALL VirtualProtectEx(HANDLE hProcess,
+                                LPVOID lpAddress,
+                                DWORD dwSize,
+                                DWORD flNewProtect,
+                                PDWORD lpflOldProtect)
+{
+   NTSTATUS Status;
+   
+   Status = ZwProtectVirtualMemory(hProcess,
+                                  lpAddress,
+                                  dwSize,
+                                  flNewProtect,
+                                  lpflOldProtect);
+   if (Status != STATUS_SUCCESS)
+     {
+       return(FALSE);
+     }
+   return(TRUE);
+}
index 5bc2a68..633e088 100644 (file)
@@ -1,3 +1,4 @@
+#include <windows.h>
 #include <process.h>
 /*
  * Win32 Process Api functions
 #define NT_CURRENT_THREAD      0xFFFFFFFE
 
 
-WINBASEAPI
-HANDLE
-WINAPI
-GetCurrentProcess()
+HANDLE STDCALL GetCurrentProcess(VOID)
 {
        return NT_CURRENT_PROCESS;
 }
 
-WINBASEAPI
-DWORD
-WINAPI
-GetCurrentProcessId()
+HANDLE STDCALL GetCurrentThread()
 {
-       return GetTeb()->dwProcessId; 
+       return NT_CURRENT_PROCESS;
 }
 
+#if 0
 
 WINBASEAPI
-HANDLE
+DWORD
 WINAPI
-GetCurrentThread()
+GetCurrentProcessId()
 {
-       return NT_CURRENT_PROCESS;
+       return GetTeb()->dwProcessId; 
 }
 
+
 WINBASEAPI
 DWORD
 WINAPI
@@ -135,3 +132,5 @@ BOOL FlushInstructionCache(
                return FALSE;
        }
 }
+
+#endif
index af3e0e0..2135d00 100644 (file)
@@ -1,7 +1,10 @@
-all: genntdll$(EXE_POSTFIX)
+all: ntdll.a
 
-genntdll$(EXE_POSTFIX): genntdll.c
-       $(NATIVE_CC) -g genntdll.c -o genntdll$(EXE_POSTFIX)
+OBJECTS = napi.o
+
+ntdll.a: $(OBJECTS)
+       $(AR) vcsr ntdll.a $(OBJECTS)
+       
 dummy:
 
 include ../../rules.mak
index 91b86dc..cf9fba3 100644 (file)
 #
 # Select your host
 #
-#HOST =        djgpp-linux
-#HOST =        mingw32-linux
+#HOST = djgpp-linux
+#HOST = mingw32-linux
 HOST = djgpp-msdos
-#HOST =        mingw32-windows
+#HOST = mingw32-windows
 
-include        rules.mak
+include rules.mak
 
 #
 # Required to run the system
 #
-COMPONENTS = kernel lib
+COMPONENTS = iface_native ntoskrnl kernel32 ntdll crtdll mingw32
 
 #
-# Select the loader(s) you want        to build
+# Select the server(s) you want to build
 #
-LOADERS        = dos
+SERVERS = win32 posix linux os2
 
 #
-# Select the modules you want
+# Select the loader(s) you want to build
 #
-MODULES        = parallel keyboard
+LOADERS = dos
 
-all: $(COMPONENTS) $(LOADERS) $(MODULES)
+#
+# Select the device drivers and filesystems you want
+#
+KERNEL_SERVICES = parallel keyboard null mouse serial sound ide test sdisk \
+                  minix vfat
+
+APPS = hello shell
+
+all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES) $(APPS)
+
+clean: dummy
+       make -C iface/native clean
+
+#
+# Applications
+#
+hello: dummy
+       make -C apps/hello
+
+cmd: dummy
+       make -C apps/cmd
 
+shell: dummy
+       make -C apps/shell
+
+#
+# Interfaces
 #
-# Device driver        rules
+iface_native: dummy
+       make -C iface/native
+
 #
+# Device driver rules
+#
+vfat: dummy
+       make -C services/fs/vfat
+       
+sdisk: dummy
+       make -C services/dd/sdisk
+       
+minix: dummy
+       make -C services/fs/minix
+       
+template: dummy
+       make -C services/fs/template
+
+
+ide-test: dummy
+       make -C services/dd/ide-test
+
 ide: dummy
-              make -C services/ide
+       make -C services/dd/ide 
+
+test: dummy
+       make -C services/dd/test
+
+test1: dummy
+       make -C services/dd/test1
+
+null: dummy
+       make -C services/dd/null
 
 parallel: dummy
-                     make -C services/parallel
+       make -C services/dd/parallel
 
 keyboard: dummy
-       make -C services/keyboard
+       make -C services/dd/keyboard
 
 mouse: dummy
-       make -C services/mouse
+       make -C services/dd/mouse
+       
+serial: dummy
+       make -C services/dd/serial
+
+sound: dummy
+       make -C services/dd/sound
 
 #
 # Kernel loaders
 #
 
 dos: dummy
-       make -C loaders/dos
+       make -C loaders/dos
 
 #
 # Required system components
 #
 
-kernel:        dummy
-       make -C ntoskrnl
+ntoskrnl: dummy
+       make -C ntoskrnl
+
+kernel32: dummy
+       make -C lib/kernel32
+
+ntdll: dummy
+       make -C lib/ntdll
+
+crtdll: dummy
+       make -C lib/crtdll
 
-lib: dummy
-       make -C lib
+mingw32: dummy
+       make -C lib/mingw32
 
 dummy:
index 643a658..0c577b1 100644 (file)
 
 /* FUNCTIONS *****************************************************************/
 
+NTSTATUS STDCALL NtSystemDebugControl(VOID)
+{
+   UNIMPLEMENTED;
+}
+
 VOID DbgBreakPoint(VOID)
 {
    __asm__("int $3\n\t");
index 3bd3d78..45c85af 100644 (file)
@@ -23,9 +23,12 @@ VOID ExCallUserCallBack(PVOID fn)
 {
 }
 
-VOID NtReturnFromCallBack(VOID)
-/*
- * FUNCTION: Returns from a user callback
- */
+NTSTATUS STDCALL NtCallbackReturn(VOID)
+{
+   UNIMPLEMENTED;
+}
+
+NTSTATUS STDCALL NtW32Call(VOID)
 {
+   UNIMPLEMENTED;
 }
index ac2969f..355d7a8 100644 (file)
 
 /* FUNCTIONS *****************************************************************/
 
+NTSTATUS STDCALL NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
+                                IN PLARGE_INTEGER NewSystemTime OPTIONAL)
+{
+   return(ZwSetSystemTime(SystemTime,NewSystemTime));
+}
+
+NTSTATUS STDCALL ZwSetSystemTime(IN PLARGE_INTEGER SystemTime,
+                                IN PLARGE_INTEGER NewSystemTime OPTIONAL)
+{
+   UNIMPLEMENTED;
+}
+
+NTSTATUS STDCALL NtQuerySystemTime (OUT TIME *CurrentTime)
+{
+   return(ZwQuerySystemTime(CurrentTime));
+}
+
+NTSTATUS STDCALL ZwQuerySystemTime (OUT TIME *CurrentTime)
+{
+   UNIMPLEMENTED;
+}
+
 VOID ExLocalTimeToSystemTime(PLARGE_INTEGER LocalTime, 
                             PLARGE_INTEGER SystemTime)
 {
index 405e39c..2b36620 100644 (file)
@@ -142,7 +142,7 @@ VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,
    ASSERT_IRQL(DISPATCH_LEVEL);
    
    /*
-    * Insert the item in the appropiate queue and wake on any thread
+    * Insert the item in the appropiate queue and wake up any thread
     * waiting for something to do
     */
    switch(QueueType)
@@ -152,5 +152,5 @@ VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,
                                    &normal_work_queue.Lock);
        KeSetEvent(&normal_work_queue.Busy,IO_NO_INCREMENT,FALSE);
        break;
-     };
+     }
 }
index 5208b4a..61e28f7 100644 (file)
@@ -377,3 +377,10 @@ ZwUnmapViewOfSection
 ZwWriteFile
 sprintf
 wcschr
+wcsncat
+wcsncpy
+wtolower
+wtoupper
+CbInitDccb
+CbAcquireForRead
+CbReleaseFromRead
index bbb7f78..834d2a5 100644 (file)
@@ -18,8 +18,8 @@
 #include <ddk/ntddk.h>
 #include <internal/mm.h>
 #include <internal/string.h>
-#include <internal/hal/page.h>
-#include <internal/hal/segment.h>
+#include <internal/mmhal.h>
+#include <internal/i386/segment.h>
 
 /* TYPES ******************************************************************/
 
index 68c3bc9..7f8326f 100644 (file)
 #include <windows.h>
 #include <internal/ntoskrnl.h>
 #include <internal/ke.h>
-#include <internal/hal/segment.h>
-#include <internal/hal/page.h>
+#include <internal/i386/segment.h>
+#include <internal/mmhal.h>
 
 #define NDEBUG
 #include <internal/debug.h>
 
 /* GLOBALS *****************************************************************/
 
-typedef unsigned int (exception_hook)(CONTEXT* c, unsigned int exp);
-asmlinkage unsigned int ExHookException(exception_hook fn, UINT exp);
+asmlinkage int page_fault_handler(unsigned int cs,
+                                  unsigned int eip);
 
 extern descriptor idt[256];
 static exception_hook* exception_hooks[256]={NULL,};
@@ -30,43 +30,74 @@ static exception_hook* exception_hooks[256]={NULL,};
 #define _STR(x) #x
 #define STR(x) _STR(x)
 
+extern void interrupt_handler2e(void);
+
 /* FUNCTIONS ****************************************************************/
 
 #define EXCEPTION_HANDLER_WITH_ERROR(x,y)  \
       void exception_handler##y (void);   \
        __asm__("\n\t_exception_handler"##x":\n\t" \
+                "pushl %gs\n\t" \
+                "pushl %fs\n\t" \
+                "pushl %es\n\t" \
                 "pushl %ds\n\t"    \
                 "pushl $"##x"\n\t"                        \
                 "pusha\n\t"                          \
                 "movw $"STR(KERNEL_DS)",%ax\n\t"        \
                 "movw %ax,%ds\n\t"      \
+                "movw %ax,%es\n\t"      \
+                "movw %ax,%fs\n\t"      \
+                "movw %ax,%gs\n\t"      \
                 "call _exception_handler\n\t"        \
                 "popa\n\t" \
-                "addl $8,%esp\n\t"                   \
+                "addl $4,%esp\n\t"                   \
+                "popl %ds\n\t&qu