ntoskrnl header cleanups
Modified: trunk/reactos/include/ndk/i386/ketypes.h
Modified: trunk/reactos/ntoskrnl/cc/cacheman.c
Modified: trunk/reactos/ntoskrnl/cc/copy.c
Modified: trunk/reactos/ntoskrnl/cc/view.c
Modified: trunk/reactos/ntoskrnl/include/internal/cc.h
Deleted: trunk/reactos/ntoskrnl/include/internal/fs.h
Added: trunk/reactos/ntoskrnl/include/internal/fsrtl.h
Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h
Modified: trunk/reactos/ntoskrnl/include/internal/io.h
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
Modified: trunk/reactos/ntoskrnl/include/internal/ldr.h
Added: trunk/reactos/ntoskrnl/include/internal/lpc.h
Modified: trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h
Deleted: trunk/reactos/ntoskrnl/include/internal/port.h
Deleted: trunk/reactos/ntoskrnl/include/internal/v86m.h
Deleted: trunk/reactos/ntoskrnl/include/internal/xhal.h
Modified: trunk/reactos/ntoskrnl/ke/bug.c
Modified: trunk/reactos/ntoskrnl/ke/clock.c
Modified: trunk/reactos/ntoskrnl/ke/dpc.c
Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c
Modified: trunk/reactos/ntoskrnl/ke/i386/irq.c
Modified: trunk/reactos/ntoskrnl/ke/i386/kernel.c
Modified: trunk/reactos/ntoskrnl/ke/i386/usertrap.c
Modified: trunk/reactos/ntoskrnl/ke/i386/v86m.c
Modified: trunk/reactos/ntoskrnl/ke/ipi.c
Modified: trunk/reactos/ntoskrnl/ke/kthread.c
Modified: trunk/reactos/ntoskrnl/ldr/loader.c

Modified: trunk/reactos/include/ndk/i386/ketypes.h
--- trunk/reactos/include/ndk/i386/ketypes.h	2005-09-14 01:05:50 UTC (rev 17846)
+++ trunk/reactos/include/ndk/i386/ketypes.h	2005-09-14 01:44:19 UTC (rev 17847)
@@ -20,6 +20,12 @@
 #define I386_INTERRUPT_GATE    0xE
 #define I386_TRAP_GATE         0xF
 
+#define IPI_APC                 1
+#define IPI_DPC                 2
+#define IPI_FREEZE              3
+#define IPI_PACKET_READY        4
+#define IPI_SYNCH_REQUEST       10
+
 /* EXPORTED DATA *************************************************************/
 
 /* ENUMERATIONS **************************************************************/

Modified: trunk/reactos/ntoskrnl/cc/cacheman.c
--- trunk/reactos/ntoskrnl/cc/cacheman.c	2005-09-14 01:05:50 UTC (rev 17846)
+++ trunk/reactos/ntoskrnl/cc/cacheman.c	2005-09-14 01:44:19 UTC (rev 17847)
@@ -16,6 +16,7 @@
 /* FUNCTIONS *****************************************************************/
 
 VOID
+NTAPI
 CcInit(VOID)
 {
   CcInitView();

Modified: trunk/reactos/ntoskrnl/cc/copy.c
--- trunk/reactos/ntoskrnl/cc/copy.c	2005-09-14 01:05:50 UTC (rev 17846)
+++ trunk/reactos/ntoskrnl/cc/copy.c	2005-09-14 01:44:19 UTC (rev 17847)
@@ -39,6 +39,7 @@
 /* FUNCTIONS *****************************************************************/
 
 VOID
+NTAPI
 CcInitCacheZeroPage(VOID)
 {
    NTSTATUS Status;
@@ -58,6 +59,7 @@
 }
 
 NTSTATUS
+NTAPI
 ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
 		      PVOID Buffer)
 {
@@ -187,6 +189,7 @@
 }
 
 NTSTATUS
+NTAPI
 ReadCacheSegment(PCACHE_SEGMENT CacheSeg)
 {
   ULONG Size;
@@ -228,6 +231,7 @@
 }
 
 NTSTATUS
+NTAPI
 WriteCacheSegment(PCACHE_SEGMENT CacheSeg)
 {
   ULONG Size;

Modified: trunk/reactos/ntoskrnl/cc/view.c
--- trunk/reactos/ntoskrnl/cc/view.c	2005-09-14 01:05:50 UTC (rev 17846)
+++ trunk/reactos/ntoskrnl/cc/view.c	2005-09-14 01:44:19 UTC (rev 17847)
@@ -159,6 +159,7 @@
 }
 
 NTSTATUS
