Fixed header inclusion order.
authorEric Kohl <eric.kohl@reactos.org>
Thu, 7 Oct 1999 23:46:27 +0000 (23:46 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 7 Oct 1999 23:46:27 +0000 (23:46 +0000)
svn path=/trunk/; revision=687

77 files changed:
reactos/include/ddk/zwtypes.h
reactos/include/structs.h
reactos/lib/crtdll/malloc/heap.c
reactos/lib/kernel32/except/except.c
reactos/lib/kernel32/file/copy.c
reactos/lib/kernel32/file/create.c
reactos/lib/kernel32/file/delete.c
reactos/lib/kernel32/file/deviceio.c
reactos/lib/kernel32/file/dir.c
reactos/lib/kernel32/file/dosdev.c
reactos/lib/kernel32/file/file.c
reactos/lib/kernel32/file/find.c
reactos/lib/kernel32/file/iocompl.c
reactos/lib/kernel32/file/lock.c
reactos/lib/kernel32/file/move.c
reactos/lib/kernel32/file/pipe.c
reactos/lib/kernel32/file/rw.c
reactos/lib/kernel32/file/volume.c
reactos/lib/kernel32/internal/dprintf.c
reactos/lib/kernel32/internal/init.c
reactos/lib/kernel32/internal/string.c
reactos/lib/kernel32/mem/section.c
reactos/lib/kernel32/mem/virtual.c
reactos/lib/kernel32/misc/atom.c
reactos/lib/kernel32/misc/console.c
reactos/lib/kernel32/misc/dllmain.c
reactos/lib/kernel32/misc/env.c
reactos/lib/kernel32/misc/error.c
reactos/lib/kernel32/misc/handle.c
reactos/lib/kernel32/misc/stubs.c
reactos/lib/kernel32/misc/time.c
reactos/lib/kernel32/process/cmdline.c
reactos/lib/kernel32/process/create.c
reactos/lib/kernel32/process/lib.c
reactos/lib/kernel32/process/proc.c
reactos/lib/kernel32/string/lstring.c
reactos/lib/kernel32/synch/event.c
reactos/lib/kernel32/synch/timer.c
reactos/lib/kernel32/synch/wait.c
reactos/lib/kernel32/thread/thread.c
reactos/lib/kernel32/thread/tls.c
reactos/lib/ntdll/rtl/process.c
reactos/lib/ntdll/stubs/stubs.c
reactos/ntoskrnl/cm/registry.c
reactos/ntoskrnl/ex/time.c
reactos/ntoskrnl/ex/work.c
reactos/ntoskrnl/hal/x86/exp.c
reactos/ntoskrnl/hal/x86/halinit.c
reactos/ntoskrnl/hal/x86/irqhand.c
reactos/ntoskrnl/hal/x86/isa.c
reactos/ntoskrnl/hal/x86/pci.c
reactos/ntoskrnl/hal/x86/printk.c
reactos/ntoskrnl/hal/x86/usercall.c
reactos/ntoskrnl/io/cleanup.c
reactos/ntoskrnl/io/create.c
reactos/ntoskrnl/io/iomgr.c
reactos/ntoskrnl/io/queue.c
reactos/ntoskrnl/ke/catch.c
reactos/ntoskrnl/ke/dispatch.c
reactos/ntoskrnl/ke/kernel.c
reactos/ntoskrnl/ke/main.c
reactos/ntoskrnl/ke/wait.c
reactos/ntoskrnl/ldr/init.c
reactos/ntoskrnl/ldr/loader.c
reactos/ntoskrnl/ldr/syspath.c
reactos/ntoskrnl/mm/mm.c
reactos/ntoskrnl/mm/npool.c
reactos/ntoskrnl/mm/pool.c
reactos/ntoskrnl/mm/virtual.c
reactos/ntoskrnl/ob/handle.c
reactos/ntoskrnl/ps/kill.c
reactos/ntoskrnl/ps/psmgr.c
reactos/ntoskrnl/ps/thread.c
reactos/ntoskrnl/rtl/largeint.c
reactos/ntoskrnl/rtl/list.c
reactos/ntoskrnl/rtl/slist.c
reactos/ntoskrnl/se/semgr.c

index 19acbc0..9244fb7 100644 (file)
@@ -131,6 +131,10 @@ struct _LPC_MESSAGE
 
 #define SystemTimeZoneInformation              44
 
+// memory information
+
+#define MemoryBasicInformation                  0
+
 // shutdown action
 
 typedef enum SHUTDOWN_ACTION_TAG {
@@ -143,7 +147,12 @@ typedef enum SHUTDOWN_ACTION_TAG {
 
 #define WaitAll                                        0
 #define WaitAny                                        1
+
+// number of wait objects
+
+#define THREAD_WAIT_OBJECTS                     3
+//#define MAXIMUM_WAIT_OBJECTS                    64
+
 // key restore flags
 
 #define REG_WHOLE_HIVE_VOLATILE                1   
@@ -737,4 +746,4 @@ struct _LPC_PORT_BASIC_INFORMATION
 
 } LPC_PORT_BASIC_INFORMATION, * PLPC_PORT_BASIC_INFORMATION;
 
-#endif 
+#endif
index f82fb42..71e68e1 100644 (file)
@@ -363,6 +363,17 @@ typedef struct _DISK_GEOMETRY {
   DWORD  BytesPerSector; 
 } DISK_GEOMETRY ; 
 
+typedef struct _MEMORY_BASIC_INFORMATION { 
+  PVOID BaseAddress;
+  PVOID AllocationBase; 
+  DWORD AllocationProtect; 
+  DWORD RegionSize; 
+  DWORD State; 
+  DWORD Protect; 
+  DWORD Type; 
+} MEMORY_BASIC_INFORMATION;
+typedef MEMORY_BASIC_INFORMATION *PMEMORY_BASIC_INFORMATION;
+
 typedef struct _SYSTEMTIME {  
   WORD wYear; 
   WORD wMonth; 
@@ -2700,17 +2711,6 @@ typedef struct tagMEASUREITEMSTRUCT {
   DWORD itemData;     
 } MEASUREITEMSTRUCT, *LPMEASUREITEMSTRUCT; 
  
-typedef struct _MEMORY_BASIC_INFORMATION { 
-  PVOID BaseAddress;            
-  PVOID AllocationBase;         
-  DWORD AllocationProtect;      
-  DWORD RegionSize;             
-  DWORD State;                  
-  DWORD Protect;                
-  DWORD Type;                   
-} MEMORY_BASIC_INFORMATION; 
-typedef MEMORY_BASIC_INFORMATION *PMEMORY_BASIC_INFORMATION; 
 typedef struct _MEMORYSTATUS { 
   DWORD dwLength;        
   DWORD dwMemoryLoad;    
index 8f9a6ed..1eed228 100644 (file)
@@ -1,7 +1,5 @@
 
 #include <windows.h>
-#include <kernel32/proc.h>
-#include <kernel32/heap.h>
 #include <crtdll/malloc.h>
 
 int    _heapchk (void)
index 378d9e6..d267075 100644 (file)
@@ -4,18 +4,18 @@
  * FILE:            lib/kernel32/misc/except.c
  * PURPOSE:         Exception functions
  * PROGRAMMER:      Ariadne ( ariadne@xs4all.nl)
-                   modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ]
*                  modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ]
  * UPDATE HISTORY:
  *                  Created 01/11/98
  */
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 
 
 typedef LONG (STDCALL *LPTOP_LEVEL_EXCEPTION_FILTER)(
        struct _EXCEPTION_POINTERS *ExceptionInfo
-       );
+       );
 
 UINT GlobalErrMode;
 LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter;
@@ -51,17 +51,7 @@ SetUnhandledExceptionFilter(
 }
 
 
-
-
-
-
-
-
-
-
-
-
-LONG 
+LONG
 STDCALL
 UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
 {
@@ -69,20 +59,18 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
        HANDLE DebugPort;
        NTSTATUS errCode;
 
-
-
        if(ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION) {
                // might check read only resource
                // Is there a debugger running ?
                errCode = NtQueryInformationProcess(NtCurrentProcess(),ProcessDebugPort,&DebugPort,sizeof(HANDLE),NULL);
-               if ( !NT_SUCCESS(errCode) ) {
+               if ( !NT_SUCCESS(errCode) ) {
                        SetLastError(RtlNtStatusToDosError(errCode));
                        return EXCEPTION_EXECUTE_HANDLER;
                }
                if ( DebugPort ) {
                        //return EXCEPTION_CONTINUE_SEARCH;
-               }   
-       if(GlobalTopLevelExceptionFilter != NULL) {
+               }
+               if(GlobalTopLevelExceptionFilter != NULL) {
                dbgRet = GlobalTopLevelExceptionFilter(ExceptionInfo);
                if(dbgRet == EXCEPTION_EXECUTE_HANDLER) 
                        return EXCEPTION_EXECUTE_HANDLER;
@@ -91,7 +79,7 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
                }
 
        }
-       
+
        //if ( GetErrorMode() & SEM_NOGPFAULTERRORBOX == SEM_NOGPFAULTERRORBOX ) {
                // produce a stack trace or pop a message
                //sprintf( message, "Unhandled exception 0x%08lx at address 0x%08lx.",
@@ -107,10 +95,3 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
        return EXCEPTION_EXECUTE_HANDLER;
        
 }
-
-
-
-
-
-
-
index 343960c..96293ea 100644 (file)
@@ -11,8 +11,8 @@
 
 /* INCLUDES ****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <wchar.h>
 #include <string.h>
 
index 8376c16..6bd2b4b 100644 (file)
@@ -12,8 +12,8 @@
 
 /* INCLUDES *****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <wchar.h>
 #include <string.h>
 
index a943b5a..afe2e46 100644 (file)
@@ -10,8 +10,8 @@
 
 /* INCLUDES ****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <wchar.h>
 #include <string.h>
 
index 3905dec..b40f3ee 100644 (file)
@@ -8,8 +8,8 @@
  *                  Created 01/11/98
  */
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 
 #define NDEBUG
 #include <kernel32/kernel32.h>
index 663e052..fca339e 100644 (file)
@@ -14,8 +14,8 @@
 
 /* INCLUDES ******************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <string.h>
 #include <wchar.h>
 
index 1ca8413..4db0ada 100644 (file)
@@ -8,8 +8,8 @@
  *                  Created 01/11/98
  */
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 
 
 WINBOOL
@@ -25,27 +25,24 @@ DefineDosDeviceA(
        WCHAR DeviceNameW[MAX_PATH];
        WCHAR TargetPathW[MAX_PATH];
 
-       
-
-       i = 0;
-       while ((*lpDeviceName)!=0 && i < MAX_PATH)
-       {
+       i = 0;
+       while ((*lpDeviceName)!=0 && i < MAX_PATH)
+       {
                DeviceNameW[i] = *lpDeviceName;
                lpDeviceName++;
                i++;
-       }
-       DeviceNameW[i] = 0;
+       }
+       DeviceNameW[i] = 0;
 
        i = 0;
-       while ((*lpTargetPath)!=0 && i < MAX_PATH)
-       {
+       while ((*lpTargetPath)!=0 && i < MAX_PATH)
+       {
                TargetPathW[i] = *lpTargetPath;
                lpTargetPath++;
                i++;
-       }
-       TargetPathW[i] = 0;
+       }
+       TargetPathW[i] = 0;
        return DefineDosDeviceW(dwFlags,DeviceNameW,TargetPathW);
-    
 }
 
 
index bb42e50..eb3159e 100644 (file)
@@ -11,8 +11,8 @@
 
 /* INCLUDES *****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <wchar.h>
 #include <string.h>
 
index a5d9a86..4e109c8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: find.c,v 1.21 1999/08/29 06:59:01 ea Exp $
+/* $Id: find.c,v 1.22 1999/10/07 23:43:28 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -11,9 +11,9 @@
 
 /* INCLUDES *****************************************************************/
 
+#include <ddk/ntddk.h>
 #include <windows.h>
 #include <wchar.h>
-#include <ddk/ntddk.h>
 #include <string.h>
 
 #define NDEBUG
index 569c8ba..f1d225d 100644 (file)
@@ -8,34 +8,34 @@
  *                  Created 01/11/98
  */
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <wchar.h>
 
 
-typedef struct _FILE_COMPLETION_INFORMATION {                    
-    HANDLE CompletionPort;                                     
-    ULONG CompletionKey;                                      
+typedef struct _FILE_COMPLETION_INFORMATION {
+    HANDLE CompletionPort;
+    ULONG CompletionKey;
 } FILE_COMPLETION_INFORMATION;
-typedef FILE_COMPLETION_INFORMATION *PFILE_COMPLETION_INFORMATION;   
+typedef FILE_COMPLETION_INFORMATION *PFILE_COMPLETION_INFORMATION;
 
 
-VOID 
-STDCALL 
+VOID
+STDCALL
 FileIOCompletionRoutine(
-       DWORD dwErrorCode,      
-       DWORD dwNumberOfBytesTransfered,        
-       LPOVERLAPPED lpOverlapped        
+       DWORD dwErrorCode,
+       DWORD dwNumberOfBytesTransfered,
+       LPOVERLAPPED lpOverlapped
        );
 
 
-HANDLE 
+HANDLE
 STDCALL
-CreateIoCompletionPort( 
-    HANDLE FileHandle, 
-    HANDLE ExistingCompletionPort, 
-    DWORD CompletionKey, 
-    DWORD NumberOfConcurrentThreads 
+CreateIoCompletionPort(
+    HANDLE FileHandle,
+    HANDLE ExistingCompletionPort,
+    DWORD CompletionKey,
+    DWORD NumberOfConcurrentThreads
     )
 {
        HANDLE CompletionPort = NULL;
@@ -48,7 +48,7 @@ CreateIoCompletionPort(
                 return FALSE;
         }
 
-        if ( ExistingCompletionPort != NULL )  {
+        if ( ExistingCompletionPort != NULL ) {
                 CompletionPort = ExistingCompletionPort;
        }
        else {
@@ -57,27 +57,26 @@ CreateIoCompletionPort(
                         SetLastError(RtlNtStatusToDosError(errCode));
                         return FALSE;
                 }
-                
+
         }
         if ( FileHandle != INVALID_HANDLE_VALUE ) {
 
                CompletionInformation.CompletionPort = CompletionPort;
                 CompletionInformation.CompletionKey  = CompletionKey;
-              
+
                 errCode = NtSetInformationFile(FileHandle, &IoStatusBlock,&CompletionInformation,sizeof(FILE_COMPLETION_INFORMATION),FileCompletionInformation);
                 if ( !NT_SUCCESS(errCode) ) {
                        if ( ExistingCompletionPort == NULL )
                                NtClose(CompletionPort);
                         SetLastError(RtlNtStatusToDosError(errCode));
                         return FALSE;
-                }    
+                }
         }
-        
+
         return CompletionPort;
 }
 
 
-
 WINBOOL
 STDCALL
 GetQueuedCompletionStatus(
@@ -88,7 +87,6 @@ GetQueuedCompletionStatus(
                          DWORD dwMilliseconds
                          )
 {
-
        NTSTATUS errCode;
        ULONG CompletionStatus;
        LARGE_INTEGER TimeToWait;
@@ -99,50 +97,38 @@ GetQueuedCompletionStatus(
                return FALSE;
        }
 
-       return TRUE; 
-       
+       return TRUE;
 }
 
 
-
-WINBOOL 
+WINBOOL
 STDCALL
 PostQueuedCompletionStatus(
-  HANDLE CompletionPort,  
-  DWORD dwNumberOfBytesTransferred,  
-  DWORD dwCompletionKey, 
-  LPOVERLAPPED lpOverlapped  
+  HANDLE CompletionPort,
+  DWORD dwNumberOfBytesTransferred,
+  DWORD dwCompletionKey,
+  LPOVERLAPPED lpOverlapped
 )
 {
+       NTSTATUS errCode;
+       errCode = NtSetIoCompletion(CompletionPort,  dwCompletionKey, (PIO_STATUS_BLOCK)lpOverlapped , 0, (PULONG)&dwNumberOfBytesTransferred );
 
-        NTSTATUS errCode;
-        errCode = NtSetIoCompletion(CompletionPort,  dwCompletionKey, (PIO_STATUS_BLOCK)lpOverlapped , 0, (PULONG)&dwNumberOfBytesTransferred );
-
-                                  
-        if ( !NT_SUCCESS(errCode) ) {
+       if ( !NT_SUCCESS(errCode) ) {
                SetLastError(RtlNtStatusToDosError(errCode));
                return FALSE;
-        }
-        return TRUE;
+       }
+       return TRUE;
 }
 
 
 // this should be a place holder ??????????????????
-VOID 
-STDCALL 
+VOID
+STDCALL
 FileIOCompletionRoutine(
-       DWORD dwErrorCode,      
-       DWORD dwNumberOfBytesTransfered,        
-       LPOVERLAPPED lpOverlapped        
+       DWORD dwErrorCode,
+       DWORD dwNumberOfBytesTransfered,
+       LPOVERLAPPED lpOverlapped
        )
 {
        return;
 }
-
-
-
-
-
-
-
-
index 33ef1b8..c07d337 100644 (file)
@@ -13,8 +13,8 @@
 
 /* INCLUDES ****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <wchar.h>
 #include <string.h>
 
index 4e5445d..454967f 100644 (file)
@@ -13,8 +13,8 @@
 
 /* INCLUDES ****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <wchar.h>
 #include <string.h>
 
index d536773..29dbe4c 100644 (file)
@@ -9,8 +9,8 @@
 
 /* INCLUDES *****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <wchar.h>
 #include <string.h>
 
index ca39ebc..b6c6c19 100644 (file)
@@ -10,8 +10,8 @@
 
 /* INCLUDES ****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <wchar.h>
 #include <string.h>
 
index 479f598..07156ee 100644 (file)
@@ -18,8 +18,8 @@
  * Copyright 1996 Alexandre Julliard
  */
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <wchar.h>
 #include <string.h>
 
index 9e3aac0..b36ffc2 100644 (file)
@@ -1,5 +1,5 @@
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <stdarg.h>
 #include <stdio.h>
 
index b7bc81a..b647b65 100644 (file)
@@ -1,5 +1,5 @@
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <stdarg.h>
 
 #include <kernel32/kernel32.h>
index d29ba6b..b176795 100644 (file)
@@ -1,5 +1,5 @@
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <stdarg.h>
 
 BOOL KERNEL32_AnsiToUnicode(PWSTR DestStr,
index ff473d1..6b92da7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: section.c,v 1.4 1999/10/03 23:19:15 ea Exp $
+/* $Id: section.c,v 1.5 1999/10/07 23:44:28 ekohl Exp $
  *
  * COPYRIGHT:            See COPYING in the top level directory
  * PROJECT:              ReactOS kernel
@@ -9,7 +9,6 @@
 
 /* INCLUDES ******************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 
 /* FUNCTIONS *****************************************************************/
@@ -31,7 +30,17 @@ CreateFileMappingA (
    OBJECT_ATTRIBUTES ObjectAttributes;
    ANSI_STRING AnsiName;
    UNICODE_STRING UnicodeName;
-   
+   PSECURITY_DESCRIPTOR SecurityDescriptor;
+
+   if (lpFileMappingAttributes)
+     {
+        SecurityDescriptor = lpFileMappingAttributes->lpSecurityDescriptor;
+     }
+   else
+     {
+        SecurityDescriptor = NULL;
+     }
+
    MaximumSize.u.LowPart = dwMaximumSizeLow;
    MaximumSize.u.HighPart = dwMaximumSizeHigh;
    RtlInitAnsiString(&AnsiName, (LPSTR)lpName);
@@ -40,8 +49,8 @@ CreateFileMappingA (
                              &UnicodeName,
                              0,
                              NULL,
-                             lpFileMappingAttributes);
-   Status = ZwCreateSection(&SectionHandle,
+                             SecurityDescriptor);
+   Status = NtCreateSection(&SectionHandle,
                            SECTION_ALL_ACCESS,
                            &ObjectAttributes,
                            &MaximumSize,
@@ -74,7 +83,17 @@ CreateFileMappingW (
    LARGE_INTEGER MaximumSize;
    OBJECT_ATTRIBUTES ObjectAttributes;
    UNICODE_STRING UnicodeName;
-   
+   PSECURITY_DESCRIPTOR SecurityDescriptor;
+
+   if (lpFileMappingAttributes)
+     {
+        SecurityDescriptor = lpFileMappingAttributes->lpSecurityDescriptor;
+     }
+   else
+     {
+        SecurityDescriptor = NULL;
+     }
+
    MaximumSize.u.LowPart = dwMaximumSizeLow;
    MaximumSize.u.HighPart = dwMaximumSizeHigh;
    RtlInitUnicodeString(&UnicodeName, lpName);
@@ -82,8 +101,8 @@ CreateFileMappingW (
                              &UnicodeName,
                              0,
                              NULL,
-                             lpFileMappingAttributes);
-   Status = ZwCreateSection(&SectionHandle,
+                             SecurityDescriptor);
+   Status = NtCreateSection(&SectionHandle,
                            SECTION_ALL_ACCESS,
                            &ObjectAttributes,
                            &MaximumSize,
@@ -112,10 +131,6 @@ MapViewOfFileEx (
        )
 {
    NTSTATUS Status;
-   
-
-
-
    LARGE_INTEGER SectionOffset;
    ULONG ViewSize;
    ULONG Protect;
@@ -124,23 +139,17 @@ MapViewOfFileEx (
    SectionOffset.u.LowPart = dwFileOffsetLow;
    SectionOffset.u.HighPart = dwFileOffsetHigh;
 
-   
-  
-   
-
-
-   if ( ( dwDesiredAccess & FILE_MAP_WRITE ) == FILE_MAP_WRITE ) 
+   if ( ( dwDesiredAccess & FILE_MAP_WRITE ) == FILE_MAP_WRITE )
        Protect  = PAGE_READWRITE;
-   else if ( ( dwDesiredAccess & FILE_MAP_READ ) == FILE_MAP_READ ) 
+   else if ( ( dwDesiredAccess & FILE_MAP_READ ) == FILE_MAP_READ )
        Protect = PAGE_READONLY;
-   else if ( ( dwDesiredAccess & FILE_MAP_ALL_ACCESS ) == FILE_MAP_ALL_ACCESS ) 
-       Protect  = PAGE_READWRITE;      
-   else if ( ( dwDesiredAccess & FILE_MAP_COPY ) == FILE_MAP_COPY ) 
+   else if ( ( dwDesiredAccess & FILE_MAP_ALL_ACCESS ) == FILE_MAP_ALL_ACCESS )
+       Protect  = PAGE_READWRITE;
+   else if ( ( dwDesiredAccess & FILE_MAP_COPY ) == FILE_MAP_COPY )
        Protect = PAGE_WRITECOPY;
    else
        Protect  = PAGE_READWRITE;
 
-
    Status = ZwMapViewOfSection(hFileMappingObject,
                        NtCurrentProcess(),
                        &BaseAddress,
@@ -154,14 +163,13 @@ MapViewOfFileEx (
                        
                        
 
-       if (!NT_SUCCESS(Status))
+       if (!NT_SUCCESS(Status))
                {
                SetLastError(RtlNtStatusToDosError(Status));
                return NULL;
                }
 
        return BaseAddress;
-                              
 }
 
 LPVOID
@@ -188,7 +196,7 @@ UnmapViewOfFile (
        NTSTATUS Status;
        Status = NtUnmapViewOfSection(NtCurrentProcess(),lpBaseAddress);
        
-       if (!NT_SUCCESS(Status))
+       if (!NT_SUCCESS(Status))
        {
                SetLastError(RtlNtStatusToDosError(Status));
                return FALSE;
@@ -202,8 +210,8 @@ HANDLE
 STDCALL
 OpenFileMappingA (
        DWORD   dwDesiredAccess,
-       WINBOOL bInheritHandle, 
-       LPCSTR  lpName  
+       WINBOOL bInheritHandle,
+       LPCSTR  lpName
        )
 {
    NTSTATUS Status;
@@ -211,12 +219,12 @@ OpenFileMappingA (
    OBJECT_ATTRIBUTES ObjectAttributes;
    ANSI_STRING AnsiName;
    UNICODE_STRING UnicodeName;
-  
+
    ULONG Attributes = 0;
 
    if ( bInheritHandle )
-               Attributes = OBJ_INHERIT; 
-        
+               Attributes = OBJ_INHERIT;
+
    RtlInitAnsiString(&AnsiName, lpName);
    RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE);
 
@@ -226,7 +234,7 @@ OpenFileMappingA (
                              Attributes,
                              NULL,
                              NULL);
-   Status = ZwOpenSection(&SectionHandle,
+   Status = NtOpenSection(&SectionHandle,
                            SECTION_ALL_ACCESS,
                            &ObjectAttributes
                );
@@ -244,20 +252,20 @@ HANDLE
 STDCALL
 OpenFileMappingW (
        DWORD   dwDesiredAccess,
-       WINBOOL bInheritHandle, 
-       LPCWSTR lpName  
+       WINBOOL bInheritHandle,
+       LPCWSTR lpName
        )
 {
    NTSTATUS Status;
    HANDLE SectionHandle;
    OBJECT_ATTRIBUTES ObjectAttributes;
    UNICODE_STRING UnicodeName;
-   
+
    ULONG Attributes = 0;
 
    if ( bInheritHandle )
                Attributes = OBJ_INHERIT;
-  
+
    RtlInitUnicodeString(&UnicodeName, lpName);
    InitializeObjectAttributes(&ObjectAttributes,
                              &UnicodeName,
@@ -276,5 +284,4 @@ OpenFileMappingW (
        return SectionHandle;
 }
 
-
 /* EOF */
index dc8d2c2..8c918ad 100644 (file)
@@ -8,8 +8,8 @@
 
 /* INCLUDES ******************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 
 /* FUNCTIONS *****************************************************************/
 
index 7eda3cd..d7174a6 100644 (file)
@@ -4,11 +4,12 @@
  * FILE:            lib/kernel32/misc/atom.c
  * PURPOSE:         Atom functions
  * PROGRAMMER:      Ariadne ( ariadne@xs4all.nl)
-                   modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ]
*                  modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ]
  * UPDATE HISTORY:
  *                  Created 01/11/98
  */
 
+#include <ddk/ntddk.h>
 #include <kernel32/atom.h>
 #include <kernel32/proc.h>
 #include <kernel32/thread.h>
index 4248dde..09eb7a4 100644 (file)
@@ -9,9 +9,9 @@
  *     19990204 EA     SetConsoleTitleA
  *      19990306 EA    Stubs
  */
-#include <windows.h>
 #include <ddk/ntddk.h>
 #include <ddk/ntddblue.h>
+#include <windows.h>
 #include <assert.h>
 #include <wchar.h>
 
index 6968989..b0aa4e6 100644 (file)
@@ -8,8 +8,8 @@
  *                  Created 01/11/98
  */
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <wchar.h>
 #include <kernel32/proc.h>
 #include <internal/teb.h>
index 60a1add..1803545 100644 (file)
@@ -8,8 +8,8 @@
  *                  Created 01/11/98
  */
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <wchar.h>
 #include <string.h>
 
@@ -18,7 +18,7 @@
 #define MAX_ENVIRONMENT_VARS 255
 #define MAX_VALUE 1024
 
-typedef struct _ENV_ELEMENT 
+typedef struct _ENV_ELEMENT
 {
        UNICODE_STRING Name;
        UNICODE_STRING Value;
@@ -66,7 +66,7 @@ GetEnvironmentVariableW(
 
        while (i < nEnvVar) 
        {
-                if ( _wcsnicmp(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length/sizeof(WCHAR))) != 0 ) {
+               if ( _wcsnicmp(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length/sizeof(WCHAR))) != 0 ) {
                        lstrcpynW(lpBuffer,Environment[i].Value.Buffer,min(nSize,Environment[i].Value.Length/sizeof(WCHAR)));
                        
                        return lstrlenW(Environment[i].Value.Buffer);
@@ -92,27 +92,26 @@ SetEnvironmentVariableA(
 
        int i=0;
        while ((*lpName)!=0 && i < MAX_PATH)
-       {
+       {
                NameW[i] = *lpName;
                lpName++;
                i++;
-       }
-       NameW[i] = 0;
+       }
+       NameW[i] = 0;
 
        i = 0;
-       
+
        while ((*lpValue)!=0 && i < MAX_PATH)
-       {
+       {
                ValueW[i] = *lpValue;
                lpValue++;
                i++;
-       }
-       ValueW[i] = 0;
+       }
+       ValueW[i] = 0;
        return SetEnvironmentVariableW(NameW,ValueW);
-
-       
 }
 
+
 WINBOOL
 STDCALL
 SetEnvironmentVariableW(
@@ -130,7 +129,7 @@ SetEnvironmentVariableW(
 
        while (i < nEnvVar) 
        {
-                if ( _wcsnicmp(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length/sizeof(WCHAR))) != 0 ) {
+               if ( _wcsnicmp(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length/sizeof(WCHAR))) != 0 ) {
                        if ( lpValue != NULL ) {
                                lstrcpynW(Environment[i].Value.Buffer,lpValue,min(ValueLen,Environment[i].Value.MaximumLength/sizeof(WCHAR)));
                                return TRUE;
@@ -141,9 +140,6 @@ SetEnvironmentVariableW(
                                Environment[i].Name.Length = 0;
                                return FALSE;
                        }
-                               
-                               
-                       
                }
                i++;
        }
@@ -151,9 +147,9 @@ SetEnvironmentVariableW(
        if ( nEnvVar >= MAX_ENVIRONMENT_VARS )
                return FALSE;
 
-       while (i < nEnvVar) 
+       while (i < nEnvVar)
        {
-               if ( Environment[i].Valid == FALSE ) 
+               if ( Environment[i].Valid == FALSE )
                        break;
                i++;
        }
@@ -173,36 +169,31 @@ SetEnvironmentVariableW(
        lstrcpynW(Environment[i].Name.Buffer,lpValue,min(NameLen,(Environment[i].Name.MaximumLength-sizeof(WCHAR))/sizeof(WCHAR)));
        Environment[i].Name.Length = NameLen*sizeof(WCHAR);
 
-       
        lstrcpynW(Environment[i].Value.Buffer,lpValue,min(ValueLen,(Environment[i].Value.MaximumLength-sizeof(WCHAR)))/sizeof(WCHAR));
        Environment[i].Value.Length = ValueLen*sizeof(WCHAR);
-       
-       
-       
-       return TRUE;
 
+       return TRUE;
 }
 
-DWORD 
+DWORD
 STDCALL
 GetVersion(VOID)
 {
        DWORD Version = 0;
        OSVERSIONINFO VersionInformation;
        GetVersionExW(&VersionInformation);
-       
+
        Version |= ( VersionInformation.dwMajorVersion << 8 );
        Version |= VersionInformation.dwMinorVersion;
-       
+
        Version |= ( VersionInformation.dwPlatformId << 16 );
 
        return Version;
-               
 }
 
 
 
-WINBOOL 
+WINBOOL
 STDCALL
 GetVersionExW(
     LPOSVERSIONINFO lpVersionInformation       
@@ -217,7 +208,7 @@ GetVersionExW(
        return TRUE;
 }
 
-WINBOOL 
+WINBOOL
 STDCALL
 GetVersionExA(
     LPOSVERSIONINFO lpVersionInformation       
@@ -233,10 +224,9 @@ GetVersionExA(
 }
 
 
-
-
-
-LPSTR STDCALL GetEnvironmentStringsA(VOID)
+LPSTR
+STDCALL
+GetEnvironmentStringsA(VOID)
 {
 #if 0
    WCHAR *EnvironmentStringsW;
@@ -271,7 +261,9 @@ LPSTR STDCALL GetEnvironmentStringsA(VOID)
 }
 
 
-LPWSTR STDCALL GetEnvironmentStringsW(VOID)
+LPWSTR
+STDCALL
+GetEnvironmentStringsW(VOID)
 {
 #if 0
    int size = 0;
index 8676f0f..950c32a 100644 (file)
@@ -1,9 +1,8 @@
-/* $Id: error.c,v 1.11 1999/08/29 06:59:02 ea Exp $
+/* $Id: error.c,v 1.12 1999/10/07 23:45:07 ekohl Exp $
  *
  * reactos/lib/kernel32/misc/error.c
  *
  */
-#include <windows.h>
 #include <ddk/ntddk.h>
 #include <ddk/ntddbeep.h>
 
index 65decf8..7c47ff3 100644 (file)
@@ -7,17 +7,16 @@
  * UPDATE HISTORY:
  *                  Created 01/11/98
  */
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 
 
 
-WINBOOL 
-WINAPI 
-GetHandleInformation( 
-    HANDLE hObject, 
-    LPDWORD lpdwFlags 
+WINBOOL
+WINAPI
+GetHandleInformation(
+    HANDLE hObject,
+    LPDWORD lpdwFlags
     )
 {
        OBJECT_DATA_INFORMATION HandleInfo;
@@ -34,18 +33,17 @@ GetHandleInformation(
        if ( HandleInfo.bProtectFromClose )
                *lpdwFlags &= HANDLE_FLAG_PROTECT_FROM_CLOSE;
        return TRUE;
-       
-       
-} 
-WINBOOL 
-STDCALL 
-SetHandleInformation( 
-    HANDLE hObject, 
-    DWORD dwMask, 
-    DWORD dwFlags 
+}
+
+
+WINBOOL
+STDCALL
+SetHandleInformation(
+    HANDLE hObject,
+    DWORD dwMask,
+    DWORD dwFlags
     )
-{      
+{
        OBJECT_DATA_INFORMATION HandleInfo;
        NTSTATUS errCode;
        ULONG BytesWritten;
@@ -70,53 +68,45 @@ SetHandleInformation(
 
        return TRUE;
 }
 
 
-WINBOOL 
+WINBOOL
 STDCALL
 CloseHandle(    HANDLE  hObject )
 {
-
        NTSTATUS errCode;
 
-        errCode = NtClose(hObject);
-        if(!NT_SUCCESS(errCode)) {
-               SetLastError(RtlNtStatusToDosError(errCode));
-               return FALSE;
+       errCode = NtClose(hObject);
+       if(!NT_SUCCESS(errCode)) {
+               SetLastError(RtlNtStatusToDosError(errCode));
+               return FALSE;
        }
-       
+
        return TRUE;
 }
 
 
-
 WINBOOL
 STDCALL
 DuplicateHandle(
-    HANDLE hSourceProcessHandle,       
-    HANDLE hSourceHandle,      
-    HANDLE hTargetProcessHandle,       
-    LPHANDLE lpTargetHandle,   
-    DWORD dwDesiredAccess,      
-    BOOL bInheritHandle,       
-    DWORD dwOptions    
+    HANDLE hSourceProcessHandle,
+    HANDLE hSourceHandle,
+    HANDLE hTargetProcessHandle,
+    LPHANDLE lpTargetHandle,
+    DWORD dwDesiredAccess,
+    BOOL bInheritHandle,
+    DWORD dwOptions
    )
 {
-
-       
        NTSTATUS errCode;
-       
+
        errCode = NtDuplicateObject(hSourceProcessHandle,hSourceHandle,hTargetProcessHandle,lpTargetHandle, dwDesiredAccess, (BOOLEAN)bInheritHandle,dwOptions);
        if ( !NT_SUCCESS(errCode) ) {
                SetLastError(RtlNtStatusToDosError(errCode));
                return FALSE;
        }
-               
-                       
-       
+
        return TRUE;
-               
 }
 
 UINT STDCALL
@@ -124,10 +114,3 @@ SetHandleCount(UINT nCount)
 {
        return nCount;
 }
-
-
-
-
-
-
index f910f3a..14fecf3 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.6 1999/10/03 23:19:15 ea Exp $
+/* $Id: stubs.c,v 1.7 1999/10/07 23:45:07 ekohl Exp $
  *
  * KERNEL32.DLL stubs (unimplemented functions)
  * Remove from this file, if you implement them.
@@ -815,8 +815,6 @@ ExitVDM (
 }
 
 
-
-
 DWORD
 STDCALL
 ExpungeConsoleCommandHistoryW (
@@ -985,12 +983,11 @@ FindResourceExA (
 }
 
 
-
 WINBOOL
 STDCALL
-FlushViewOfFile (
+FlushViewOfFile(
        LPCVOID lpBaseAddress,
-       DWORD   dwNumberOfBytesToFlush
+       DWORD           dwNumberOfBytesToFlush
        )
 {
        SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
@@ -1013,7 +1010,6 @@ FoldStringW (
 }
 
 
-
 int
 STDCALL
 FoldStringA (
@@ -1029,7 +1025,6 @@ FoldStringA (
 }
 
 
-   
 DWORD
 STDCALL
 FormatMessageW (
@@ -2713,8 +2708,6 @@ InitAtomTable (
 }
 
 
-
-
 DWORD
 STDCALL
 InvalidateConsoleDIBits (
@@ -2727,8 +2720,6 @@ InvalidateConsoleDIBits (
 }
 
 
-
-
 WINBOOL
 STDCALL
 IsDBCSLeadByte (
@@ -2991,7 +2982,6 @@ LockResource (
 }
 
 
-
 int
 STDCALL
 MulDiv (
@@ -3815,8 +3805,6 @@ TrimVirtualBuffer (
 }
 
 
-
-
 WINBOOL
 STDCALL
 UpdateResourceA (
@@ -3922,9 +3910,6 @@ VirtualBufferExceptionHandler (
 }
 
 
-
-
-
 WINBOOL
 STDCALL
 WaitCommEvent (
@@ -4020,9 +4005,6 @@ WriteConsoleInputVDMW (
 }
 
 
-
-
-
 WINBOOL
 STDCALL
 WritePrivateProfileSectionA (
index 95b036d..c5975b1 100644 (file)
@@ -11,9 +11,8 @@
 
 /* INCLUDES ******************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
-#include <string.h>
+#include <windows.h>
 #include <internal/string.h>
 #include <string.h>
 
index 87870ad..6c7042a 100644 (file)
@@ -11,6 +11,7 @@
 /* INCLUDES ****************************************************************/
 
 #define UNICODE
+#include <ddk/ntddk.h>
 #include <windows.h>
 #include <kernel32/proc.h>
 #include <kernel32/thread.h>
index 782e164..702f47c 100644 (file)
@@ -11,6 +11,7 @@
 /* INCLUDES ****************************************************************/
 
 #define WIN32_NO_PEHDR
+#include <ddk/ntddk.h>
 #include <windows.h>
 #include <kernel32/proc.h>
 #include <kernel32/thread.h>
index bf6010a..e5db68f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: lib.c,v 1.3 1999/08/29 06:59:03 ea Exp $
+/* $Id: lib.c,v 1.4 1999/10/07 23:45:25 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -12,6 +12,7 @@
 /* INCLUDES ****************************************************************/
 
 #define UNICODE
+#include <ddk/ntddk.h>
 #include <windows.h>
 #include <kernel32/proc.h>
 #include <kernel32/thread.h>
index f73b90b..ff952c3 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: proc.c,v 1.20 1999/09/12 20:58:29 ekohl Exp $
+/* $Id: proc.c,v 1.21 1999/10/07 23:45:25 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -12,6 +12,7 @@
 /* INCLUDES ****************************************************************/
 
 #define UNICODE
+#include <ddk/ntddk.h>
 #include <windows.h>
 #include <kernel32/proc.h>
 #include <kernel32/thread.h>
index f17b44f..855da67 100644 (file)
@@ -32,6 +32,7 @@ lstrcmpiA(
 {
         return _stricmp(lpString1,lpString2); 
 }
+
 LPSTR
 STDCALL
 lstrcpynA(
@@ -75,9 +76,9 @@ lstrlenA(
 int
 STDCALL
 lstrcmpW(
-    LPCWSTR lpString1,
-    LPCWSTR lpString2
-    )
+        LPCWSTR lpString1,
+        LPCWSTR lpString2
+        )
 {
        return wcscmp(lpString1,lpString2);
 }
@@ -130,7 +131,6 @@ lstrlenW(
     )
 {
        return wcslen(lpString);
-       
 }
 
 
index f63a43a..4f67a30 100644 (file)
@@ -8,8 +8,8 @@
  *                  Created 01/11/98
  */
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 #include <wchar.h>
 
 
index 9a61cfc..dda9ead 100644 (file)
@@ -8,8 +8,8 @@
 
 /* INCLUDES ******************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
+#include <windows.h>
 
 /* FUNCTIONS *****************************************************************/
 
index 9c58169..cd28bf8 100644 (file)
@@ -8,9 +8,9 @@
  *                  Created 01/11/98
  */
 
+#include <ddk/ntddk.h>
 #include <windows.h>
 #include <wchar.h>
-#include <ddk/ntddk.h>
 
 HANDLE
 STDCALL
index 89f883a..1b89381 100644 (file)
@@ -11,9 +11,9 @@
 
 /* INCLUDES ******************************************************************/
 
+#include <ddk/ntddk.h>
 #include <windows.h>
 #include <kernel32/thread.h>
-#include <ddk/ntddk.h>
 #include <string.h>
 #include <internal/i386/segment.h>
 
index 677028c..32084eb 100644 (file)
@@ -4,16 +4,16 @@
  * FILE:            lib/kernel32/thread/tls.c
  * PURPOSE:         Thread functions
  * PROGRAMMER:      Ariadne ( ariadne@xs4all.nl)
- *                     Tls functions are modified from WINE
+ *                  Tls functions are modified from WINE
  * UPDATE HISTORY:
  *                  Created 01/11/98
  */
 
 /* INCLUDES ******************************************************************/
 
+#include <ddk/ntddk.h>
 #include <windows.h>
 #include <kernel32/thread.h>
-#include <ddk/ntddk.h>
 #include <string.h>
 
 /* FUNCTIONS *****************************************************************/
index 2abf09b..3fa4a21 100644 (file)
@@ -12,9 +12,6 @@
 
 #define WIN32_NO_PEHDR
 #include <ddk/ntddk.h>
-//#include <windows.h>
-//#include <kernel32/proc.h>
-//#include <kernel32/thread.h>
 #include <wchar.h>
 #include <string.h>
 #include <pe.h>
@@ -23,7 +20,7 @@
 #include <internal/teb.h>
 #include <ntdll/base.h>
 
-//#define NDEBUG
+#define NDEBUG
 #include <ntdll/ntdll.h>
 
 /* FUNCTIONS ****************************************************************/
index 61c5f97..ed8ba2d 100644 (file)
@@ -1,4 +1,3 @@
-#include <windows.h>
 #include <ddk/ntddk.h>
 
 #define STUB(x) void x(void) { UNICODE_STRING UnicodeString; \
index a376315..4ffd02d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: registry.c,v 1.18 1999/08/29 06:59:05 ea Exp $
+/* $Id: registry.c,v 1.19 1999/10/07 23:33:22 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -11,7 +11,6 @@
  */
 
 #undef WIN32_LEAN_AND_MEAN
-#include <windows.h>
 #include <ddk/ntddk.h>
 #include <internal/ob.h>
 #include <wchar.h>
index 4460876..9e52aef 100644 (file)
@@ -24,6 +24,7 @@
 /* Note: Bias[minutes] = UTC - local time */
 TIME_ZONE_INFORMATION SystemTimeZoneInfo;
 
+
 /* FUNCTIONS ****************************************************************/
 
 VOID
@@ -36,6 +37,7 @@ ExInitTimeZoneInfo (VOID)
 
 }
 
+
 NTSTATUS
 STDCALL
 NtSetSystemTime (
index ebe03d9..cf58a71 100644 (file)
@@ -10,7 +10,6 @@
 
 /* INCLUDES ******************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 
 #include <internal/debug.h>
index b289325..a9a458b 100644 (file)
@@ -10,7 +10,7 @@
 
 /* INCLUDES *****************************************************************/
 
-#include <windows.h>
+#include <ddk/ntddk.h>
 #include <internal/ntoskrnl.h>
 #include <internal/ke.h>
 #include <internal/symbol.h>
index 3704d80..6ed2449 100644 (file)
@@ -10,6 +10,7 @@
 
 /* INCLUDES *****************************************************************/
 
+#include <ddk/ntddk.h>
 #include <internal/ntoskrnl.h>
 #include <internal/ke.h>
 #include <internal/hal.h>
index aa49b75..1c333ec 100644 (file)
@@ -1,5 +1,5 @@
 
-#include <windows.h>
+#include <ddk/ntddk.h>
 #include <internal/ntoskrnl.h>
 #include <internal/ke.h>
 #include <internal/symbol.h>
index d92fe99..83b98ea 100644 (file)
@@ -10,7 +10,6 @@
 
 /* INCLUDES ***************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 
 /* FUNCTIONS *****************************************************************/
index 90a384e..66675ce 100644 (file)
@@ -14,7 +14,6 @@
 
 /* INCLUDES ***************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 
 /* FUNCTIONS **************************************************************/
index d6a0e9a..701c5b3 100644 (file)
 
 /* INCLUDES *****************************************************************/
 
+#include <ddk/ntddk.h>
 #include <internal/ntoskrnl.h>
 #include <string.h>
 #include <internal/string.h>
 #include <internal/mmhal.h>
 #include <internal/halio.h>
 
+#define NDEBUG
+#include <internal/debug.h>
+
+/* GLOBALS ******************************************************************/
+
 //#define BOCHS_DEBUGGING 1
 //#define SERIAL_DEBUGGING
 #define SERIAL_PORT 0x03f8
 #define SERIAL_BAUD_RATE 19200
 #define SERIAL_LINE_CONTROL (SR_LCR_CS8 | SR_LCR_ST1 | SR_LCR_PNO)
 
-#define NDEBUG
-#include <internal/debug.h>
-
-/* GLOBALS ******************************************************************/
 
 #define IDMAP_BASE         (0xd0000000)
 
index d13010e..0fb7a92 100644 (file)
@@ -1,4 +1,15 @@
-#include <windows.h>
+/* $Id: usercall.c,v 1.4 1999/10/07 23:35:10 ekohl Exp $
+ *
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS kernel
+ * FILE:            ntoskrnl/hal/x86/usercall.c
+ * PURPOSE:         2E interrupt handler
+ * PROGRAMMER:      ???
+ * UPDATE HISTORY:
+ *                  ???
+ */
+
+#include <ddk/ntddk.h>
 #include <internal/ntoskrnl.h>
 #include <internal/ke.h>
 #include <internal/symbol.h>
index 2637787..3590a82 100644 (file)
@@ -10,7 +10,6 @@
 
 /* INCLUDES ****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 #include <internal/io.h>
 #include <string.h>
index ba37f16..57553cc 100644 (file)
@@ -10,7 +10,6 @@
 
 /* INCLUDES ***************************************************************/
 
-#include <wchar.h>
 #include <ddk/ntddk.h>
 #include <internal/ob.h>
 #include <internal/io.h>
index bd9e195..3d25877 100644 (file)
@@ -10,7 +10,6 @@
 
 /* INCLUDES ****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 #include <internal/ob.h>
 #include <internal/io.h>
index a9d8dfb..e4a72b2 100644 (file)
@@ -8,7 +8,6 @@
 
 /* INCLUDES ******************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 
 #define NDEBUG
index 189aa3b..47d9c4b 100644 (file)
@@ -8,7 +8,6 @@
 
 /* INCLUDES *****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 
 #include <internal/debug.h>
index 15a5b4c..234d7c8 100644 (file)
@@ -8,7 +8,6 @@
 
 /* INCLUDES *****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 #include <internal/ke.h>
 #include <internal/ps.h>
index 5ba1f87..764820b 100644 (file)
@@ -10,8 +10,8 @@
 
 /* INCLUDES *****************************************************************/
 
-#include <internal/ke.h>
 #include <ddk/ntddk.h>
+#include <internal/ke.h>
 
 #include <internal/debug.h>
 
index eb1f11b..b6213c9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.22 1999/08/29 06:59:10 ea Exp $
+/* $Id: main.c,v 1.23 1999/10/07 23:36:00 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -11,8 +11,7 @@
 
 /* INCLUDES *****************************************************************/
 
-#include <windows.h>
-
+#include <ddk/ntddk.h>
 #include <internal/ntoskrnl.h>
 #include <internal/version.h>
 #include <internal/mm.h>
index 59a89a8..6659a74 100644 (file)
@@ -14,7 +14,6 @@
 
 /* INCLUDES ******************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 #include <internal/ke.h>
 
@@ -73,6 +72,7 @@ static BOOLEAN KeDispatcherObjectWakeAll(DISPATCHER_HEADER* hdr)
 {
    PKWAIT_BLOCK current;
    PLIST_ENTRY current_entry;
+   PKWAIT_BLOCK PrevBlock;
 
    DPRINT("KeDispatcherObjectWakeAll(hdr %x)\n",hdr);
 
@@ -88,9 +88,42 @@ static BOOLEAN KeDispatcherObjectWakeAll(DISPATCHER_HEADER* hdr)
                                            WaitListEntry);
         DPRINT("Waking %x\n",current->Thread);
 
-        if (current->NextWaitBlock != NULL)
+        if (current->WaitType == WaitAny)
           {
-             DbgPrint("DANGLING POINTERS!!! We're in trouble!\n");
+             DPRINT("WaitAny: Remove all wait blocks.\n");
+             current->Thread->WaitBlockList = NULL;
+          }
+        else
+          {
+             DPRINT("WaitAll: Remove the current wait block only.\n");
+
+             PrevBlock = current->Thread->WaitBlockList;
+             if (PrevBlock)
+               {
+                  if (PrevBlock->NextWaitBlock == current)
+                    {
+                       DPRINT("WaitAll: Current block is list head.\n");
+                       PrevBlock->NextWaitBlock = current->NextWaitBlock;
+                    }
+                  else
+                    {
+                       DPRINT("WaitAll: Current block is list head.\n");
+                       while (PrevBlock &&
+                              PrevBlock->NextWaitBlock != current)
+                         {
+                            PrevBlock = PrevBlock->NextWaitBlock;
+                         }
+
+                       if (PrevBlock)
+                         {
+                            PrevBlock->NextWaitBlock = current->NextWaitBlock;
+                         }
+                    }
+               }
+             else
+               {
+                  DPRINT("WaitAll: Wait Block List is empty!\n");
+               }
           }
 
        PsResumeThread(CONTAINING_RECORD(current->Thread,ETHREAD,Tcb));
@@ -102,6 +135,7 @@ static BOOLEAN KeDispatcherObjectWakeOne(DISPATCHER_HEADER* hdr)
 {
    PKWAIT_BLOCK current;
    PLIST_ENTRY current_entry;
+   PKWAIT_BLOCK PrevBlock;
 
    DPRINT("KeDispatcherObjectWakeOn(hdr %x)\n",hdr);
    DPRINT("hdr->WaitListHead.Flink %x hdr->WaitListHead.Blink %x\n",
@@ -114,6 +148,45 @@ static BOOLEAN KeDispatcherObjectWakeOne(DISPATCHER_HEADER* hdr)
    current = CONTAINING_RECORD(current_entry,KWAIT_BLOCK,
                               WaitListEntry);
    DPRINT("current_entry %x current %x\n",current_entry,current);
+
+
+   if (current->WaitType == WaitAny)
+     {
+        DPRINT("WaitAny: Remove all wait blocks.\n");
+        current->Thread->WaitBlockList = NULL;
+     }
+   else
+     {
+        DPRINT("WaitAll: Remove the current wait block only.\n");
+
+        PrevBlock = current->Thread->WaitBlockList;
+        if (PrevBlock)
+          {
+             if (PrevBlock->NextWaitBlock == current)
+               {
+                  DPRINT("WaitAll: Current block is list head.\n");
+                  PrevBlock->NextWaitBlock = current->NextWaitBlock;
+               }
+             else
+               {
+                  DPRINT("WaitAll: Current block is list head.\n");
+                  while (PrevBlock && PrevBlock->NextWaitBlock != current)
+                    {
+                       PrevBlock = PrevBlock->NextWaitBlock;
+                    }
+
+                  if (PrevBlock)
+                    {
+                       PrevBlock->NextWaitBlock = current->NextWaitBlock;
+                    }
+               }
+          }
+         else
+           {
+              DPRINT("WaitAll: Wait Block List is empty!\n");
+           }
+     }
+
    DPRINT("Waking %x\n",current->Thread);
    if (hdr->Type == SemaphoreType)
       hdr->SignalState--;
@@ -163,7 +236,7 @@ BOOLEAN KeDispatcherObjectWake(DISPATCHER_HEADER* hdr)
       case ID_THREAD_OBJECT:
        return(KeDispatcherObjectWakeAll(hdr));
      }
-   DbgPrint("Dispatcher object %x has unknown type\n",hdr);
+   DPRINT("Dispatcher object %x has unknown type\n",hdr);
    KeBugCheck(0);
    return(FALSE);
 }
@@ -190,10 +263,13 @@ NTSTATUS KeWaitForSingleObject(PVOID Object,
 {
    DISPATCHER_HEADER* hdr = (DISPATCHER_HEADER *)Object;
    KWAIT_BLOCK blk;
+   PKTHREAD CurrentThread;
 
    DPRINT("Entering KeWaitForSingleObject(Object %x) "
          "PsGetCurrentThread() %x\n",Object,PsGetCurrentThread());
 
+   CurrentThread = KeGetCurrentThread();
+
    KeAcquireDispatcherDatabaseLock(FALSE);
 
    DPRINT("hdr->SignalState %d\n", hdr->SignalState);
@@ -225,18 +301,21 @@ NTSTATUS KeWaitForSingleObject(PVOID Object,
           
        }
       KeReleaseDispatcherDatabaseLock(FALSE);
-      return(STATUS_SUCCESS);
+      return(STATUS_WAIT_0);
    }
 
    if (Timeout != NULL)
      {
-       KeAddThreadTimeout(KeGetCurrentThread(),Timeout);
+        KeAddThreadTimeout(CurrentThread,Timeout);
      }
 
-   blk.Object=Object;
-   blk.Thread=KeGetCurrentThread();
+   /* Append wait block to the KTHREAD wait block list */
+   CurrentThread->WaitBlockList = &blk;
+
+   blk.Object = Object;
+   blk.Thread = CurrentThread;
    blk.WaitKey = 0;
-   blk.WaitType = WaitAll;
+   blk.WaitType = WaitAny;
    blk.NextWaitBlock = NULL;
    InsertTailList(&(hdr->WaitListHead),&(blk.WaitListEntry));
 //   DPRINT("hdr->WaitListHead.Flink %x hdr->WaitListHead.Blink %x\n",
@@ -249,9 +328,11 @@ NTSTATUS KeWaitForSingleObject(PVOID Object,
    if (Timeout != NULL)
      {
        KeCancelTimer(&KeGetCurrentThread()->Timer);
+        if (KeReadStateTimer(&KeGetCurrentThread()->Timer))
+            return(STATUS_TIMEOUT);
      }
    DPRINT("Returning from KeWaitForSingleObject()\n");
-   return(STATUS_SUCCESS);
+   return(STATUS_WAIT_0);
 }
 
 NTSTATUS KeWaitForMultipleObjects(ULONG Count,
@@ -265,24 +346,32 @@ NTSTATUS KeWaitForMultipleObjects(ULONG Count,
 {
     DISPATCHER_HEADER* hdr;
     PKWAIT_BLOCK blk;
+    PKTHREAD CurrentThread;
     ULONG CountSignaled;
     ULONG i;
 
-    DbgPrint("Entering KeWaitForMultipleObjects(Count %lu Object[] %p) "
+    DPRINT("Entering KeWaitForMultipleObjects(Count %lu Object[] %p) "
     "PsGetCurrentThread() %x\n",Count,Object,PsGetCurrentThread());
 
     CountSignaled = 0;
+    CurrentThread = KeGetCurrentThread();
 
     if (WaitBlockArray == NULL)
     {
-        DbgPrint("FIXME: Use internal wait blocks!\n");
-        return STATUS_UNSUCCESSFUL;
+        if (Count > 3)
+        {
+            DbgPrint("(%s:%d) Too many objects!\n",
+                     __FILE__,__LINE__);
+            return STATUS_UNSUCCESSFUL;
+        }
+        blk = &CurrentThread->WaitBlock[1];
     }
     else
     {
         if (Count > 64)
         {
-            DbgPrint("Too many objects!\n");
+            DbgPrint("(%s:%d) Too many objects!\n",
+                     __FILE__,__LINE__);
             return STATUS_UNSUCCESSFUL;
         }
         blk = WaitBlockArray;
@@ -294,7 +383,7 @@ NTSTATUS KeWaitForMultipleObjects(ULONG Count,
     {
         hdr = (DISPATCHER_HEADER *)Object[i];
 
-//        DbgPrint("hdr->SignalState %d\n", hdr->SignalState);
+        DPRINT("hdr->SignalState %d\n", hdr->SignalState);
 
         if (hdr->SignalState > 0)
         {
@@ -327,8 +416,8 @@ NTSTATUS KeWaitForMultipleObjects(ULONG Count,
             if (WaitType == WaitAny)
             {
                 KeReleaseDispatcherDatabaseLock(FALSE);
-                DbgPrint("One object is already signaled!\n");
-                return(STATUS_SUCCESS);
+                DPRINT("One object is already signaled!\n");
+                return(STATUS_WAIT_0 + i);
             }
         }
     }
@@ -336,30 +425,33 @@ NTSTATUS KeWaitForMultipleObjects(ULONG Count,
     if ((WaitType == WaitAll) && (CountSignaled == Count))
     {
         KeReleaseDispatcherDatabaseLock(FALSE);
-        DbgPrint("All objects are already signaled!\n");
-        return(STATUS_SUCCESS);
+        DPRINT("All objects are already signaled!\n");
+        return(STATUS_WAIT_0);
     }
 
     if (Timeout != NULL)
     {
-       KeAddThreadTimeout(KeGetCurrentThread(),Timeout);
+        KeAddThreadTimeout(CurrentThread,Timeout);
     }
 
+    /* Append wait block to the KTHREAD wait block list */
+    CurrentThread->WaitBlockList = blk;
+
     for (i = 0; i < Count; i++)
     {
         hdr = (DISPATCHER_HEADER *)Object[i];
 
-        DbgPrint("hdr->SignalState %d\n", hdr->SignalState);
+        DPRINT("hdr->SignalState %d\n", hdr->SignalState);
 
-        blk->Object=Object[i];
-        blk->Thread=KeGetCurrentThread();
+        blk->Object = Object[i];
+        blk->Thread = CurrentThread;
         blk->WaitKey = i;
         blk->WaitType = WaitType;
         if (i == Count - 1)
             blk->NextWaitBlock = NULL;
         else
             blk->NextWaitBlock = (PVOID)((ULONG)blk+sizeof(KWAIT_BLOCK));
-        DbgPrint("blk %p blk->NextWaitBlock %p\n",
+        DPRINT("blk %p blk->NextWaitBlock %p\n",
                blk, blk->NextWaitBlock);
 
         InsertTailList(&(hdr->WaitListHead),&(blk->WaitListEntry));
@@ -371,18 +463,29 @@ NTSTATUS KeWaitForMultipleObjects(ULONG Count,
 
     KeReleaseDispatcherDatabaseLock(FALSE);
 
-    DbgPrint("Waiting at %s:%d with irql %d\n", __FILE__, __LINE__, 
-             KeGetCurrentIrql());
+    DPRINT("Waiting at %s:%d with irql %d\n", __FILE__, __LINE__, 
+           KeGetCurrentIrql());
     PsSuspendThread(PsGetCurrentThread());
    
     if (Timeout != NULL)
     {
        KeCancelTimer(&KeGetCurrentThread()->Timer);
+        if (KeReadStateTimer(&KeGetCurrentThread()->Timer))
+            return(STATUS_TIMEOUT);
     }
 
-    DbgPrint("Returning from KeWaitForMultipleObjects()\n");
+    DPRINT("Returning from KeWaitForMultipleObjects()\n");
+
+    if (WaitType == WaitAny)
+    {
+        for (i = 0; i < Count; i++)
+        {
+            if (((DISPATCHER_HEADER *)Object[i])->SignalState)
+                return(STATUS_WAIT_0+i);
+        }
+    }
 
-    return STATUS_SUCCESS;
+    return(STATUS_WAIT_0);
 }
 
 VOID KeInitializeDispatcher(VOID)
@@ -401,21 +504,16 @@ NtWaitForMultipleObjects (
        IN      PLARGE_INTEGER  Time
        )
 {
-   KWAIT_BLOCK WaitBlockArray[64];
-   PVOID ObjectPtrArray[64];
-//   KWAIT_BLOCK WaitBlockArray[MAXIMUM_WAIT_OBJECTS];
-//   PVOID ObjectPtrArray[MAXIMUM_WAIT_OBJECTS];
+   KWAIT_BLOCK WaitBlockArray[64]; /* FIXME: use MAXIMUM_WAIT_OBJECTS instead */
+   PVOID ObjectPtrArray[64];       /* FIXME: use MAXIMUM_WAIT_OBJECTS instead */
    NTSTATUS Status;
    ULONG i, j;
 
-
    DPRINT("NtWaitForMultipleObjects(Count %lu Object[] %x, Alertable %d, Time %x)\n",
           Count,Object,Alertable,Time);
 
-   if (Count > 64)
-//   if (Count > MAXIMUM_WAIT_OBJECTS)
+   if (Count > 64)  /* FIXME: use MAXIMUM_WAIT_OBJECTS instead */
         return STATUS_UNSUCCESSFUL;
-//        return WAIT_FAIL;  /* this must be returned by WaitForMultipleObjects */
 
    /* reference all objects */
    for (i = 0; i < Count; i++)
index fbd1fea..37096df 100644 (file)
@@ -17,8 +17,7 @@
 
 /* INCLUDES *****************************************************************/
 
-#include <windows.h>
-
+#include <ddk/ntddk.h>
 #include <internal/i386/segment.h>
 #include <internal/linkage.h>
 #include <internal/module.h>
@@ -29,7 +28,6 @@
 #include <internal/string.h>
 #include <internal/symbol.h>
 #include <internal/teb.h>
-#include <ddk/ntddk.h>
 
 //#define NDEBUG
 #include <internal/debug.h>
index b797218..43ea069 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: loader.c,v 1.31 1999/09/05 12:40:20 ekohl Exp $
+/* $Id: loader.c,v 1.32 1999/10/07 23:36:24 ekohl Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -17,8 +17,7 @@
 
 /* INCLUDES *****************************************************************/
 
-#include <windows.h>
-
+#include <ddk/ntddk.h>
 #include <internal/i386/segment.h>
 #include <internal/linkage.h>
 #include <internal/module.h>
@@ -30,8 +29,6 @@
 #include <internal/string.h>
 #include <internal/symbol.h>
 
-#include <ddk/ntddk.h>
-
 #define NDEBUG
 #include <internal/debug.h>
 
index 6dae0f8..09c3a71 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: syspath.c,v 1.1 1999/07/17 23:10:27 ea Exp $
+/* $Id: syspath.c,v 1.2 1999/10/07 23:36:25 ekohl Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
 
 /* INCLUDES *****************************************************************/
 
-#include <windows.h>
+#include <ddk/ntddk.h>
 #include <wchar.h>
 #include <string.h>
-#include <ddk/ntddk.h>
 
 
 /**********************************************************************
index e955cbf..e5736ae 100644 (file)
@@ -10,6 +10,7 @@
 
 /* INCLUDES *****************************************************************/
 
+#include <ddk/ntddk.h>
 #include <internal/hal/io.h>
 #include <internal/i386/segment.h>
 #include <internal/stddef.h>
index 6dda185..dcc75a8 100644 (file)
@@ -15,6 +15,7 @@
 
 /* INCLUDES ****************************************************************/
 
+#include <ddk/ntddk.h>
 #include <string.h>
 #include <internal/string.h>
 #include <internal/stddef.h>
@@ -26,7 +27,6 @@
 #define NDEBUG
 #include <internal/debug.h>
 
-#include <ddk/ntddk.h>
 
 
 #if 0
index e363687..3a905da 100644 (file)
@@ -8,8 +8,8 @@
 
 /* INCLUDES ****************************************************************/
 
-#include <internal/ntoskrnl.h>
 #include <ddk/ntddk.h>
+#include <internal/ntoskrnl.h>
 #include <internal/pool.h>
 
 #define NDEBUG
index 0df248c..1e6f261 100644 (file)
@@ -12,6 +12,7 @@
  
 /* INCLUDE *****************************************************************/
 
+#include <ddk/ntddk.h>
 #include <internal/mm.h>
 #include <internal/mmhal.h>
 #include <internal/ob.h>
@@ -416,7 +417,82 @@ NtQueryVirtualMemory (
        OUT     PULONG  ResultLength
        )
 {
-       UNIMPLEMENTED;
+   NTSTATUS Status;
+   PEPROCESS Process;
+   MEMORY_AREA* MemoryArea;
+
+#if 0
+   DbgPrint("NtReadVirtualMemory(ProcessHandle %x, Address %x, "
+            "VirtualMemoryInformationClass %d, VirtualMemoryInformation %x, "
+            "Length %lu ResultLength %x)\n",ProcessHandle,Address,
+            VirtualMemoryInformationClass,VirtualMemoryInformation,
+            Length,ResultLength);
+#endif
+   switch(VirtualMemoryInformationClass)
+     {
+        case MemoryBasicInformation:
+          {
+             PMEMORY_BASIC_INFORMATION Info =
+                (PMEMORY_BASIC_INFORMATION)VirtualMemoryInformation;
+
+             if (Length < sizeof(MEMORY_BASIC_INFORMATION))
+               {
+                  ObDereferenceObject(Process);
+                  return(STATUS_INFO_LENGTH_MISMATCH);
+               }
+
+             *ResultLength = sizeof(MEMORY_BASIC_INFORMATION);
+
+
+             Status = ObReferenceObjectByHandle(ProcessHandle,
+                                                PROCESS_QUERY_INFORMATION,
+                                                NULL,
+                                                UserMode,
+                                                (PVOID*)(&Process),
+                                                NULL);
+
+             if (!NT_SUCCESS(Status))
+               {
+//                  DbdPrint("NtQueryVirtualMemory() = %x\n",Status);
+                  return(Status);
+               }
+
+             MemoryArea = MmOpenMemoryAreaByAddress(Process,
+                                                    Address);
+
+             if (MemoryArea == NULL)
+               {
+                  Info->State = MEM_FREE;
+                  DbgPrint("Virtual memory at %p is free.\n", Address);
+                  ObDereferenceObject(Process);
+                  return (STATUS_SUCCESS);
+               }
+
+             if (MemoryArea->Type == MEMORY_AREA_COMMIT)
+               {
+                  Info->State = MEM_COMMIT;
+               }
+             else
+               {
+                  Info->State = MEM_RESERVE;
+               }
+
+             Info->BaseAddress = MemoryArea->BaseAddress;
+             Info->RegionSize  = MemoryArea->Length;
+
+   DbgPrint("BaseAddress %p, Length %x\n",
+             Info->BaseAddress, Info->RegionSize);
+
+
+             ObDereferenceObject(Process);
+             return (STATUS_SUCCESS);
+          }
+          break;
+     }
+
+   return(STATUS_INVALID_INFO_CLASS);
+
+//    UNIMPLEMENTED;
 }
 
 
index 66cac98..6d55a84 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: handle.c,v 1.11 1999/08/29 06:59:11 ea Exp $
+/* $Id: handle.c,v 1.12 1999/10/07 23:38:08 ekohl Exp $
  *
  * COPYRIGHT:          See COPYING in the top level directory
  * PROJECT:            ReactOS kernel
@@ -11,7 +11,6 @@
 
 /* INCLUDES ****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 #include <internal/ob.h>
 #include <string.h>
index 04fd59d..6eb4735 100644 (file)
@@ -44,6 +44,7 @@ VOID PsTerminateCurrentThread(NTSTATUS ExitStatus)
    CurrentThread->ThreadsProcess = NULL;
    KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
    CurrentThread->Tcb.State = THREAD_STATE_TERMINATED;
+   CurrentThread->Tcb.DispatcherHeader.SignalState = TRUE;
    KeDispatcherObjectWake(&CurrentThread->Tcb.DispatcherHeader);
    ZwYieldExecution();
    for(;;);
@@ -59,6 +60,7 @@ VOID PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus)
    PiNrThreads--;
    KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
    Thread->Tcb.State = THREAD_STATE_TERMINATED;
+   Thread->Tcb.DispatcherHeader.SignalState = TRUE;
    KeDispatcherObjectWake(&Thread->Tcb.DispatcherHeader);
    ObDereferenceObject(Thread->ThreadsProcess);
    Thread->ThreadsProcess = NULL;
@@ -94,6 +96,7 @@ NtTerminateProcess (
    PiTerminateProcessThreads(Process, ExitStatus);
    KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
    Process->Pcb.ProcessState = PROCESS_STATE_TERMINATED;
+   Process->Pcb.DispatcherHeader.SignalState = TRUE;
    KeDispatcherObjectWake(&Process->Pcb.DispatcherHeader);
    if (PsGetCurrentThread()->ThreadsProcess == Process)
    {
index 8d322e8..24d1012 100644 (file)
@@ -8,7 +8,6 @@
 
 /* INCLUDES **************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 #include <internal/ps.h>
 
index dfe949f..74b18b3 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: thread.c,v 1.26 1999/09/06 21:28:33 ekohl Exp $
+/* $Id: thread.c,v 1.27 1999/10/07 23:38:30 ekohl Exp $
  *
  * COPYRIGHT:              See COPYING in the top level directory
  * PROJECT:                ReactOS kernel
@@ -19,7 +19,6 @@
 
 /* INCLUDES ****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 #include <internal/ke.h>
 #include <internal/ob.h>
@@ -398,6 +397,139 @@ PsInitThreadManagment(VOID)
 }
 
 
+static NTSTATUS
+PsCreateTeb (HANDLE ProcessHandle,
+             PNT_TEB *TebPtr,
+             PETHREAD Thread,
+             PINITIAL_TEB InitialTeb)
+{
+   MEMORY_BASIC_INFORMATION Info;
+   NTSTATUS Status;
+   ULONG ByteCount;
+   ULONG RegionSize;
+   ULONG TebSize;
+   PVOID TebBase;
+   NT_TEB Teb;
+
+   TebBase = (PVOID)0x7FFDE000;
+   TebSize = PAGESIZE;
+
+   while (TRUE)
+     {
+        Status = NtQueryVirtualMemory(ProcessHandle,
+                                      TebBase,
+                                      MemoryBasicInformation,
+                                      &Info,
+                                      sizeof(MEMORY_BASIC_INFORMATION),
+                                      &ByteCount);
+        if (!NT_SUCCESS(Status))
+          {
+             DbgPrint ("NtQueryVirtualMemory (Status %x)\n",Status);
+             return Status;
+          }
+
+        if (Info.State == MEM_FREE)
+          {
+             DbgPrint("Virtual memory at %p is free.\n",
+                      TebBase);
+          }
+        else
+          {
+             DbgPrint("Virtual memory at %p is allocated (BaseAddress %p RegionSize %x).\n",
+                      TebBase, Info.BaseAddress, Info.RegionSize);
+          }
+
+        if (Info.State == MEM_FREE)
+          {
+             break;
+          }
+          
+        TebBase = Info.BaseAddress - TebSize;
+   }
+
+//   if (Info.State != MEM_FREE)
+//       return STATUS_SUCCESS;
+
+
+   /* The TEB must reside in user space */
+   Status = NtAllocateVirtualMemory(ProcessHandle,
+                                    &TebBase,
+                                    0,
+                                    &TebSize,
+                                    MEM_COMMIT,
+                                    PAGE_READWRITE);
+
+   if (!NT_SUCCESS(Status))
+     {
+        DbgPrint ("TEB allocation failed!\n");
+        DbgPrint ("Status %x\n",Status);
+        return Status;
+     }
+
+   DbgPrint ("TebBase %p TebSize %lu\n", TebBase, TebSize);
+
+
+   /* set all pointers to and from the TEB */
+   Teb.Tib.Self = TebBase;
+   if (Thread->ThreadsProcess)
+     {
+        Teb.Peb = Thread->ThreadsProcess->Peb; /* No PEB yet!! */
+     }
+
+   /* store stack information from InitialTeb */
+   if (InitialTeb != NULL)
+     {
+        Teb.Tib.StackBase = InitialTeb->StackBase;
+        Teb.Tib.StackLimit = InitialTeb->StackLimit;
+
+        /*
+         * I don't know if this is really stored in a WNT-TEB,
+         * but it's needed to free the thread stack. (Eric Kohl)
+         */
+        Teb.StackCommit = InitialTeb->StackCommit;
+        Teb.StackCommitMax = InitialTeb->StackCommitMax;
+        Teb.StackReserved = InitialTeb->StackReserved;
+     }
+
+
+   /* more initialization */
+   Teb.Cid.UniqueThread = Thread->Cid.UniqueThread;
+   Teb.Cid.UniqueProcess = Thread->Cid.UniqueProcess;
+
+   /* write TEB data into teb page */
+   Status = NtWriteVirtualMemory(ProcessHandle,
+                                 TebBase,
+                                 &Teb,
+                                 sizeof(NT_TEB),
+                                 &ByteCount);
+
+   if (!NT_SUCCESS(Status))
+     {
+        /* free TEB */
+        DbgPrint ("Writing TEB failed!\n");
+
+        RegionSize = 0;
+        NtFreeVirtualMemory(ProcessHandle,
+                            TebBase,
+                            &RegionSize,
+                            MEM_RELEASE);
+
+        return Status;
+     }
+
+   /* FIXME: fs:[0] = TEB */
+
+   if (TebPtr != NULL)
+     {
+//        *TebPtr = (PNT_TEB)TebBase;
+     }
+
+   DbgPrint ("TEB allocated at %p\n", TebBase);
+
+   return Status;
+}
+
+
 NTSTATUS
 STDCALL
 NtCreateThread (
@@ -412,6 +544,7 @@ NtCreateThread (
        )
 {
    PETHREAD Thread;
+   PNT_TEB  TebBase;
    NTSTATUS Status;
    
    DPRINT("NtCreateThread(ThreadHandle %x, PCONTEXT %x)\n",
@@ -429,6 +562,19 @@ NtCreateThread (
      {
        return(Status);
      }
+
+   Status = PsCreateTeb (ProcessHandle,
+                         &TebBase,
+                         Thread,
+                         InitialTeb);
+   if (!NT_SUCCESS(Status))
+     {
+        return(Status);
+     }
+
+   /* Attention: TebBase is in user memory space */
+//   Thread->Tcb.Teb = TebBase;
+
    Thread->StartAddress=NULL;
 
    if (Client!=NULL)
index f55c49d..b6f6956 100644 (file)
@@ -10,9 +10,9 @@
 
 /* INCLUDES *****************************************************************/
 
+#include <ddk/ntddk.h>
 #include <internal/ke.h>
 #include <internal/linkage.h>
-#include <ddk/ntddk.h>
 
 #define NDEBUG
 #include <internal/debug.h>
index 32da500..041954a 100644 (file)
@@ -8,7 +8,6 @@
 
 /* INCLUDES *****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 
 #define NDEBUG
index f0ee9d3..c31c9ac 100644 (file)
@@ -10,7 +10,6 @@
 
 /* INCLUDES *****************************************************************/
 
-#include <windows.h>
 #include <ddk/ntddk.h>
 
 #include <internal/debug.h>
index 5771bb2..ae119f5 100644 (file)
@@ -290,7 +290,7 @@ NTSTATUS STDCALL NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
                               IN HANDLE ClientToken,
                               IN ACCESS_MASK DesiredAccess,
                               IN PGENERIC_MAPPING GenericMapping,
-                              OUT PPRIVILEGE_SET PrivilegeSet,
+                               OUT PPRIVILEGE_SET PrivilegeSet,
                               OUT PULONG ReturnLength,
                               OUT PULONG GrantedAccess,
                               OUT PBOOLEAN AccessStatus)