Partial merge from the ROX-U branch (various fixes for Visual C++ compilation, see logs for r16198 and r16208)
Modified: trunk/reactos/ntoskrnl/cc/copy.c
Modified: trunk/reactos/ntoskrnl/cc/fs.c
Modified: trunk/reactos/ntoskrnl/ex/evtpair.c
Modified: trunk/reactos/ntoskrnl/ex/init.c
Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
Modified: trunk/reactos/ntoskrnl/fs/name.c
Modified: trunk/reactos/ntoskrnl/include/internal/arch/ke.h
Modified: trunk/reactos/ntoskrnl/include/internal/arch/mm.h
Modified: trunk/reactos/ntoskrnl/include/internal/arch/ps.h
Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
Modified: trunk/reactos/ntoskrnl/include/internal/ps.h
Modified: trunk/reactos/ntoskrnl/io/driver.c
Modified: trunk/reactos/ntoskrnl/io/iomgr.c
Modified: trunk/reactos/ntoskrnl/io/irp.c
Modified: trunk/reactos/ntoskrnl/io/wmi.c
Modified: trunk/reactos/ntoskrnl/ke/ipi.c
Modified: trunk/reactos/ntoskrnl/ke/kqueue.c
Modified: trunk/reactos/ntoskrnl/ke/main.c
Modified: trunk/reactos/ntoskrnl/ke/profile.c
Modified: trunk/reactos/ntoskrnl/ldr/loader.c
Modified: trunk/reactos/ntoskrnl/ldr/resource.c
Modified: trunk/reactos/ntoskrnl/ldr/rtl.c
Modified: trunk/reactos/ntoskrnl/mm/iospace.c
Modified: trunk/reactos/ntoskrnl/mm/process.c
Modified: trunk/reactos/ntoskrnl/mm/section.c
Modified: trunk/reactos/ntoskrnl/ob/handle.c
Modified: trunk/reactos/ntoskrnl/ps/kill.c
Modified: trunk/reactos/ntoskrnl/ps/psmgr.c
Modified: trunk/reactos/ntoskrnl/se/acl.c
Modified: trunk/reactos/ntoskrnl/se/luid.c
Modified: trunk/reactos/ntoskrnl/se/semgr.c
Modified: trunk/reactos/ntoskrnl/se/token.c
Modified: trunk/reactos/w32api/include/ddk/batclass.h
Modified: trunk/reactos/w32api/include/ddk/ntddk.h
Modified: trunk/reactos/w32api/include/ddk/ntifs.h
Modified: trunk/reactos/w32api/include/ddk/ntpoapi.h
Modified: trunk/reactos/w32api/include/ddk/winddk.h
Modified: trunk/reactos/w32api/include/ntdef.h
Modified: trunk/reactos/w32api/include/windef.h
Modified: trunk/reactos/w32api/include/winnt.h

Modified: trunk/reactos/ntoskrnl/cc/copy.c
--- trunk/reactos/ntoskrnl/cc/copy.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/cc/copy.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -136,7 +136,7 @@
 	  while (current2 != NULL && !current2->Valid && current_size < MAX_RW_LENGTH)
 	    {
 	      PVOID address = current2->BaseAddress;
-	      for (i = 0; i < (Bcb->CacheSegmentSize / PAGE_SIZE); i++, address += PAGE_SIZE)
+	      for (i = 0; i < (Bcb->CacheSegmentSize / PAGE_SIZE); i++, address = RVA(address, PAGE_SIZE))
 		{
 		  *MdlPages++ = MmGetPfnForProcess(NULL, address);
 		}

Modified: trunk/reactos/ntoskrnl/cc/fs.c
--- trunk/reactos/ntoskrnl/cc/fs.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/cc/fs.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -39,9 +39,8 @@
 	IN	PVOID			Context2
 	)
 {
-	UNIMPLEMENTED;
-
 	LARGE_INTEGER i;
+	UNIMPLEMENTED;
 	i.QuadPart = 0;
 	return i;
 }
@@ -69,9 +68,8 @@
 	OUT	PLARGE_INTEGER	OldestLsn OPTIONAL
 	)
 {
-	UNIMPLEMENTED;
-
 	LARGE_INTEGER i;
+	UNIMPLEMENTED;
 	i.QuadPart = 0;
 	return i;
 }

Modified: trunk/reactos/ntoskrnl/ex/evtpair.c
--- trunk/reactos/ntoskrnl/ex/evtpair.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/ex/evtpair.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -18,7 +18,7 @@
 
 /* GLOBALS *******************************************************************/
 