+NTAPI
 CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment)
 {
   NTSTATUS Status;
@@ -179,6 +180,7 @@
 }
 
 NTSTATUS
+NTAPI
 CcRosFlushDirtyPages(ULONG Target, PULONG Count)
 {
   PLIST_ENTRY current_entry;
@@ -355,6 +357,7 @@
 }
 
 NTSTATUS
+NTAPI
 CcRosReleaseCacheSegment(PBCB Bcb,
 			 PCACHE_SEGMENT CacheSeg,
 			 BOOLEAN Valid,
@@ -403,6 +406,7 @@
 }
 
 PCACHE_SEGMENT
+NTAPI
 CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset)
 {
   PLIST_ENTRY current_entry;
@@ -434,6 +438,7 @@
 }
 
 NTSTATUS
+NTAPI
 CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset)
 {
   PCACHE_SEGMENT CacheSeg;
@@ -470,6 +475,7 @@
 }
 
 NTSTATUS
+NTAPI
 CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty)
 {
   PCACHE_SEGMENT CacheSeg;
@@ -689,6 +695,7 @@
 }
 
 NTSTATUS
+NTAPI
 CcRosGetCacheSegmentChain(PBCB Bcb,
 			  ULONG FileOffset,
 			  ULONG Length,
@@ -752,6 +759,7 @@
 }
 
 NTSTATUS
+NTAPI
 CcRosGetCacheSegment(PBCB Bcb,
 		     ULONG FileOffset,
 		     PULONG BaseOffset,
@@ -889,6 +897,7 @@
 }
 
 NTSTATUS
+NTAPI
 CcRosFreeCacheSegment(PBCB Bcb, PCACHE_SEGMENT CacheSeg)
 {
   NTSTATUS Status;
@@ -995,6 +1004,7 @@
 }
 
 NTSTATUS
