some __stdcall fixes in ntoskrnl and ntdll
authorEmanuele Aliberti <ea@iol.it>
Sun, 29 Aug 1999 06:59:11 +0000 (06:59 +0000)
committerEmanuele Aliberti <ea@iol.it>
Sun, 29 Aug 1999 06:59:11 +0000 (06:59 +0000)
svn path=/trunk/; revision=629

35 files changed:
reactos/include/ddk/exfuncs.h
reactos/include/ddk/iofuncs.h
reactos/include/ddk/ntddk.h
reactos/include/ddk/rtl.h
reactos/include/ddk/zw.h
reactos/include/ntdll/rtl.h
reactos/include/reactos/resource.h
reactos/lib/kernel32/file/find.c
reactos/lib/kernel32/file/lfile.c
reactos/lib/kernel32/kernel32.edf
reactos/lib/kernel32/mem/heap.c
reactos/lib/kernel32/misc/error.c
reactos/lib/kernel32/misc/stubs.c
reactos/lib/kernel32/process/lib.c
reactos/lib/kernel32/process/proc.c
reactos/lib/kernel32/synch/critical.c
reactos/lib/ntdll/def/ntdll.def
reactos/lib/ntdll/def/ntdll.edf
reactos/lib/ntdll/ldr/startup.c
reactos/lib/ntdll/ldr/utils.c
reactos/ntoskrnl/cm/registry.c
reactos/ntoskrnl/ex/interlck.c
reactos/ntoskrnl/io/device.c
reactos/ntoskrnl/io/file.c
reactos/ntoskrnl/io/rw.c
reactos/ntoskrnl/io/symlink.c
reactos/ntoskrnl/ke/main.c
reactos/ntoskrnl/mm/section.c
reactos/ntoskrnl/ntoskrnl.def
reactos/ntoskrnl/ntoskrnl.edf
reactos/ntoskrnl/ob/dirobj.c
reactos/ntoskrnl/ob/handle.c
reactos/ntoskrnl/ob/ntobj.c
reactos/ntoskrnl/ps/thread.c
reactos/ntoskrnl/rtl/interlck.c

index b80fd52..6598cbf 100644 (file)
@@ -1,16 +1,53 @@
-/* EXECUTIVE ROUTINES ******************************************************/
+#ifndef _NTOS_EXFUNCS_H
+#define _NTOS_EXFUNCS_H
 
-VOID ExAcquireFastMutex(PFAST_MUTEX FastMutex);
-VOID ExAcquireFastMutexUnsafe(PFAST_MUTEX FastMutex);
+/* EXECUTIVE ROUTINES ******************************************************/
 
-BOOLEAN ExAcquireResourceExclusive(PERESOURCE Resource, BOOLEAN Wait);
-BOOLEAN ExAcquireResourceExclusiveLite(PERESOURCE Resource, BOOLEAN Wait);
-BOOLEAN ExAcquireResourceSharedLite(PERESOURCE Resource, BOOLEAN Wait);
-BOOLEAN ExAcquireSharedStarveExclusive(PERESOURCE Resource, BOOLEAN Wait);
-BOOLEAN ExAcquireSharedWaitForExclusive(PERESOURCE Resource, BOOLEAN Wait);
-PVOID ExAllocateFromNPagedLookasideList(PNPAGED_LOOKASIDE_LIST LookSide);
-PVOID ExAllocateFromPagedLookasideList(PPAGED_LOOKASIDE_LIST LookSide);
-PVOID ExAllocateFromZone(PZONE_HEADER Zone);
+VOID
+ExAcquireFastMutex (
+       PFAST_MUTEX     FastMutex
+       );
+VOID
+ExAcquireFastMutexUnsafe (
+       PFAST_MUTEX     FastMutex
+       );
+BOOLEAN
+ExAcquireResourceExclusive (
+       PERESOURCE      Resource,
+       BOOLEAN         Wait
+       );
+BOOLEAN
+ExAcquireResourceExclusiveLite (
+       PERESOURCE      Resource,
+       BOOLEAN         Wait
+       );
+BOOLEAN
+ExAcquireResourceSharedLite (
+       PERESOURCE      Resource,
+       BOOLEAN         Wait
+       );
+BOOLEAN
+ExAcquireSharedStarveExclusive (
+       PERESOURCE      Resource,
+       BOOLEAN         Wait
+       );
+BOOLEAN
+ExAcquireSharedWaitForExclusive (
+       PERESOURCE      Resource,
+       BOOLEAN         Wait
+       );
+PVOID
+ExAllocateFromNPagedLookasideList (
+       PNPAGED_LOOKASIDE_LIST  LookSide
+       );
+PVOID
+ExAllocateFromPagedLookasideList (
+       PPAGED_LOOKASIDE_LIST   LookSide
+       );
+PVOID
+ExAllocateFromZone (
+       PZONE_HEADER    Zone
+       );
 
 /*
  * FUNCTION: Allocates memory from the nonpaged pool
@@ -20,133 +57,371 @@ PVOID ExAllocateFromZone(PZONE_HEADER Zone);
  * RETURNS:
  *      the address of the block if it succeeds
  */
-PVOID ExAllocatePool(POOL_TYPE PoolType, ULONG size);
+PVOID
+ExAllocatePool (
+       POOL_TYPE       PoolType,
+       ULONG           size
+       );
 
-PVOID ExAllocatePoolWithQuota(POOL_TYPE PoolType, ULONG NumberOfBytes);
-PVOID ExAllocatePoolWithQuotaTag(POOL_TYPE PoolType, ULONG NumberOfBytes,
-                                ULONG Tag);
-PVOID ExAllocatePoolWithTag(POOL_TYPE PoolType, ULONG NumberOfBytes,
-                           ULONG Tag);
-VOID ExConvertExclusiveToSharedLite(PERESOURCE Resource);
-VOID ExDeleteNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside);
-VOID ExDeletePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside);
-NTSTATUS ExDeleteResource(PERESOURCE Resource);
-NTSTATUS ExDeleteResourceLite(PERESOURCE Resource);
-NTSTATUS ExExtendZone(PZONE_HEADER Zone, PVOID Segment, ULONG SegmentSize);
+PVOID
+ExAllocatePoolWithQuota (
+       POOL_TYPE       PoolType,
+       ULONG           NumberOfBytes
+       );
+PVOID
+ExAllocatePoolWithQuotaTag (
+       POOL_TYPE       PoolType,
+       ULONG           NumberOfBytes,
+       ULONG           Tag
+       );
+PVOID
+ExAllocatePoolWithTag (
+       POOL_TYPE       PoolType,
+       ULONG           NumberOfBytes,
+       ULONG           Tag
+       );
+VOID
+ExConvertExclusiveToSharedLite (
+       PERESOURCE      Resource
+       );
+VOID
+ExDeleteNPagedLookasideList (
+       PNPAGED_LOOKASIDE_LIST  Lookaside
+       );
+VOID
+ExDeletePagedLookasideList (
+       PPAGED_LOOKASIDE_LIST   Lookaside
+       );
+NTSTATUS
+ExDeleteResource (
+       PERESOURCE      Resource
+       );
+NTSTATUS
+ExDeleteResourceLite (
+       PERESOURCE      Resource
+       );
+NTSTATUS
+ExExtendZone (
+       PZONE_HEADER    Zone,
+       PVOID           Segment,
+       ULONG           SegmentSize
+       );
 
 /*
  * FUNCTION: Releases previously allocated memory
  * ARGUMENTS:
  *        block = block to free
  */
-VOID ExFreePool(PVOID block);
-
-VOID ExFreeToNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
-                                PVOID Entry);
-VOID ExFreeToPagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside,
-                                PVOID Entry);
-PVOID ExFreeToZone(PZONE_HEADER Zone, PVOID Block);
-ERESOURCE_THREAD ExGetCurrentResourceThread(VOID);
-ULONG ExGetExclusiveWaiterCount(PERESOURCE Resource);
-ULONG ExGetSharedWaiterCount(PERESOURCE Resource);
-VOID ExInitializeFastMutex(PFAST_MUTEX FastMutex);
-VOID ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
-                                    PALLOCATE_FUNCTION Allocate,
-                                    PFREE_FUNCTION Free,
-                                    ULONG Flags,
-                                    ULONG Size,
-                                    ULONG Tag,
-                                    USHORT Depth);
-VOID ExInitializePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside,
-                                    PALLOCATE_FUNCTION Allocate,
-                                    PFREE_FUNCTION Free,
-                                    ULONG Flags,
-                                    ULONG Size,
-                                    ULONG Tag,
-                                    USHORT Depth);
-NTSTATUS ExInitializeResource(PERESOURCE Resource);
-NTSTATUS ExInitializeResourceLite(PERESOURCE Resource);
-VOID ExInitializeSListHead(PSLIST_HEADER SListHead);
-VOID ExInitializeWorkItem(PWORK_QUEUE_ITEM Item,
-                         PWORKER_THREAD_ROUTINE Routine,
-                         PVOID Context);
-NTSTATUS ExInitializeZone(PZONE_HEADER Zone,
-                         ULONG BlockSize,
-                         PVOID InitialSegment,
-                         ULONG InitialSegmentSize);
-LARGE_INTEGER ExInterlockedAddLargeInteger(PLARGE_INTEGER Addend,
-                                          LARGE_INTEGER Increment,
-                                          PKSPIN_LOCK Lock);
-ULONG ExInterlockedAddUlong(PULONG Addend, ULONG Increment, PKSPIN_LOCK Lock);
-
-VOID ExInterlockedRemoveEntryList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry,
-                                 PKSPIN_LOCK Lock);
-VOID RemoveEntryFromList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry);   
-PLIST_ENTRY ExInterlockedRemoveHeadList(PLIST_ENTRY Head, PKSPIN_LOCK Lock);
-
-PLIST_ENTRY ExInterlockedInsertTailList(PLIST_ENTRY ListHead,
-                                       PLIST_ENTRY ListEntry,
-                                       PKSPIN_LOCK Lock);
+VOID
+ExFreePool (
+       PVOID   block
+       );
 
-PLIST_ENTRY ExInterlockedInsertHeadList(PLIST_ENTRY ListHead,
-                                       PLIST_ENTRY ListEntry,
-                                       PKSPIN_LOCK Lock);
+VOID
+ExFreeToNPagedLookasideList (
+       PNPAGED_LOOKASIDE_LIST  Lookaside,
+       PVOID                   Entry
+       );
+VOID
+ExFreeToPagedLookasideList (
+       PPAGED_LOOKASIDE_LIST   Lookaside,
+       PVOID                   Entry
+       );
+PVOID
+ExFreeToZone (
+       PZONE_HEADER    Zone,
+       PVOID           Block
+       );
+ERESOURCE_THREAD
+ExGetCurrentResourceThread (
+       VOID
+       );
+ULONG
+ExGetExclusiveWaiterCount (
+       PERESOURCE      Resource
+       );
+ULONG
+ExGetSharedWaiterCount (
+       PERESOURCE      Resource
+       );
+VOID
+ExInitializeFastMutex (
+       PFAST_MUTEX     FastMutex
+       );
+VOID
+ExInitializeNPagedLookasideList (
+       PNPAGED_LOOKASIDE_LIST  Lookaside,
+       PALLOCATE_FUNCTION      Allocate,
+       PFREE_FUNCTION          Free,
+       ULONG                   Flags,
+       ULONG                   Size,
+       ULONG                   Tag,
+       USHORT                  Depth
+       );
+VOID
+ExInitializePagedLookasideList (
+       PPAGED_LOOKASIDE_LIST   Lookaside,
+       PALLOCATE_FUNCTION      Allocate,
+       PFREE_FUNCTION          Free,
+       ULONG                   Flags,
+       ULONG                   Size,
+       ULONG                   Tag,
+       USHORT                  Depth
+       );
+NTSTATUS
+ExInitializeResource (
+       PERESOURCE      Resource
+       );
+NTSTATUS
+ExInitializeResourceLite (
+       PERESOURCE      Resource
+       );
+VOID
+ExInitializeSListHead (
+       PSLIST_HEADER   SListHead
+       );
+VOID
+ExInitializeWorkItem (
+       PWORK_QUEUE_ITEM        Item,
+       PWORKER_THREAD_ROUTINE  Routine,
+       PVOID                   Context
+       );
+NTSTATUS
+ExInitializeZone (
+       PZONE_HEADER    Zone,
+       ULONG           BlockSize,
+       PVOID           InitialSegment,
+       ULONG           InitialSegmentSize
+       );
+LARGE_INTEGER
+ExInterlockedAddLargeInteger (
+       PLARGE_INTEGER  Addend,
+       LARGE_INTEGER   Increment,
+       PKSPIN_LOCK     Lock
+       );
+ULONG
+ExInterlockedAddUlong (
+       PULONG          Addend,
+       ULONG           Increment,
+       PKSPIN_LOCK     Lock
+       );
 
-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);
-ULONG ExIsResourceAcquiredSharedLite(PERESOURCE Resource);
-USHORT ExQueryDepthSListHead(PSLIST_HEADER SListHead);
+VOID
+ExInterlockedRemoveEntryList (
+       PLIST_ENTRY     ListHead,
+       PLIST_ENTRY     Entry,
+       PKSPIN_LOCK     Lock
+       );
+VOID
+RemoveEntryFromList (
+       PLIST_ENTRY     ListHead,
+       PLIST_ENTRY     Entry
+       );   
+PLIST_ENTRY
+ExInterlockedRemoveHeadList (
+       PLIST_ENTRY     Head,
+       PKSPIN_LOCK     Lock
+       );
+PLIST_ENTRY
+ExInterlockedInsertTailList (
+       PLIST_ENTRY     ListHead,
+       PLIST_ENTRY     ListEntry,
+       PKSPIN_LOCK     Lock
+       );
+PLIST_ENTRY
+ExInterlockedInsertHeadList (
+       PLIST_ENTRY     ListHead,
+       PLIST_ENTRY     ListEntry,
+       PKSPIN_LOCK     Lock
+       );
+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
+       );
+/*
+LONG
+FASTCALL
+InterlockedCompareExchange (
+       PLONG   Target,
+       LONG    Value,
+       LONG    Reference
+       );
+*/
+PVOID
+FASTCALL
+InterlockedCompareExchange (
+       PVOID   * Destination,
+       PVOID   Exchange,
+       PVOID   Comperand
+       );
+#ifdef _GNU_H_WINDOWS_H
+#ifdef InterlockedDecrement
+#undef InterlockedDecrement
+#undef InterlockedExchange
+#undef InterlockedExchangeAdd
+#undef InterlockedIncrement
+#endif /* def InterlockedDecrement */
+#endif /* def _GNU_H_WINDOWS_H */
+LONG
+FASTCALL
+InterlockedDecrement (
+       PLONG   Addend
+       );
+LONG
+FASTCALL
+InterlockedExchange (
+       PLONG   Target,
+       LONG    Value
+       );
+LONG
+FASTCALL
+InterlockedExchangeAdd (
+       PLONG   Addend,
+       LONG    Value
+       );
+LONG
+FASTCALL
+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
+       );
+ULONG
+ExIsResourceAcquiredSharedLite (
+       PERESOURCE      Resource
+       );
+USHORT
+ExQueryDepthSListHead (
+       PSLIST_HEADER   SListHead
+       );
 
+#endif /* ndef _NTOS_EXFUNCS_H */
index dd77649..e1b8077 100644 (file)
@@ -370,6 +370,7 @@ IoCreateNotificationEvent (
        );
 
 NTSTATUS