-POBJECT_TYPE EXPORTED ExEventPairObjectType = NULL;
+POBJECT_TYPE ExEventPairObjectType = NULL;
 
 static GENERIC_MAPPING ExEventPairMapping = {
     STANDARD_RIGHTS_READ,

Modified: trunk/reactos/ntoskrnl/ex/init.c
--- trunk/reactos/ntoskrnl/ex/init.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/ex/init.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -496,7 +496,7 @@
         KeCreateApplicationProcessorIdleThread(KeNumberProcessors);
 
         /* Allocate a stack for use when booting the processor */
-        ProcessorStack = Ki386InitialStackArray[((int)KeNumberProcessors)] + MM_STACK_SIZE;
+        ProcessorStack = RVA(Ki386InitialStackArray[((int)KeNumberProcessors)], MM_STACK_SIZE);
 
         /* Tell HAL a new CPU is being started */
         HalStartNextProcessor(0, (ULONG)ProcessorStack - 2*sizeof(FX_SAVE_AREA));

Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
--- trunk/reactos/ntoskrnl/ex/sysinfo.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/ex/sysinfo.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -835,6 +835,10 @@
 /* Class 16 - Handle Information */
 QSI_DEF(SystemHandleInformation)
 {
+	PEPROCESS pr, syspr;
+	int curSize, i = 0;
+	ULONG hCount = 0;
+
         PSYSTEM_HANDLE_INFORMATION Shi =
         	(PSYSTEM_HANDLE_INFORMATION) Buffer;
 
@@ -848,10 +852,6 @@
 
 	DPRINT("SystemHandleInformation 1\n");
 
-	PEPROCESS pr, syspr;
-	int curSize, i = 0;
-	ULONG hCount = 0;
-
         /* First Calc Size from Count. */
         syspr = PsGetNextProcess(NULL);
 	pr = syspr;
@@ -937,6 +937,7 @@
 /* Class 18 -  Information */
 QSI_DEF(SystemPageFileInformation)
 {
+	UNICODE_STRING FileName; /* FIXME */
 	SYSTEM_PAGEFILE_INFORMATION *Spfi = (SYSTEM_PAGEFILE_INFORMATION *) Buffer;
 
 	if (Size < sizeof (SYSTEM_PAGEFILE_INFORMATION))
@@ -945,7 +946,6 @@
 		return (STATUS_INFO_LENGTH_MISMATCH);
 	}
 
-	UNICODE_STRING FileName; /* FIXME */
 	RtlInitUnicodeString(&FileName, NULL); /* FIXME */
 
 	/* FIXME */

Modified: trunk/reactos/ntoskrnl/fs/name.c
--- trunk/reactos/ntoskrnl/fs/name.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/fs/name.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -149,7 +149,7 @@
   FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL     /*         0x7f */
 };
 
-PUCHAR EXPORTED FsRtlLegalAnsiCharacterArray = LegalAnsiCharacterArray;
+PUCHAR FsRtlLegalAnsiCharacterArray = LegalAnsiCharacterArray;
 
 /* FUNCTIONS *****************************************************************/
 

Modified: trunk/reactos/ntoskrnl/include/internal/arch/ke.h
--- trunk/reactos/ntoskrnl/include/internal/arch/ke.h	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/include/internal/arch/ke.h	2005-06-21 23:42:58 UTC (rev 16212)
@@ -19,7 +19,7 @@
 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_ARCH_KE_H
 #define __NTOSKRNL_INCLUDE_INTERNAL_ARCH_KE_H
 
-#ifdef i386
+#ifdef _M_IX86
 #include "../i386/ke.h"
 #else
 #error "Unknown processor"

Modified: trunk/reactos/ntoskrnl/include/internal/arch/mm.h
--- trunk/reactos/ntoskrnl/include/internal/arch/mm.h	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/include/internal/arch/mm.h	2005-06-21 23:42:58 UTC (rev 16212)
@@ -19,7 +19,7 @@
 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_ARCH_MM_H
 #define __NTOSKRNL_INCLUDE_INTERNAL_ARCH_MM_H
 
-#ifdef i386
+#ifdef _M_IX86
 #include <internal/i386/mm.h>
 #else
 #error "Unknown processor"

Modified: trunk/reactos/ntoskrnl/include/internal/arch/ps.h
--- trunk/reactos/ntoskrnl/include/internal/arch/ps.h	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/include/internal/arch/ps.h	2005-06-21 23:42:58 UTC (rev 16212)
@@ -19,7 +19,7 @@
 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_ARCH_PS_H
 #define __NTOSKRNL_INCLUDE_INTERNAL_ARCH_PS_H
 
-#ifdef i386
+#ifdef _M_IX86
 #include <internal/i386/ps.h>
 #define KiArchContextSwitch          KiSwapContext
 #define KiArchInitThreadWithContext  Ke386InitThreadWithContext

Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h
--- trunk/reactos/ntoskrnl/include/internal/i386/ke.h	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/include/internal/i386/ke.h	2005-06-21 23:42:58 UTC (rev 16212)
@@ -189,8 +189,7 @@
 
 typedef
 VOID
-STDCALL
-(*PKSYSTEM_ROUTINE)(PKSTART_ROUTINE StartRoutine,
+(STDCALL*PKSYSTEM_ROUTINE)(PKSTART_ROUTINE StartRoutine,
                     PVOID StartContext);
 
 VOID
@@ -215,7 +214,7 @@
 #define LOCK "lock ; "
 #else
 #define LOCK ""
-#define KeGetCurrentIrql(X) (((PKPCR)KPCR_BASE)->Irql)
+#define KeGetCurrentIrql() (((PKPCR)KPCR_BASE)->Irql)
 #endif
 
 #if defined(__GNUC__)

Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
--- trunk/reactos/ntoskrnl/include/internal/ke.h	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/include/internal/ke.h	2005-06-21 23:42:58 UTC (rev 16212)
@@ -224,13 +224,13 @@
 
 /* MACROS *************************************************************************/
 
-#define KeEnterCriticalRegion(X) \
+#define KeEnterCriticalRegion() \
 { \
     PKTHREAD _Thread = KeGetCurrentThread(); \
     if (_Thread) _Thread->KernelApcDisable--; \
 }
 
-#define KeLeaveCriticalRegion(X) \
+#define KeLeaveCriticalRegion() \
 { \
     PKTHREAD _Thread = KeGetCurrentThread(); \
     if((_Thread) && (++_Thread->KernelApcDisable == 0)) \
@@ -354,8 +354,8 @@
 VOID STDCALL
 DbgBreakPointNoBugCheck(VOID);
 
+VOID
 STDCALL
-VOID
 KeInitializeProfile(struct _KPROFILE* Profile,
                     struct _KPROCESS* Process,
                     PVOID ImageBase,
@@ -364,21 +364,21 @@
                     KPROFILE_SOURCE ProfileSource,
                     KAFFINITY Affinity);
 
+VOID
 STDCALL
-VOID
 KeStartProfile(struct _KPROFILE* Profile,
                PVOID Buffer);
 
+VOID
 STDCALL
-VOID
 KeStopProfile(struct _KPROFILE* Profile);
 
+ULONG
 STDCALL
-ULONG
 KeQueryIntervalProfile(KPROFILE_SOURCE ProfileSource);
 
+VOID
 STDCALL
-VOID
 KeSetIntervalProfile(KPROFILE_SOURCE ProfileSource,
                      ULONG Interval);
 

Modified: trunk/reactos/ntoskrnl/include/internal/ps.h
--- trunk/reactos/ntoskrnl/include/internal/ps.h	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/include/internal/ps.h	2005-06-21 23:42:58 UTC (rev 16212)
@@ -160,7 +160,7 @@
            ULONG                   OwnsSessionWorkingSetShared:1;
            ULONG                   ApcNeeded:1;
         };
-        ULONG                      SameThreadPassiveFlags;      /* 248 */
+        ULONG                      SameThreadApcFlags;          /* 248 */
     };
     UCHAR                          ForwardClusterOnly;          /* 24C */
     UCHAR                          DisablePageFaultClustering;  /* 24D */

Modified: trunk/reactos/ntoskrnl/io/driver.c
--- trunk/reactos/ntoskrnl/io/driver.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/io/driver.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -337,8 +337,8 @@
 IopDisplayLoadingMessage(PVOID ServiceName, 
                          BOOLEAN Unicode)
 {
+    CHAR TextBuffer[256];
     if (SetupMode) return;
-    CHAR TextBuffer[256];
     if (Unicode) 
     {
         sprintf(TextBuffer, "Loading %S...\n", (PWCHAR)ServiceName);

Modified: trunk/reactos/ntoskrnl/io/iomgr.c
--- trunk/reactos/ntoskrnl/io/iomgr.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/io/iomgr.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -15,16 +15,16 @@
 
 /* DATA ********************************************************************/
 
-POBJECT_TYPE EXPORTED IoDeviceObjectType = NULL;
-POBJECT_TYPE EXPORTED IoFileObjectType = NULL;
+POBJECT_TYPE IoDeviceObjectType = NULL;
+POBJECT_TYPE IoFileObjectType = NULL;
 extern POBJECT_TYPE IoControllerObjectType;
-ULONG         EXPORTED IoReadOperationCount = 0;
-LARGE_INTEGER EXPORTED IoReadTransferCount = {{0, 0}};
-ULONG         EXPORTED IoWriteOperationCount = 0;
-LARGE_INTEGER EXPORTED IoWriteTransferCount = {{0, 0}};
-ULONG                  IoOtherOperationCount = 0;
-LARGE_INTEGER          IoOtherTransferCount = {{0, 0}};
-KSPIN_LOCK    EXPORTED IoStatisticsLock = 0;
+ULONG IoReadOperationCount = 0;
+LARGE_INTEGER IoReadTransferCount = {{0, 0}};
+ULONG IoWriteOperationCount = 0;
+LARGE_INTEGER IoWriteTransferCount = {{0, 0}};
+ULONG IoOtherOperationCount = 0;
+LARGE_INTEGER IoOtherTransferCount = {{0, 0}};
+KSPIN_LOCK IoStatisticsLock = 0;
 
 GENERIC_MAPPING IopFileMapping = {
     FILE_GENERIC_READ,

Modified: trunk/reactos/ntoskrnl/io/irp.c
--- trunk/reactos/ntoskrnl/io/irp.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/io/irp.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -619,13 +619,6 @@
             }
 
             /* Probe and Lock */
-            _SEH_FILTER(FreeAndGoOn)
-            {
-                /* Free the IRP and its MDL */
-                IoFreeMdl(Irp->MdlAddress);
-                IoFreeIrp(Irp);
-                return EXCEPTION_CONTINUE_SEARCH;
-             }
             _SEH_TRY
             {
                 /* Do the probe */

Modified: trunk/reactos/ntoskrnl/io/wmi.c
--- trunk/reactos/ntoskrnl/io/wmi.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/io/wmi.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -19,8 +19,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 IoWMIRegistrationControl(
     IN PDEVICE_OBJECT DeviceObject,
     IN ULONG Action
@@ -33,8 +33,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 IoWMIAllocateInstanceIds(
     IN GUID *Guid,
     IN ULONG InstanceCount,
@@ -48,8 +48,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 IoWMISuggestInstanceName(
     IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
     IN PUNICODE_STRING SymbolicLinkName OPTIONAL,
@@ -64,8 +64,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 IoWMIWriteEvent(
     IN PVOID WnodeEventItem
     )
@@ -77,8 +77,8 @@
 /*
  * @unimplemented
  */
-STDCALL
-NTSTATUS IoWMIOpenBlock(
+NTSTATUS
+STDCALL IoWMIOpenBlock(
     IN GUID *DataBlockGuid,
     IN ULONG DesiredAccess,
     OUT PVOID *DataBlockObject
@@ -91,8 +91,8 @@
 /*
  * @unimplemented
  */
-STDCALL
-NTSTATUS IoWMIQueryAllData(
+NTSTATUS
+STDCALL IoWMIQueryAllData(
     IN PVOID DataBlockObject,
     IN OUT ULONG *InOutBufferSize,
     OUT PVOID OutBuffer
@@ -105,8 +105,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 IoWMIQueryAllDataMultiple(
     IN PVOID *DataBlockObjectList,
     IN ULONG ObjectCount,
@@ -121,8 +121,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 IoWMIQuerySingleInstance(
     IN PVOID DataBlockObject,
     IN PUNICODE_STRING InstanceName,
@@ -137,8 +137,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 IoWMIQuerySingleInstanceMultiple(
     IN PVOID *DataBlockObjectList,
     IN PUNICODE_STRING InstanceNames,
@@ -154,8 +154,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 IoWMISetSingleInstance(
     IN PVOID DataBlockObject,
     IN PUNICODE_STRING InstanceName,
@@ -171,8 +171,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 IoWMISetSingleItem(
     IN PVOID DataBlockObject,
     IN PUNICODE_STRING InstanceName,
@@ -189,8 +189,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 IoWMIExecuteMethod(
     IN PVOID DataBlockObject,
     IN PUNICODE_STRING InstanceName,
@@ -207,8 +207,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 IoWMISetNotificationCallback(
     IN PVOID Object,
     IN WMI_NOTIFICATION_CALLBACK Callback,
@@ -222,8 +222,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 IoWMIHandleToInstanceName(
     IN PVOID DataBlockObject,
     IN HANDLE FileHandle,
@@ -237,8 +237,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 IoWMIDeviceObjectToInstanceName(
     IN PVOID DataBlockObject,
     IN PDEVICE_OBJECT DeviceObject,

Modified: trunk/reactos/ntoskrnl/ke/ipi.c
--- trunk/reactos/ntoskrnl/ke/ipi.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/ke/ipi.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -89,7 +89,7 @@
 #endif
          }
       }
-      ((VOID STDCALL(*)(PVOID))(Prcb->SignalDone->WorkerRoutine))(Prcb->SignalDone->CurrentPacket[0]);
+      ((VOID (STDCALL*)(PVOID))(Prcb->SignalDone->WorkerRoutine))(Prcb->SignalDone->CurrentPacket[0]);
       Ke386TestAndClearBit(KeGetCurrentProcessorNumber(), &Prcb->SignalDone->TargetSet);
       if (InterlockedCompareExchangeUL(&Prcb->SignalDone->CurrentPacket[2], 0, 0))
       {
@@ -116,7 +116,7 @@
 
 VOID
 STDCALL
-KiIpiSendPacket(ULONG TargetSet, VOID STDCALL (*WorkerRoutine)(PVOID), PVOID Argument, ULONG Count, BOOLEAN Synchronize)
+KiIpiSendPacket(ULONG TargetSet, VOID (STDCALL*WorkerRoutine)(PVOID), PVOID Argument, ULONG Count, BOOLEAN Synchronize)
 {
     ULONG i, Processor, CurrentProcessor;
     PKPRCB Prcb, CurrentPrcb;

Modified: trunk/reactos/ntoskrnl/ke/kqueue.c
--- trunk/reactos/ntoskrnl/ke/kqueue.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/ke/kqueue.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -245,8 +245,8 @@
 /*
  * @unimplemented
  */
+PKDEVICE_QUEUE_ENTRY
 STDCALL
-PKDEVICE_QUEUE_ENTRY
 KeRemoveByKeyDeviceQueueIfBusy(IN PKDEVICE_QUEUE DeviceQueue,
                                IN ULONG SortKey)
 {

Modified: trunk/reactos/ntoskrnl/ke/main.c
--- trunk/reactos/ntoskrnl/ke/main.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/ke/main.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -82,7 +82,9 @@
 }
 
 VOID
+#ifdef __GNUC__
 __attribute((noinline))
+#endif
 KiSystemStartup(BOOLEAN BootProcessor)
 {
     DPRINT("KiSystemStartup(%d)\n", BootProcessor);

Modified: trunk/reactos/ntoskrnl/ke/profile.c
--- trunk/reactos/ntoskrnl/ke/profile.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/ke/profile.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -22,8 +22,8 @@
 
 /* FUNCTIONS *****************************************************************/
 
+VOID
 STDCALL
-VOID
 KeInitializeProfile(PKPROFILE Profile,
                     PKPROCESS Process,
                     PVOID ImageBase,
@@ -40,14 +40,14 @@
     Profile->Process = Process;
     Profile->RegionStart = ImageBase;
     Profile->BucketShift = BucketSize - 2; /* See ntinternals.net -- Alex */
-    Profile->RegionEnd = (PVOID)(ULONG_PTR)ImageBase + ImageSize;
+    Profile->RegionEnd = (PVOID)((ULONG_PTR)ImageBase + ImageSize);
     Profile->Active = FALSE;
     Profile->Source = ProfileSource;
     Profile->Affinity = Affinity;
 }
 
+VOID
 STDCALL
-VOID
 KeStartProfile(PKPROFILE Profile,
                PVOID Buffer)
 {
@@ -133,8 +133,8 @@
     if (!FreeBuffer) ExFreePool(SourceBuffer);
 }
 
+VOID
 STDCALL
-VOID
 KeStopProfile(PKPROFILE Profile)
 {
     KIRQL OldIrql;
@@ -178,8 +178,8 @@
     if (CurrentSource) ExFreePool(CurrentSource);
 }
 
+ULONG
 STDCALL
-ULONG
 KeQueryIntervalProfile(KPROFILE_SOURCE ProfileSource)
 {
     /* Check if this is the timer profile */
@@ -200,8 +200,8 @@
     }
 }
 
+VOID
 STDCALL
-VOID
 KeSetIntervalProfile(KPROFILE_SOURCE ProfileSource,
                      ULONG Interval)
 {
@@ -224,8 +224,8 @@
 /*
  * @implemented
  */
+VOID
 STDCALL
-VOID
 KeProfileInterrupt(PKTRAP_FRAME TrapFrame)
 {
     /* Called from HAL for Timer Profiling */
@@ -257,7 +257,7 @@
         }
 
         /* Get the Pointer to the Bucket Value representing this EIP */
-        BucketValue = (PULONG)(((ULONG_PTR)(Profile->Buffer +
+        BucketValue = (PULONG)((((ULONG_PTR)Profile->Buffer +
                                (TrapFrame->Eip - (ULONG_PTR)Profile->RegionStart))
                                 >> Profile->BucketShift) &~ 0x3);
 
@@ -276,8 +276,8 @@
  *         from the trap frame into the buffer, while using buckets and
  *         shifting like we specified. -- Alex
  */
+VOID
 STDCALL
-VOID
 KeProfileInterruptWithSource(IN PKTRAP_FRAME TrapFrame,
                              IN KPROFILE_SOURCE Source)
 {
@@ -291,8 +291,8 @@
 /*
  * @implemented
  */
+VOID
 STDCALL
-VOID
 KeSetProfileIrql(IN KIRQL ProfileIrql)
 {
     /* Set the IRQL at which Profiling will run */

Modified: trunk/reactos/ntoskrnl/ldr/loader.c
--- trunk/reactos/ntoskrnl/ldr/loader.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/ldr/loader.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -910,7 +910,7 @@
             Protect = PAGE_EXECUTE_READWRITE;
         }
 #endif
-        if (PageAddress < DriverBase + DriverSize)
+        if (PageAddress < RVA(DriverBase, DriverSize))
         {
             MmSetPageProtect(NULL, PageAddress, Protect);
         }
@@ -937,14 +937,14 @@
         PageAddress = (PVOID)((ULONG_PTR)PageAddress + PAGE_SIZE);
         while ((ULONG_PTR)PageAddress + PAGE_SIZE < (ULONG_PTR)BaseAddress + Length)
         {
-            if (PageAddress < DriverBase + DriverSize)
+            if (PageAddress < RVA(DriverBase, DriverSize))
             {
                 MmSetPageProtect(NULL, PageAddress, Protect);
             }
             PageAddress = (PVOID)((ULONG_PTR)PageAddress + PAGE_SIZE);
         }
         if (PageAddress < (PVOID)((ULONG_PTR)BaseAddress + Length) &&
-            PageAddress < DriverBase + DriverSize)
+            PageAddress < RVA(DriverBase, DriverSize))
         {
             Protect = LdrLookupPageProtection(PageAddress, DriverBase, &PENtHeaders->FileHeader, PESectionHeaders);
             MmSetPageProtect(NULL, PageAddress, Protect);
@@ -1214,20 +1214,20 @@
     Delta = (ULONG_PTR)DriverBase - NtHeaders->OptionalHeader.ImageBase;
     RelocationDir = (PIMAGE_BASE_RELOCATION)((ULONG_PTR)DriverBase + RelocationDDir->VirtualAddress);
     RelocationEnd = (PIMAGE_BASE_RELOCATION)((ULONG_PTR)RelocationDir + RelocationDDir->Size);
-    MaxAddress = DriverBase + DriverSize;
+    MaxAddress = RVA(DriverBase, DriverSize);
 
     while (RelocationDir < RelocationEnd &&
         RelocationDir->SizeOfBlock > 0)
     {
         Count = (RelocationDir->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / sizeof(USHORT);
-        Address = DriverBase + RelocationDir->VirtualAddress;
+        Address = RVA(DriverBase, RelocationDir->VirtualAddress);
         TypeOffset = (PUSHORT)(RelocationDir + 1);
 
         for (i = 0; i < Count; i++)
         {
             Offset = *TypeOffset & 0xFFF;
             Type = *TypeOffset >> 12;
-            ShortPtr = (PUSHORT)(Address + Offset);
+            ShortPtr = (PUSHORT)(RVA(Address, Offset));
 
             /* Don't relocate after the end of the loaded driver */
             if ((PVOID)ShortPtr >= MaxAddress)
@@ -1276,6 +1276,9 @@
 
     return STATUS_SUCCESS;
 }
+#ifndef PATH_MAX
+#define PATH_MAX 260
+#endif
 
 static NTSTATUS
 LdrPEGetOrLoadModule (
@@ -1552,16 +1555,16 @@
     }
 
     /* Get the import address list. */
-    ImportAddressList = (PVOID*)(DriverBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk);
+    ImportAddressList = (PVOID*)RVA(DriverBase, ImportModuleDirectory->FirstThunk);
 
     /* Get the list of functions to import. */
     if (ImportModuleDirectory->OriginalFirstThunk != 0)
     {
-        FunctionNameList = (PULONG) (DriverBase + (ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk);
+        FunctionNameList = (PULONG)RVA(DriverBase, ImportModuleDirectory->OriginalFirstThunk);
     }
     else
     {
-        FunctionNameList = (PULONG)(DriverBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk);
+        FunctionNameList = (PULONG)RVA(DriverBase, ImportModuleDirectory->FirstThunk);
     }
 
     /* Walk through function list and fixup addresses. */

Modified: trunk/reactos/ntoskrnl/ldr/resource.c
--- trunk/reactos/ntoskrnl/ldr/resource.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/ldr/resource.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -195,8 +195,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 LdrFindResourceDirectory_U(
 	IN PVOID   	BaseAddress,
 	IN PLDR_RESOURCE_INFO			ResourceInfo,
@@ -211,8 +211,8 @@
 /*
  * @unimplemented
  */
+NTSTATUS
 STDCALL
-NTSTATUS
 LdrEnumResources(
 	IN PVOID   	BaseAddress,
 	IN PLDR_RESOURCE_INFO			ResourceInfo,

Modified: trunk/reactos/ntoskrnl/ldr/rtl.c
--- trunk/reactos/ntoskrnl/ldr/rtl.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/ldr/rtl.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -17,8 +17,6 @@
 
 /* FUNCTIONS ****************************************************************/
 
-#define RVA(m, b) ((ULONG)b + m)
-
 NTSTATUS STDCALL
 LdrGetProcedureAddress (IN PVOID BaseAddress,
                         IN PANSI_STRING Name,

Modified: trunk/reactos/ntoskrnl/mm/iospace.c
--- trunk/reactos/ntoskrnl/mm/iospace.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/mm/iospace.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -145,7 +145,7 @@
    PVOID Address = BaseAddress;
 
    Offset = (ULONG_PTR)Address % PAGE_SIZE;
-   Address -= Offset;
+   Address = RVA(Address, - Offset);
    NumberOfBytes += Offset;
 
    MmLockAddressSpace(MmGetKernelAddressSpace());

Modified: trunk/reactos/ntoskrnl/mm/process.c
--- trunk/reactos/ntoskrnl/mm/process.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/mm/process.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -28,8 +28,8 @@
     PMADDRESS_SPACE ProcessAddressSpace = &Process->AddressSpace;
     PMEMORY_AREA MemoryArea;
     PHYSICAL_ADDRESS BoundaryAddressMultiple;
+    PVOID AllocatedBase = BaseAddress;
     BoundaryAddressMultiple.QuadPart = 0;
-    PVOID AllocatedBase = BaseAddress;
 
     /* Acquire the Lock */
     MmLockAddressSpace(ProcessAddressSpace);
@@ -54,7 +54,7 @@
                                     TRUE,
                                     FALSE,
                                     BoundaryAddressMultiple);
-        AllocatedBase = AllocatedBase - PAGE_SIZE;
+        AllocatedBase = RVA(AllocatedBase, -PAGE_SIZE);
     } while (Status != STATUS_SUCCESS);
 
     /* Initialize the Region */
@@ -69,7 +69,7 @@
     /* Unlock Address Space */
     DPRINT("Returning\n");
     MmUnlockAddressSpace(ProcessAddressSpace);
-    return AllocatedBase + PAGE_SIZE;
+    return RVA(AllocatedBase, PAGE_SIZE);
 }
 
 VOID
@@ -345,9 +345,9 @@
     PVOID BaseAddress;
     PMEMORY_AREA MemoryArea;
     PHYSICAL_ADDRESS BoundaryAddressMultiple;
-    BoundaryAddressMultiple.QuadPart = 0;
     ULONG ViewSize = 0;
     PVOID ImageBase = 0;
+    BoundaryAddressMultiple.QuadPart = 0;
 
     /* Initialize the Addresss Space */
     MmInitializeAddressSpace(Process, ProcessAddressSpace);

Modified: trunk/reactos/ntoskrnl/mm/section.c
--- trunk/reactos/ntoskrnl/mm/section.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/mm/section.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -1952,7 +1952,7 @@
    if (Section->AllocationAttributes & SEC_IMAGE)
    {
       Segment = MemoryArea->Data.SectionData.Segment;
-      Info->AllocationBase = MemoryArea->StartingAddress - Segment->VirtualAddress;
+      Info->AllocationBase = (PBYTE)MemoryArea->StartingAddress - Segment->VirtualAddress;
       Info->Type = MEM_IMAGE;
    }
    else

Modified: trunk/reactos/ntoskrnl/ob/handle.c
--- trunk/reactos/ntoskrnl/ob/handle.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/ob/handle.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -60,8 +60,8 @@
 ObpDecrementHandleCount(PVOID ObjectBody)
 {
   POBJECT_HEADER ObjectHeader = BODY_TO_HEADER(ObjectBody);
+  LONG NewHandleCount = InterlockedDecrement(&ObjectHeader->HandleCount);
   DPRINT("Header: %x\n", ObjectHeader);
-  LONG NewHandleCount = InterlockedDecrement(&ObjectHeader->HandleCount);
   DPRINT("NewHandleCount: %x\n", NewHandleCount);
   DPRINT("HEADER_TO_OBJECT_NAME: %x\n", HEADER_TO_OBJECT_NAME(ObjectHeader));
 
@@ -1008,15 +1008,15 @@
     if (FoundHeader && FoundHeader->Type == ObDirectoryType &&
         RemainingPath.Buffer)
     {
-        ObpAddEntryDirectory(FoundObject, Header, NULL);
-        ObjectAttached = TRUE;
-        
         /* The name was changed so let's update it */
         /* FIXME: TEMPORARY HACK This will go in ObFindObject in the next commit */
         PVOID NewName;
         PWSTR BufferPos = RemainingPath.Buffer;
         ULONG Delta = 0;
         
+        ObpAddEntryDirectory(FoundObject, Header, NULL);
+        ObjectAttached = TRUE;
+        
         ObjectNameInfo = HEADER_TO_OBJECT_NAME(Header);
         
         if (BufferPos[0] == L'\\')

Modified: trunk/reactos/ntoskrnl/ps/kill.c
--- trunk/reactos/ntoskrnl/ps/kill.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/ps/kill.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -24,8 +24,8 @@
 
 /* FUNCTIONS *****************************************************************/
 
+VOID
 STDCALL
-VOID
 PspReapRoutine(PVOID Context)
 {
     KIRQL OldIrql;

Modified: trunk/reactos/ntoskrnl/ps/psmgr.c
--- trunk/reactos/ntoskrnl/ps/psmgr.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/ps/psmgr.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -173,8 +173,7 @@
 				ProcessObject,
 				sizeof(EPROCESS),
 				FALSE);
-   PsIdleProcess->Pcb.DirectoryTableBase =
-     (LARGE_INTEGER)(LONGLONG)(ULONG)MmGetPageDirectory();
+   PsIdleProcess->Pcb.DirectoryTableBase.QuadPart = (ULONG_PTR)MmGetPageDirectory();
    strcpy(PsIdleProcess->ImageFileName, "Idle");
 
    /*
@@ -234,6 +233,7 @@
    InitializeListHead(&PsInitialSystemProcess->ThreadListHead);
 
 #ifndef SCHED_REWRITE
+    {
     PTOKEN BootToken;
 
     /* No parent, this is the Initial System Process. Assign Boot Token */
@@ -241,6 +241,7 @@
     BootToken->TokenInUse = TRUE;
     PsInitialSystemProcess->Token.Object = BootToken; /* FIXME */
     ObReferenceObject(BootToken);
+	}
 #endif
 }
 

Modified: trunk/reactos/ntoskrnl/se/acl.c
--- trunk/reactos/ntoskrnl/se/acl.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/se/acl.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -15,8 +15,8 @@
 
 /* GLOBALS ******************************************************************/
 
-PACL EXPORTED SePublicDefaultDacl = NULL;
-PACL EXPORTED SeSystemDefaultDacl = NULL;
+PACL SePublicDefaultDacl = NULL;
+PACL SeSystemDefaultDacl = NULL;
 
 PACL SePublicDefaultUnrestrictedDacl = NULL;
 PACL SePublicOpenDacl = NULL;

Modified: trunk/reactos/ntoskrnl/se/luid.c
--- trunk/reactos/ntoskrnl/se/luid.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/se/luid.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -39,7 +39,7 @@
   /* atomically increment the luid */
   do
   {
-    PrevLuid = (volatile LARGE_INTEGER)LuidValue;
+    PrevLuid = LuidValue;
     NewLuid = RtlLargeIntegerAdd(PrevLuid,
                                  LuidIncrement);
   } while(ExfInterlockedCompareExchange64(&LuidValue.QuadPart,

Modified: trunk/reactos/ntoskrnl/se/semgr.c
--- trunk/reactos/ntoskrnl/se/semgr.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/se/semgr.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -16,7 +16,7 @@
 
 /* GLOBALS ******************************************************************/
 
-PSE_EXPORTS EXPORTED SeExports = NULL;
+PSE_EXPORTS SeExports = NULL;
 SE_EXPORTS SepExports;
 
 static ERESOURCE SepSubjectContextLock;

Modified: trunk/reactos/ntoskrnl/se/token.c
--- trunk/reactos/ntoskrnl/se/token.c	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/ntoskrnl/se/token.c	2005-06-21 23:42:58 UTC (rev 16212)
@@ -1820,18 +1820,20 @@
   NTSTATUS Status;
   ULONG uSize;
   ULONG i;
+  ULONG uLocalSystemLength;
+  ULONG uWorldLength;
+  ULONG uAuthUserLength;
+  ULONG uAdminsLength;
+  PTOKEN AccessToken;
+  PVOID SidArea;
 
   PAGED_CODE();
 
-  ULONG uLocalSystemLength = RtlLengthSid(SeLocalSystemSid);
-  ULONG uWorldLength       = RtlLengthSid(SeWorldSid);
-  ULONG uAuthUserLength    = RtlLengthSid(SeAuthenticatedUserSid);
-  ULONG uAdminsLength      = RtlLengthSid(SeAliasAdminsSid);
+  uLocalSystemLength = RtlLengthSid(SeLocalSystemSid);
+  uWorldLength       = RtlLengthSid(SeWorldSid);
+  uAuthUserLength    = RtlLengthSid(SeAuthenticatedUserSid);
+  uAdminsLength      = RtlLengthSid(SeAliasAdminsSid);
 
-  PTOKEN AccessToken;
-
-  PVOID SidArea;
-
  /*
   * Initialize the token
   */

Modified: trunk/reactos/w32api/include/ddk/batclass.h
--- trunk/reactos/w32api/include/ddk/batclass.h	2005-06-21 22:07:44 UTC (rev 16211)
+++ trunk/reactos/w32api/include/ddk/batclass.h	2005-06-21 23:42:58 UTC (rev 16212)
@@ -183,12 +183,12 @@
   CTL_CODE(FILE_DEVICE_BATTERY, 0x13, METHOD_BUFFERED, FILE_READ_ACCESS)
 
 
-typedef NTSTATUS DDKAPI
-(*BCLASS_DISABLE_STATUS_NOTIFY)(
+typedef NTSTATUS
+(DDKAPI*BCLASS_DISABLE_STATUS_NOTIFY)(
   IN PVOID  Context);
 
-typedef NTSTATUS DDKAPI
-(*BCLASS_QUERY_INFORMATION)(
+typedef NTSTATUS
+(DDKAPI*BCLASS_QUERY_INFORMATION)(
   IN PVOID  Context,
   IN ULONG  BatteryTag,
   IN BATTERY_QUERY_INFORMATION_LEVEL  Level,
@@ -197,26 +197,26 @@
   IN ULONG  BufferLength,
   OUT PULONG  ReturnedLength);
 
-typedef NTSTATUS DDKAPI
-(*BCLASS_QUERY_STATUS)(
+typedef NTSTATUS
+(DDKAPI*BCLASS_QUERY_STATUS)(
   IN PVOID  Context,
   IN ULONG  BatteryTag,
   OUT PBATTERY_STATUS  BatteryStatus);
 
-typedef NTSTATUS DDKAPI
-(*BCLASS_QUERY_TAG)(
+typedef NTSTATUS
+(DDKAPI*BCLASS_QUERY_TAG)(
   IN PVOID  Context,
   OUT PULONG  BatteryTag);
 
[truncated at 1000 lines; 333 more skipped]