+NTAPI
 CcRosDeleteFileCache(PFILE_OBJECT FileObject, PBCB Bcb)
 /*
  * FUNCTION: Releases the BCB associated with a file object
@@ -1065,7 +1075,9 @@
    return(STATUS_SUCCESS);
 }
 
-VOID CcRosReferenceCache(PFILE_OBJECT FileObject)
+VOID
+NTAPI
+CcRosReferenceCache(PFILE_OBJECT FileObject)
 {
   PBCB Bcb;
   ExAcquireFastMutex(&ViewLock);
@@ -1086,7 +1098,9 @@
   ExReleaseFastMutex(&ViewLock);
 }
 
-VOID CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer)
+VOID
+NTAPI
+CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer)
 {
   PBCB Bcb;
   DPRINT("CcRosSetRemoveOnClose()\n");
@@ -1104,7 +1118,9 @@
 }
 
 
-VOID CcRosDereferenceCache(PFILE_OBJECT FileObject)
+VOID
+NTAPI
+CcRosDereferenceCache(PFILE_OBJECT FileObject)
 {
   PBCB Bcb;
   ExAcquireFastMutex(&ViewLock);
@@ -1171,6 +1187,7 @@
 }
 
 NTSTATUS
+NTAPI
 CcTryToInitializeFileCache(PFILE_OBJECT FileObject)
 {
    PBCB Bcb;
@@ -1328,7 +1345,9 @@
    }
 }
 
-VOID INIT_FUNCTION
+VOID
+INIT_FUNCTION
+NTAPI
 CcInitView(VOID)
 {
 #ifdef CACHE_BITMAP

Modified: trunk/reactos/ntoskrnl/include/internal/cc.h
--- trunk/reactos/ntoskrnl/include/internal/cc.h	2005-09-14 01:05:50 UTC (rev 17846)
+++ trunk/reactos/ntoskrnl/include/internal/cc.h	2005-09-14 01:44:19 UTC (rev 17847)
@@ -77,36 +77,45 @@
 );
 
 NTSTATUS
+NTAPI
 CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment);
 
 NTSTATUS
+NTAPI
 CcRosGetCacheSegment(
     PBCB Bcb,
     ULONG FileOffset,
     PULONG BaseOffset,
-    PVOID* BaseAddress,
+    PVOID *BaseAddress,
     PBOOLEAN UptoDate,
-    PCACHE_SEGMENT* CacheSeg
+    PCACHE_SEGMENT *CacheSeg
 );
 
 VOID
+NTAPI
 CcInitView(VOID);
 
 NTSTATUS
+NTAPI
 CcRosFreeCacheSegment(
     PBCB,
     PCACHE_SEGMENT
 );
 
 NTSTATUS
+NTAPI
 ReadCacheSegment(PCACHE_SEGMENT CacheSeg);
 
 NTSTATUS
+NTAPI
 WriteCacheSegment(PCACHE_SEGMENT CacheSeg);
 
-VOID CcInit(VOID);
+VOID
+NTAPI
+CcInit(VOID);
 
 NTSTATUS
+NTAPI
 CcRosUnmapCacheSegment(
     PBCB Bcb,
     ULONG FileOffset,
@@ -114,12 +123,14 @@
 );
 
 PCACHE_SEGMENT
+NTAPI
 CcRosLookupCacheSegment(
     PBCB Bcb,
     ULONG FileOffset
 );
 
 NTSTATUS
+NTAPI
 CcRosGetCacheSegmentChain(
     PBCB Bcb,
     ULONG FileOffset,
@@ -128,49 +139,57 @@
 );
 
 VOID
+NTAPI
 CcInitCacheZeroPage(VOID);
 
 NTSTATUS
+NTAPI
 CcRosMarkDirtyCacheSegment(
     PBCB Bcb,
     ULONG FileOffset
 );
 
 NTSTATUS
+NTAPI
 CcRosFlushDirtyPages(
     ULONG Target,
     PULONG Count
 );
 
 VOID
+NTAPI
 CcRosDereferenceCache(PFILE_OBJECT FileObject);
 
 VOID
+NTAPI
 CcRosReferenceCache(PFILE_OBJECT FileObject);
 
 VOID
+NTAPI
 CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer);
 
 NTSTATUS
+NTAPI
 CcRosReleaseCacheSegment(
-    BCB*		    Bcb,
-    CACHE_SEGMENT*    CacheSeg,
-    BOOLEAN	    Valid,
-    BOOLEAN	    Dirty,
-    BOOLEAN	    Mapped
+    BCB* Bcb,
+    CACHE_SEGMENT *CacheSeg,
+    BOOLEAN Valid,
+    BOOLEAN Dirty,
+    BOOLEAN Mapped
 );
 
 NTSTATUS
 STDCALL
 CcRosRequestCacheSegment(
-    BCB*		    Bcb,
-    ULONG		    FileOffset,
-    PVOID*	    BaseAddress,
-    PBOOLEAN	    UptoDate,
-    CACHE_SEGMENT**   CacheSeg
+    BCB *Bcb,
+    ULONG FileOffset,
+    PVOID* BaseAddress,
+    PBOOLEAN UptoDate,
+    CACHE_SEGMENT **CacheSeg
 );
 
 NTSTATUS
+NTAPI
 CcTryToInitializeFileCache(PFILE_OBJECT FileObject);
 
 /*

Deleted: trunk/reactos/ntoskrnl/include/internal/fs.h
--- trunk/reactos/ntoskrnl/include/internal/fs.h	2005-09-14 01:05:50 UTC (rev 17846)
+++ trunk/reactos/ntoskrnl/include/internal/fs.h	2005-09-14 01:44:19 UTC (rev 17847)
@@ -1,89 +0,0 @@
-#ifndef __INCLUDE_INTERNAL_IFS_H
-#define __INCLUDE_INTERNAL_IFS_H
-
-typedef struct _FILE_LOCK_GRANTED {
-	LIST_ENTRY			ListEntry;
-	FILE_LOCK_INFO			Lock;
-   PVOID             UnlockContext;
-} FILE_LOCK_GRANTED, *PFILE_LOCK_GRANTED;
-
-
-typedef struct _FILE_LOCK_TOC {
-	KSPIN_LOCK			SpinLock;
-	LIST_ENTRY			GrantedListHead;
-	LIST_ENTRY			PendingListHead;
-} FILE_LOCK_TOC, *PFILE_LOCK_TOC;
-
-VOID
-STDCALL INIT_FUNCTION
-FsRtlpInitNotifyImplementation(VOID);
-
-
-VOID STDCALL
-FsRtlpInitFileLockingImplementation(VOID);
-
-VOID STDCALL
-FsRtlpFileLockCancelRoutine(
-	IN PDEVICE_OBJECT DeviceObject,
-	IN PIRP Irp
-	);
-
-BOOLEAN FASTCALL
-FsRtlpCheckLockForReadOrWriteAccess(
-    IN PFILE_LOCK           FileLock,
-    IN PLARGE_INTEGER       FileOffset,
-    IN PLARGE_INTEGER       Length,
-    IN ULONG                Key,
-    IN PFILE_OBJECT         FileObject,
-    IN PEPROCESS            Process,
-	IN BOOLEAN				Read
-   );
-
-NTSTATUS FASTCALL
-FsRtlpFastUnlockAllByKey(
-    IN PFILE_LOCK           FileLock,
-    IN PFILE_OBJECT         FileObject,
-    IN PEPROCESS            Process,
-    IN DWORD                Key,      /* FIXME: guess */
-    IN BOOLEAN              UseKey,   /* FIXME: guess */
-    IN PVOID                Context OPTIONAL
-    );
-
-BOOLEAN FASTCALL
-FsRtlpAddLock(
-    IN PFILE_LOCK_TOC		LockToc,
-    IN PFILE_OBJECT         FileObject,
-    IN PLARGE_INTEGER       FileOffset,
-    IN PLARGE_INTEGER       Length,
-    IN PEPROCESS            Process,
-    IN ULONG                Key,
-    IN BOOLEAN              ExclusiveLock,
-    IN PVOID                UnlockContext
-	);
-
-VOID FASTCALL
-FsRtlpCompletePendingLocks(
-	IN		PFILE_LOCK		FileLock,
-	IN		PFILE_LOCK_TOC	LockToc,
-	IN OUT	PKIRQL			oldirql,
-   IN    PVOID          Context
-	);
-
-NTSTATUS FASTCALL
-FsRtlpUnlockSingle(
-    IN PFILE_LOCK           FileLock,
-    IN PFILE_OBJECT         FileObject,
-    IN PLARGE_INTEGER       FileOffset,
-    IN PLARGE_INTEGER       Length,
-    IN PEPROCESS            Process,
-    IN ULONG                Key,
-    IN PVOID                Context OPTIONAL,
-	IN BOOLEAN				CallUnlockRoutine
-	);
-
-VOID FASTCALL
-FsRtlpDumpFileLocks(
-	IN PFILE_LOCK	FileLock
-	);
-
-#endif