+STDCALL
 IoCreateSymbolicLink (
        PUNICODE_STRING SymbolicLinkName,
        PUNICODE_STRING DeviceName
@@ -382,6 +383,7 @@ IoCreateSynchronizationEvent (
        );
 
 NTSTATUS
+STDCALL
 IoCreateUnprotectedSymbolicLink (
        PUNICODE_STRING SymbolicLinkName,
        PUNICODE_STRING DeviceName
@@ -404,6 +406,7 @@ IoDeleteDevice (
        );
 
 NTSTATUS
+STDCALL
 IoDeleteSymbolicLink (
        PUNICODE_STRING SymbolicLinkName
        );
index 6a06b3f..e88e43f 100644 (file)
@@ -20,6 +20,11 @@ extern "C"
 
 #include <windows.h>
 
+/* GCC can not handle __fastcall */
+#ifndef FASTCALL
+#define FASTCALL STDCALL
+#endif
+
 #include <internal/id.h>
 #include <ddk/status.h>
 #include <ddk/ntdef.h>
index 5d5c771..cf4ed33 100644 (file)
@@ -200,6 +200,7 @@ RtlCharToInteger (
        );
 
 NTSTATUS
+STDCALL
 RtlCheckRegistryKey (
        ULONG   RelativeTo,
        PWSTR   Path
@@ -263,6 +264,7 @@ RtlCopyUnicodeString (
        );
 
 NTSTATUS
+STDCALL
 RtlCreateRegistryKey (
        ULONG   RelativeTo,
        PWSTR   Path
@@ -275,6 +277,7 @@ RtlCreateSecurityDescriptor (
        );
 
 NTSTATUS
+STDCALL
 RtlDeleteRegistryValue (
        ULONG   RelativeTo,
        PWSTR   Path,
@@ -575,6 +578,7 @@ RtlMoveMemory (
        );
 
 NTSTATUS
+STDCALL
 RtlQueryRegistryValues (
        ULONG                           RelativeTo,
        PWSTR                           Path, 
@@ -713,6 +717,7 @@ RtlValidSecurityDescriptor (
        );
 
 NTSTATUS
+STDCALL
 RtlWriteRegistryValue (
        ULONG   RelativeTo,
        PWSTR   Path,
@@ -768,6 +773,7 @@ RtlUnlockHeap (
        );
 
 UINT
+STDCALL
 RtlCompactHeap (
        HANDLE  hheap,
        DWORD   flags
index 3099a0b..0956340 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zw.h,v 1.17 1999/07/22 21:29:46 ekohl Exp $
+/* $Id: zw.h,v 1.18 1999/08/29 06:58:59 ea Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -4143,21 +4143,21 @@ ZwSetHighWaitLowEventPair(
 NTSTATUS
 STDCALL
 NtSetInformationFile(
-       IN HANDLE FileHandle,
-       IN PIO_STATUS_BLOCK IoStatusBlock,
-       IN PVOID FileInformation,
-       IN ULONG Length,
-       IN FILE_INFORMATION_CLASS FileInformationClass
-       );
+       IN      HANDLE                  FileHandle,
+       IN      PIO_STATUS_BLOCK        IoStatusBlock,
+       IN      PVOID                   FileInformation,
+       IN      ULONG                   Length,
+       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
-       );
+       IN      HANDLE                  FileHandle,
+       IN      PIO_STATUS_BLOCK        IoStatusBlock,
+       IN      PVOID                   FileInformation,
+       IN      ULONG                   Length,
+       IN      FILE_INFORMATION_CLASS  FileInformationClass
+       );
 
 
 
index 08abcc7..4b3c388 100644 (file)
@@ -1,10 +1,36 @@
-VOID WINAPI __RtlInitHeap(PVOID base, ULONG minsize, ULONG maxsize);
+VOID
+WINAPI
+__RtlInitHeap (
+       PVOID   base,
+       ULONG   minsize,
+       ULONG   maxsize
+       );
 
 #define HEAP_BASE (0xa0000000)
 
-VOID RtlDeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
-VOID RtlEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
-VOID RtlInitializeCriticalSection(LPCRITICAL_SECTION pcritical);
-VOID RtlLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
-WINBOOL RtlTryEntryCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
-DWORD WINAPI RtlCompactHeap( HANDLE heap, DWORD flags );
+VOID
+RtlDeleteCriticalSection (
+       LPCRITICAL_SECTION      lpCriticalSection
+       );
+VOID
+RtlEnterCriticalSection (
+       LPCRITICAL_SECTION      lpCriticalSection
+       );
+VOID
+RtlInitializeCriticalSection (
+       LPCRITICAL_SECTION      pcritical
+       );
+VOID
+RtlLeaveCriticalSection (
+       LPCRITICAL_SECTION      lpCriticalSection
+       );
+WINBOOL
+RtlTryEntryCriticalSection (
+       LPCRITICAL_SECTION      lpCriticalSection
+       );
+UINT
+STDCALL
+RtlCompactHeap (
+       HANDLE  heap,
+       DWORD   flags
+       );
index 31bfa32..f645dda 100644 (file)
@@ -7,7 +7,7 @@
 #define RES_UINT_FV_MINOR      0
 #define RES_UINT_FV_REVISION   14
 /* Build number as YYYYMMDD */
-#define RES_UINT_FV_BUILD      19990717
+#define RES_UINT_FV_BUILD      19990828
 
 /* ReactOS Product Version UINTs */
 
index 850f97e..a5d9a86 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: find.c,v 1.21 1999/08/29 06:59:01 ea Exp $
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
  * FILE:            lib/kernel32/file/find.c
@@ -178,7 +179,10 @@ HANDLE STDCALL InternalFindFirstFile(LPCWSTR lpFileName,
    return(IData);
 }
 
-HANDLE FindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
+
+HANDLE
+STDCALL
+FindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
 {
    WCHAR lpFileNameW[MAX_PATH];
    ULONG i;
@@ -227,7 +231,10 @@ HANDLE FindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
    return(IData);
 }
 
-WINBOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData)
+
+WINBOOL
+STDCALL
+FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData)
 {
    PWIN32_FIND_DATA_ASCII Ret;
    PKERNEL32_FIND_FILE_DATA IData;
@@ -265,7 +272,10 @@ WINBOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData)
    return(TRUE);
 }
 
-BOOL FindClose(HANDLE hFindFile)
+
+BOOL
+STDCALL
+FindClose(HANDLE hFindFile)
 {
    PKERNEL32_FIND_FILE_DATA IData;
    
@@ -282,8 +292,13 @@ BOOL FindClose(HANDLE hFindFile)
    return(TRUE);
 }
 
-HANDLE STDCALL FindFirstFileW(LPCWSTR lpFileName,
-                             LPWIN32_FIND_DATA lpFindFileData)
+
+HANDLE
+STDCALL
+FindFirstFileW (
+       LPCWSTR                 lpFileName,
+       LPWIN32_FIND_DATA       lpFindFileData
+       )
 {
    PWIN32_FIND_DATA_UNICODE Ret;
    PKERNEL32_FIND_FILE_DATA IData;
@@ -299,8 +314,13 @@ HANDLE STDCALL FindFirstFileW(LPCWSTR lpFileName,
    return(IData);
 }
 
-WINBOOL STDCALL FindNextFileW(HANDLE hFindFile,
-                             LPWIN32_FIND_DATA lpFindFileData)
+
+WINBOOL
+STDCALL
+FindNextFileW (
+       HANDLE                  hFindFile,
+       LPWIN32_FIND_DATA       lpFindFileData
+       )
 {
    PWIN32_FIND_DATA_UNICODE Ret;
    PKERNEL32_FIND_FILE_DATA IData;
@@ -320,3 +340,6 @@ WINBOOL STDCALL FindNextFileW(HANDLE hFindFile,
 
    return(TRUE);
 }
+
+
+/* EOF */
index ce4ff86..a246481 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: lfile.c,v 1.4 1999/08/29 06:59:01 ea Exp $
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
  * FILE:            lib/kernel32/file/lfile.c
 
 
 
-long _hread(
-    HFILE  hFile,      
-    LPVOID  lpBuffer,  
-    long  lBytes       
-   )
+long
+STDCALL
+_hread(
+       HFILE   hFile,  
+       LPVOID  lpBuffer,       
+       long    lBytes  
+       )
 {
-       DWORD  NumberOfBytesRead;
-       if ( ReadFile((HANDLE)hFile,(LPVOID)lpBuffer,(DWORD)lBytes,&NumberOfBytesRead, NULL) == FALSE )
+       DWORD   NumberOfBytesRead;
+       
+       if (ReadFile(
+               (HANDLE) hFile,
+               (LPVOID) lpBuffer,
+               (DWORD) lBytes,
+               & NumberOfBytesRead,
+               NULL
+               ) == FALSE)
+       {
                return -1;
-       else
-               return NumberOfBytesRead;
-
+       }
+       return NumberOfBytesRead;
 }
 
-UINT STDCALL _lread(HFILE fd,LPVOID buffer,UINT count)
+
+/*
+//19990828.EA: aliased in DEF
+UINT
+STDCALL
+_lread (
+       HFILE   fd,
+       LPVOID  buffer,
+       UINT    count
+       )
 {
-    return _hread(fd,buffer, count);
+       return _hread(
+                fd,
+                buffer,
+                count
+                );
 }
+*/
 
 
-long _hwrite(
-    HFILE  hFile,      
-    LPCSTR  lpBuffer,  
-    long  lBytes       
-   )
+long
+STDCALL
+_hwrite (
+       HFILE   hFile,  
+       LPCSTR  lpBuffer,       
+       long    lBytes  
+       )
 {
-
-       DWORD  NumberOfBytesWritten;
-       if ( lBytes == 0 ) {
+       DWORD   NumberOfBytesWritten;
+       
+       if (lBytes == 0)
+       {
                if ( SetEndOfFile((HANDLE) hFile ) == FALSE )
+               {
                        return -1;
-               else
-                       return 0;
+               }
+               return 0;
        }
-       if ( WriteFile((HANDLE)hFile,(LPVOID)lpBuffer,(DWORD)lBytes, &NumberOfBytesWritten,NULL) == FALSE )
+       if ( WriteFile(
+               (HANDLE) hFile,
+               (LPVOID) lpBuffer,
+               (DWORD) lBytes,
+               & NumberOfBytesWritten,
+               NULL
+               ) == FALSE )
+       {
                return -1;
-       else
-               return NumberOfBytesWritten;
-
+       }
+       return NumberOfBytesWritten;
 }
 
+
+/*
+//19990828.EA: aliased in DEF
+
 UINT
 STDCALL
 _lwrite(
-       HFILE hFile,
-       LPCSTR lpBuffer,
-       UINT uBytes
+       HFILE   hFile,
+       LPCSTR  lpBuffer,
+       UINT    uBytes
        )
 {
        return _hwrite(hFile,lpBuffer,uBytes);
 }
+*/
 
 
-
-
-
-HFILE _lopen( LPCSTR  lpPathName, int  iReadWrite       )
+HFILE
+STDCALL
+_lopen (
+       LPCSTR  lpPathName,
+       int     iReadWrite
+       )
 {
-
-
-       
        DWORD dwAccessMask = 0;
        DWORD dwShareMode = 0;
        
@@ -87,31 +125,39 @@ HFILE _lopen( LPCSTR  lpPathName, int  iReadWrite   )
        else if ( (iReadWrite & OF_WRITE ) == OF_WRITE )
                dwAccessMask = GENERIC_WRITE;
 
-
-
-
-
-if ((iReadWrite & OF_SHARE_COMPAT) == OF_SHARE_COMPAT )
-       dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
-else if ((iReadWrite & OF_SHARE_DENY_NONE) == OF_SHARE_DENY_NONE)
-       dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
-else if ((iReadWrite & OF_SHARE_DENY_READ) == OF_SHARE_DENY_READ)
-       dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_DELETE;     
-else if ((iReadWrite & OF_SHARE_DENY_WRITE) == OF_SHARE_DENY_WRITE )
-       dwShareMode = FILE_SHARE_READ | FILE_SHARE_DELETE;              
-else if ((iReadWrite & OF_SHARE_EXCLUSIVE) == OF_SHARE_EXCLUSIVE)
-       dwShareMode = 0;        
+       if ((iReadWrite & OF_SHARE_COMPAT) == OF_SHARE_COMPAT )
+               dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
+       else if ((iReadWrite & OF_SHARE_DENY_NONE) == OF_SHARE_DENY_NONE)
+               dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
+       else if ((iReadWrite & OF_SHARE_DENY_READ) == OF_SHARE_DENY_READ)
+               dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_DELETE;     
+       else if ((iReadWrite & OF_SHARE_DENY_WRITE) == OF_SHARE_DENY_WRITE )
+               dwShareMode = FILE_SHARE_READ | FILE_SHARE_DELETE;              
+       else if ((iReadWrite & OF_SHARE_EXCLUSIVE) == OF_SHARE_EXCLUSIVE)
+               dwShareMode = 0;        
 
        
 
        SetLastError(0);
-       return (HFILE) CreateFileA( lpPathName,dwAccessMask,dwShareMode,
-                       NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); 
+       return (HFILE) CreateFileA(
+                       lpPathName,
+                       dwAccessMask,
+                       dwShareMode,
+                       NULL,
+                       OPEN_EXISTING,
+                       FILE_ATTRIBUTE_NORMAL,
+                       NULL
+                       );      
 
 }
 
 
-HFILE _lcreat(  LPCSTR  lpPathName,     int  iAttribute         )
+HFILE
+STDCALL
+_lcreat (
+       LPCSTR  lpPathName,
+       int     iAttribute
+       )
 {
 
        DWORD FileAttributes = 0;
@@ -125,28 +171,47 @@ HFILE _lcreat(  LPCSTR  lpPathName,        int  iAttribute         )
        else if (  iAttribute == 4 )
                FileAttributes |= FILE_ATTRIBUTE_SYSTEM;
 
-       return(HFILE) CreateFileA( lpPathName,GENERIC_ALL,FILE_SHARE_READ|FILE_SHARE_WRITE,
-                       NULL,CREATE_ALWAYS,iAttribute ,NULL);   
+       return (HFILE) CreateFileA(
+                       lpPathName,
+                       GENERIC_ALL,
+                       (FILE_SHARE_READ | FILE_SHARE_WRITE),
+                       NULL,
+                       CREATE_ALWAYS,
+                       iAttribute,
+                       NULL
+                       );      
 }
 
 
-int _lclose(
-    HFILE  hFile       
-   )
+int
+STDCALL
+_lclose (
+       HFILE  hFile    
+       )
 {
        if ( CloseHandle((HANDLE)hFile) )
+       {
                return 0;
-       else
-               return -1; 
+       }
+       return -1; 
 }
 
-LONG _llseek(
-    HFILE  hFile,
-    LONG  lOffset, 
-    int  iOrigin 
-   )
+
+LONG
+STDCALL
+_llseek(
+       HFILE   hFile,
+       LONG    lOffset, 
+       int     iOrigin 
+       )
 {
-       return  SetFilePointer((HANDLE)  hFile,  lOffset, NULL,(DWORD)iOrigin );
+       return  SetFilePointer(
+                       (HANDLE) hFile,
+                       lOffset,
+                       NULL,
+                       (DWORD) iOrigin
+                       );
 }
 
 
+/* EOF */
index 93d6bf8..26ec1a2 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: kernel32.edf,v 1.1 1999/07/17 23:10:20 ea Exp $
+; $Id: kernel32.edf,v 1.2 1999/08/29 06:59:01 ea Exp $
 ;
 ; kernel32.edf
 ;
@@ -649,8 +649,8 @@ _lclose=_lclose@4
 _lcreat=_lcreat@8
 _llseek=_llseek@12
 _lopen=_lopen@8
-_lread=_lread@12
-_lwrite=_lwrite@12
+_lread=_hread@12
+_lwrite=_hwrite@12
 lstrcat=lstrcatA@8
 lstrcatA=lstrcatA@8
 lstrcatW=lstrcatW@8
index c0e36a6..eb82d74 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: heap.c,v 1.15 1999/08/29 06:59:01 ea Exp $
+ *
  * kernel/heap.c
  * Copyright (C) 1996, Onno Hovers, All rights reserved
  *
@@ -117,9 +118,17 @@ BOOL WINAPI HeapUnlock(HANDLE hheap)
 * NT uses this function to compact moveable blocks and other things  *
 * Here it does not compact, but it finds the largest free region     *
 *********************************************************************/
-UINT HeapCompact(HANDLE hheap, DWORD flags)
+UINT
+STDCALL
+HeapCompact (
+       HANDLE  hheap,
+       DWORD   flags
+       )
 {
-   return(RtlCompactHeap(hheap, flags));
+       return RtlCompactHeap(
+                       hheap,
+                       flags
+                       );
 }
 
 /*********************************************************************
@@ -140,3 +149,5 @@ BOOL WINAPI HeapValidate(HANDLE hheap, DWORD flags, LPCVOID pmem)
    return(RtlValidateHeap(hheap, flags, (PVOID)pmem));
 }
 
+
+/* EOF */
index b17f134..8676f0f 100644 (file)
@@ -1,3 +1,8 @@
+/* $Id: error.c,v 1.11 1999/08/29 06:59:02 ea Exp $
+ *
+ * reactos/lib/kernel32/misc/error.c
+ *
+ */
 #include <windows.h>
 #include <ddk/ntddk.h>
 #include <ddk/ntddbeep.h>
 static DWORD LastError=0;
 
 
-VOID SetLastError(DWORD dwErrorCode)
+VOID
+STDCALL
+SetLastError (
+       DWORD   dwErrorCode
+       )
 {
-   LastError = dwErrorCode;
+       /* FIXME: it is per thread */
+       LastError = dwErrorCode;
 }
 
-DWORD GetLastError(VOID)
+DWORD
+STDCALL
+GetLastError (VOID)
 {
-   return(LastError);
+       /* FIXME: it is per thread */
+       return LastError;
 }
 
-BOOL __ErrorReturnFalse(ULONG ErrorCode)
+
+BOOL
+__ErrorReturnFalse (ULONG ErrorCode)
 {
    return(FALSE);
 }
 
-PVOID __ErrorReturnNull(ULONG ErrorCode)
+
+PVOID
+__ErrorReturnNull (ULONG ErrorCode)
 {
    return(NULL);
 }
 
+
 WINBOOL
 STDCALL
 Beep (DWORD dwFreq, DWORD dwDuration)
@@ -65,3 +83,5 @@ Beep (DWORD dwFreq, DWORD dwDuration)
     return TRUE;
 }
 
+
+/* EOF */
index c69bc4f..7a06118 100644 (file)
@@ -1,4 +1,5 @@
-/* $Id: stubs.c,v 1.2 1999/07/17 23:10:20 ea Exp $
+/* $Id: stubs.c,v 1.3 1999/08/29 06:59:03 ea Exp $
+ *
  * KERNEL32.DLL stubs (unimplemented functions)
  * Remove from this file, if you implement them.
  */
@@ -3443,17 +3444,6 @@ RegisterConsoleVDM (
 }
 
 
-WINBOOL
-STDCALL
-RegisterWaitForInputIdle (
-       DWORD   Unknown0
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return FALSE;
-}
-
-
 WINBOOL
 STDCALL
 RegisterWowBaseHandlers (
index fb9cf05..bf6010a 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: lib.c,v 1.3 1999/08/29 06:59:03 ea Exp $
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
  * FILE:            lib/kernel32/proc/proc.c
 
 /* FUNCTIONS ****************************************************************/
 
-HINSTANCE LoadLibraryW(LPCWSTR lpLibFileName)
+HINSTANCE
+STDCALL
+LoadLibraryW (
+       LPCWSTR lpLibFileName
+       )
 {
    UNIMPLEMENTED;
    return(NULL);
 }
 
-HINSTANCE LoadLibraryA(LPCSTR lpLibFileName)
+
+HINSTANCE
+STDCALL
+LoadLibraryA (
+       LPCSTR  lpLibFileName
+       )
 {
    UNIMPLEMENTED;
    return(NULL);
 }
 
-BOOL STDCALL FreeLibrary(HMODULE hLibModule)
+
+BOOL
+STDCALL
+FreeLibrary (
+       HMODULE hLibModule
+       )
 {
    UNIMPLEMENTED;
    return(FALSE);
 }
+
+
+/* EOF */
index d4eb520..0a6cf51 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: proc.c,v 1.19 1999/08/29 06:59:03 ea Exp $
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
  * FILE:            lib/kernel32/proc/proc.c
@@ -49,44 +50,79 @@ typedef struct _WSTARTUPINFO {
 
 WaitForInputIdleType  lpfnGlobalRegisterWaitForInputIdle;
 
-VOID RegisterWaitForInputIdle(WaitForInputIdleType  lpfnRegisterWaitForInputIdle);
+VOID
+STDCALL
+RegisterWaitForInputIdle (
+       WaitForInputIdleType    lpfnRegisterWaitForInputIdle
+       );
 
 /* FUNCTIONS ****************************************************************/
 
-WINBOOL STDCALL GetProcessId(HANDLE hProcess, LPDWORD lpProcessId);
+WINBOOL
+STDCALL
+GetProcessId (
+       HANDLE  hProcess,
+       LPDWORD lpProcessId
+       );
 
-FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName)
+
+FARPROC
+STDCALL
+GetProcAddress (
+       HMODULE hModule,
+       LPCSTR  lpProcName
+       )
 {
-   UNIMPLEMENTED;
-   return(NULL);
+       UNIMPLEMENTED;
+       return NULL;
 }
 
-WINBOOL STDCALL GetProcessTimes(HANDLE hProcess,
-                               LPFILETIME lpCreationTime,
-                               LPFILETIME lpExitTime,
-                               LPFILETIME lpKernelTime,
-                               LPFILETIME lpUserTime)
+
+WINBOOL
+STDCALL
+GetProcessTimes (
+       HANDLE          hProcess,
+       LPFILETIME      lpCreationTime,
+       LPFILETIME      lpExitTime,
+       LPFILETIME      lpKernelTime,
+       LPFILETIME      lpUserTime
+       )
 {
-   dprintf("GetProcessTimes is unimplemented\n");
-   return(FALSE);
+       dprintf("GetProcessTimes is unimplemented\n");
+       return FALSE;
 }
 
-HANDLE STDCALL GetCurrentProcess(VOID)
+
+HANDLE
+STDCALL
+GetCurrentProcess (VOID)
 {
-       return (HANDLE)NtCurrentProcess();
+       return (HANDLE) NtCurrentProcess();
 }
 
-HANDLE STDCALL GetCurrentThread(VOID)
+
+HANDLE
+STDCALL
+GetCurrentThread (VOID)
 {
-       return (HANDLE)NtCurrentThread();
+       return (HANDLE) NtCurrentThread();
 }
 
-DWORD STDCALL GetCurrentProcessId(VOID)
+
+DWORD
+STDCALL
+GetCurrentProcessId (VOID)
 {      
-       return (DWORD)(GetTeb()->Cid).UniqueProcess;            
+       return (DWORD) (GetTeb()->Cid).UniqueProcess;           
 }
 
-WINBOOL STDCALL GetExitCodeProcess(HANDLE hProcess, LPDWORD lpExitCode)
+
+WINBOOL
+STDCALL
+GetExitCodeProcess (
+       HANDLE  hProcess,
+       LPDWORD lpExitCode
+       )
 {
    NTSTATUS errCode;
    PROCESS_BASIC_INFORMATION ProcessBasic;
@@ -106,7 +142,13 @@ WINBOOL STDCALL GetExitCodeProcess(HANDLE hProcess, LPDWORD lpExitCode)
    return TRUE;        
 }
 
-WINBOOL STDCALL GetProcessId(HANDLE hProcess, LPDWORD lpProcessId )
+
+WINBOOL
+STDCALL
+GetProcessId (
+       HANDLE  hProcess,
+       LPDWORD lpProcessId 
+       )
 {
    NTSTATUS errCode;
    PROCESS_BASIC_INFORMATION ProcessBasic;
@@ -126,7 +168,13 @@ WINBOOL STDCALL GetProcessId(HANDLE hProcess, LPDWORD lpProcessId )
    return TRUE;        
 }
 
-PWSTR InternalAnsiToUnicode(PWSTR Out, LPCSTR In, ULONG MaxLength)
+
+PWSTR
+InternalAnsiToUnicode (
+       PWSTR   Out,
+       LPCSTR  In,
+       ULONG   MaxLength
+       )
 {
    ULONG i;
    
@@ -148,9 +196,14 @@ PWSTR InternalAnsiToUnicode(PWSTR Out, LPCSTR In, ULONG MaxLength)
      }
 }
 
-HANDLE STDCALL OpenProcess(DWORD dwDesiredAccess,
-                          WINBOOL bInheritHandle,
-                          DWORD dwProcessId)
+
+HANDLE
+STDCALL
+OpenProcess (
+       DWORD   dwDesiredAccess,
+       WINBOOL bInheritHandle,
+       DWORD   dwProcessId
+       )
 {
    NTSTATUS errCode;
    HANDLE ProcessHandle;
@@ -183,7 +236,13 @@ HANDLE STDCALL OpenProcess(DWORD dwDesiredAccess,
    return ProcessHandle;
 }
 
-UINT WinExec (LPCSTR lpCmdLine, UINT uCmdShow)
+
+UINT
+STDCALL
+WinExec (
+       LPCSTR  lpCmdLine,
+       UINT    uCmdShow
+       )
 {
    STARTUPINFO StartupInfo;
    PROCESS_INFORMATION  ProcessInformation;    
@@ -217,27 +276,45 @@ UINT WinExec (LPCSTR lpCmdLine, UINT uCmdShow)
 }
 
 
-
-VOID RegisterWaitForInputIdle(WaitForInputIdleType 
-                             lpfnRegisterWaitForInputIdle)
+VOID
+STDCALL
+RegisterWaitForInputIdle (
+       WaitForInputIdleType    lpfnRegisterWaitForInputIdle
+       )
 {
-   lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle; 
-   return;
+       lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle; 
+       return;
 }
 
-DWORD STDCALL WaitForInputIdle(HANDLE hProcess,        
-                              DWORD dwMilliseconds)
+
+DWORD
+STDCALL
+WaitForInputIdle (
+       HANDLE  hProcess,       
+       DWORD   dwMilliseconds
+       )
 {
-   return 0;
+       return 0;
 }
 
-VOID STDCALL Sleep(DWORD dwMilliseconds)
+
+VOID
+STDCALL
+Sleep (
+       DWORD   dwMilliseconds
+       )
 {
-   SleepEx(dwMilliseconds,FALSE);
-   return;
+       SleepEx (dwMilliseconds, FALSE);
+       return;
 }
 
-DWORD STDCALL SleepEx(DWORD dwMilliseconds, BOOL bAlertable)
+
+DWORD
+STDCALL
+SleepEx (
+       DWORD   dwMilliseconds,
+       BOOL    bAlertable
+       )
 {
        TIME Interval;
        NTSTATUS errCode;       
@@ -245,14 +322,20 @@ DWORD STDCALL SleepEx(DWORD dwMilliseconds, BOOL bAlertable)
         Interval.QuadPart = dwMilliseconds * 1000;
 
        errCode = NtDelayExecution(bAlertable,&Interval);
-       if ( !NT_SUCCESS(errCode) ) {
+       if ( !NT_SUCCESS(errCode) )
+       {
                SetLastError(RtlNtStatusToDosError(errCode));
                return -1;
        }
        return 0;
 }
 
-VOID STDCALL GetStartupInfoW(LPSTARTUPINFO _lpStartupInfo)
+
+VOID
+STDCALL
+GetStartupInfoW (
+       LPSTARTUPINFO   _lpStartupInfo
+       )
 {
    NT_PEB *pPeb = NtCurrentPeb();
    LPWSTARTUPINFO lpStartupInfo = (LPWSTARTUPINFO)_lpStartupInfo;
@@ -305,7 +388,11 @@ VOID STDCALL GetStartupInfoW(LPSTARTUPINFO _lpStartupInfo)
 }
 
 
-VOID STDCALL GetStartupInfoA(LPSTARTUPINFO lpStartupInfo)
+VOID
+STDCALL
+GetStartupInfoA (
+       LPSTARTUPINFO   lpStartupInfo
+       )
 {
    NT_PEB *pPeb = NtCurrentPeb();
    ULONG i = 0;
@@ -355,26 +442,50 @@ VOID STDCALL GetStartupInfoA(LPSTARTUPINFO lpStartupInfo)
    return;
 }
 
-BOOL STDCALL FlushInstructionCache(HANDLE hProcess,    
-                                  LPCVOID lpBaseAddress,       
-                                  DWORD dwSize)
+
+BOOL
+STDCALL
+FlushInstructionCache (
+       HANDLE  hProcess,       
+       LPCVOID lpBaseAddress,  
+       DWORD   dwSize
+       )
 {
-   NTSTATUS errCode;
-   errCode = NtFlushInstructionCache(hProcess,(PVOID)lpBaseAddress,dwSize);
-   if (!NT_SUCCESS(errCode))
-     {
-       SetLastError(RtlNtStatusToDosError(errCode));
-       return FALSE;
-     }
-   return TRUE;
+       NTSTATUS        errCode;
+
+       errCode = NtFlushInstructionCache(
+                       hProcess,
+                       (PVOID) lpBaseAddress,
+                       dwSize
+                       );
+       if (!NT_SUCCESS(errCode))
+       {
+               SetLastError(RtlNtStatusToDosError(errCode));
+               return FALSE;
+       }
+       return TRUE;
 }
 
-VOID STDCALL ExitProcess(UINT uExitCode)
+
+VOID
+STDCALL
+ExitProcess (
+       UINT    uExitCode
+       )
 {
-   NtTerminateProcess(NtCurrentProcess(), uExitCode);
+       NtTerminateProcess(
+               NtCurrentProcess(),
+               uExitCode
+               );
 }
 
-WINBOOL STDCALL TerminateProcess(HANDLE hProcess, UINT uExitCode)
+
+WINBOOL
+STDCALL
+TerminateProcess (
+       HANDLE  hProcess,
+       UINT    uExitCode
+       )
 {
    NTSTATUS errCode;
    errCode = NtTerminateProcess(hProcess, uExitCode);
@@ -386,7 +497,12 @@ WINBOOL STDCALL TerminateProcess(HANDLE hProcess, UINT uExitCode)
    return TRUE;
 }
 
-VOID STDCALL FatalAppExitA(UINT uAction, LPCSTR lpMessageText)
+VOID
+STDCALL
+FatalAppExitA (
+       UINT    uAction,
+       LPCSTR  lpMessageText
+       )
 {
    WCHAR MessageTextW[MAX_PATH];
    UINT i;
@@ -404,7 +520,15 @@ VOID STDCALL FatalAppExitA(UINT uAction, LPCSTR lpMessageText)
 
 
        
-VOID STDCALL FatalAppExitW(UINT uAction, LPCWSTR lpMessageText)
+VOID
+STDCALL
+FatalAppExitW (
+       UINT    uAction,
+       LPCWSTR lpMessageText
+       )
 {
-   return;     
+       return; 
 }
+
+
+/* EOF */
index 7b982f8..7b77387 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: critical.c,v 1.5 1999/08/29 06:59:03 ea Exp $
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
  * FILE:            lib/kernel32/sync/critical.c
 
 /* FUNCTIONS *****************************************************************/
 
-VOID DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
+
+VOID
+STDCALL
+DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
 {
    UNIMPLEMENTED;
 }
 
-VOID EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
+
+VOID
+STDCALL
+EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
 {
    UNIMPLEMENTED;
 }
 
-VOID InitializeCriticalSection(LPCRITICAL_SECTION pcritical)
+
+VOID
+STDCALL
+InitializeCriticalSection(LPCRITICAL_SECTION pcritical)
 {
    UNIMPLEMENTED;
 }
 
-VOID LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
+
+VOID
+STDCALL
+LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
 {
    UNIMPLEMENTED;
 }
 
-WINBOOL TryEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
+
+WINBOOL
+STDCALL
+TryEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
 {
    UNIMPLEMENTED;
    return(FALSE);
 }
 
+
+/* EOF */
index 095ecda..291ed74 100644 (file)
@@ -1,3 +1,7 @@
+; $Id: ntdll.def,v 1.13 1999/08/29 06:59:04 ea Exp $
+;
+; ReactOS Operating System
+;
 EXPORTS
 InitializeObjectAttributes
 NtAcceptConnectPort@24
index d3427be..acda056 100644 (file)
@@ -1,3 +1,7 @@
+; $Id: ntdll.edf,v 1.4 1999/08/29 06:59:04 ea Exp $
+;
+; ReactOS Operating System
+;
 EXPORTS
 InitializeObjectAttributes
 NtAcceptConnectPort=NtAcceptConnectPort@24
index 000cf7c..e6c55ac 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: startup.c,v 1.9 1999/08/29 06:59:04 ea Exp $
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
  * FILE:            lib/ntdll/ldr/startup.c
@@ -9,6 +10,7 @@
 
 /* INCLUDES *****************************************************************/
 
+#include <reactos/config.h>
 #define WIN32_NO_PEHDR
 #include <windows.h>
 #include <ddk/ntddk.h>
@@ -18,7 +20,9 @@
 #include <ntdll/ldr.h>
 #include <ntdll/rtl.h>
 
+#ifndef DBG_NTDLL_LDR_STARTUP
 #define NDEBUG
+#endif
 #include <ntdll/ntdll.h>
 
 /* GLOBALS *******************************************************************/
@@ -30,8 +34,11 @@ extern HANDLE __ProcessHeap;
 
 /* FUNCTIONS *****************************************************************/
 
-NTSTATUS LdrMapNTDllForProcess(HANDLE ProcessHandle,
-                              PHANDLE PtrNTDllSectionHandle)
+NTSTATUS
+LdrMapNTDllForProcess (
+       HANDLE  ProcessHandle,
+       PHANDLE PtrNTDllSectionHandle
+       )
 {
    ULONG InitialViewSize;
    NTSTATUS Status;
@@ -125,3 +132,6 @@ VOID LdrStartup(HANDLE SectionHandle,
    Status = EntryPoint();
    ZwTerminateProcess(NtCurrentProcess(),Status);
 }
+
+
+/* EOF */
index af1f1a3..6d04814 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: utils.c,v 1.9 1999/07/17 23:10:24 ea Exp $
+/* $Id: utils.c,v 1.10 1999/08/29 06:59:04 ea Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -10,6 +10,7 @@
 
 /* INCLUDES *****************************************************************/
 
+#include <reactos/config.h>
 #define WIN32_NO_PEHDR
 #include <windows.h>
 #include <ddk/ntddk.h>
 #include <wchar.h>
 #include <ntdll/ldr.h>
 
+#ifdef DBG_NTDLL_LDR_UTILS
 #define NDEBUG
+#endif
 #include <ntdll/ntdll.h>
 
 /* FUNCTIONS *****************************************************************/
 
-typedef WINBOOL STDCALL (*PDLLMAIN_FUNC)(HANDLE hInst, 
-                                        ULONG ul_reason_for_call,
-                                        LPVOID lpReserved);
 
+/* Type for a DLL's entry point */
+typedef
+WINBOOL
+STDCALL
+(* PDLLMAIN_FUNC) (
+       HANDLE  hInst, 
+       ULONG   ul_reason_for_call,
+       LPVOID  lpReserved
+       );
 
-static NTSTATUS LdrLoadDll(PDLL* Dll, PCHAR Name)
+
+/**********************************************************************
+ * NAME
+ *     LdrLoadDll
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ * NOTE
+ *
+ */
+static
+NTSTATUS
+LdrLoadDll (
+       PDLL    * Dll,
+       PCHAR   Name
+       )
 {
-   char fqname[255] = "\\??\\C:\\reactos\\system32\\";
-   ANSI_STRING AnsiString;
-   UNICODE_STRING UnicodeString;
-   OBJECT_ATTRIBUTES FileObjectAttributes;
-   char BlockBuffer[1024];
-   PIMAGE_DOS_HEADER DosHeader;
-   NTSTATUS Status;
-   PIMAGE_NT_HEADERS NTHeaders;
-   PEPFUNC DllStartupAddr;
-   ULONG ImageSize, InitialViewSize;
-   PVOID ImageBase;
-   HANDLE FileHandle, SectionHandle;
-   PDLLMAIN_FUNC Entrypoint;
-   
-   DPRINT("LdrLoadDll(Base %x, Name %s)\n",Dll,Name);
-   
-   strcat(fqname, Name);
-   
-   DPRINT("fqname %s\n",fqname);
+       char                    fqname [255] = "\\??\\C:\\reactos\\system32\\";
+       ANSI_STRING             AnsiString;
+       UNICODE_STRING          UnicodeString;
+       OBJECT_ATTRIBUTES       FileObjectAttributes;
+       char                    BlockBuffer [1024];
+       PIMAGE_DOS_HEADER       DosHeader;
+       NTSTATUS                Status;
+       PIMAGE_NT_HEADERS       NTHeaders;
+       PEPFUNC                 DllStartupAddr;
+       ULONG                   ImageSize;
+       ULONG                   InitialViewSize;
+       PVOID                   ImageBase;
+       HANDLE                  FileHandle;
+       HANDLE                  SectionHandle;
+       PDLLMAIN_FUNC           Entrypoint;
    
-   RtlInitAnsiString(&AnsiString,fqname);
-   RtlAnsiStringToUnicodeString(&UnicodeString,&AnsiString,TRUE);
-   
-   InitializeObjectAttributes(&FileObjectAttributes,
-                             &UnicodeString,
-                             0,
-                             NULL,
-                             NULL);
-   DPRINT("Opening dll\n");
-   Status = ZwOpenFile(&FileHandle, FILE_ALL_ACCESS, &FileObjectAttributes, 
-                      NULL, 0, 0);
-   if (!NT_SUCCESS(Status))
-     {
-       DPRINT("Dll open failed ");
-       return Status;
-     }
-   Status = ZwReadFile(FileHandle, 0, 0, 0, 0, BlockBuffer, 1024, 0, 0);
-   if (!NT_SUCCESS(Status))
-     {
-       DPRINT("Dll header read failed ");
-       ZwClose(FileHandle);
-       return Status;
-    }    
+
+       DPRINT("LdrLoadDll(Base %x, Name \"%s\")\n", Dll, Name);
+
+       /*
+        * Build the DLL's absolute name
+        */
+       strcat(fqname, Name);
    
-   DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer;
-   if (DosHeader->e_magic != IMAGE_DOS_MAGIC || 
-       DosHeader->e_lfanew == 0L ||
-       *(PULONG)((PUCHAR)BlockBuffer + DosHeader->e_lfanew) != IMAGE_PE_MAGIC)
-     {
-       DPRINT("NTDLL format invalid\n");
-       ZwClose(FileHandle);
+       DPRINT("fqname \"%s\"\n", fqname);
+       /*
+        * Open the DLL's image file.
+        */
+       RtlInitAnsiString(
+               & AnsiString,
+               fqname
+               );
+       RtlAnsiStringToUnicodeString(
+               & UnicodeString,
+               & AnsiString,
+               TRUE
+               );
+
+       InitializeObjectAttributes(
+               & FileObjectAttributes,
+               & UnicodeString,
+               0,
+               NULL,
+               NULL
+               );
+
+       DPRINT("Opening dll \"%s\"\n", fqname);
        
-       return STATUS_UNSUCCESSFUL;
-     }
-   NTHeaders = (PIMAGE_NT_HEADERS)(BlockBuffer + DosHeader->e_lfanew);
-   ImageBase = (PVOID)NTHeaders->OptionalHeader.ImageBase;
-   ImageSize = NTHeaders->OptionalHeader.SizeOfImage;
-
-   DPRINT("ImageBase %x\n",ImageBase);
-   DllStartupAddr = (PEPFUNC)(ImageBase + 
-                             NTHeaders->OptionalHeader.AddressOfEntryPoint);
-   
-   /* Create a section for NTDLL */
-   Status = ZwCreateSection(&SectionHandle,
-                           SECTION_ALL_ACCESS,
-                           NULL,
-                           NULL,
-                           PAGE_READWRITE,
-                           MEM_COMMIT,
-                           FileHandle);
-   if (!NT_SUCCESS(Status))
-     {
-       DPRINT("NTDLL create section failed ");
-       ZwClose(FileHandle);       
-       return Status;
-     }
-   
-   /*  Map the NTDLL into the process  */
-   InitialViewSize = DosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS) 
-     + sizeof(IMAGE_SECTION_HEADER) * NTHeaders->FileHeader.NumberOfSections;
-   Status = ZwMapViewOfSection(SectionHandle,
-                              NtCurrentProcess(),
-                              (PVOID *)&ImageBase,
-                              0,
-                              InitialViewSize,
-                              NULL,
-                              &InitialViewSize,
-                              0,
-                              MEM_COMMIT,
-                              PAGE_READWRITE);
-   if (!NT_SUCCESS(Status))
-     {
-       DPRINT("NTDLL map view of secion failed ");
-       ZwClose(FileHandle);
+       Status = ZwOpenFile(
+                       & FileHandle,
+                       FILE_ALL_ACCESS,
+                       & FileObjectAttributes, 
+                       NULL,
+                       0,
+                       0
+                       );
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("Dll open failed: Status = 0x%08x\n", Status);
+               return Status;
+       }
+       Status = ZwReadFile(
+                       FileHandle,
+                       0,
+                       0,
+                       0,
+                       0,
+                       BlockBuffer,
+                       sizeof BlockBuffer,
+                       0,
+                       0
+                       );
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("Dll header read failed: Status = 0x%08x\n", Status);
+               ZwClose(FileHandle);
+               return Status;
+       }
+       /*
+        * Overlay DOS and NT headers structures to the 
+        * buffer with DLL's header raw data.
+        */
+       DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer;
+       NTHeaders = (PIMAGE_NT_HEADERS) (BlockBuffer + DosHeader->e_lfanew);
+       /*
+        * Check it is a PE image file.
+        */
+       if (    (DosHeader->e_magic != IMAGE_DOS_MAGIC)
+               || (DosHeader->e_lfanew == 0L)
+//             || (*(PULONG)((PUCHAR)BlockBuffer + DosHeader->e_lfanew) != IMAGE_PE_MAGIC)
+               || (*(PULONG)(NTHeaders) != IMAGE_PE_MAGIC)
+               )
+       {
+               DPRINT("NTDLL format invalid\n");
+               ZwClose(FileHandle);
+       
+               return STATUS_UNSUCCESSFUL;
+       }
+
+//     NTHeaders = (PIMAGE_NT_HEADERS) (BlockBuffer + DosHeader->e_lfanew);
+       ImageBase = (PVOID) NTHeaders->OptionalHeader.ImageBase;
+       ImageSize = NTHeaders->OptionalHeader.SizeOfImage;
+
+       DPRINT("ImageBase 0x%08x\n", ImageBase);
        
-       return Status;
-     }
-   ZwClose(FileHandle);
+       DllStartupAddr =
+               (PEPFUNC) (
+                       ImageBase
+                       + NTHeaders->OptionalHeader.AddressOfEntryPoint
+                       );
+       /*
+        * Create a section for NTDLL.
+        */
+       Status = ZwCreateSection(
+                       & SectionHandle,
+                       SECTION_ALL_ACCESS,
+                       NULL,
+                       NULL,
+                       PAGE_READWRITE,
+                       MEM_COMMIT,
+                       FileHandle
+                       );
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("NTDLL create section failed: Status = 0x%08x\n", Status);
+               ZwClose(FileHandle);       
+               return Status;
+       }
+       /*
+        * Map the NTDLL into the process.
+        */
+       InitialViewSize =
+               DosHeader->e_lfanew
+               + sizeof (IMAGE_NT_HEADERS)
+               + sizeof (IMAGE_SECTION_HEADER) * NTHeaders->FileHeader.NumberOfSections;
+       Status = ZwMapViewOfSection(
+                       SectionHandle,
+                       NtCurrentProcess(),
+                       (PVOID *) & ImageBase,
+                       0,
+                       InitialViewSize,
+                       NULL,
+                       & InitialViewSize,
+                       0,
+                       MEM_COMMIT,
+                        PAGE_READWRITE
+                       );
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("NTDLL.LDR: map view of section failed ");
+               ZwClose(FileHandle);
+       
+               return Status;
+       }
+       ZwClose(FileHandle);
    
-   (*Dll) = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(DLL));
-   (*Dll)->Headers = NTHeaders;
-   (*Dll)->BaseAddress = (PVOID)ImageBase;
-   (*Dll)->Next = LdrDllListHead.Next;
-   (*Dll)->Prev = &LdrDllListHead;
-   LdrDllListHead.Next->Prev = (*Dll);
-   LdrDllListHead.Next = (*Dll);
+       (*Dll) = RtlAllocateHeap(
+                       RtlGetProcessHeap(),
+                       0,
+                       sizeof (DLL)
+                       );
+       (*Dll)->Headers = NTHeaders;
+       (*Dll)->BaseAddress = (PVOID)ImageBase;
+       (*Dll)->Next = LdrDllListHead.Next;
+       (*Dll)->Prev = & LdrDllListHead;
+       LdrDllListHead.Next->Prev = (*Dll);
+       LdrDllListHead.Next = (*Dll);
    
-   Entrypoint = (PDLLMAIN_FUNC)LdrPEStartup(ImageBase, SectionHandle);
-   if (Entrypoint != NULL)
-     {
-       DPRINT("Calling entry point at %x\n",Entrypoint);
-       Entrypoint(ImageBase, DLL_PROCESS_ATTACH, NULL);
-       DPRINT("Successful called entrypoint\n");
-     }
+       Entrypoint =
+               (PDLLMAIN_FUNC) LdrPEStartup(
+                                       ImageBase,
+                                       SectionHandle
+                                       );
+       if (Entrypoint != NULL)
+       {
+               DPRINT("Calling entry point at 0x%08x\n", Entrypoint);
+               if (FALSE == Entrypoint(
+                               ImageBase,
+                               DLL_PROCESS_ATTACH,
+                               NULL
+                               ))
+               {
+                       DPRINT("NTDLL.LDR: DLL \"%s\" failed to initialize\n", fqname);
+                       /* FIXME: should clean up and fail */
+               }
+               else
+               {
+                       DPRINT("NTDLL.LDR: DLL \"%s\" initialized successfully\n", fqname);
+               }
+       }
+       else
+       {
+               DPRINT("NTDLL.LDR: Entrypoint is NULL for \"%s\"\n", fqname);
+       }
    
-   return(STATUS_SUCCESS);
+       return STATUS_SUCCESS;
 }
 
-static NTSTATUS LdrFindDll(PDLL* Dll, PCHAR Name)
+
+/**********************************************************************
+ * NAME                                                                LOCAL
+ *     LdrFindDll
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ * NOTE
+ *
+ */
+static
+NTSTATUS
+LdrFindDll (
+       PDLL    * Dll,
+       PCHAR   Name
+       )
 {
-   PIMAGE_EXPORT_DIRECTORY ExportDir;
-   DLL* current;
-   PIMAGE_OPTIONAL_HEADER OptionalHeader;
-   
-   DPRINT("LdrFindDll(Name %s)\n",Name);
+       PIMAGE_EXPORT_DIRECTORY ExportDir;
+       DLL                     * current;
+       PIMAGE_OPTIONAL_HEADER  OptionalHeader;
+
+
+       DPRINT("NTDLL.LdrFindDll(Name %s)\n", Name);
    
-   current = &LdrDllListHead;
-   do
-     {
-       OptionalHeader = &current->Headers->OptionalHeader;
-       ExportDir = (PIMAGE_EXPORT_DIRECTORY)OptionalHeader->DataDirectory[
-                     IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
-       ExportDir = (PIMAGE_EXPORT_DIRECTORY)
-         ((ULONG)ExportDir + (ULONG)current->BaseAddress);
+       current = & LdrDllListHead;
+       do
+       {
+               OptionalHeader = & current->Headers->OptionalHeader;
+               ExportDir = (PIMAGE_EXPORT_DIRECTORY)
+                       OptionalHeader->DataDirectory[
+                               IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
+               ExportDir = (PIMAGE_EXPORT_DIRECTORY)
+                       ((ULONG)ExportDir + (ULONG)current->BaseAddress);
        
-       DPRINT("Scanning  %x %x %x\n", ExportDir->Name,
-              current->BaseAddress, ExportDir->Name + current->BaseAddress);
-       DPRINT("Scanning %s\n", ExportDir->Name + current->BaseAddress);
-       if (strcmp(ExportDir->Name + current->BaseAddress, Name) == 0)
-         {
-            *Dll = current;
-            return(STATUS_SUCCESS);
-         }
+               DPRINT("Scanning  %x %x %x\n",
+                       ExportDir->Name,
+                       current->BaseAddress,
+                       (ExportDir->Name + current->BaseAddress)
+                       );
+               DPRINT("Scanning %s\n",
+                       ExportDir->Name + current->BaseAddress
+                       );
+               if (strcmp(ExportDir->Name + current->BaseAddress, Name) == 0)
+               {
+                       *Dll = current;
+                       return STATUS_SUCCESS;
+               }
        
-       current = current->Next;
-     } while (current != &LdrDllListHead);
+               current = current->Next;
+               
+       } while (current != & LdrDllListHead);
    
-   dprintf("Failed to find dll %s\n",Name);
+       dprintf("Failed to find dll %s\n",Name);
    
-   return(LdrLoadDll(Dll, Name));
+       return (LdrLoadDll(Dll, Name));
 }
 
-NTSTATUS LdrMapSections(HANDLE ProcessHandle,
-                       PVOID ImageBase,
-                       HANDLE SectionHandle,
-                       PIMAGE_NT_HEADERS NTHeaders)
+
+/**********************************************************************
+ * NAME
+ *     LdrMapSections
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ * NOTE
+ *
+ */
+NTSTATUS
+LdrMapSections (
+       HANDLE                  ProcessHandle,
+       PVOID                   ImageBase,
+       HANDLE                  SectionHandle,
+       PIMAGE_NT_HEADERS       NTHeaders
+       )
 {
-   ULONG i;
-   NTSTATUS Status;
-   
-   for (i=0; i<NTHeaders->FileHeader.NumberOfSections; i++)
-     {
-       PIMAGE_SECTION_HEADER Sections;
-       LARGE_INTEGER Offset;
-       ULONG Base;
+       ULONG           i;
+       NTSTATUS        Status;
+
+
+       for (   i = 0;
+               (i < NTHeaders->FileHeader.NumberOfSections);
+               i++
+               )
+       {
+               PIMAGE_SECTION_HEADER   Sections;
+               LARGE_INTEGER           Offset;
+               ULONG                   Base;
        
-       Sections = (PIMAGE_SECTION_HEADER)SECHDROFFSET(ImageBase);
-       Base = (ULONG)(Sections[i].VirtualAddress + ImageBase);
-        Offset.u.LowPart = Sections[i].PointerToRawData;
-        Offset.u.HighPart = 0;
-       Status = ZwMapViewOfSection(SectionHandle,
-                                   ProcessHandle,
-                                   (PVOID *)&Base,
-                                   0,
-                                   Sections[i].Misc.VirtualSize,
-                                   &Offset,
-                                   (PULONG)&Sections[i].Misc.VirtualSize,
-                                   0,
-                                   MEM_COMMIT,
-                                   PAGE_READWRITE);
-       if (!NT_SUCCESS(Status))
-         {
-            return Status;
-         }
-     }
-   return(STATUS_SUCCESS);
+               Sections = (PIMAGE_SECTION_HEADER) SECHDROFFSET(ImageBase);
+               Base = (ULONG) (Sections[i].VirtualAddress + ImageBase);
+               Offset.u.LowPart = Sections[i].PointerToRawData;
+               Offset.u.HighPart = 0;
+               Status = ZwMapViewOfSection(
+                               SectionHandle,
+                               ProcessHandle,
+                               (PVOID *) & Base,
+                               0,
+                               Sections[i].Misc.VirtualSize,
+                               & Offset,
+                               (PULONG) & Sections[i].Misc.VirtualSize,
+                               0,
+                               MEM_COMMIT,
+                               PAGE_READWRITE
+                               );
+               if (!NT_SUCCESS(Status))
+               {
+                       return Status;
+               }
+       }
+       return STATUS_SUCCESS;
 }
 
-static PVOID LdrGetExportByOrdinal(PDLL Module, ULONG Ordinal)
+
+/**********************************************************************
+ * NAME                                                                LOCAL
+ *     LdrGetExportByOrdinal
+ *     
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ * NOTE
+ *
+ */
+static
+PVOID
+LdrGetExportByOrdinal (
+       PDLL    Module,
+       ULONG   Ordinal
+       )
 {
-   PIMAGE_EXPORT_DIRECTORY ExportDir;
-   PDWORD* ExFunctions;
-   USHORT* ExOrdinals;
+       PIMAGE_EXPORT_DIRECTORY ExportDir;
+       PDWORD                  * ExFunctions;
+       USHORT                  * ExOrdinals;
 
-   ExportDir = (Module->BaseAddress + 
-               (Module->Headers->OptionalHeader.
-                DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress));
+       ExportDir = (
+               Module->BaseAddress
+               + (Module->Headers->OptionalHeader
+                       .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]
+                               .VirtualAddress
+                               )
+               );
    
-   ExOrdinals = (USHORT*)RVA(Module->BaseAddress, 
-                            ExportDir->AddressOfNameOrdinals);
-   ExFunctions = (PDWORD*)RVA(Module->BaseAddress, 
-                             ExportDir->AddressOfFunctions);
-   dprintf("LdrGetExportByOrdinal(Ordinal %d) = %x\n",
-          Ordinal,ExFunctions[ExOrdinals[Ordinal - ExportDir->Base]]);
-   return(ExFunctions[ExOrdinals[Ordinal - ExportDir->Base]]);
+       ExOrdinals = (USHORT *)
+               RVA(
+                       Module->BaseAddress, 
+                       ExportDir->AddressOfNameOrdinals
+                       );
+       ExFunctions = (PDWORD *)
+               RVA(
+                       Module->BaseAddress, 
+                       ExportDir->AddressOfFunctions
+                       );
+       dprintf(
+               "LdrGetExportByOrdinal(Ordinal %d) = %x\n",
+               Ordinal,
+               ExFunctions[ExOrdinals[Ordinal - ExportDir->Base]]
+               );
+       return(ExFunctions[ExOrdinals[Ordinal - ExportDir->Base]]);
 }
 
-static PVOID LdrGetExportByName(PDLL Module, PUCHAR SymbolName)
+
+/**********************************************************************
+ * NAME                                                                LOCAL
+ *     LdrGetExportByName
+ *     
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ * NOTE
+ *
+ */
+static
+PVOID
+LdrGetExportByName (
+       PDLL    Module,
+       PUCHAR  SymbolName
+       )
 {
-   PIMAGE_EXPORT_DIRECTORY ExportDir;
-   PDWORD* ExFunctions;
-   PDWORD* ExNames;
-   USHORT* ExOrdinals;
-   ULONG i;
-   PVOID ExName;
-   ULONG Ordinal;
+       PIMAGE_EXPORT_DIRECTORY ExportDir;
+       PDWORD                  * ExFunctions;
+       PDWORD                  * ExNames;
+       USHORT                  * ExOrdinals;
+       ULONG                   i;
+       PVOID                   ExName;
+       ULONG                   Ordinal;
    
-   DPRINT("LdrFindExport(Module %x, SymbolName %s)\n",
-         Module, SymbolName);
+       DPRINT(
+               "LdrFindExport(Module %x, SymbolName %s)\n",
+               Module,
+               SymbolName
+               );
    
-   ExportDir = (Module->BaseAddress + 
-               (Module->Headers->OptionalHeader.
-                DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress));
-   
-   /*  Get header pointers  */
-   ExNames = (PDWORD*)RVA(Module->BaseAddress, ExportDir->AddressOfNames);
-   ExOrdinals = (USHORT*)RVA(Module->BaseAddress, 
-                            ExportDir->AddressOfNameOrdinals);
-   ExFunctions = (PDWORD*)RVA(Module->BaseAddress, 
-                             ExportDir->AddressOfFunctions);
-   for (i=0; i<ExportDir->NumberOfFunctions; i++)
-     {
-       ExName = RVA(Module->BaseAddress, ExNames[i]);
-       DPRINT("Comparing '%s' '%s'\n",ExName,SymbolName);
-       if (strcmp(ExName,SymbolName) == 0)
-         {
-            Ordinal = ExOrdinals[i];
-            return(RVA(Module->BaseAddress, ExFunctions[Ordinal]));
-         }
-     }
-   dprintf("LdrGetExportByName() = failed to find %s\n",SymbolName);
-   return(NULL);
+       ExportDir = (
+               Module->BaseAddress
+               + (Module->Headers->OptionalHeader
+                       .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]
+                               .VirtualAddress
+                               )
+               );
+       /*
+        * Get header pointers
+        */
+       ExNames = (PDWORD *)
+               RVA(
+                       Module->BaseAddress,
+                       ExportDir->AddressOfNames
+                       );
+       ExOrdinals = (USHORT *)
+               RVA(
+                       Module->BaseAddress, 
+                       ExportDir->AddressOfNameOrdinals
+                       );
+       ExFunctions = (PDWORD *)
+               RVA(
+                       Module->BaseAddress, 
+                       ExportDir->AddressOfFunctions
+                       );
+       for (   i = 0;
+               ( i < ExportDir->NumberOfFunctions);
+               i++
+               )
+       {
+               ExName = RVA(
+                               Module->BaseAddress,
+                               ExNames[i]
+                               );
+               DPRINT(
+                       "Comparing '%s' '%s'\n",
+                       ExName,
+                       SymbolName
+                       );
+               if (strcmp(ExName,SymbolName) == 0)
+               {
+                       Ordinal = ExOrdinals[i];
+                       return(RVA(Module->BaseAddress, ExFunctions[Ordinal]));
+               }
+       }
+
+       dprintf("LdrGetExportByName() = failed to find %s\n",SymbolName);
+
+       return NULL;
 }
 
-static NTSTATUS LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders,
-                                     PVOID ImageBase)
+
+/**********************************************************************
+ * NAME                                                                LOCAL
+ *     LdrPerformRelocations
+ *     
+ * DESCRIPTION
+ *     Relocate a DLL's memory image.
+ *     
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ * NOTE
+ *
+ */
+static
+NTSTATUS
+LdrPerformRelocations (
+       PIMAGE_NT_HEADERS       NTHeaders,
+       PVOID                   ImageBase
+       )
 {
-   USHORT NumberOfEntries;
-   PUSHORT pValue16;
-   ULONG RelocationRVA;
-   ULONG Delta32, Offset;
-   PULONG pValue32;
-   PRELOCATION_DIRECTORY RelocationDir;
-   PRELOCATION_ENTRY RelocationBlock;
-   int i;
-   
-   RelocationRVA = NTHeaders->OptionalHeader.DataDirectory[
-                      IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;
-   if (RelocationRVA)
-     {
-       RelocationDir = (PRELOCATION_DIRECTORY)((PCHAR)ImageBase + 
-                                               RelocationRVA);
-       while (RelocationDir->SizeOfBlock)
-         {
-            Delta32 = (unsigned long)(ImageBase - 
-                                      NTHeaders->OptionalHeader.ImageBase);
-            RelocationBlock = (PRELOCATION_ENTRY) 
-              (RelocationRVA + ImageBase + sizeof(RELOCATION_DIRECTORY));
-            NumberOfEntries = 
-              (RelocationDir->SizeOfBlock - sizeof(RELOCATION_DIRECTORY)) / 
-              sizeof(RELOCATION_ENTRY);
-            for (i = 0; i < NumberOfEntries; i++)
-              {
-                  Offset = (RelocationBlock[i].TypeOffset & 0xfff) + 
-                    RelocationDir->VirtualAddress;
-                  switch (RelocationBlock[i].TypeOffset >> 12)
-                    {
-                      case TYPE_RELOC_ABSOLUTE:
-                        break;
-                      
-                    case TYPE_RELOC_HIGH:
-                      pValue16 = (PUSHORT) (ImageBase + Offset);
-                      *pValue16 += Delta32 >> 16;
-                      break;
-                      
-                    case TYPE_RELOC_LOW:
-                      pValue16 = (PUSHORT)(ImageBase + Offset);
-                      *pValue16 += Delta32 & 0xffff;
-                      break;
-                      
-                    case TYPE_RELOC_HIGHLOW:
-                      pValue32 = (PULONG) (ImageBase + Offset);
-                      *pValue32 += Delta32;
-                      break;
-                      
-                      case TYPE_RELOC_HIGHADJ:
-                      /* FIXME: do the highadjust fixup  */
-                        DPRINT("TYPE_RELOC_HIGHADJ fixup not implemented"
-                              ", sorry\n");
-                      return(STATUS_UNSUCCESSFUL);
+       USHORT                  NumberOfEntries;
+       PUSHORT                 pValue16;
+       ULONG                   RelocationRVA;
+       ULONG                   Delta32;
+       ULONG                   Offset;
+       PULONG                  pValue32;
+       PRELOCATION_DIRECTORY   RelocationDir;
+       PRELOCATION_ENTRY       RelocationBlock;
+       int                     i;
+
+
+       RelocationRVA =
+               NTHeaders->OptionalHeader
+                       .DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC]
+                               .VirtualAddress;
+       if (RelocationRVA)
+       {
+               RelocationDir = (PRELOCATION_DIRECTORY)
+                       ((PCHAR)ImageBase + RelocationRVA);
+
+               while (RelocationDir->SizeOfBlock)
+               {
+                       Delta32 = (unsigned long) (
+                               ImageBase
+                               - NTHeaders->OptionalHeader.ImageBase
+                               );
+                       RelocationBlock = (PRELOCATION_ENTRY) (
+                               RelocationRVA
+                               + ImageBase
+                               + sizeof (RELOCATION_DIRECTORY)
+                               );
+                       NumberOfEntries = (
+                               RelocationDir->SizeOfBlock
+                               - sizeof (RELOCATION_DIRECTORY)
+                               )
+                               / sizeof (RELOCATION_ENTRY);
+
+                       for (   i = 0;
+                               (i < NumberOfEntries);
+                               i++
+                               )
+                       {
+                               Offset = (
+                                       RelocationBlock[i].TypeOffset
+                                       & 0xfff
+                                       )
+                                       + RelocationDir->VirtualAddress;
+                               /*
+                                * What kind of relocations should we perform
+                                * for the current entry?
+                                */
+                               switch (RelocationBlock[i].TypeOffset >> 12)
+                               {
+                               case TYPE_RELOC_ABSOLUTE:
+                                       break;
+
+                               case TYPE_RELOC_HIGH:
+                                       pValue16 = (PUSHORT) (ImageBase + Offset);
+                                       *pValue16 += Delta32 >> 16;
+                                       break;
+
+                               case TYPE_RELOC_LOW:
+                                       pValue16 = (PUSHORT)(ImageBase + Offset);
+                                       *pValue16 += Delta32 & 0xffff;
+                                       break;
+
+                               case TYPE_RELOC_HIGHLOW:
+                                       pValue32 = (PULONG) (ImageBase + Offset);
+                                       *pValue32 += Delta32;
+                                       break;
+
+                               case TYPE_RELOC_HIGHADJ:
+                                       /* FIXME: do the highadjust fixup  */
+                                       DPRINT(
+                                               "TYPE_RELOC_HIGHADJ fixup not implemented"
+                                               ", sorry\n"
+                                               );
+                                       return(STATUS_UNSUCCESSFUL);
                       
-                      default:
-                      DPRINT("unexpected fixup type\n");
-                      return(STATUS_UNSUCCESSFUL);
-                    }
-              }
-            RelocationRVA += RelocationDir->SizeOfBlock;
-            RelocationDir = (PRELOCATION_DIRECTORY)(ImageBase + 
-                                                    RelocationRVA);
-         }
-     }
-   return(STATUS_SUCCESS);
+                               default:
+                                       DPRINT("unexpected fixup type\n");
+                                       return STATUS_UNSUCCESSFUL;
+                               }
+                       }
+                       RelocationRVA += RelocationDir->SizeOfBlock;
+                       RelocationDir = (PRELOCATION_DIRECTORY) (
+                               ImageBase
+                               + RelocationRVA
+                               );
+               }
+       }
+       return STATUS_SUCCESS;
 }
 
-static NTSTATUS LdrFixupImports(PIMAGE_NT_HEADERS NTHeaders,
-                               PVOID ImageBase)
+
+/**********************************************************************
+ * NAME                                                                LOCAL
+ *     LdrFixupImports
+ *     
+ * DESCRIPTION
+ *     Compute the entry point for every symbol the DLL imports
+ *     from other modules.
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ * NOTE
+ *
+ */
+static
+NTSTATUS
+LdrFixupImports (
+       PIMAGE_NT_HEADERS       NTHeaders,
+       PVOID                   ImageBase
+       )
 {
-   PIMAGE_IMPORT_MODULE_DIRECTORY ImportModuleDirectory;
-   ULONG Ordinal;
-   PDLL Module;
-   NTSTATUS Status;
-   
-   /*  Process each import module  */
-   ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY)
-     (ImageBase + NTHeaders->OptionalHeader.
-      DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
-   while (ImportModuleDirectory->dwRVAModuleName)
-     {
-       PVOID *ImportAddressList; 
-       PULONG FunctionNameList;
-       DWORD pName;
-       PWORD pHint;
-       
-       Status = LdrFindDll(&Module,
-                           (PCHAR)(ImageBase +
-                                   ImportModuleDirectory->dwRVAModuleName));
-       if (!NT_SUCCESS(Status))
-         {
-            return(Status);
-         }    
-       
-       /*  Get the import address list  */
-       ImportAddressList = (PVOID *)
-         (NTHeaders->OptionalHeader.ImageBase + 
-          ImportModuleDirectory->dwRVAFunctionAddressList);
-       
-       /*  Get the list of functions to import  */
-       if (ImportModuleDirectory->dwRVAFunctionNameList != 0)
-         {
-            FunctionNameList = (PULONG) (ImageBase + 
-                                         ImportModuleDirectory->dwRVAFunctionNameList);
-         }
-       else
-         {
-            FunctionNameList = (PULONG) (ImageBase + 
-                                         ImportModuleDirectory->dwRVAFunctionAddressList);
-         }
+       PIMAGE_IMPORT_MODULE_DIRECTORY  ImportModuleDirectory;
+       ULONG                           Ordinal;
+       PDLL                            Module;
+       NTSTATUS                        Status;
+
+
+       /*
+        * Process each import module.
+        */
+       ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY) (
+               ImageBase
+               + NTHeaders->OptionalHeader
+                       .DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]
+                               .VirtualAddress
+               );
+       while (ImportModuleDirectory->dwRVAModuleName)
+       {
+               PVOID   * ImportAddressList; 
+               PULONG  FunctionNameList;
+               DWORD   pName;
+               PWORD   pHint;
        
-       /*  Walk through function list and fixup addresses  */
-       while(*FunctionNameList != 0L)
-         {
-            if ((*FunctionNameList) & 0x80000000)
-              {
-                 Ordinal = (*FunctionNameList) & 0x7fffffff;
-                 *ImportAddressList = LdrGetExportByOrdinal(Module, Ordinal);
-              }
-            else 
-              {
-                 pName = (DWORD)(ImageBase + *FunctionNameList + 2);
-                 pHint = (PWORD)(ImageBase + *FunctionNameList);
+               Status = LdrFindDll(
+                               & Module,
+                               (PCHAR) (
+                                       ImageBase
+                                       + ImportModuleDirectory->dwRVAModuleName
+                                       )
+                               );
+               if (!NT_SUCCESS(Status))
+               {
+                       return Status;
+               }
+               /*
+                * Get the import address list.
+                */
+               ImportAddressList = (PVOID *) (
+                       NTHeaders->OptionalHeader.ImageBase
+                       + ImportModuleDirectory->dwRVAFunctionAddressList
+                       );
+               /*
+                * Get the list of functions to import.
+                */
+               if (ImportModuleDirectory->dwRVAFunctionNameList != 0)
+               {
+                       FunctionNameList = (PULONG) (
+                               ImageBase
+                               + ImportModuleDirectory->dwRVAFunctionNameList
+                               );
+               }
+               else
+               {
+                       FunctionNameList = (PULONG) (
+                               ImageBase
+                               + ImportModuleDirectory->dwRVAFunctionAddressList
+                               );
+               }
+               /*
+                * Walk through function list and fixup addresses.
+                */
+               while (*FunctionNameList != 0L)
+               {
+                       if ((*FunctionNameList) & 0x80000000)
+                       {
+                               Ordinal = (*FunctionNameList) & 0x7fffffff;
+                               *ImportAddressList = 
+                                       LdrGetExportByOrdinal(
+                                               Module,
+                                               Ordinal
+                                               );
+                       }
+                       else
+                       {
+                               pName = (DWORD) (
+                                               ImageBase
+                                               + *FunctionNameList
+                                               + 2
+                                               );
+                               pHint = (PWORD) (
+                                               ImageBase
+                                               + *FunctionNameList
+                                               );
                                  
-                 *ImportAddressList = LdrGetExportByName(Module,
-                                                         (PUCHAR)pName);
-                 if ((*ImportAddressList) == NULL)
-                   {
-                      return(STATUS_UNSUCCESSFUL);
-                   }
-              }
-            
-            ImportAddressList++;
-            FunctionNameList++;
-         }
-       ImportModuleDirectory++;
-     }
-   return(STATUS_SUCCESS);
+                               *ImportAddressList =
+                                       LdrGetExportByName(
+                                               Module,
+                                               (PUCHAR) pName
+                                               );
+                               if ((*ImportAddressList) == NULL)
+                               {
+                                       return STATUS_UNSUCCESSFUL;
+                               }
+                       }
+                       ImportAddressList++;
+                       FunctionNameList++;
+               }
+               ImportModuleDirectory++;
+       }
+       return STATUS_SUCCESS;
 }
 
-PEPFUNC LdrPEStartup(PVOID ImageBase, HANDLE SectionHandle)
+
+/**********************************************************************
+ * NAME
+ *     LdrPEStartup
+ *
+ * DESCRIPTION
+ *     1. Map the DLL's sections into memory.
+ *     2. Relocate, if needed the DLL.
+ *     3. Fixup any imported symbol.
+ *     4. Compute the DLL's entry point.
+ *
+ * ARGUMENTS
+ *     ImageBase
+ *             Address at which the DLL's image
+ *             is loaded.
+ *             
+ *     SectionHandle
+ *             Handle of the section that contains
+ *             the DLL's image.
+ *
+ * RETURN VALUE
+ *     NULL on error; otherwise the entry point
+ *     to call for initializing the DLL.
+ *
+ * REVISIONS
+ *
+ * NOTE
+ *
+ */
+PEPFUNC
+LdrPEStartup (
+       PVOID   ImageBase,
+       HANDLE  SectionHandle
+       )
 {
-   NTSTATUS Status;
-   PEPFUNC EntryPoint;
-   PIMAGE_DOS_HEADER DosHeader;
-   PIMAGE_NT_HEADERS NTHeaders;
-   
-   DosHeader = (PIMAGE_DOS_HEADER) ImageBase;
-   NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + DosHeader->e_lfanew);
-   
-   /*  Initialize Image sections  */
-   LdrMapSections(NtCurrentProcess(), ImageBase, SectionHandle, NTHeaders);
-   
-   if (ImageBase != (PVOID)NTHeaders->OptionalHeader.ImageBase)
-     {
-       Status = LdrPerformRelocations(NTHeaders, ImageBase);
-       if (!NT_SUCCESS(Status))
-         {
-            dprintf("LdrPerformRelocations() failed\n");
-            return(NULL);
-         }
-     }
-   
-   if (NTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].
-       VirtualAddress != 0)
-     {
-       Status = LdrFixupImports(NTHeaders, ImageBase);
-       if (!NT_SUCCESS(Status))
-         {
-            dprintf("LdrFixupImports() failed\n");
-            return(NULL);
-         }
-     }
-   
-   EntryPoint = (PEPFUNC)(ImageBase + 
-                         NTHeaders->OptionalHeader.AddressOfEntryPoint);
-   dprintf("LdrPEStartup() = %x\n",EntryPoint);
-   return(EntryPoint);
+       NTSTATUS                Status;
+       PEPFUNC                 EntryPoint;
+       PIMAGE_DOS_HEADER       DosHeader;
+       PIMAGE_NT_HEADERS       NTHeaders;
+
+
+       /*
+        * Overlay DOS and WNT headers structures
+        * to the DLL's image.
+        */
+       DosHeader = (PIMAGE_DOS_HEADER) ImageBase;
+       NTHeaders = (PIMAGE_NT_HEADERS) (ImageBase + DosHeader->e_lfanew);
+       /*
+        * Initialize image sections.
+        */
+       LdrMapSections(
+               NtCurrentProcess(),
+               ImageBase,
+               SectionHandle,
+               NTHeaders
+               );
+       /*
+        * If the base address is different from the
+        * one the DLL is actually loaded, perform any
+        * relocation.
+        */
+       if (ImageBase != (PVOID) NTHeaders->OptionalHeader.ImageBase)
+       {
+               Status = LdrPerformRelocations(
+                               NTHeaders,
+                               ImageBase
+                               );
+               if (!NT_SUCCESS(Status))
+               {
+                       dprintf("LdrPerformRelocations() failed\n");
+                       return NULL;
+               }
+       }
+       /*
+        * If the DLL's imports symbols from other
+        * modules, fixup the imported calls entry points.
+        */
+       if (NTHeaders->OptionalHeader
+                       .DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]
+                               .VirtualAddress != 0)
+       {
+               Status = LdrFixupImports(
+                               NTHeaders,
+                               ImageBase
+                               );
+               if (!NT_SUCCESS(Status))
+               {
+                       dprintf("LdrFixupImports() failed\n");
+                       return NULL;
+               }
+       }
+       /*
+        * Compute the DLL's entry point's address.
+        */
+       EntryPoint = (PEPFUNC) (
+               ImageBase
+               + NTHeaders->OptionalHeader.AddressOfEntryPoint
+               );
+       dprintf("LdrPEStartup() = %x\n",EntryPoint);
+       return EntryPoint;
 }
 
 
 