Copied: trunk/reactos/ntoskrnl/include/internal/fsrtl.h (from rev 17811, trunk/reactos/ntoskrnl/include/internal/fs.h)
--- trunk/reactos/ntoskrnl/include/internal/fs.h	2005-09-11 22:32:20 UTC (rev 17811)
+++ trunk/reactos/ntoskrnl/include/internal/fsrtl.h	2005-09-14 01:44:19 UTC (rev 17847)
@@ -0,0 +1,96 @@
+#ifndef __INCLUDE_INTERNAL_IFS_H
+#define __INCLUDE_INTERNAL_IFS_H
+
+typedef struct _FILE_LOCK_GRANTED
+{
+    LIST_ENTRY            ListEntry;
+    FILE_LOCK_INFO            Lock;
+    PVOID             UnlockContext;
+} FILE_LOCK_GRANTED, *PFILE_LOCK_GRANTED;
+
+typedef struct _FILE_LOCK_TOC
+{
+    KSPIN_LOCK            SpinLock;
+    LIST_ENTRY            GrantedListHead;
+    LIST_ENTRY            PendingListHead;
+} FILE_LOCK_TOC, *PFILE_LOCK_TOC;
+
+VOID
+INIT_FUNCTION
+STDCALL
+FsRtlpInitNotifyImplementation(VOID);
+
+VOID 
+STDCALL
+FsRtlpInitFileLockingImplementation(VOID);
+
+VOID
+STDCALL
+FsRtlpFileLockCancelRoutine(
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp
+    );
+
+BOOLEAN
+FASTCALL
+FsRtlpCheckLockForReadOrWriteAccess(
+    IN PFILE_LOCK FileLock,
+    IN PLARGE_INTEGER FileOffset,
+    IN PLARGE_INTEGER Length,
+    IN ULONG Key,
+    IN PFILE_OBJECT FileObject,
+    IN PEPROCESS Process,
+    IN BOOLEAN Read
+);
+
+NTSTATUS
+FASTCALL
+FsRtlpFastUnlockAllByKey(
+    IN PFILE_LOCK FileLock,
+    IN PFILE_OBJECT FileObject,
+    IN PEPROCESS Process,
+    IN DWORD Key,
+    IN BOOLEAN UseKey,
+    IN PVOID Context OPTIONAL
+);
+
+BOOLEAN
+FASTCALL
+FsRtlpAddLock(
+    IN PFILE_LOCK_TOC LockToc,
+    IN PFILE_OBJECT FileObject,
+    IN PLARGE_INTEGER FileOffset,
+    IN PLARGE_INTEGER Length,
+    IN PEPROCESS Process,
+    IN ULONG Key,
+    IN BOOLEAN ExclusiveLock,
+    IN PVOID UnlockContext
+);
+
+VOID
+FASTCALL
+FsRtlpCompletePendingLocks(
+    IN PFILE_LOCK FileLock,
+    IN PFILE_LOCK_TOC LockToc,
+    IN OUT PKIRQL  oldirql,
+    IN PVOID Context
+);
+
+NTSTATUS
+FASTCALL
+FsRtlpUnlockSingle(
+    IN PFILE_LOCK FileLock,
+    IN PFILE_OBJECT FileObject,
+    IN PLARGE_INTEGER FileOffset,
+    IN PLARGE_INTEGER Length,
+    IN PEPROCESS Process,
+    IN ULONG Key,
+    IN PVOID Context OPTIONAL,
+    IN BOOLEAN CallUnlockRoutine
+);
+
+VOID
+FASTCALL
+FsRtlpDumpFileLocks(IN PFILE_LOCK FileLock);
+
+#endif

Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h
--- trunk/reactos/ntoskrnl/include/internal/i386/ke.h	2005-09-14 01:05:50 UTC (rev 17846)
+++ trunk/reactos/ntoskrnl/include/internal/i386/ke.h	2005-09-14 01:44:19 UTC (rev 17847)
@@ -71,6 +71,61 @@
    ULONG Eflags;
 } KIRQ_TRAPFRAME, *PKIRQ_TRAPFRAME;
 
+/* Emulate cli/sti instructions */
+#define KV86M_EMULATE_CLI_STI          (0x1)
+/* Allow the v86 mode code to access i/o ports */
+#define KV86M_ALLOW_IO_PORT_ACCESS      (0x2)
+
+typedef struct _KV86M_REGISTERS
+{
+    /*
+     * General purpose registers
+     */
+    ULONG Ebp;
+    ULONG Edi;
+    ULONG Esi;
+    ULONG Edx;
+    ULONG Ecx;
+    ULONG Ebx;
+    ULONG Eax;
+    ULONG Ds;
+    ULONG Es;
+    ULONG Fs;
+    ULONG Gs;
+
+    /*
+     * Control registers
+     */
+    ULONG Eip;
+    ULONG Cs;
+    ULONG Eflags;
+    ULONG Esp;
+    ULONG Ss;
+
+    /*
+     * Control structures
+     */
+    ULONG RecoveryAddress;
+    UCHAR RecoveryInstruction[4];
+    ULONG Vif;
+    ULONG Flags;
+    PNTSTATUS PStatus;
+} KV86M_REGISTERS, *PKV86M_REGISTERS;
+
+typedef struct _KV86M_TRAP_FRAME
+{
+    KTRAP_FRAME Tf;
+
+    ULONG SavedExceptionStack;
+
+    /*
+     * These are put on the top of the stack by the routine that entered
+     * v86 mode so the exception handlers can find the control information
+     */
+    struct _KV86M_REGISTERS* regs;
+    ULONG orig_ebp;
+} KV86M_TRAP_FRAME, *PKV86M_TRAP_FRAME;
+
 extern ULONG Ke386CacheAlignment;
 
 struct _KPCR;

Modified: trunk/reactos/ntoskrnl/include/internal/io.h
--- trunk/reactos/ntoskrnl/include/internal/io.h	2005-09-14 01:05:50 UTC (rev 17846)
+++ trunk/reactos/ntoskrnl/include/internal/io.h	2005-09-14 01:44:19 UTC (rev 17847)
@@ -1,6 +1,8 @@
 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_IO_H
 #define __NTOSKRNL_INCLUDE_INTERNAL_IO_H
 