+/* EOF */
index 7f8f0f6..a376315 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: registry.c,v 1.18 1999/08/29 06:59:05 ea Exp $
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/cm/registry.c
@@ -363,13 +364,16 @@ CHECKPOINT;
 
 
 NTSTATUS 
-NtCreateKey(OUT PHANDLE  KeyHandle,
-            IN ACCESS_MASK  DesiredAccess,
-            IN POBJECT_ATTRIBUTES  ObjectAttributes, 
-            IN ULONG  TitleIndex,
-            IN PUNICODE_STRING  Class, 
-            IN ULONG  CreateOptions,
-            OUT PULONG  Disposition)
+STDCALL
+NtCreateKey (
+       OUT     PHANDLE                 KeyHandle,
+       IN      ACCESS_MASK             DesiredAccess,
+       IN      POBJECT_ATTRIBUTES      ObjectAttributes, 
+       IN      ULONG                   TitleIndex,
+       IN      PUNICODE_STRING         Class,
+       IN      ULONG                   CreateOptions,
+       OUT     PULONG                  Disposition
+       )
 {
 #if PROTO_REG
   PWSTR  KeyNameBuf;
@@ -455,7 +459,10 @@ NtCreateKey(OUT PHANDLE  KeyHandle,
 
 
 NTSTATUS 
-NtDeleteKey(IN HANDLE  KeyHandle)
+STDCALL
+NtDeleteKey (
+       IN      HANDLE  KeyHandle
+       )
 {
 #ifdef PROTO_REG
   NTSTATUS  Status;
@@ -489,12 +496,15 @@ NtDeleteKey(IN HANDLE  KeyHandle)
 
 
 NTSTATUS 
-NtEnumerateKey(IN HANDLE  KeyHandle, 
-               IN ULONG  Index,
-               IN KEY_INFORMATION_CLASS  KeyInformationClass,
-               OUT PVOID  KeyInformation,
-               IN ULONG  Length,
-               OUT PULONG  ResultLength)
+STDCALL
+NtEnumerateKey (
+       IN      HANDLE                  KeyHandle,
+       IN      ULONG                   Index,
+       IN      KEY_INFORMATION_CLASS   KeyInformationClass,
+       OUT     PVOID                   KeyInformation,
+       IN      ULONG                   Length,
+       OUT     PULONG                  ResultLength
+       )
 {
 #ifdef PROTO_REG
   NTSTATUS  Status;
@@ -637,7 +647,9 @@ NtEnumerateKey(IN HANDLE  KeyHandle,
 #endif
 }
 
+
 NTSTATUS 
+STDCALL
 NtEnumerateValueKey (
        IN      HANDLE                          KeyHandle,
        IN      ULONG                           Index,
@@ -654,8 +666,12 @@ NtEnumerateValueKey (
 #endif
 }
 
+
 NTSTATUS 
-NtFlushKey(IN HANDLE  KeyHandle)
+STDCALL
+NtFlushKey (
+       IN      HANDLE  KeyHandle
+       )
 {
 #ifdef PROTO_REG
   return  STATUS_SUCCESS;
@@ -664,10 +680,14 @@ NtFlushKey(IN HANDLE  KeyHandle)
 #endif
 }
 
+
 NTSTATUS 
-NtOpenKey(OUT PHANDLE  KeyHandle, 
-          IN ACCESS_MASK  DesiredAccess,
-          IN POBJECT_ATTRIBUTES  ObjectAttributes)
+STDCALL
+NtOpenKey (
+       OUT     PHANDLE                 KeyHandle, 
+       IN      ACCESS_MASK             DesiredAccess,
+       IN      POBJECT_ATTRIBUTES      ObjectAttributes
+       )
 {
 #ifdef PROTO_REG
   NTSTATUS  Status;
@@ -757,7 +777,9 @@ NtOpenKey(OUT PHANDLE  KeyHandle,
 #endif
 }
 
+
 NTSTATUS 
+STDCALL
 NtQueryKey (
        IN      HANDLE                  KeyHandle, 
        IN      KEY_INFORMATION_CLASS   KeyInformationClass,
@@ -895,7 +917,9 @@ NtQueryKey (
 #endif
 }
 
+
 NTSTATUS 
+STDCALL
 NtQueryValueKey (
        IN      HANDLE                          KeyHandle,
        IN      PUNICODE_STRING                 ValueName,
@@ -1024,7 +1048,9 @@ NtQueryValueKey (
 #endif
 }
 
+
 NTSTATUS 
+STDCALL
 NtSetValueKey (
        IN      HANDLE                  KeyHandle, 
        IN      PUNICODE_STRING         ValueName,
@@ -1088,7 +1114,8 @@ NtSetValueKey (
 #endif
 }
 
-NTSTATUS STDCALL
+NTSTATUS
+STDCALL
 NtDeleteValueKey (
        IN      HANDLE          KeyHandle,
        IN      PUNICODE_STRING ValueName
@@ -1246,6 +1273,7 @@ NtInitializeRegistry (
 
 
 NTSTATUS 
+STDCALL
 RtlCheckRegistryKey (
        ULONG   RelativeTo,
        PWSTR   Path
@@ -1256,6 +1284,7 @@ RtlCheckRegistryKey (
 
 
 NTSTATUS 
+STDCALL
 RtlCreateRegistryKey (
        IN      ULONG   RelativeTo,
        IN      PWSTR   Path
@@ -1266,6 +1295,7 @@ RtlCreateRegistryKey (
 
 
 NTSTATUS 
+STDCALL
 RtlDeleteRegistryValue (
        IN      ULONG   RelativeTo, 
        IN      PWSTR   Path,
@@ -1277,6 +1307,7 @@ RtlDeleteRegistryValue (
 
 
 NTSTATUS 
+STDCALL
 RtlQueryRegistryValues (
        IN      ULONG                           RelativeTo,
        IN      PWSTR                           Path,
@@ -1290,6 +1321,7 @@ RtlQueryRegistryValues (
 
 
 NTSTATUS 
+STDCALL
 RtlWriteRegistryValue (
        ULONG   RelativeTo,
        PWSTR   Path,
@@ -2690,4 +2722,4 @@ CmiReleaseBlock(PREGISTRY_FILE  RegistryFile,
 
 #endif
 
-
+/* EOF */
index 25287e6..f6479d1 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: interlck.c,v 1.2 1999/08/29 06:59:06 ea Exp $
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ex/interlck.c
 
 /* FUNCTIONS *****************************************************************/
 
-INTERLOCKED_RESULT ExInterlockedDecrementLong(PLONG Addend,
-                                             PKSPIN_LOCK Lock)
+INTERLOCKED_RESULT
+ExInterlockedDecrementLong (
+       PLONG           Addend,
+       PKSPIN_LOCK     Lock
+       )
 {
-   UNIMPLEMENTED;
+       UNIMPLEMENTED;
 }
 
-ULONG ExInterlockedExchangeUlong(PULONG Target,
-                                ULONG Value,
-                                PKSPIN_LOCK Lock)
+
+ULONG
+ExInterlockedExchangeUlong (
+       PULONG          Target,
+       ULONG           Value,
+       PKSPIN_LOCK     Lock
+       )
 {
-   UNIMPLEMENTED;
+       UNIMPLEMENTED;
 }
 
-ULONG ExInterlockedAddUlong(PULONG Addend,
-                           ULONG Increment,
-                           PKSPIN_LOCK Lock)
+
+ULONG
+ExInterlockedAddUlong (
+       PULONG          Addend,
+       ULONG           Increment,
+       PKSPIN_LOCK     Lock
+       )
 {
-   UNIMPLEMENTED;
+       UNIMPLEMENTED;
 }
 
-INTERLOCKED_RESULT ExInterlockedIncrementLong(PLONG Addend,
-                                             PKSPIN_LOCK Lock)
+
+INTERLOCKED_RESULT
+ExInterlockedIncrementLong (
+       PLONG           Addend,
+       PKSPIN_LOCK     Lock
+       )
 {
-   UNIMPLEMENTED;
+       UNIMPLEMENTED;
 }
+
+
+/* EOF */
index f242b8b..530111c 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: device.c,v 1.10 1999/08/29 06:59:06 ea Exp $
+ *
  * COPYRIGHT:      See COPYING in the top level directory
  * PROJECT:        ReactOS kernel
  * FILE:           ntoskrnl/io/device.c
@@ -33,20 +34,32 @@ NtUnloadDriver (
 }
 
 
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     NtLoadDriver
+ *
+ * DESCRIPTION
+ *     Loads a device driver.
+ *     
+ * ARGUMENTS
+ *     DriverServiceName
+ *             Name of the service to load (registry key).
+ *             
+ * RETURN VALUE
+ *     Status.
+ *
+ * REVISIONS
+ */
 NTSTATUS
+STDCALL
 NtLoadDriver (
        PUNICODE_STRING DriverServiceName
        )
-/*
- * FUNCTION: Loads a driver
- * ARGUMENTS:
- *         DriverServiceName = Name of the service to load (registry key)
- * RETURNS: Status
- */
 {
        UNIMPLEMENTED;
 }
 
+
 NTSTATUS
 IoAttachDeviceByPointer (
        PDEVICE_OBJECT  SourceDevice,
@@ -307,3 +320,6 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
    
    return(STATUS_SUCCESS);
 }
+
+
+/* EOF */
index 780ef65..770922d 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: file.c,v 1.9 1999/08/29 06:59:06 ea Exp $
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/io/file.c
@@ -89,7 +90,9 @@ NtQueryInformationFile (
    return(Status);
 }
 
+
 NTSTATUS
+STDCALL
 NtSetInformationFile (
        HANDLE                  FileHandle,
        PIO_STATUS_BLOCK        IoStatusBlock,
@@ -98,65 +101,100 @@ NtSetInformationFile (
        FILE_INFORMATION_CLASS  FileInformationClass
        )
 {
-  NTSTATUS Status;
-  PFILE_OBJECT FileObject;
-  PIRP Irp;
-  PIO_STACK_LOCATION StackPtr;
-  KEVENT Event;
+       NTSTATUS                Status;
+       PFILE_OBJECT            FileObject;
+       PIRP                    Irp;
+       PIO_STACK_LOCATION      StackPtr;
+       KEVENT                  Event;
    
-  DPRINT("NtSetInformationFile(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n",
-         FileHandle,
-         IoStatusBlock,
-         FileInformation,
-         Length,
-         FileInformationClass);
+       DPRINT(
+               "NtSetInformationFile(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n",
+               FileHandle,
+               IoStatusBlock,
+               FileInformation,
+               Length,
+               FileInformationClass
+               );
    
-  /*  Get the file object from the file handle  */
-  Status = ObReferenceObjectByHandle(FileHandle,
-                                     FILE_WRITE_ATTRIBUTES,
-                                     IoFileType,
-                                     UserMode,
-                                     (PVOID *) &FileObject,
-                                     NULL);
-  if (!NT_SUCCESS(Status))
-    {
-      return Status;
-    }
-  DPRINT("FileObject %x\n", FileObject);
+       /*  Get the file object from the file handle  */
+       Status = ObReferenceObjectByHandle(
+                       FileHandle,
+                        FILE_WRITE_ATTRIBUTES,
+                        IoFileType,
+                        UserMode,
+                        (PVOID *) & FileObject,
+                        NULL
+                       );
+       if (!NT_SUCCESS(Status))
+       {
+               return Status;
+       }
+       
+       DPRINT("FileObject %x\n", FileObject);
    
-  /*  initialize an event object to wait on for the request  */
-  KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
-  /*  build the IRP to be sent to the driver for the request  */
-  Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SET_INFORMATION,
-                                     FileObject->DeviceObject,
-                                     FileInformation,
-                                     Length,
-                                     0,
-                                     &Event,
-                                     IoStatusBlock);
-  StackPtr = IoGetNextIrpStackLocation(Irp);
-  StackPtr->FileObject = FileObject;
-  StackPtr->Parameters.SetFile.Length = Length;
-  StackPtr->Parameters.SetFile.FileInformationClass = FileInformationClass;
+       /*
+        * Initialize an event object to wait
+        * on for the request.
+        */
+       KeInitializeEvent(
+               & Event,
+               NotificationEvent,
+               FALSE
+               );
+       /*
+        * Build the IRP to be sent to the driver
+        * for the request.
+        */
+       Irp = IoBuildSynchronousFsdRequest(
+               IRP_MJ_SET_INFORMATION,
+               FileObject->DeviceObject,
+               FileInformation,
+               Length,
+               0,
+               & Event,
+               IoStatusBlock
+               );
+
+       StackPtr = IoGetNextIrpStackLocation(Irp);
+       StackPtr->FileObject = FileObject;
+       StackPtr->Parameters.SetFile.Length = Length;
+       StackPtr->Parameters.SetFile.FileInformationClass =
+               FileInformationClass;
    
-  /*  Pass the IRP to the FSD (and wait for it if required) */
-  DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject);
-  Status = IoCallDriver(FileObject->DeviceObject, Irp);
-  if (Status == STATUS_PENDING  && (FileObject->Flags & FO_SYNCHRONOUS_IO))
-    {
-      KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
-      Status = Irp->IoStatus.Status;
-    } 
-
-  return Status;
+       /*
+        * Pass the IRP to the FSD (and wait for
+        * it if required)
+        */
+       DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject);
+       Status = IoCallDriver(
+                       FileObject->DeviceObject,
+                       Irp
+                       );
+       if (    (Status == STATUS_PENDING)
+               && (FileObject->Flags & FO_SYNCHRONOUS_IO)
+               )
+       {
+               KeWaitForSingleObject(
+                       & Event,
+                       Executive,
+                       KernelMode,
+                       FALSE,
+                       NULL
+                       );
+               Status = Irp->IoStatus.Status;
+       }
+
+       return Status;
 }
 
-PGENERIC_MAPPING IoGetFileObjectGenericMapping(VOID)
+
+PGENERIC_MAPPING
+IoGetFileObjectGenericMapping(VOID)
 {
-  UNIMPLEMENTED;
+       UNIMPLEMENTED;
 }
 
+
 NTSTATUS
 STDCALL
 NtQueryAttributesFile (
@@ -210,3 +248,4 @@ NtSetEaFile (
 }
 
 
+/* EOF */
index 74d01aa..801c5fe 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: rw.c,v 1.26 1999/08/29 06:59:06 ea Exp $
+ *
  * COPYRIGHT:      See COPYING in the top level directory
  * PROJECT:        ReactOS kernel
  * FILE:           ntoskrnl/io/rw.c
 
 /* FUNCTIONS ***************************************************************/
 
+
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     NtReadFile
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ */
 NTSTATUS
+STDCALL
 NtReadFile (
        HANDLE                  FileHandle,
        HANDLE                  EventHandle,
@@ -34,94 +50,142 @@ NtReadFile (
        PULONG                  Key
        )
 {
-   NTSTATUS Status;
-   PFILE_OBJECT FileObject;
-   PIRP Irp;
-   PIO_STACK_LOCATION StackPtr;
-   PKEVENT ptrEvent = NULL;
-   KEVENT Event;
+       NTSTATUS                Status;
+       PFILE_OBJECT            FileObject;
+       PIRP                    Irp;
+       PIO_STACK_LOCATION      StackPtr;
+       PKEVENT                 ptrEvent = NULL;
+       KEVENT                  Event;
    
-   DPRINT("NtReadFile(FileHandle %x Buffer %x Length %x ByteOffset %x, "
-         "IoStatusBlock %x)\n",
-         FileHandle,Buffer,Length,ByteOffset,IoStatusBlock);
+       DPRINT(
+               "NtReadFile(FileHandle %x Buffer %x Length %x ByteOffset %x, "
+               "IoStatusBlock %x)\n",
+               FileHandle,
+               Buffer,
+               Length,
+               ByteOffset,
+               IoStatusBlock
+               );
 
-   assert_irql(PASSIVE_LEVEL);
+       assert_irql(PASSIVE_LEVEL);
    
-   Status = ObReferenceObjectByHandle(FileHandle,
-                                     FILE_READ_DATA,
-                                     IoFileType,
-                                     UserMode,
-                                     (PVOID *) &FileObject,
-                                     NULL);
-   if (!NT_SUCCESS(Status))
-     {
-       DPRINT("NtReadFile() = %x\n",Status);
-       return(Status);
-     }
+       Status = ObReferenceObjectByHandle(
+                       FileHandle,
+                       FILE_READ_DATA,
+                       IoFileType,
+                       UserMode,
+                       (PVOID *) & FileObject,
+                       NULL
+                       );
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("NtReadFile() = %x\n",Status);
+               return Status;
+       }
    
-   DPRINT("ByteOffset %x FileObject->CurrentByteOffset %d\n",
-         ByteOffset,
-         FileObject->CurrentByteOffset.LowPart);
-   if (ByteOffset==NULL)
-     {
-       ByteOffset = &(FileObject->CurrentByteOffset);
-     }
+       DPRINT(
+               "ByteOffset %x FileObject->CurrentByteOffset %d\n",
+               ByteOffset,
+               FileObject->CurrentByteOffset.LowPart
+               );
+       if (ByteOffset == NULL)
+       {
+               ByteOffset = & (FileObject->CurrentByteOffset);
+       }
    
-   if (EventHandle != NULL)
-     {
-       Status = ObReferenceObjectByHandle(EventHandle,
-                                          SYNCHRONIZE,
-                                          ExEventType,
-                                          UserMode,
-                                          (PVOID *)ptrEvent,
-                                          NULL);
-       if (!NT_SUCCESS(Status))
-         {
-            return(Status);
-         }
-     }
-   else
-     {
-       KeInitializeEvent(&Event,NotificationEvent,FALSE);
-       ptrEvent = &Event;
-     }
+       if (EventHandle != NULL)
+       {
+               Status = ObReferenceObjectByHandle(
+                               EventHandle,
+                               SYNCHRONIZE,
+                               ExEventType,
+                               UserMode,
+                               (PVOID *) ptrEvent,
+                               NULL
+                               );
+               if (!NT_SUCCESS(Status))
+               {
+                       return Status;
+               }
+       }
+       else
+       {
+               KeInitializeEvent(
+                       & Event,
+                       NotificationEvent,
+                       FALSE
+                       );
+               ptrEvent = & Event;
+       }
                                           
-   DPRINT("FileObject %x\n",FileObject);
-   Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
-                                     FileObject->DeviceObject,
-                                     Buffer,
-                                     Length,
-                                     ByteOffset,
-                                     ptrEvent,
-                                     IoStatusBlock);
+       DPRINT("FileObject %x\n",FileObject);
+       
+       Irp = IoBuildSynchronousFsdRequest(
+                       IRP_MJ_READ,
+                       FileObject->DeviceObject,
+                       Buffer,
+                       Length,
+                       ByteOffset,
+                       ptrEvent,
+                       IoStatusBlock
+                       );
    
-   Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
-   Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
+       Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
+       Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
    
-   StackPtr = IoGetNextIrpStackLocation(Irp);
-   StackPtr->FileObject = FileObject;
-   if (Key!=NULL)
-   {
-         StackPtr->Parameters.Read.Key = *Key;
-   }
-   else
-   {
-        StackPtr->Parameters.Read.Key = 0;
-   }
+       StackPtr = IoGetNextIrpStackLocation(Irp);
+       StackPtr->FileObject = FileObject;
+       if (Key != NULL)
+       {
+               StackPtr->Parameters.Read.Key = *Key;
+       }
+       else
+       {
+               StackPtr->Parameters.Read.Key = 0;
+       }
    
-   Status = IoCallDriver(FileObject->DeviceObject, Irp);
-   if (Status == STATUS_PENDING  && (FileObject->Flags & FO_SYNCHRONOUS_IO))
-     {
-       KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
-       Status = IoStatusBlock->Status;
-     }
-   DPRINT("NtReadFile() = %x\n",Status);
-   assert_irql(PASSIVE_LEVEL);
-   return(Status);
+       Status = IoCallDriver(
+                       FileObject->DeviceObject,
+                       Irp
+                       );
+       if (
+               (Status == STATUS_PENDING)
+               && (FileObject->Flags & FO_SYNCHRONOUS_IO)
+               )
+       {
+               KeWaitForSingleObject(
+                       & Event,
+                       Executive,
+                       KernelMode,
+                       FALSE,
+                       NULL
+                       );
+               Status = IoStatusBlock->Status;
+       }
+       
+       DPRINT("NtReadFile() = %x\n",Status);
+       
+       assert_irql(PASSIVE_LEVEL);
+       
+       return Status;
 }
 
 
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     NtWriteFile
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ */
 NTSTATUS
+STDCALL
 NtWriteFile (
        HANDLE                  FileHandle,
        HANDLE                  EventHandle,
@@ -134,63 +198,101 @@ NtWriteFile (
        PULONG                  Key
        )
 {
-   NTSTATUS Status;
-   PFILE_OBJECT FileObject;
-   PIRP Irp;
-   PIO_STACK_LOCATION StackPtr;
-   KEVENT Event;
+       NTSTATUS                Status;
+       PFILE_OBJECT            FileObject;
+       PIRP                    Irp;
+       PIO_STACK_LOCATION      StackPtr;
+       KEVENT                  Event;
    
-   DPRINT("NtWriteFile(FileHandle %x, Buffer %x, Length %d)\n",
-         FileHandle,Buffer,Length);
+       DPRINT(
+               "NtWriteFile(FileHandle %x, Buffer %x, Length %d)\n",
+               FileHandle,
+               Buffer,
+               Length
+               );
    
-   Status = ObReferenceObjectByHandle(FileHandle,
-                                     FILE_WRITE_DATA,
-                                     IoFileType,
-                                     UserMode,
-                                     (PVOID *) &FileObject,
-                                     NULL);
-   if (!NT_SUCCESS(Status))
-     {
-       return(Status);
-     }
-   if (ByteOffset==NULL)
-     {
-       ByteOffset = &(FileObject->CurrentByteOffset);
-     }
+       Status = ObReferenceObjectByHandle(
+                       FileHandle,
+                       FILE_WRITE_DATA,
+                       IoFileType,
+                       UserMode,
+                       (PVOID *) & FileObject,
+                       NULL
+                       );
+       if (!NT_SUCCESS(Status))
+       {
+               return Status;
+       }
+       if (ByteOffset == NULL)
+       {
+               ByteOffset = & (FileObject->CurrentByteOffset);
+       }
    
-   KeInitializeEvent(&Event,NotificationEvent,FALSE);
-   Irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
-                                     FileObject->DeviceObject,
-                                     Buffer,
-                                     Length,
-                                     ByteOffset,
-                                     &Event,
-                                     IoStatusBlock);
+       KeInitializeEvent(
+               & Event,
+               NotificationEvent,
+               FALSE
+               );
+       Irp = IoBuildSynchronousFsdRequest(
+                       IRP_MJ_WRITE,
+                       FileObject->DeviceObject,
+                       Buffer,
+                       Length,
+                       ByteOffset,
+                       & Event,
+                       IoStatusBlock
+                       );
    
-   Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
-   Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
+       Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
+       Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
    
-   DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
-   StackPtr = IoGetNextIrpStackLocation(Irp);
-   StackPtr->FileObject = FileObject;
-   if (Key!=NULL)
-     {
-       StackPtr->Parameters.Write.Key = *Key;
-     }
-   else
-     {
-        StackPtr->Parameters.Write.Key = 0;
-     }
-   Status = IoCallDriver(FileObject->DeviceObject,Irp);
-   if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
-     {
-       KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
-        Status = Irp->IoStatus.Status;
-     }
-   return(Status);
+       DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
+       
+       StackPtr = IoGetNextIrpStackLocation(Irp);
+       StackPtr->FileObject = FileObject;
+       if (Key != NULL)
+       {
+               StackPtr->Parameters.Write.Key = *Key;
+       }
+       else
+       {
+               StackPtr->Parameters.Write.Key = 0;
+       }
+       Status = IoCallDriver(
+                       FileObject->DeviceObject,
+                       Irp
+                       );
+       if (
+               (Status == STATUS_PENDING)
+               && (FileObject->Flags & FO_SYNCHRONOUS_IO)
+               )
+       {
+               KeWaitForSingleObject(
+                       & Event,
+                       Executive,
+                       KernelMode,
+                       FALSE,
+                       NULL
+                       );
+               Status = Irp->IoStatus.Status;
+       }
+       return Status;
 }
 
 
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     NtReadFileScatter
+ *     
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ */
 NTSTATUS
 STDCALL
 NtReadFileScatter (
@@ -209,6 +311,19 @@ NtReadFileScatter (
 }
 
 
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     NtWriteFileGather
+ *     
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ */
 NTSTATUS
 STDCALL
 NtWriteFileGather (
@@ -225,3 +340,6 @@ NtWriteFileGather (
 {
        UNIMPLEMENTED;
 }
+
+
+/* EOF */
index f796ed8..8204acd 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: symlink.c,v 1.9 1999/08/29 06:59:08 ea Exp $
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/io/symlink.c
 
 /* GLOBALS ******************************************************************/
 
-typedef struct
+typedef
+struct
 {
-   CSHORT Type;
-   CSHORT Size;
-   UNICODE_STRING TargetName;
-   OBJECT_ATTRIBUTES Target;
+       CSHORT                  Type;
+       CSHORT                  Size;
+       UNICODE_STRING          TargetName;
+       OBJECT_ATTRIBUTES       Target;
+       
 } SYMLNK_OBJECT, *PSYMLNK_OBJECT;
 
-POBJECT_TYPE IoSymbolicLinkType = NULL;
+
+POBJECT_TYPE
+IoSymbolicLinkType = NULL;
 
 /* FUNCTIONS *****************************************************************/
 
-NTSTATUS IopCreateSymbolicLink(PVOID Object,
-                              PVOID Parent,
-                              PWSTR RemainingPath,
-                              POBJECT_ATTRIBUTES ObjectAttributes)
+
+/**********************************************************************
+ * NAME                                                        INTERNAL
+ *     IopCreateSymbolicLink
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURNN VALUE
+ *     Status.
+ *
+ * REVISIONS
+ */
+NTSTATUS
+IopCreateSymbolicLink (
+       PVOID                   Object,
+       PVOID                   Parent,
+       PWSTR                   RemainingPath,
+       POBJECT_ATTRIBUTES      ObjectAttributes
+       )
 {
-   if (Parent != NULL && RemainingPath != NULL)
-     {
-       ObAddEntryDirectory(Parent, Object, RemainingPath+1);
-     }
-   return(STATUS_SUCCESS);
+       if (    (Parent != NULL)
+               && (RemainingPath != NULL)
+               )
+       {
+               ObAddEntryDirectory(
+                       Parent,
+                       Object,
+                       RemainingPath + 1
+                       );
+       }
+       return STATUS_SUCCESS;
 }
 
-PVOID IopParseSymbolicLink(PVOID Object,
-                          PWSTR* RemainingPath)
+
+/**********************************************************************
+ * NAME                                                        INTERNAL
+ *     IopParseSymbolicLink
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURNN VALUE
+ *
+ * REVISIONS
+ */
+PVOID
+IopParseSymbolicLink (
+       PVOID   Object,
+       PWSTR   * RemainingPath
+       )
 {
-   NTSTATUS Status;
-   PSYMLNK_OBJECT SymlinkObject = (PSYMLNK_OBJECT)Object;
-   PVOID ReturnedObject;
+       NTSTATUS        Status;
+       PSYMLNK_OBJECT  SymlinkObject = (PSYMLNK_OBJECT) Object;
+       PVOID           ReturnedObject;
    
-   Status = ObReferenceObjectByName(SymlinkObject->Target.ObjectName,
-                                   0,
-                                   NULL,
-                                   STANDARD_RIGHTS_REQUIRED,
-                                   NULL,
-                                   UserMode,
-                                   NULL,
-                                   &ReturnedObject);
-   if (NT_SUCCESS(Status))
-     {
-       return(ReturnedObject);
-     }
-   return(NULL);
+       Status = ObReferenceObjectByName(
+                       SymlinkObject->Target.ObjectName,
+                       0,
+                       NULL,
+                       STANDARD_RIGHTS_REQUIRED,
+                       NULL,
+                       UserMode,
+                       NULL,
+                       & ReturnedObject
+                       );
+       if (NT_SUCCESS(Status))
+       {
+               return ReturnedObject;
+       }
+       return NULL;
 }
 
-VOID IoInitSymbolicLinkImplementation(VOID)
+
+/**********************************************************************
+ * NAME                                                        INTERNAL
+ *     IoInitSymbolicLinkImplementation
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *     None.
+ *
+ * RETURNN VALUE
+ *     None.
+ *
+ * REVISIONS
+ */
+VOID
+IoInitSymbolicLinkImplementation (VOID)
 {
-   ANSI_STRING AnsiString;
+       ANSI_STRING AnsiString;
    
-   IoSymbolicLinkType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
+       IoSymbolicLinkType = ExAllocatePool(
+                               NonPagedPool,
+                               sizeof (OBJECT_TYPE)
+                               );
    
-   IoSymbolicLinkType->TotalObjects = 0;
-   IoSymbolicLinkType->TotalHandles = 0;
-   IoSymbolicLinkType->MaxObjects = ULONG_MAX;
-   IoSymbolicLinkType->MaxHandles = ULONG_MAX;
-   IoSymbolicLinkType->PagedPoolCharge = 0;
-   IoSymbolicLinkType->NonpagedPoolCharge = sizeof(SYMLNK_OBJECT);
-   IoSymbolicLinkType->Dump = NULL;
-   IoSymbolicLinkType->Open = NULL;
-   IoSymbolicLinkType->Close = NULL;
-   IoSymbolicLinkType->Delete = NULL;
-   IoSymbolicLinkType->Parse = IopParseSymbolicLink;
-   IoSymbolicLinkType->Security = NULL;
-   IoSymbolicLinkType->QueryName = NULL;
-   IoSymbolicLinkType->OkayToClose = NULL;
-   IoSymbolicLinkType->Create = IopCreateSymbolicLink;
+       IoSymbolicLinkType->TotalObjects = 0;
+       IoSymbolicLinkType->TotalHandles = 0;
+       IoSymbolicLinkType->MaxObjects = ULONG_MAX;
+       IoSymbolicLinkType->MaxHandles = ULONG_MAX;
+       IoSymbolicLinkType->PagedPoolCharge = 0;
+       IoSymbolicLinkType->NonpagedPoolCharge = sizeof (SYMLNK_OBJECT);
+       IoSymbolicLinkType->Dump = NULL;
+       IoSymbolicLinkType->Open = NULL;
+       IoSymbolicLinkType->Close = NULL;
+       IoSymbolicLinkType->Delete = NULL;
+       IoSymbolicLinkType->Parse = IopParseSymbolicLink;
+       IoSymbolicLinkType->Security = NULL;
+       IoSymbolicLinkType->QueryName = NULL;
+       IoSymbolicLinkType->OkayToClose = NULL;
+       IoSymbolicLinkType->Create = IopCreateSymbolicLink;
    
-   RtlInitAnsiString(&AnsiString,"Symbolic Link");
-   RtlAnsiStringToUnicodeString(&IoSymbolicLinkType->TypeName,
-                               &AnsiString,TRUE);
+       RtlInitAnsiString(
+               & AnsiString,
+               "Symbolic Link"
+               );
+       RtlAnsiStringToUnicodeString(
+               & IoSymbolicLinkType->TypeName,
+               & AnsiString,
+               TRUE
+               );
 }
 
 
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     NtOpenSymbolicLinkObject
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ */
 NTSTATUS
+STDCALL
 NtOpenSymbolicLinkObject (
        OUT     PHANDLE                 LinkHandle,
        IN      ACCESS_MASK             DesiredAccess,
        IN      POBJECT_ATTRIBUTES      ObjectAttributes
        )
 {
-   NTSTATUS Status;
-   PVOID Object;
-
-   Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
-                                   ObjectAttributes->Attributes,
-                                   NULL,
-                                   DesiredAccess,
-                                   NULL,
-                                   UserMode,
-                                   NULL,
-                                   &Object);
-   if (!NT_SUCCESS(Status))
-     {
-       return(Status);
-     }
+       NTSTATUS        Status;
+       PVOID           Object;
+
+       Status = ObReferenceObjectByName(
+                       ObjectAttributes->ObjectName,
+                       ObjectAttributes->Attributes,
+                       NULL,
+                       DesiredAccess,
+                       NULL,
+                       UserMode,
+                       NULL,
+                       & Object
+                       );
+       if (!NT_SUCCESS(Status))
+       {
+               return Status;
+       }
    
-   Status = ObCreateHandle(PsGetCurrentProcess(),
-                          Object,
-                          DesiredAccess,
-                          FALSE,
-                          LinkHandle);
-   if (!NT_SUCCESS(Status))
-     {
-       return(Status);
-     }
+       Status = ObCreateHandle(
+                       PsGetCurrentProcess(),
+                       Object,
+                       DesiredAccess,
+                       FALSE,
+                       LinkHandle
+                       );
+       if (!NT_SUCCESS(Status))
+       {
+               return Status;
+       }
    
-   return(STATUS_SUCCESS);
+       return STATUS_SUCCESS;
 }
 
 
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     NtQuerySymbolicLinkObject
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ */
 NTSTATUS
+STDCALL
 NtQuerySymbolicLinkObject (
        IN      HANDLE          LinkHandle,
        IN OUT  PUNICODE_STRING LinkTarget,
        OUT     PULONG          ReturnedLength  OPTIONAL
        )
 {
-   PSYMLNK_OBJECT SymlinkObject;
-   NTSTATUS Status;
+       PSYMLNK_OBJECT  SymlinkObject;
+       NTSTATUS        Status;
    
-   Status = ObReferenceObjectByHandle(LinkHandle,
-                                     SYMBOLIC_LINK_QUERY,
-                                     IoSymbolicLinkType,
-                                     UserMode,
-                                     (PVOID*)&SymlinkObject,
-                                     NULL);
-   if (Status != STATUS_SUCCESS)
-     {
-       return(Status);
-     }
+       Status = ObReferenceObjectByHandle(
+                       LinkHandle,
+                       SYMBOLIC_LINK_QUERY,
+                       IoSymbolicLinkType,
+                       UserMode,
+                       (PVOID *) & SymlinkObject,
+                       NULL
+                       );
+       if (Status != STATUS_SUCCESS)
+       {
+               return Status;
+       }
    
-   RtlCopyUnicodeString(LinkTarget,SymlinkObject->Target.ObjectName);
-   if (ReturnedLength!=NULL)
-     {
-       *ReturnedLength=SymlinkObject->Target.Length;
-     }
-   ObDereferenceObject(SymlinkObject);
-   return(STATUS_SUCCESS);
+       RtlCopyUnicodeString(
+               LinkTarget,
+               SymlinkObject->Target.ObjectName
+               );
+       if (ReturnedLength != NULL)
+       {
+               *ReturnedLength = SymlinkObject->Target.Length;
+       }
+       ObDereferenceObject(SymlinkObject);
+       
+       return STATUS_SUCCESS;
 }
 
-NTSTATUS IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
-                                        PUNICODE_STRING DeviceName)
+
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     IoCreateUnprotectedSymbolicLink
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ */
+NTSTATUS
+STDCALL
+IoCreateUnprotectedSymbolicLink (
+       PUNICODE_STRING SymbolicLinkName,
+       PUNICODE_STRING DeviceName
+       )
 {
-   return(IoCreateSymbolicLink(SymbolicLinkName,DeviceName));
+       return IoCreateSymbolicLink(
+                       SymbolicLinkName,
+                       DeviceName
+                       );
 }
 
-NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName,
-                             PUNICODE_STRING DeviceName)
+
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     IoCreateSymbolicLink
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ */
+NTSTATUS
+STDCALL
+IoCreateSymbolicLink (
+       PUNICODE_STRING SymbolicLinkName,
+       PUNICODE_STRING DeviceName
+       )
 {
-   OBJECT_ATTRIBUTES ObjectAttributes;
-   HANDLE SymbolicLinkHandle;
-   PSYMLNK_OBJECT SymbolicLink;
+       OBJECT_ATTRIBUTES       ObjectAttributes;
+       HANDLE                  SymbolicLinkHandle;
+       PSYMLNK_OBJECT          SymbolicLink;
    
-   assert_irql(PASSIVE_LEVEL);
+       assert_irql(PASSIVE_LEVEL);
    
-   DPRINT("IoCreateSymbolicLink(SymbolicLinkName %w, DeviceName %w)\n",
-         SymbolicLinkName->Buffer,DeviceName->Buffer);
+       DPRINT(
+               "IoCreateSymbolicLink(SymbolicLinkName %w, DeviceName %w)\n",
+               SymbolicLinkName->Buffer,
+               DeviceName->Buffer
+               );
    
-   InitializeObjectAttributes(&ObjectAttributes,SymbolicLinkName,0,NULL,NULL);
-   SymbolicLink = ObCreateObject(&SymbolicLinkHandle,
-                                SYMBOLIC_LINK_ALL_ACCESS,
-                                &ObjectAttributes,
-                                IoSymbolicLinkType);
-   if (SymbolicLink == NULL)
-     {
-       return(STATUS_UNSUCCESSFUL);
-     }
+       InitializeObjectAttributes(
+               & ObjectAttributes,
+               SymbolicLinkName,
+               0,
+               NULL,
+               NULL
+               );
+       SymbolicLink = ObCreateObject(
+                       & SymbolicLinkHandle,
+                       SYMBOLIC_LINK_ALL_ACCESS,
+                       & ObjectAttributes,
+                       IoSymbolicLinkType
+                       );
+       if (SymbolicLink == NULL)
+       {
+               return STATUS_UNSUCCESSFUL;
+       }
    
-   ZwClose(SymbolicLinkHandle);
-   SymbolicLink->TargetName.Length = 0;
-   SymbolicLink->TargetName.MaximumLength = 
-     ((wcslen(DeviceName->Buffer) + 1) * sizeof(WCHAR));
-   SymbolicLink->TargetName.Buffer = ExAllocatePool(NonPagedPool,
-                                      SymbolicLink->TargetName.MaximumLength);
-   RtlCopyUnicodeString(&(SymbolicLink->TargetName), DeviceName);
-   DPRINT("DeviceName %w\n", SymbolicLink->TargetName.Buffer);
-   InitializeObjectAttributes(&(SymbolicLink->Target),
-                             &(SymbolicLink->TargetName),0,NULL,NULL);
-   DPRINT("%s() = STATUS_SUCCESS\n",__FUNCTION__);
-   return(STATUS_SUCCESS);
+       ZwClose(SymbolicLinkHandle);
+       
+       SymbolicLink->TargetName.Length = 0;
+       SymbolicLink->TargetName.MaximumLength = 
+               ((wcslen(DeviceName->Buffer) + 1) * sizeof(WCHAR));
+       SymbolicLink->TargetName.Buffer =
+               ExAllocatePool(
+                       NonPagedPool,
+                        SymbolicLink->TargetName.MaximumLength
+                       );
+       RtlCopyUnicodeString(
+               & (SymbolicLink->TargetName),
+               DeviceName
+               );
+       
+       DPRINT("DeviceName %w\n", SymbolicLink->TargetName.Buffer);
+       
+       InitializeObjectAttributes(
+               & (SymbolicLink->Target),
+               & (SymbolicLink->TargetName),
+               0,
+               NULL,
+               NULL
+               );
+       
+       DPRINT("%s() = STATUS_SUCCESS\n",__FUNCTION__);
+
+       return STATUS_SUCCESS;
 }
 
 
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     IoDeleteSymbolicLink
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ */
 NTSTATUS
-IoDeleteSymbolicLink(PUNICODE_STRING DeviceName)
+STDCALL
+IoDeleteSymbolicLink (
+       PUNICODE_STRING DeviceName
+       )
 {
        UNIMPLEMENTED;
 }
 
 
+/**********************************************************************
+ * NAME                                                (EXPORTED as Zw)
+ *     NtCreateSymbolicLinkObject
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ */
 NTSTATUS
 STDCALL
 NtCreateSymbolicLinkObject (
@@ -222,3 +426,5 @@ NtCreateSymbolicLinkObject (
        UNIMPLEMENTED;
 }
 
+
+/* EOF */
index e0816c9..eb1f11b 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: main.c,v 1.22 1999/08/29 06:59:10 ea Exp $
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ke/main.c
@@ -107,13 +108,13 @@ extern int edata;
 extern int end;
 
 static char * INIData =
-  "[HKEY_LOCAL_MACHINE\HARDWARE]\r\n"
+  "[HKEY_LOCAL_MACHINE\\HARDWARE]\r\n"
   "\r\n"
-  "[HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP]\r\n"
+  "[HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP]\r\n"
   "\r\n"
-  "[HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\AtDisk]\r\n"
+  "[HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\AtDisk]\r\n"
   "\r\n"
-  "[HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\AtDisk\Controller 0]\r\n"
+  "[HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\AtDisk\\Controller 0]\r\n"
   "Controller Address=dword:000001f0\r\n"
   "Controller Interrupt=dword:0000000e\r\n"
   "\r\n"
@@ -148,7 +149,7 @@ asmlinkage void _main(boot_param* _bp)
     */
    HalInitConsole(&bp);
    
-   DbgPrint("Starting ReactOS "KERNEL_VERSION"\n");
+   DbgPrint("Starting ReactOS "KERNEL_VERSION" (Build "__DATE__", "__TIME__")\n");
 
    start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
    if (start < ((int)&end))
@@ -214,3 +215,5 @@ asmlinkage void _main(boot_param* _bp)
    PsTerminateSystemThread(STATUS_SUCCESS);
 }
 
+
+/* EOF */
index b2fbf94..6cd618a 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: section.c,v 1.14 1999/08/29 06:59:10 ea Exp $
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/mm/section.c
@@ -179,39 +180,110 @@ NtCreateSection (
 }
 
 
+/**********************************************************************
+ * NAME
+ *     NtOpenSection
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *     SectionHandle
+ *
+ *     DesiredAccess
+ *
+ *     ObjectAttributes
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ *
+ */
 NTSTATUS
+STDCALL
 NtOpenSection (
        PHANDLE                 SectionHandle,
        ACCESS_MASK             DesiredAccess,
        POBJECT_ATTRIBUTES      ObjectAttributes
        )
 {
-   PVOID Object;
-   NTSTATUS Status;
+       PVOID           Object;
+       NTSTATUS        Status;
    
-   *SectionHandle = 0;
+       *SectionHandle = 0;
 
-   Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
-                                   ObjectAttributes->Attributes,
-                                   NULL,
-                                   DesiredAccess,
-                                   MmSectionType,
-                                   UserMode,
-                                   NULL,
-                                   &Object);
-   if (!NT_SUCCESS(Status))
-     {
-       return(Status);
-     }
+       Status = ObReferenceObjectByName(
+                       ObjectAttributes->ObjectName,
+                       ObjectAttributes->Attributes,
+                       NULL,
+                       DesiredAccess,
+                       MmSectionType,
+                       UserMode,
+                       NULL,
+                       & Object
+                       );
+       if (!NT_SUCCESS(Status))
+       {
+               return Status;
+       }
        
-   Status = ObCreateHandle(PsGetCurrentProcess(),
-                          Object,
-                          DesiredAccess,
-                          FALSE,
-                          SectionHandle);
-   return(Status);
+       Status = ObCreateHandle(
+                       PsGetCurrentProcess(),
+                       Object,
+                       DesiredAccess,
+                       FALSE,
+                       SectionHandle
+                       );
+       return Status;
 }
 
+
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     NtMapViewOfSection
+ *
+ * DESCRIPTION
+ *     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.
+ *
+ * RETURN VALUE
+ *     Status.
+ */
 NTSTATUS
 STDCALL
 NtMapViewOfSection (
@@ -226,137 +298,158 @@ NtMapViewOfSection (
        ULONG           AllocationType,
        ULONG           Protect
        )
-/*
- * 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
- */
 {
-   PSECTION_OBJECT Section;
-   PEPROCESS Process;
-   MEMORY_AREA* Result;
-   NTSTATUS Status;
+       PSECTION_OBJECT Section;
+       PEPROCESS       Process;
+       MEMORY_AREA     * Result;
+       NTSTATUS        Status;
    
-   DPRINT("NtMapViewOfSection(Section:%08lx, Process:%08lx,\n"
-          "  Base:%08lx, ZeroBits:%08lx, CommitSize:%08lx,\n"
-          "  SectionOffs:%08lx, *ViewSize:%08lx, InheritDisp:%08lx,\n"
-          "  AllocType:%08lx, Protect:%08lx)\n",
-         SectionHandle, 
-          ProcessHandle,
-          BaseAddress,
-          ZeroBits,
-          CommitSize,
-          SectionOffset,
-          *ViewSize,
-          InheritDisposition,
-          AllocationType,
-          Protect);
-   DPRINT("  *Base:%08lx\n", *BaseAddress);
+       DPRINT(
+               "NtMapViewOfSection(Section:%08lx, Process:%08lx,\n"
+               "  Base:%08lx, ZeroBits:%08lx, CommitSize:%08lx,\n"
+               "  SectionOffs:%08lx, *ViewSize:%08lx, InheritDisp:%08lx,\n"
+               "  AllocType:%08lx, Protect:%08lx)\n",
+               SectionHandle, 
+               ProcessHandle,
+               BaseAddress,
+               ZeroBits,
+               CommitSize,
+               SectionOffset,
+               *ViewSize,
+               InheritDisposition,
+               AllocationType,
+               Protect
+               );
    
-   Status = ObReferenceObjectByHandle(SectionHandle,
-                                     SECTION_MAP_READ,
-                                     MmSectionType,
-                                     UserMode,
-                                     (PVOID*)&Section,
-                                     NULL);
-   if (Status != STATUS_SUCCESS)
-     {
-       DPRINT("ObReference failed rc=%x\n",Status);
-       return(Status);
-     }
+       DPRINT("  *Base:%08lx\n", *BaseAddress);
    
-   DPRINT("Section %x\n",Section);
+       Status = ObReferenceObjectByHandle(
+                       SectionHandle,
+                       SECTION_MAP_READ,
+                       MmSectionType,
+                       UserMode,
+                       (PVOID *) & Section,
+                       NULL
+                       );
+       if (Status != STATUS_SUCCESS)
+       {
+               DPRINT("ObReference failed rc=%x\n",Status);
+
+               return Status;
+       }
    
-   Status = ObReferenceObjectByHandle(ProcessHandle,
-                                     PROCESS_VM_OPERATION,
-                                     PsProcessType,
-                                     UserMode,
-                                     (PVOID*)&Process,
-                                     NULL);
-   if (Status != STATUS_SUCCESS)
-     {
-       ObDereferenceObject(Section);
-       return(Status);
-     }
+       DPRINT("Section %x\n",Section);
+
+       Status = ObReferenceObjectByHandle(
+                       ProcessHandle,
+                       PROCESS_VM_OPERATION,
+                       PsProcessType,
+                       UserMode,
+                       (PVOID *) & Process,
+                       NULL
+                       );
+       if (Status != STATUS_SUCCESS)
+       {
+               ObDereferenceObject(Section);
+               
+               return Status;
+       }
    
-   DPRINT("ViewSize %x\n",ViewSize);
-   if ((*ViewSize) > Section->MaximumSize.u.LowPart)
-     {
-        (*ViewSize) = Section->MaximumSize.u.LowPart;
-     }
+       DPRINT("ViewSize %x\n",ViewSize);
    
-   Status = MmCreateMemoryArea(UserMode,
-                              Process,
-                              MEMORY_AREA_SECTION_VIEW_COMMIT,
-                              BaseAddress,
-                              *ViewSize,
-                              Protect,
-                              &Result);
-   if (!NT_SUCCESS(Status))
-     {
-       DPRINT("NtMapViewOfSection() = %x\n",Status);
-       ObDereferenceObject(Process);
-       ObDereferenceObject(Section);
-       return(Status);
-     }
-   Result->Data.SectionData.Section = Section;
+       if ((*ViewSize) > Section->MaximumSize.u.LowPart)
+       {
+               (*ViewSize) = Section->MaximumSize.u.LowPart;
+       }
    
-   DPRINT("SectionOffset %x\n",SectionOffset);
+       Status = MmCreateMemoryArea(
+                       UserMode,
+                       Process,
+                       MEMORY_AREA_SECTION_VIEW_COMMIT,
+                       BaseAddress,
+                       * ViewSize,
+                       Protect,
+                       & Result
+                       );
+       if (!NT_SUCCESS(Status))
+       {
+               DPRINT("NtMapViewOfSection() = %x\n",Status);
+
+               ObDereferenceObject(Process);
+               ObDereferenceObject(Section);
+               
+               return Status;
+       }
+       Result->Data.SectionData.Section = Section;
    
-   if (SectionOffset == NULL)
-     {
-       Result->Data.SectionData.ViewOffset = 0;
-     }
-   else
-     {
-        Result->Data.SectionData.ViewOffset = SectionOffset->u.LowPart;
-     }
+       DPRINT("SectionOffset %x\n",SectionOffset);
    
-   DPRINT("*BaseAddress %x\n",*BaseAddress);
-   ObDereferenceObject(Process);   
-   ObDereferenceObject(Section);
-   return(STATUS_SUCCESS);
+       if (SectionOffset == NULL)
+       {
+               Result->Data.SectionData.ViewOffset = 0;
+       }
+       else
+       {
+               Result->Data.SectionData.ViewOffset =
+                       SectionOffset->u.LowPart;
+       }
+   
+       DPRINT("*BaseAddress %x\n",*BaseAddress);
+       ObDereferenceObject(Process);   
+       ObDereferenceObject(Section);
+       
+       return STATUS_SUCCESS;
 }
 
 
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     NtUnmapViewOfSection
+ *
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *     ProcessHandle
+ *
+ *     BaseAddress
+ *
+ * RETURN VALUE
+ *     Status.
+ *
+ * REVISIONS
+ *
+ */
 NTSTATUS
+STDCALL
 NtUnmapViewOfSection (
        HANDLE  ProcessHandle,
        PVOID   BaseAddress
        )
 {
-   PEPROCESS Process;
-   NTSTATUS Status;
+       PEPROCESS       Process;
+       NTSTATUS        Status;
    
-   Status = ObReferenceObjectByHandle(ProcessHandle,
-                                     PROCESS_VM_OPERATION,
-                                     PsProcessType,
-                                     UserMode,
-                                     (PVOID*)&Process,
-                                     NULL);
-   if (Status != STATUS_SUCCESS)
-     {
-       return(Status);
-     }
-   Status = MmFreeMemoryArea(Process,BaseAddress,0,TRUE);
-   ObDereferenceObject(Process);
-   return(Status);
+       Status = ObReferenceObjectByHandle(
+                       ProcessHandle,
+                       PROCESS_VM_OPERATION,
+                       PsProcessType,
+                       UserMode,
+                       (PVOID *) & Process,
+                       NULL
+                       );
+       if (Status != STATUS_SUCCESS)
+       {
+               return Status;
+       }
+       Status = MmFreeMemoryArea(
+                       Process,
+                       BaseAddress,
+                       0,
+                       TRUE
+                       );
+       ObDereferenceObject(Process);
+
+       return Status;
 }
 
 
@@ -395,3 +488,6 @@ NtExtendSection (
 {
        UNIMPLEMENTED;
 }
+
+
+/* EOF */
index 67d1119..216e816 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: ntoskrnl.def,v 1.15 1999/08/17 12:01:38 ekohl Exp $
+; $Id: ntoskrnl.def,v 1.16 1999/08/29 06:59:05 ea Exp $
 ;
 ; reactos/ntoskrnl/ntoskrnl.def
 ;
@@ -104,7 +104,7 @@ IoConnectInterrupt
 IoCreateController
 IoCreateDevice
 IoCreateStreamFileObject
-IoCreateSymbolicLink
+IoCreateSymbolicLink@8
 IoDeleteController
 IoDeleteDevice
 IoDisconnectInterrupt
index d371b43..bcbcb14 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: ntoskrnl.edf,v 1.3 1999/08/17 12:01:39 ekohl Exp $
+; $Id: ntoskrnl.edf,v 1.4 1999/08/29 06:59:05 ea Exp $
 ;
 ; reactos/ntoskrnl/ntoskrnl.def
 ;
@@ -104,7 +104,7 @@ IoConnectInterrupt
 IoCreateController
 IoCreateDevice
 IoCreateStreamFileObject
-IoCreateSymbolicLink
+IoCreateSymbolicLink=IoCreateSymbolicLink@8
 IoDeleteController
 IoDeleteDevice
 IoDisconnectInterrupt
@@ -129,7 +129,7 @@ NtAllocateUuids=NtAllocateUuids@12
 NtAllocateVirtualMemory=NtAllocateVirtualMemory@24
 ;NtBuildNumber <--- variable?
 NtClose=NtClose@4
-;NtConnectPort=;NtConnectPort@32
+;NtConnectPort@32
 NtConnectPort=NtConnectPort@8
 NtCreateEvent=NtCreateEvent@20
 NtCreateFile=NtCreateFile@44
@@ -155,13 +155,13 @@ NtQueryEaFile=NtQueryEaFile@36
 NtQueryInformationFile=NtQueryInformationFile@20
 NtQueryInformationProcess=NtQueryInformationProcess@20
 NtQueryInformationToken=NtQueryInformationToken@20
-;NtQueryOleDirectoryFile=;NtQueryOleDirectoryFile@ <--- ?
+;NtQueryOleDirectoryFile@ <--- ?
 NtQuerySecurityObject=NtQuerySecurityObject@20
 NtQueryVolumeInformationFile=NtQueryVolumeInformationFile@20
 NtReadFile=NtReadFile@36
-;NtRequestPort=;NtRequestPort@8
+;NtRequestPort@8
 NtRequestPort=NtRequestPort@20
-;NtRequestWaitReplyPort=;NtRequestWaitReplyPort@8
+;NtRequestWaitReplyPort@8
 NtRequestWaitReplyPort=NtRequestWaitReplyPort@0
 NtSetEvent=NtSetEvent@8
 NtSetInformationFile=NtSetInformationFile@20
@@ -169,7 +169,7 @@ NtSetInformationProcess=NtSetInformationProcess@16
 NtSetInformationThread=NtSetInformationThread@16
 NtSetSecurityObject=NtSetSecurityObject@12
 NtUnlockFile=NtUnlockFile@20
-;NtVdmControl=;NtVdmControl@8 <--- ?
+;NtVdmControl@8 <--- ?
 NtWaitForSingleObject=NtWaitForSingleObject@12
 NtWriteFile=NtWriteFile@36
 RtlAnsiStringToUnicodeString
index 560ad41..5881811 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: dirobj.c,v 1.5 1999/08/29 06:59:10 ea Exp $
+ *
  * COPYRIGHT:      See COPYING in the top level directory
  * PROJECT:        ReactOS kernel
  * FILE:           ntoskrnl/ob/dirobj.c
 
 /* FUNCTIONS **************************************************************/
 
+
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     NtOpenDirectoryObject
+ *
+ * DESCRIPTION
+ *     Opens a namespace directory object.
+ *     
+ * ARGUMENTS
+ *     DirectoryHandle (OUT)
+ *             Variable which receives the directory handle.
+ *             
+ *     DesiredAccess
+ *             Desired access to the directory.
+ *             
+ *     ObjectAttributes
+ *             Structure describing the directory.
+ *             
+ * RETURN VALUE
+ *     Status.
+ *     
+ * NOTES
+ *     Undocumented.
+ */
 NTSTATUS
+STDCALL
 NtOpenDirectoryObject (
        PHANDLE                 DirectoryHandle,
        ACCESS_MASK             DesiredAccess,
        POBJECT_ATTRIBUTES      ObjectAttributes
        )
-/*
- * FUNCTION: Opens a namespace directory object
- * ARGUMENTS:
- *       DirectoryHandle (OUT) = Variable which receives the directory handle
- *       DesiredAccess = Desired access to the directory
- *       ObjectAttributes = Structure describing the directory
- * RETURNS: Status
- * NOTES: Undocumented
- */
 {
-   PVOID Object;
-   NTSTATUS Status;
+       PVOID           Object;
+       NTSTATUS        Status;
    
-   *DirectoryHandle = 0;
+       *DirectoryHandle = 0;
    
-   Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
-                                   ObjectAttributes->Attributes,
-                                   NULL,
-                                   DesiredAccess,
-                                   ObDirectoryType,
-                                   UserMode,
-                                   NULL,
-                                   &Object);
-   if (!NT_SUCCESS(Status))
-     {
-       return(Status);
-     }
+       Status = ObReferenceObjectByName(
+                       ObjectAttributes->ObjectName,
+                       ObjectAttributes->Attributes,
+                       NULL,
+                       DesiredAccess,
+                       ObDirectoryType,
+                       UserMode,
+                       NULL,
+                       & Object
+                       );
+       if (!NT_SUCCESS(Status))
+       {
+               return Status;
+       }
        
-   Status = ObCreateHandle(PsGetCurrentProcess(),
-                          Object,
-                          DesiredAccess,
-                          FALSE,
-                          DirectoryHandle);
-   return(STATUS_SUCCESS);
+       Status = ObCreateHandle(
+                       PsGetCurrentProcess(),
+                       Object,
+                       DesiredAccess,
+                       FALSE,
+                       DirectoryHandle
+                       );
+       return STATUS_SUCCESS;
 }
 
 
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     NtQueryDirectoryObject
+ * 
+ * DESCRIPTION
+ *     Reads information from a namespace directory.
+ *     
+ * ARGUMENTS
+ *     DirObjInformation (OUT)
+ *             Buffer to hold the data read.
+ *             
+ *     BufferLength
+ *             Size of the buffer in bytes.
+ *             
+ *     GetNextIndex
+ *             If TRUE then set ObjectIndex to the index of the
+ *             next object.
+ *             If FALSE then set ObjectIndex to the number of
+ *             objects in the directory.
+ *             
+ *     IgnoreInputIndex
+ *             If TRUE start reading at index 0.
+ *             If FALSE start reading at the index specified
+ *             by object index.
+ *             
+ *     ObjectIndex
+ *             Zero based index into the directory, interpretation
+ *             depends on IgnoreInputIndex and GetNextIndex.
+ *             
+ *     DataWritten (OUT)
+ *             Caller supplied storage for the number of bytes
+ *             written (or NULL).
+ *
+ * RETURN VALUE
+ *     Status.
+ */
 NTSTATUS
+STDCALL
 NtQueryDirectoryObject (
        IN      HANDLE                  DirObjHandle,
        OUT     POBJDIR_INFORMATION     DirObjInformation, 
@@ -75,114 +133,149 @@ NtQueryDirectoryObject (
        IN OUT  PULONG                  ObjectIndex,
        OUT     PULONG                  DataWritten     OPTIONAL
        )
-/*
- * FUNCTION: Reads information from a namespace directory
- * ARGUMENTS:
- *        DirObjInformation (OUT) = Buffer to hold the data read
- *        BufferLength = Size of the buffer in bytes
- *        GetNextIndex = If TRUE then set ObjectIndex to the index of the
- *                       next object
- *                       If FALSE then set ObjectIndex to the number of
- *                       objects in the directory
- *        IgnoreInputIndex = If TRUE start reading at index 0
- *                           If FALSE start reading at the index specified
- *                           by object index
- *        ObjectIndex = Zero based index into the directory, interpretation
- *                      depends on IgnoreInputIndex and GetNextIndex
- *        DataWritten (OUT) = Caller supplied storage for the number of bytes
- *                            written (or NULL)
- * RETURNS: Status
- */
 {
-   PDIRECTORY_OBJECT dir = NULL;
-   ULONG EntriesToRead;
-   PLIST_ENTRY current_entry;
-   POBJECT_HEADER current;
-   ULONG i=0;
-   ULONG EntriesToSkip;
-   NTSTATUS Status;
-   
-   DPRINT("NtQueryDirectoryObject(DirObjHandle %x)\n",DirObjHandle);
-   DPRINT("dir %x namespc_root %x\n",dir,HEADER_TO_BODY(&(namespc_root.hdr)));
-   
-//   assert_irql(PASSIVE_LEVEL);
+       PDIRECTORY_OBJECT       dir = NULL;
+       ULONG                   EntriesToRead;
+       PLIST_ENTRY             current_entry;
+       POBJECT_HEADER          current;
+       ULONG                   i=0;
+       ULONG                   EntriesToSkip;
+       NTSTATUS                Status;
+
+
+       DPRINT(
+               "NtQueryDirectoryObject(DirObjHandle %x)\n",
+               DirObjHandle
+               );
+       DPRINT(
+               "dir %x namespc_root %x\n",
+               dir,
+               HEADER_TO_BODY(&(namespc_root.hdr))
+               );
    
-   Status = ObReferenceObjectByHandle(DirObjHandle,
-                                     DIRECTORY_QUERY,
-                                     ObDirectoryType,
-                                     UserMode,
-                                     (PVOID*)&dir,
-                                     NULL);
-   if (Status != STATUS_SUCCESS)
-     {
-       return(Status);
-     }
+//     assert_irql(PASSIVE_LEVEL);
    
-   EntriesToRead = BufferLength / sizeof(OBJDIR_INFORMATION);
-   *DataWritten = 0;
+       Status = ObReferenceObjectByHandle(
+                       DirObjHandle,
+                       DIRECTORY_QUERY,
+                       ObDirectoryType,
+                       UserMode,
+                       (PVOID *) & dir,
+                       NULL
+                       );
+       if (Status != STATUS_SUCCESS)
+       {
+               return Status;
+       }
+
+       EntriesToRead = BufferLength / sizeof (OBJDIR_INFORMATION);
+       *DataWritten = 0;
    
-   DPRINT("EntriesToRead %d\n",EntriesToRead);
+       DPRINT("EntriesToRead %d\n",EntriesToRead);
    
-   current_entry = dir->head.Flink;
+       current_entry = dir->head.Flink;
    
-   /*
-    * Optionally, skip over some entries at the start of the directory
-    */
-   if (!IgnoreInputIndex)
-     {
-       CHECKPOINT;
+       /*
+        * Optionally, skip over some entries at the start of the directory
+        */
+       if (!IgnoreInputIndex)
+       {
+               CHECKPOINT;
        
-       EntriesToSkip = *ObjectIndex;
-       while ( i<EntriesToSkip && current_entry!=NULL)
-         {
-            current_entry = current_entry->Flink;
-         }
-     }
+               EntriesToSkip = *ObjectIndex;
+               while ( (i < EntriesToSkip) && (current_entry != NULL))
+               {
+                       current_entry = current_entry->Flink;
+               }
+       }
    
-   DPRINT("DirObjInformation %x\n",DirObjInformation);
+       DPRINT("DirObjInformation %x\n",DirObjInformation);
    
-   /*
-    * Read the maximum entries possible into the buffer
-    */
-   while ( i<EntriesToRead && current_entry!=(&(dir->head)))
-     {
-       current = CONTAINING_RECORD(current_entry,OBJECT_HEADER,Entry);
-       DPRINT("Scanning %w\n",current->Name.Buffer);
-       DirObjInformation[i].ObjectName.Buffer = 
-                      ExAllocatePool(NonPagedPool,(current->Name.Length+1)*2);
-       DirObjInformation[i].ObjectName.Length = current->Name.Length;
-       DirObjInformation[i].ObjectName.MaximumLength = current->Name.Length;
-       DPRINT("DirObjInformation[i].ObjectName.Buffer %x\n",
-              DirObjInformation[i].ObjectName.Buffer);
-       RtlCopyUnicodeString(&DirObjInformation[i].ObjectName,
-                            &(current->Name));
-       i++;
-       current_entry = current_entry->Flink;
-       (*DataWritten) = (*DataWritten) + sizeof(OBJDIR_INFORMATION);
+       /*
+        * Read the maximum entries possible into the buffer
+        */
+       while ( (i < EntriesToRead) && (current_entry != (&(dir->head))))
+       {
+               current = CONTAINING_RECORD(
+                               current_entry,
+                               OBJECT_HEADER,
+                               Entry
+                               );
+               DPRINT(
+                       "Scanning %w\n",
+                       current->Name.Buffer
+                       );
+               
+               DirObjInformation[i].ObjectName.Buffer = 
+                       ExAllocatePool(
+                               NonPagedPool,
+                               (current->Name.Length + 1) * 2
+                               );
+               DirObjInformation[i].ObjectName.Length =
+                       current->Name.Length;
+               DirObjInformation[i].ObjectName.MaximumLength =
+                       current->Name.Length;
+               
+               DPRINT(
+                       "DirObjInformation[i].ObjectName.Buffer %x\n",
+                       DirObjInformation[i].ObjectName.Buffer
+                       );
+               
+               RtlCopyUnicodeString(
+                       & DirObjInformation[i].ObjectName,
+                       & (current->Name)
+                       );
+               i++;
+               current_entry = current_entry->Flink;
+               (*DataWritten) = (*DataWritten) + sizeof (OBJDIR_INFORMATION);
+
+               CHECKPOINT;
+       }
        CHECKPOINT;
-     }
-   CHECKPOINT;
    
-   /*
-    * Optionally, count the number of entries in the directory
-    */
-   if (GetNextIndex)
-     {
-       *ObjectIndex=i;
-     }
-   else
-     {
-       while ( current_entry!=(&(dir->head)) )
-         {
-            current_entry=current_entry->Flink;
-            i++;
-         }
-       *ObjectIndex=i;
-     }
-   return(STATUS_SUCCESS);
+       /*
+        * Optionally, count the number of entries in the directory
+        */
+       if (GetNextIndex)
+       {
+               *ObjectIndex = i;
+       }
+       else
+       {
+               while ( current_entry != (&(dir->head)) )
+               {
+                       current_entry = current_entry->Flink;
+                       i++;
+               }
+               *ObjectIndex = i;
+       }
+       return STATUS_SUCCESS;
 }
 
 
+/**********************************************************************
+ * NAME                                                (EXPORTED as Zw)
+ *     NtCreateDirectoryObject
+ *     
+ * DESCRIPTION
+ *     Creates or opens a directory object (a container for other
+ *     objects).
+ *     
+ * ARGUMENTS
+ *     DirectoryHandle (OUT)
+ *             Caller supplied storage for the handle of the 
+ *             directory.
+ *             
+ *     DesiredAccess
+ *             Access desired to the directory.
+ *             
+ *     ObjectAttributes
+ *             Object attributes initialized with
+ *             InitializeObjectAttributes.
+ *             
+ * RETURN VALUE
+ *     Status.
+ */
 NTSTATUS
 STDCALL
 NtCreateDirectoryObject (
@@ -190,56 +283,77 @@ NtCreateDirectoryObject (
        ACCESS_MASK             DesiredAccess,
        POBJECT_ATTRIBUTES      ObjectAttributes
        )
-/*
- * FUNCTION: Creates or opens a directory object (a container for other
- * objects)
- * ARGUMENTS:
- *        DirectoryHandle (OUT) = Caller supplied storage for the handle
- *                                of the directory
- *        DesiredAccess = Access desired to the directory
- *        ObjectAttributes = Object attributes initialized with
- *                           InitializeObjectAttributes
- * RETURNS: Status
- */
 {
-   PDIRECTORY_OBJECT dir;
+       PDIRECTORY_OBJECT dir;
    
-   dir = ObCreateObject(DirectoryHandle,
-                       DesiredAccess,
-                       ObjectAttributes,
-                       ObDirectoryType);
-   return(STATUS_SUCCESS);
+       dir = ObCreateObject(
+               DirectoryHandle,
+               DesiredAccess,
+               ObjectAttributes,
+               ObDirectoryType
+               );
+       return STATUS_SUCCESS;
 }
 
-VOID InitializeObjectAttributes(POBJECT_ATTRIBUTES InitializedAttributes,
-                               PUNICODE_STRING ObjectName,
-                               ULONG Attributes,
-                               HANDLE RootDirectory,
-                               PSECURITY_DESCRIPTOR SecurityDescriptor)
-/*
- * FUNCTION: Sets up a parameter of type OBJECT_ATTRIBUTES for a 
- * subsequent call to ZwCreateXXX or ZwOpenXXX
- * ARGUMENTS:
- *        InitializedAttributes (OUT) = Caller supplied storage for the
- *                                      object attributes
- *        ObjectName = Full path name for object
- *        Attributes = Attributes for the object
- *        RootDirectory = Where the object should be placed or NULL
- *        SecurityDescriptor = Ignored
+
+/**********************************************************************
+ * NAME                                                (MACRO in DDK)
+ *     InitializeObjectAttributes
+ *
+ * DESCRIPTION
+ *     Sets up a parameter of type OBJECT_ATTRIBUTES for a 
+ *     subsequent call to ZwCreateXXX or ZwOpenXXX.
+ *     
+ * ARGUMENTS
+ *     InitializedAttributes (OUT)
+ *             Caller supplied storage for the object attributes.
+ *             
+ *     ObjectName
+ *             Full path name for object.
+ *             
+ *     Attributes
+ *             Attributes for the object.
+ *             
+ *     RootDirectory
+ *             Where the object should be placed or NULL.
+ *             
+ *     SecurityDescriptor
+ *             Ignored.
  * 
- * NOTE:
- *     Either ObjectName is a fully qualified pathname or a path relative
- *     to RootDirectory
+ * NOTE
+ *     Either ObjectName is a fully qualified pathname or a path
+ *     relative to RootDirectory.
  */
+VOID
+InitializeObjectAttributes (
+       POBJECT_ATTRIBUTES      InitializedAttributes,
+       PUNICODE_STRING         ObjectName,
+       ULONG                   Attributes,
+       HANDLE                  RootDirectory,
+       PSECURITY_DESCRIPTOR    SecurityDescriptor
+       )
 {
-   DPRINT("InitializeObjectAttributes(InitializedAttributes %x "
-         "ObjectName %x Attributes %x RootDirectory %x)\n",
-         InitializedAttributes,ObjectName,Attributes,RootDirectory);
-   InitializedAttributes->Length=sizeof(OBJECT_ATTRIBUTES);
-   InitializedAttributes->RootDirectory=RootDirectory;
-   InitializedAttributes->ObjectName=ObjectName;
-   InitializedAttributes->Attributes=Attributes;
-   InitializedAttributes->SecurityDescriptor=SecurityDescriptor;
-   InitializedAttributes->SecurityQualityOfService=NULL;
+       DPRINT(
+               "InitializeObjectAttributes(InitializedAttributes %x "
+               "ObjectName %x Attributes %x RootDirectory %x)\n",
+               InitializedAttributes,
+               ObjectName,
+               Attributes,
+               RootDirectory
+               );
+       InitializedAttributes->Length =
+               sizeof (OBJECT_ATTRIBUTES);
+       InitializedAttributes->RootDirectory =
+               RootDirectory;
+       InitializedAttributes->ObjectName =
+               ObjectName;
+       InitializedAttributes->Attributes =
+               Attributes;
+       InitializedAttributes->SecurityDescriptor =
+               SecurityDescriptor;
+       InitializedAttributes->SecurityQualityOfService =
+               NULL;
 }
 
+
+/* EOF */
index 2c19f2b..66cac98 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: handle.c,v 1.11 1999/08/29 06:59:11 ea Exp $
+ *
  * COPYRIGHT:          See COPYING in the top level directory
  * PROJECT:            ReactOS kernel
  * FILE:               ntoskrnl/ob/handle.c
@@ -35,7 +36,10 @@ typedef struct
 
 /* FUNCTIONS ***************************************************************/
 
-static PHANDLE_REP ObpGetObjectByHandle(PEPROCESS Process,
+
+static
+PHANDLE_REP
+ObpGetObjectByHandle(PEPROCESS Process,
                                        HANDLE h)
 /*
  * FUNCTION: Get the data structure for a handle
@@ -70,6 +74,7 @@ static PHANDLE_REP ObpGetObjectByHandle(PEPROCESS Process,
    return(&(blk->handles[handle%HANDLE_BLOCK_ENTRIES]));
 }
 
+
 NTSTATUS
 STDCALL
 NtDuplicateObject (
@@ -150,7 +155,9 @@ NtDuplicateObject (
    return(STATUS_SUCCESS);
 }
 
-VOID ObDeleteHandleTable(PEPROCESS Process)
+
+VOID
+ObDeleteHandleTable(PEPROCESS Process)
 /*
  * FUNCTION: Deletes the handle table associated with a process
  */
@@ -185,7 +192,9 @@ VOID ObDeleteHandleTable(PEPROCESS Process)
      }
 }
 
-VOID ObCreateHandleTable(PEPROCESS Parent,
+
+VOID
+ObCreateHandleTable(PEPROCESS Parent,
                         BOOLEAN Inherit,
                         PEPROCESS Process)
 /*
@@ -207,7 +216,9 @@ VOID ObCreateHandleTable(PEPROCESS Parent,
      }
 }
 
-VOID ObDeleteHandle(HANDLE Handle)
+
+       VOID
+ObDeleteHandle(HANDLE Handle)
 {
    PHANDLE_REP Rep;
    
@@ -218,7 +229,9 @@ VOID ObDeleteHandle(HANDLE Handle)
    DPRINT("Finished ObDeleteHandle()\n");
 }
 
-NTSTATUS ObCreateHandle(PEPROCESS Process,
+
+NTSTATUS
+ObCreateHandle(PEPROCESS Process,
                        PVOID ObjectBody,
                        ACCESS_MASK GrantedAccess,
                        BOOLEAN Inherit,
@@ -289,7 +302,8 @@ NTSTATUS ObCreateHandle(PEPROCESS Process,
 }
 
 
-NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
+NTSTATUS
+ObReferenceObjectByHandle(HANDLE Handle,
                                   ACCESS_MASK DesiredAccess,
                                   POBJECT_TYPE ObjectType,
                                   KPROCESSOR_MODE AccessMode,
@@ -378,46 +392,66 @@ NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
    return(STATUS_SUCCESS);
 }
 
-NTSTATUS NtClose(HANDLE Handle)
-/*
- * FUNCTION: Closes a handle reference to an object
- * ARGUMENTS:
- *         Handle = handle to close
- * RETURNS: Status
+
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     NtClose
+ *     
+ * DESCRIPTION
+ *     Closes a handle reference to an object.
+ *     
+ * ARGUMENTS
+ *     Handle
+ *             Handle to close.
+ *             
+ * RETURN VALUE
+ *     Status.
  */
+NTSTATUS
+STDCALL
+NtClose(HANDLE Handle)
 {
-   PVOID ObjectBody;
-   POBJECT_HEADER Header;
-   PHANDLE_REP HandleRep;
+       PVOID           ObjectBody;
+       POBJECT_HEADER  Header;
+       PHANDLE_REP     HandleRep;
    
-   assert_irql(PASSIVE_LEVEL);
+       assert_irql(PASSIVE_LEVEL);
    
-   DPRINT("NtClose(Handle %x)\n",Handle);
+       DPRINT("NtClose(Handle %x)\n",Handle);
    
-   HandleRep = ObpGetObjectByHandle(PsGetCurrentProcess(),
-                                   Handle);
-   if (HandleRep == NULL)
-     {
-       return(STATUS_INVALID_HANDLE);
-     }
-   ObjectBody = HandleRep->ObjectBody;
+       HandleRep = ObpGetObjectByHandle(
+                       PsGetCurrentProcess(),
+                       Handle
+                       );
+       if (HandleRep == NULL)
+       {
+               return STATUS_INVALID_HANDLE;
+       }
+       ObjectBody = HandleRep->ObjectBody;
    
-   HandleRep->ObjectBody = NULL;
+       HandleRep->ObjectBody = NULL;
    
-   Header = BODY_TO_HEADER(ObjectBody);
+       Header = BODY_TO_HEADER(ObjectBody);
    
-   Header->RefCount++;
-   Header->HandleCount--;
+       Header->RefCount++;
+       Header->HandleCount--;
    
-   if (Header->ObjectType != NULL &&
-       Header->ObjectType->Close != NULL)
-     {
-       Header->ObjectType->Close(ObjectBody, Header->HandleCount);
-     }
+       if (    (Header->ObjectType != NULL)
+               && (Header->ObjectType->Close != NULL)
+               )
+       {
+               Header->ObjectType->Close(
+                               ObjectBody,
+                               Header->HandleCount
+                               );
+       }
    
-   Header->RefCount--;
+       Header->RefCount--;
    
-   ObPerformRetentionChecks(Header);
+       ObPerformRetentionChecks(Header);
    
-   return(STATUS_SUCCESS);
+       return STATUS_SUCCESS;
 }
+
+
+/* EOF */
index af87ef3..f9203ba 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: ntobj.c,v 1.5 1999/08/29 06:59:11 ea Exp $
+ *
  * COPYRIGHT:     See COPYING in the top level directory
  * PROJECT:       ReactOS kernel
  * FILE:          ntoskrnl/ob/ntobj.c
@@ -47,39 +48,60 @@ NtQueryObject (
 }
 
 
-VOID ObMakeTemporaryObject(PVOID ObjectBody)
+VOID
+ObMakeTemporaryObject (
+       PVOID   ObjectBody
+       )
 {
-   POBJECT_HEADER ObjectHeader;
+       POBJECT_HEADER  ObjectHeader;
    
-   ObjectHeader = BODY_TO_HEADER(ObjectBody);
-   ObjectHeader->Permanent = FALSE;
+       ObjectHeader = BODY_TO_HEADER(ObjectBody);
+       ObjectHeader->Permanent = FALSE;
 }
 
 
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     NtMakeTemporaryObject
+ *     
+ * DESCRIPTION
+ *
+ * ARGUMENTS
+ *
+ * RETURN VALUE
+ *
+ * REVISIONS
+ */
 NTSTATUS
+STDCALL
 NtMakeTemporaryObject (
        HANDLE  Handle
        )
 {
-   PVOID Object;
-   NTSTATUS Status;  
-   POBJECT_HEADER ObjectHeader;
+       PVOID           Object;
+       NTSTATUS        Status;  
+       POBJECT_HEADER  ObjectHeader;
    
-   Status = ObReferenceObjectByHandle(Handle,
-                                     0,
-                                     NULL,
-                                     KernelMode,
-                                     &Object,
-                                     NULL);
-   if (Status != STATUS_SUCCESS)
-     {
-       return(Status);
-     }
+       Status = ObReferenceObjectByHandle(
+                       Handle,
+                       0,
+                       NULL,
+                       KernelMode,
+                       & Object,
+                       NULL
+                       );
+       if (Status != STATUS_SUCCESS)
+       {
+               return Status;
+       }
 
-   ObjectHeader = BODY_TO_HEADER(Object);
-   ObjectHeader->Permanent = FALSE;
+       ObjectHeader = BODY_TO_HEADER(Object);
+       ObjectHeader->Permanent = FALSE;
    
-   ObDereferenceObject(Object);
+       ObDereferenceObject(Object);
    
-   return(STATUS_SUCCESS);
+       return STATUS_SUCCESS;
 }
+
+
+/* EOF */
index e838472..4124367 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id: thread.c,v 1.25 1999/08/29 06:59:11 ea Exp $
+ *
  * COPYRIGHT:              See COPYING in the top level directory
  * PROJECT:                ReactOS kernel
  * FILE:                   ntoskrnl/ps/thread.c
@@ -117,100 +118,129 @@ VOID PsBeginThread(PKSTART_ROUTINE StartRoutine, PVOID StartContext)
    KeBugCheck(0);
 }
 
-static PETHREAD PsScanThreadList(KPRIORITY Priority)
+static
+PETHREAD
+PsScanThreadList (
+       KPRIORITY       Priority
+       )
 {
-   PLIST_ENTRY current_entry;
-   PETHREAD current;
-   PETHREAD oldest = NULL;
-   ULONG oldest_time = 0;
-   
-//   DPRINT("PsScanThreadList(Priority %d)\n",Priority);
-   
-   current_entry = PriorityListHead[THREAD_PRIORITY_MAX+Priority].Flink;
-   while (current_entry != &PriorityListHead[THREAD_PRIORITY_MAX+Priority])
-     {
-       current = CONTAINING_RECORD(current_entry,ETHREAD,Tcb.Entry);
-
-       if (current->Tcb.State == THREAD_STATE_TERMINATED &&
-           current != CurrentThread)
-         {
-            PsReleaseThread(current);
-         }
-
-       if (current->Tcb.State == THREAD_STATE_RUNNABLE)
-         {
-            if (oldest == NULL || oldest_time > current->Tcb.LastTick)
-              {
-                 oldest = current;
-                 oldest_time = current->Tcb.LastTick;
-              }
-         }
-       current_entry = current_entry->Flink;
-     }
-//   DPRINT("PsScanThreadList() = %x\n",oldest);
-   return(oldest);
+       PLIST_ENTRY     current_entry;
+       PETHREAD        current;
+       PETHREAD        oldest = NULL;
+       ULONG           oldest_time = 0;
+   
+//     DPRINT("PsScanThreadList(Priority %d)\n",Priority);
+   
+       current_entry =
+               PriorityListHead[THREAD_PRIORITY_MAX + Priority].Flink;
+
+       while (current_entry != &PriorityListHead[THREAD_PRIORITY_MAX+Priority])
+       {
+               current = CONTAINING_RECORD(
+                               current_entry,
+                               ETHREAD,
+                               Tcb.Entry
+                               );
+
+               if (    (current->Tcb.State == THREAD_STATE_TERMINATED)
+                       && (current != CurrentThread)
+                       )
+               {
+                       PsReleaseThread(current);
+               }
+
+               if (current->Tcb.State == THREAD_STATE_RUNNABLE)
+               {
+                       if (    (oldest == NULL)
+                               || (oldest_time > current->Tcb.LastTick)
+                               )
+                       {
+                               oldest = current;
+                               oldest_time = current->Tcb.LastTick;
+                       }
+               }
+               current_entry = current_entry->Flink;
+       }
+//     DPRINT("PsScanThreadList() = %x\n",oldest);
+       return oldest;
 }
 
-VOID PsDispatchThread(VOID)
+
+VOID
+PsDispatchThread (VOID)
 {
-   KPRIORITY CurrentPriority;
-   PETHREAD Candidate;
-   KIRQL irql;
-   LARGE_INTEGER TickCount;
-   
-   if (!DoneInitYet)
-     {
-       return;
-     }
-   
-   KeAcquireSpinLock(&ThreadListLock, &irql);
-   
-   DPRINT("PsDispatchThread() Current %x\n",CurrentThread);
+       KPRIORITY       CurrentPriority;
+       PETHREAD        Candidate;
+       KIRQL           irql;
+       LARGE_INTEGER   TickCount;
+
+       if (!DoneInitYet)
+       {
+               return;
+       }
+   
+       KeAcquireSpinLock(
+               & ThreadListLock,
+               & irql
+               );
+   
+       DPRINT("PsDispatchThread() Current %x\n",CurrentThread);
       
-   if (CurrentThread->Tcb.State==THREAD_STATE_RUNNING)     
-     {
-       CurrentThread->Tcb.State=THREAD_STATE_RUNNABLE;
-     }
-   
-   for (CurrentPriority=THREAD_PRIORITY_TIME_CRITICAL; 
-       CurrentPriority>=THREAD_PRIORITY_IDLE;
-       CurrentPriority--)
-     {
-       Candidate = PsScanThreadList(CurrentPriority);
-       if (Candidate == CurrentThread)
-         {
-             DPRINT("Scheduling current thread\n");
-             KeQueryTickCount(&TickCount);
-             CurrentThread->Tcb.LastTick = TickCount.u.LowPart;
-            CurrentThread->Tcb.State = THREAD_STATE_RUNNING;
-            KeReleaseSpinLock(&ThreadListLock,irql);
-            return;
-         }
-       if (Candidate != NULL)
-         {     
-             DPRINT("Scheduling %x\n",Candidate);
-            
-            Candidate->Tcb.State = THREAD_STATE_RUNNING;
+       if (CurrentThread->Tcb.State == THREAD_STATE_RUNNING)     
+       {
+               CurrentThread->Tcb.State = THREAD_STATE_RUNNABLE;
+       }
+   
+       for (   CurrentPriority = THREAD_PRIORITY_TIME_CRITICAL; 
+               (CurrentPriority >= THREAD_PRIORITY_IDLE);
+               CurrentPriority--
+               )
+       {
+               Candidate = PsScanThreadList(CurrentPriority);
+               if (Candidate == CurrentThread)
+               {
+                       DPRINT("Scheduling current thread\n");
+                       KeQueryTickCount(&TickCount);
+                       CurrentThread->Tcb.LastTick = TickCount.u.LowPart;
+                       CurrentThread->Tcb.State = THREAD_STATE_RUNNING;
+                       KeReleaseSpinLock(
+                               & ThreadListLock,
+                               irql
+                               );
+                       return;
+               }
+               if (Candidate != NULL)
+               {       
+                       DPRINT("Scheduling %x\n",Candidate);
+
+                       Candidate->Tcb.State = THREAD_STATE_RUNNING;
             
-            KeQueryTickCount(&TickCount);
-             CurrentThread->Tcb.LastTick = TickCount.u.LowPart;
+                       KeQueryTickCount(&TickCount);
+                       CurrentThread->Tcb.LastTick = TickCount.u.LowPart;
             
-            CurrentThread = Candidate;
+                       CurrentThread = Candidate;
             
-            HalTaskSwitch(&CurrentThread->Tcb);
-            KeReleaseSpinLock(&ThreadListLock, irql);
-            return;
-         }
-     }
-   DbgPrint("CRITICAL: No threads are runnable\n");
-   KeBugCheck(0);
+                       HalTaskSwitch(&CurrentThread->Tcb);
+                       KeReleaseSpinLock(
+                               & ThreadListLock,
+                               irql
+                               );
+                       return;
+               }
+       }
+       DbgPrint("CRITICAL: No threads are runnable\n");
+       KeBugCheck(0);
 }
 
-NTSTATUS PsInitializeThread(HANDLE ProcessHandle, 
-                           PETHREAD* ThreadPtr,
-                           PHANDLE ThreadHandle,
-                           ACCESS_MASK DesiredAccess,
-                           POBJECT_ATTRIBUTES ThreadAttributes)
+
+NTSTATUS
+PsInitializeThread (
+       HANDLE                  ProcessHandle, 
+       PETHREAD                * ThreadPtr,
+       PHANDLE                 ThreadHandle,
+       ACCESS_MASK             DesiredAccess,
+       POBJECT_ATTRIBUTES      ThreadAttributes
+       )
 {
    PETHREAD Thread;
    NTSTATUS Status;
@@ -273,7 +303,9 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
    return(STATUS_SUCCESS);
 }
 
-VOID PsResumeThread(PETHREAD Thread)
+
+VOID
+PsResumeThread(PETHREAD Thread)
 {
    DPRINT("PsResumeThread(Thread %x)\n",Thread);
    Thread->Tcb.SuspendCount--;
@@ -286,7 +318,9 @@ VOID PsResumeThread(PETHREAD Thread)
    DPRINT("Finished PsResumeThread()\n");
 }
 
-VOID PsSuspendThread(PETHREAD Thread)
+
+VOID
+PsSuspendThread(PETHREAD Thread)
 {
    DPRINT("PsSuspendThread(Thread %x)\n",Thread);
    Thread->Tcb.SuspendCount++;
@@ -300,12 +334,16 @@ VOID PsSuspendThread(PETHREAD Thread)
      }
 }
 
-VOID PiDeleteThread(PVOID ObjectBody)
+
+VOID
+PiDeleteThread(PVOID ObjectBody)
 {
    DbgPrint("PiDeleteThread(ObjectBody %x)\n",ObjectBody);
 }
 
-VOID PsInitThreadManagment(VOID)
+
+VOID
+PsInitThreadManagment(VOID)
 /*
  * FUNCTION: Initialize thread managment
  */
@@ -354,7 +392,9 @@ VOID PsInitThreadManagment(VOID)
    DoneInitYet = TRUE;
 }
 
+
 NTSTATUS
+STDCALL
 NtCreateThread (
        PHANDLE                 ThreadHandle,
        ACCESS_MASK             DesiredAccess,
@@ -400,7 +440,9 @@ NtCreateThread (
    return(STATUS_SUCCESS);
 }
 
-NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
+
+NTSTATUS
+PsCreateSystemThread(PHANDLE ThreadHandle,
                              ACCESS_MASK DesiredAccess,
                              POBJECT_ATTRIBUTES ObjectAttributes,
                              HANDLE ProcessHandle,
@@ -454,12 +496,16 @@ NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
    return(STATUS_SUCCESS);
 }
 
-LONG KeSetBasePriorityThread(PKTHREAD Thread, LONG Increment)
+
+LONG
+KeSetBasePriorityThread(PKTHREAD Thread, LONG Increment)
 {
    UNIMPLEMENTED;
 }
 
-KPRIORITY KeSetPriorityThread(PKTHREAD Thread, KPRIORITY Priority)
+
+KPRIORITY
+KeSetPriorityThread(PKTHREAD Thread, KPRIORITY Priority)
 {
    KPRIORITY OldPriority;
    OldPriority = Thread->BasePriority;
@@ -638,3 +684,6 @@ NtYieldExecution(VOID)
        PsDispatchThread();
        return(STATUS_SUCCESS);
 }
+
+
+/* EOF */
index 9ab7105..abb54c5 100644 (file)
+/* $Id: interlck.c,v 1.3 1999/08/29 06:59:11 ea Exp $
+ *
+ * reactos/ntoskrnl/rtl/interlck.c
+ *
+ * FIXME: change decorated names when __fastcall will be available
+ * (for both egcs 1.1.2 and gcc 2.95 FASTCALL == STDCALL).
+ */
+#include <reactos/config.h>
+#include <ntos.h>
+#include <internal/debug.h>
 
-void InterlockedIncrement(void);
-   __asm__("\n\t.global _InterlockedIncrement\n\t"
-       "_InterlockedIncrement:\n\t"
-       "pushl %ebp\n\t"
-       "movl  %esp,%ebp\n\t"
-       "pushl %ebx\n\t"
-       "movl $1,%eax\n\t"
-       "movl 8(%ebp),%ebx\n\t"
-       "xaddl %eax,(%ebx)\n\t"
-       "popl %ebx\n\t"
-       "movl %ebp,%esp\n\t"
-       "popl %ebp\n\t"
-       "ret\n\t");
-       
+
+/**********************************************************************
+ * FASTCALL: @InterlockedIncrement@0
+ * STDCALL : _InterlockedIncrement@4
+ */
+LONG
+FASTCALL
+InterlockedIncrement (
+       PLONG   Addend
+       );
+__asm__(
+       "\n\t.global _InterlockedIncrement@4\n\t"
+       "_InterlockedIncrement@4:\n\t"
+       "pushl %ebp\n\t"
+       "movl  %esp,%ebp\n\t"
+       "pushl %ebx\n\t"
+       "movl $1,%eax\n\t"
+       "movl 8(%ebp),%ebx\n\t"
+       "xaddl %eax,(%ebx)\n\t"
+       "popl %ebx\n\t"
+       "movl %ebp,%esp\n\t"
+       "popl %ebp\n\t"
+       "ret $4\n\t"
+       );
+/*
+__asm__(
+#ifndef CONFIG_USE_FASTCALL 
+       ".global _InterlockedIncrement@4\n"
+       "\t_InterlockedIncrement@4:\n"
+       "\tmovl 4(%esp), %ecx\n"
+#else
+       ".global @InterlockedIncrement@0\n"
+       "\t@InterlockedIncrement@0:\n"
+#endif
+       "\tmov  $1, %eax\n"
+       "\txadd %ecx, %eax\n"
+       "\tinc  %eax\n\n"
+#ifndef CONFIG_USE_FASTCALL 
+       "\tret  $4\n"
+#endif
+       );
+*/
        
-void InterlockedDecrement(void);
-   __asm__("\n\t.global _InterlockedDecrement\n\t"
-       "_InterlockedDecrement:\n\t"
-       "movl $0xffffffff,%eax\n\t"
-       "movl 4(%esp),%ebx\n\t"
-       "xaddl %eax,(%ebx)\n\t"
-       "decl %eax\n\t"
-       "ret\n\t");
        
-void InterlockedExchange(void);
-   __asm__("\n\t.global _InterlockedExchange\n\t"
-       "_InterlockedExchange:\n\t"
-       "pushl %ebp\n\t"
-       "movl  %esp,%ebp\n\t"
-       "pushl %eax\n\t"
-       "pushl %ebx\n\t"
-       "movl  12(%ebp),%eax\n\t"
-       "movl  8(%ebp),%ebx\n\t"
-       "xchgl %eax,(%ebx)\n\t"
-       "popl  %ebx\n\t"
-       "popl  %eax\n\t"
-       "movl  %ebp,%esp\n\t"
-       "popl  %ebp\n\t"
-       "ret\n\t");
-
-void InterlockedExchangeAdd(void);
-   __asm__("\n\t.global _InterlockedExchangeAdd\n\t"
-       "_InterlockedExchangeAdd:\n\t"
-       "movl 8(%esp),%eax\n\t"
-       "movl 4(%esp),%ebx\n\t"
-       "xaddl %eax,(%ebx)\n\t"
-       "ret\n\t");
-
-void InterlockedCompareExchange(void);
-   __asm__("\n\t.global _InterlockedCompareExchange\n\t"
-       "_InterlockedCompareExchange:\n\t"
-       "movl 12(%esp),%eax\n\t"
-       "movl 8(%esp),%edx\n\t"
-       "movl 4(%esp),%ebx\n\t"
-       "cmpxchg %edx,(%ebx)\n\t"
-       "movl %edx,%eax\n\t"
-       "ret\n\t");
+/**********************************************************************
+ * FASTCALL: @InterlockedDecrement@0
+ * STDCALL : _InterlockedDecrement@4
+ */
+LONG
+FASTCALL
+InterlockedDecrement (
+       PLONG   Addend
+       );
+__asm__(
+       "\n\t.global _InterlockedDecrement@4\n\t"
+       "_InterlockedDecrement@4:\n\t"
+       "movl $0xffffffff,%eax\n\t"
+       "movl 4(%esp),%ebx\n\t"
+       "xaddl %eax,(%ebx)\n\t"
+       "decl %eax\n\t"
+       "ret $4\n\t"
+       );
+/**********************************************************************
+ * FASTCALL: @InterlockedExchange@0
+ * STDCALL : _InterlockedExchange@8
+ */
+LONG
+FASTCALL
+InterlockedExchange (
+       PLONG   Target,
+       LONG    Value
+       );
+__asm__(
+       "\n\t.global _InterlockedExchange@8\n\t"
+       "_InterlockedExchange@8:\n\t"
+       "pushl %ebp\n\t"
+       "movl  %esp,%ebp\n\t"
+       "pushl %eax\n\t"
+       "pushl %ebx\n\t"
+       "movl  12(%ebp),%eax\n\t"
+       "movl  8(%ebp),%ebx\n\t"
+       "xchgl %eax,(%ebx)\n\t"
+       "popl  %ebx\n\t"
+       "popl  %eax\n\t"
+       "movl  %ebp,%esp\n\t"
+       "popl  %ebp\n\t"
+       "ret $8\n\t"
+       );
+/*
+__asm__(
+#ifndef CONFIG_USE_FASTCALL 
+       ".global _InterlockedExchange@8\n"
+       "_InterlockedExchange@8:\n"
+       "\tmovl 4(%esp), %ecx\n"
+       "\tmovl 8(%esp), %edx\n"
+#else
+       ".global @InterlockedExchange@0\n"
+       "@InterlockedExchange@0:\n"
+#endif
+       "\tmovl %ecx, %eax\n"
+       "__InterlockedExchange_Loop:\n"
+       "\tlock\n"
+       "\tcmpxchg %ecx, %edx\n"
+       "\tjne __InterlockedExchange_Loop\n"
+#ifndef CONFIG_USE_FASTCALL 
+       "\tmovl %ecx, 4(%esp)\n"
+       "\tret $8\n"
+#else
+       "\tret\n"
+#endif
+       );
+*/
+
+
+/**********************************************************************
+ * FASTCALL: @InterlockedExchangeAdd@0
+ * STDCALL : _InterlockedExchangeAdd@8
+ */
+LONG
+FASTCALL
+InterlockedExchangeAdd (
+       PLONG   Addend,
+       LONG    Value
+       );
+__asm__(
+       "\n\t.global _InterlockedExchangeAdd@8\n\t"
+       "_InterlockedExchangeAdd@8:\n\t"
+       "movl 8(%esp),%eax\n\t"
+       "movl 4(%esp),%ebx\n\t"
+       "xaddl %eax,(%ebx)\n\t"
+       "ret $8\n\t"
+       );
+/*
+__asm__(
+#ifndef CONFIG_USE_FASTCALL 
+       ".global _InterlockedExchangeAdd@8\n"
+       "\t_InterlockedExchangeAdd@8:\n"
+       "\tmovl 4(%esp), %ecx\n"
+       "\tmovl 8(%esp), %edx\n"
+#else
+       ".global @InterlockedExchangeAdd@0\n"
+       "\t@InterlockedExchangeAdd@0:\n"
+#endif
+       "\txadd %edx, %ecx\n"
+       "\tmovl %edx, %eax\n"
+#ifndef CONFIG_USE_FASTCALL 
+       "\tret  $8\n"
+#else
+       "\tret\n"
+#endif
+       );
+*/
+
+
+/**********************************************************************
+ * FASTCALL: @InterlockedCompareExchange@4
+ * STDCALL : _InterlockedCompareExchange@12
+ */
+PVOID
+FASTCALL
+InterlockedCompareExchange (
+       PVOID   * Destination,
+       PVOID   Exchange,
+       PVOID   Comperand
+       );
+__asm__(
+       "\n\t.global _InterlockedCompareExchange@12\n\t"
+       "_InterlockedCompareExchange@12:\n\t"
+       "movl 12(%esp),%eax\n\t"
+       "movl 8(%esp),%edx\n\t"
+       "movl 4(%esp),%ebx\n\t"
+       "cmpxchg %edx,(%ebx)\n\t"
+       "movl %edx,%eax\n\t"
+       "ret $12\n\t"
+       );
+/*
+__asm__(
+#ifndef CONFIG_USE_FASTCALL 
+       ".global _InterlockedCompareExchange@12\n"
+       "\t_InterlockedCompareExchange@12:\n"
+       "\tmovl 4(%esp), %ecx\n"
+       "\tmovl 8(%esp), %edx\n"
+       "\tmovl 12(%esp), %eax\n"
+#else
+       ".global @InterlockedCompareExchange@4\n"
+       "\t@InterlockedCompareExchange@4:\n"
+       "\tmovl 4(%esp), %eax\n"
+#endif
+       "\tcmpxchg %ecx, %edx\n"
+#ifndef CONFIG_USE_FASTCALL 
+       "\tret $12\n"
+#else
+       "\tret $4\n"
+#endif
+*/
+
+
+/* EOF */