+#include <ddk/ntdddisk.h>
+
 #define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003)
 
 extern POBJECT_TYPE IoCompletionType;
@@ -478,4 +480,59 @@
                         : \
     FIELD_OFFSET(CM_RESOURCE_LIST, List)
 
+/* xhal.c */
+NTSTATUS
+FASTCALL
+xHalQueryDriveLayout(
+    IN PUNICODE_STRING DeviceName,
+    OUT PDRIVE_LAYOUT_INFORMATION *LayoutInfo
+);
+
+#undef HalExamineMBR
+VOID 
+FASTCALL
+HalExamineMBR(
+    IN PDEVICE_OBJECT DeviceObject,
+    IN ULONG SectorSize,
+    IN ULONG MBRTypeIdentifier,
+    OUT PVOID *Buffer
+);
+
+VOID 
+FASTCALL
+xHalIoAssignDriveLetters(
+    IN PLOADER_PARAMETER_BLOCK LoaderBlock,
+    IN PSTRING NtDeviceName,
+    OUT PUCHAR NtSystemPath,
+    OUT PSTRING NtSystemPathString
+);
+
+NTSTATUS 
+FASTCALL
+xHalIoReadPartitionTable(
+    PDEVICE_OBJECT DeviceObject,
+    ULONG SectorSize,
+    BOOLEAN ReturnRecognizedPartitions,
+    PDRIVE_LAYOUT_INFORMATION *PartitionBuffer
+);
+
+NTSTATUS 
+FASTCALL
+xHalIoSetPartitionInformation(
+    IN PDEVICE_OBJECT DeviceObject,
+    IN ULONG SectorSize,
+    IN ULONG PartitionNumber,
+    IN ULONG PartitionType
+);
+
+NTSTATUS 
+FASTCALL
+xHalIoWritePartitionTable(
+    IN PDEVICE_OBJECT DeviceObject,
+    IN ULONG SectorSize,
+    IN ULONG SectorsPerTrack,
+    IN ULONG NumberOfHeads,
+    IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer
+);
+
 #endif

Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
--- trunk/reactos/ntoskrnl/include/internal/ke.h	2005-09-14 01:05:50 UTC (rev 17846)
+++ trunk/reactos/ntoskrnl/include/internal/ke.h	2005-09-14 01:44:19 UTC (rev 17847)
@@ -12,8 +12,24 @@
   PVOID Wow64;
 } WOW64_PROCESS, *PWOW64_PROCESS;
 
-/* INTERNAL KERNEL FUNCTIONS ************************************************/
+typedef struct _KPROFILE_SOURCE_OBJECT
+{
+    KPROFILE_SOURCE Source;
+    LIST_ENTRY ListEntry;
+} KPROFILE_SOURCE_OBJECT, *PKPROFILE_SOURCE_OBJECT;
 
+/* Cached modules from the loader block */
+typedef enum _CACHED_MODULE_TYPE
+{
+    AnsiCodepage,
+    OemCodepage,
+    UnicodeCasemap,
+    SystemRegistry,
+    HardwareRegistry,
+    MaximumCachedModuleType,
+} CACHED_MODULE_TYPE, *PCACHED_MODULE_TYPE;
+extern PLOADER_MODULE CachedModules[MaximumCachedModuleType];
+
 struct _KIRQ_TRAPFRAME;
 struct _KPCR;
 struct _KPRCB;
@@ -23,12 +39,9 @@
 extern PVOID KeUserCallbackDispatcher;
 extern PVOID KeUserExceptionDispatcher;
 extern PVOID KeRaiseUserExceptionDispatcher;
+extern LARGE_INTEGER SystemBootTime;
+extern ULONG_PTR KERNEL_BASE;
 
-#define IPI_REQUEST_FUNCTIONCALL    0
-#define IPI_REQUEST_APC		    1
-#define IPI_REQUEST_DPC		    2
-#define IPI_REQUEST_FREEZE	    3
-
 /* MACROS *************************************************************************/
 
 #define KeEnterCriticalRegion() \
@@ -49,6 +62,14 @@
     } \
 }
 
+#define KEBUGCHECKWITHTF(a,b,c,d,e,f) \
+    DbgPrint("KeBugCheckWithTf at %s:%i\n",__FILE__,__LINE__), KeBugCheckWithTf(a,b,c,d,e,f)
+
+#define MAXIMUM_PROCESSORS      32
+
+
+/* INTERNAL KERNEL FUNCTIONS ************************************************/
+
 /* threadsch.c ********************************************************************/
 
 /* Thread Scheduler Functions */
@@ -66,17 +87,21 @@
 /* Puts a Thread into a block state. */
 VOID
 STDCALL
-KiBlockThread(PNTSTATUS Status,
-              UCHAR Alertable,
-              ULONG WaitMode,
-              UCHAR WaitReason);
+KiBlockThread(
+    PNTSTATUS Status,
+    UCHAR Alertable,
+    ULONG WaitMode,
+    UCHAR WaitReason
+);
 
 /* Removes a thread out of a block state. */
 VOID
 STDCALL
-KiUnblockThread(PKTHREAD Thread,
-                PNTSTATUS WaitStatus,
-                KPRIORITY Increment);
+KiUnblockThread(
+    PKTHREAD Thread,
+    PNTSTATUS WaitStatus,
+    KPRIORITY Increment
+);
 
 NTSTATUS
 STDCALL
@@ -108,62 +133,59 @@
 
 VOID
 FASTCALL
-KeWaitForGate(PKGATE Gate,
-              KWAIT_REASON WaitReason,
-              KPROCESSOR_MODE WaitMode);
+KeWaitForGate(
+    PKGATE Gate,
+    KWAIT_REASON WaitReason,
+    KPROCESSOR_MODE WaitMode
+);
 
 /* ipi.c ********************************************************************/
 
-BOOLEAN STDCALL
-KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame,
-		    IN struct _KEXCEPTION_FRAME* ExceptionFrame);
+BOOLEAN
+STDCALL
+KiIpiServiceRoutine(
+    IN PKTRAP_FRAME TrapFrame,
+    IN struct _KEXCEPTION_FRAME* ExceptionFrame
+);
 
 VOID
-KiIpiSendRequest(KAFFINITY TargetSet,
-		 ULONG IpiRequest);
+NTAPI
+KiIpiSendRequest(
+    KAFFINITY TargetSet,
+    ULONG IpiRequest
+);
 
 VOID
-KeIpiGenericCall(VOID (STDCALL *WorkerRoutine)(PVOID),
-		 PVOID Argument);
+NTAPI
+KeIpiGenericCall(
+    VOID (STDCALL *WorkerRoutine)(PVOID),
+    PVOID Argument
+);
 
 /* next file ***************************************************************/
 
-typedef struct _KPROFILE_SOURCE_OBJECT
-{
-    KPROFILE_SOURCE Source;
-    LIST_ENTRY ListEntry;
-} KPROFILE_SOURCE_OBJECT, *PKPROFILE_SOURCE_OBJECT;
-
-/* Cached modules from the loader block */
-typedef enum _CACHED_MODULE_TYPE
-{
-    AnsiCodepage,
-    OemCodepage,
-    UnicodeCasemap,
-    SystemRegistry,
-    HardwareRegistry,
-    MaximumCachedModuleType,
-} CACHED_MODULE_TYPE, *PCACHED_MODULE_TYPE;
-extern PLOADER_MODULE CachedModules[MaximumCachedModuleType];
-
 VOID 
 STDCALL
 DbgBreakPointNoBugCheck(VOID);
 
 VOID
 STDCALL
-KeInitializeProfile(struct _KPROFILE* Profile,
-                    struct _KPROCESS* Process,
-                    PVOID ImageBase,
-                    ULONG ImageSize,
-                    ULONG BucketSize,
-                    KPROFILE_SOURCE ProfileSource,
-                    KAFFINITY Affinity);
+KeInitializeProfile(
+    struct _KPROFILE* Profile,
+    struct _KPROCESS* Process,
+    PVOID ImageBase,
+    ULONG ImageSize,
+    ULONG BucketSize,
+    KPROFILE_SOURCE ProfileSource,
+    KAFFINITY Affinity
+);
 
 VOID
 STDCALL
-KeStartProfile(struct _KPROFILE* Profile,
-               PVOID Buffer);
+KeStartProfile(
+    struct _KPROFILE* Profile,
+    PVOID Buffer
+);
 
 VOID
 STDCALL
@@ -175,8 +197,10 @@
 
 VOID
 STDCALL
-KeSetIntervalProfile(KPROFILE_SOURCE ProfileSource,
-                     ULONG Interval);
+KeSetIntervalProfile(
+    KPROFILE_SOURCE ProfileSource,
+    ULONG Interval
+);
 
 VOID
 STDCALL
@@ -187,40 +211,77 @@
 VOID
 STDCALL
 KeProfileInterruptWithSource(
-	IN PKTRAP_FRAME   		TrapFrame,
-	IN KPROFILE_SOURCE		Source
+    IN PKTRAP_FRAME TrapFrame,
+    IN KPROFILE_SOURCE Source
 );
 
 BOOLEAN
 STDCALL
 KiRosPrintAddress(PVOID Address);
 
-VOID STDCALL KeUpdateSystemTime(PKTRAP_FRAME TrapFrame, KIRQL Irql);
-VOID STDCALL KeUpdateRunTime(PKTRAP_FRAME TrapFrame, KIRQL Irql);
+VOID
+STDCALL
+KeUpdateSystemTime(
+    PKTRAP_FRAME TrapFrame,
+    KIRQL Irql
+);
 
-VOID STDCALL KiExpireTimers(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2);
+VOID
+STDCALL
+KeUpdateRunTime(
+    PKTRAP_FRAME TrapFrame,
+    KIRQL Irql
+);
 
-KIRQL inline FASTCALL KeAcquireDispatcherDatabaseLock(VOID);
-VOID inline FASTCALL KeAcquireDispatcherDatabaseLockAtDpcLevel(VOID);
-VOID inline FASTCALL KeReleaseDispatcherDatabaseLock(KIRQL Irql);
-VOID inline FASTCALL KeReleaseDispatcherDatabaseLockFromDpcLevel(VOID);
+VOID
+STDCALL
+KiExpireTimers(
+    PKDPC Dpc,
+    PVOID DeferredContext,
+    PVOID SystemArgument1,
+    PVOID SystemArgument2
+);
 
+KIRQL
+inline
+FASTCALL
+KeAcquireDispatcherDatabaseLock(VOID);
+
 VOID
+__inline
+FASTCALL
+KeAcquireDispatcherDatabaseLockAtDpcLevel(VOID);
+
+VOID
+__inline
+FASTCALL
+KeReleaseDispatcherDatabaseLock(KIRQL Irql);
+
+VOID
+__inline
+FASTCALL
+KeReleaseDispatcherDatabaseLockFromDpcLevel(VOID);
+
+VOID
 STDCALL
-KeInitializeThread(struct _KPROCESS* Process,
-                   PKTHREAD Thread,
-                   PKSYSTEM_ROUTINE SystemRoutine,
-                   PKSTART_ROUTINE StartRoutine,
-                   PVOID StartContext,
-                   PCONTEXT Context,
-                   PVOID Teb,
-                   PVOID KernelStack);
+KeInitializeThread(
+    struct _KPROCESS* Process,
+    PKTHREAD Thread,
+    PKSYSTEM_ROUTINE SystemRoutine,
+    PKSTART_ROUTINE StartRoutine,
+    PVOID StartContext,
+    PCONTEXT Context,
+    PVOID Teb,
+    PVOID KernelStack
+);
 
 VOID
 STDCALL
 KeRundownThread(VOID);
 
-NTSTATUS KeReleaseThread(PKTHREAD Thread);
+NTSTATUS
+NTAPI
+KeReleaseThread(PKTHREAD Thread);
 
 LONG
 STDCALL
@@ -228,45 +289,62 @@
 
 VOID
 STDCALL
-KiSetPriorityThread(PKTHREAD Thread,
-                    KPRIORITY Priority,
-                    PBOOLEAN Released);
+KiSetPriorityThread(
+    PKTHREAD Thread,
+    KPRIORITY Priority,
+    PBOOLEAN Released
+);
 
+BOOLEAN
+NTAPI
+KiDispatcherObjectWake(
+    DISPATCHER_HEADER* hdr,
+    KPRIORITY increment
+);
+
 VOID
 STDCALL
-KeStackAttachProcess (
-    IN struct _KPROCESS* Process,
-    OUT PKAPC_STATE ApcState
-    );
+KeExpireTimers(
+    PKDPC Apc,
+    PVOID Arg1,
+    PVOID Arg2,
+    PVOID Arg3
+);
 
 VOID
[truncated at 1000 lines; 1204 more skipped]