Portability fixes.
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
Modified: trunk/reactos/ntoskrnl/include/internal/pool.h
Modified: trunk/reactos/ntoskrnl/ke/main.c
Modified: trunk/reactos/ntoskrnl/mm/RPoolMgr.h
Modified: trunk/reactos/ntoskrnl/mm/freelist.c
Modified: trunk/reactos/ntoskrnl/mm/kmap.c
Modified: trunk/reactos/ntoskrnl/mm/marea.c
Modified: trunk/reactos/ntoskrnl/mm/mdl.c
Modified: trunk/reactos/ntoskrnl/mm/mm.c
Modified: trunk/reactos/ntoskrnl/mm/mminit.c
Modified: trunk/reactos/ntoskrnl/mm/npool.c
Modified: trunk/reactos/ntoskrnl/mm/pagefile.c
Modified: trunk/reactos/ntoskrnl/mm/pageop.c
Modified: trunk/reactos/ntoskrnl/mm/section.c

Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
--- trunk/reactos/ntoskrnl/include/internal/ke.h	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/include/internal/ke.h	2005-01-12 10:05:31 UTC (rev 12950)
@@ -58,7 +58,7 @@
 		 ULONG IpiRequest);
 
 VOID  
-KeIpiGenericCall(VOID STDCALL (*WorkerRoutine)(PVOID), 
+KeIpiGenericCall(VOID (STDCALL *WorkerRoutine)(PVOID), 
 		 PVOID Argument);
 
 /* next file ***************************************************************/

Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
--- trunk/reactos/ntoskrnl/include/internal/mm.h	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h	2005-01-12 10:05:31 UTC (rev 12950)
@@ -453,9 +453,9 @@
 
 VOID MiShutdownMemoryManager(VOID);
 
-VOID MmInit1(ULONG FirstKernelPhysAddress, 
-	     ULONG LastKernelPhysAddress,
-	     ULONG LastKernelAddress,
+VOID MmInit1(ULONG_PTR FirstKernelPhysAddress, 
+	     ULONG_PTR LastKernelPhysAddress,
+	     ULONG_PTR LastKernelAddress,
 	     PADDRESS_RANGE BIOSMemoryMap,
 	     ULONG AddressRangeCount,
 	     ULONG MaxMemInMeg);
@@ -507,11 +507,11 @@
 /* mm.c **********************************************************************/
 
 NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
-		       ULONG Address,
+		       ULONG_PTR Address,
 		       BOOLEAN FromMdl);
 
 NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
-			   ULONG Address,
+			   ULONG_PTR Address,
 			   BOOLEAN FromMdl);
 
 /* anonmem.c *****************************************************************/
@@ -633,10 +633,10 @@
 
 ULONG MmGetLockCountPage(PFN_TYPE Page);
 
-PVOID MmInitializePageList(PVOID FirstPhysKernelAddress,
-		           PVOID LastPhysKernelAddress,
+PVOID MmInitializePageList(ULONG_PTR FirstPhysKernelAddress,
+		           ULONG_PTR LastPhysKernelAddress,
 			   ULONG MemorySizeInPages,
-			   ULONG LastKernelBase,
+			   ULONG_PTR LastKernelBase,
 			   PADDRESS_RANGE BIOSMemoryMap,
 			   ULONG AddressRangeCount);
 

Modified: trunk/reactos/ntoskrnl/include/internal/pool.h
--- trunk/reactos/ntoskrnl/include/internal/pool.h	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/include/internal/pool.h	2005-01-12 10:05:31 UTC (rev 12950)
@@ -45,7 +45,7 @@
  */
 #define MM_CACHE_LINE_SIZE  32
 
-#define MM_ROUND_UP(x,s)    ((PVOID)(((ULONG)(x)+(s)-1) & ~((s)-1)))
-#define MM_ROUND_DOWN(x,s)  ((PVOID)(((ULONG)(x)) & ~((s)-1)))
+#define MM_ROUND_UP(x,s)    ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
+#define MM_ROUND_DOWN(x,s)  ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
 
 #endif /* __INTERNAL_POOL_H */

Modified: trunk/reactos/ntoskrnl/ke/main.c
--- trunk/reactos/ntoskrnl/ke/main.c	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/ke/main.c	2005-01-12 10:05:31 UTC (rev 12950)
@@ -76,9 +76,9 @@
 static CHAR KeLoaderCommandLine[256];
 static ADDRESS_RANGE KeMemoryMap[64];
 static ULONG KeMemoryMapRangeCount;
-static ULONG FirstKrnlPhysAddr;
-static ULONG LastKrnlPhysAddr;
-static ULONG LastKernelAddress;
+static ULONG_PTR FirstKrnlPhysAddr;
+static ULONG_PTR LastKrnlPhysAddr;
+static ULONG_PTR LastKernelAddress;
 volatile BOOLEAN Initialized = FALSE;
 extern ULONG MmCoreDumpType;
 extern CHAR KiTimerSystemAuditing;

Modified: trunk/reactos/ntoskrnl/mm/RPoolMgr.h
--- trunk/reactos/ntoskrnl/mm/RPoolMgr.h	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/mm/RPoolMgr.h	2005-01-12 10:05:31 UTC (rev 12950)
@@ -13,16 +13,16 @@
 
 typedef unsigned long rulong;
 
-#define R_IS_POOL_PTR(pool,ptr) (void*)(ptr) >= pool->UserBase && (char*)(ptr) < ((char*)pool->UserBase+pool->UserSize)
+#define R_IS_POOL_PTR(pool,ptr) (void*)(ptr) >= pool->UserBase && (ULONG_PTR)(ptr) < ((ULONG_PTR)pool->UserBase + pool->UserSize)
 #define R_ASSERT_PTR(pool,ptr) ASSERT( R_IS_POOL_PTR(pool,ptr) )
 #define R_ASSERT_SIZE(pool,sz) ASSERT( sz > (sizeof(R_USED)+2*R_RZ) && sz >= sizeof(R_FREE) && sz < pool->UserSize )
 
 #ifndef R_ROUND_UP
-#define R_ROUND_UP(x,s)    ((PVOID)(((rulong)(x)+(s)-1) & ~((s)-1)))
+#define R_ROUND_UP(x,s)    ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
 #endif//R_ROUND_UP
 
 #ifndef R_ROUND_DOWN
-#define R_ROUND_DOWN(x,s)  ((PVOID)(((rulong)(x)) & ~((s)-1)))
+#define R_ROUND_DOWN(x,s)  ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
 #endif//R_ROUND_DOWN
 
 #ifndef R_QUEMIN
@@ -79,7 +79,7 @@
 	rulong Status : 2;
 	rulong Size;
 #if R_STACK
-	rulong LastOwnerStack[R_STACK];
+	ULONG_PTR LastOwnerStack[R_STACK];
 #endif//R_STACK
 	struct _R_FREE* NextFree;
 	struct _R_FREE* PrevFree;
@@ -95,7 +95,7 @@
 	rulong Status : 2;
 	rulong Size;
 #if R_STACK
-	rulong LastOwnerStack[R_STACK];
+	ULONG_PTR LastOwnerStack[R_STACK];
 #endif//R_STACK
 	struct _R_USED* NextUsed;
 #if R_RZ
@@ -245,7 +245,7 @@
 		pool->FirstFree = Item->NextFree;
 	}
 #if defined(DBG) || defined(KDBG)
-	Item->NextFree = Item->PrevFree = (PR_FREE)0xDEADBEEF;
+	Item->NextFree = Item->PrevFree = (PR_FREE)(ULONG_PTR)0xDEADBEEF;
 #endif//DBG || KDBG
 }
 
@@ -281,7 +281,7 @@
 	block->Status = 0;
 	RFreeFillStack ( block );
 #if defined(DBG) || defined(KDBG)
-	block->PrevFree = block->NextFree = (PR_FREE)0xDEADBEEF;
+	block->PrevFree = block->NextFree = (PR_FREE)(ULONG_PTR)0xDEADBEEF;
 #endif//DBG || KDBG
 	return block;
 }
@@ -644,7 +644,7 @@
 
 	// now add the block to the used block list
 #if defined(DBG) || defined(KDBG)
-	Block->NextUsed = (PR_USED)0xDEADBEEF;
+	Block->NextUsed = (PR_USED)(ULONG_PTR)0xDEADBEEF;
 #endif//R_USED_LIST
 
 	Block->Tag = Tag;

Modified: trunk/reactos/ntoskrnl/mm/freelist.c
--- trunk/reactos/ntoskrnl/mm/freelist.c	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/mm/freelist.c	2005-01-12 10:05:31 UTC (rev 12950)
@@ -284,10 +284,10 @@
          
 
 PVOID INIT_FUNCTION
-MmInitializePageList(PVOID FirstPhysKernelAddress,
-                     PVOID LastPhysKernelAddress,
+MmInitializePageList(ULONG_PTR FirstPhysKernelAddress,
+                     ULONG_PTR LastPhysKernelAddress,
                      ULONG MemorySizeInPages,
-                     ULONG LastKernelAddress,
+                     ULONG_PTR LastKernelAddress,
                      PADDRESS_RANGE BIOSMemoryMap,
                      ULONG AddressRangeCount)
 /*
@@ -331,9 +331,9 @@
    DPRINT("Reserved %d\n", Reserved);
 
    LastKernelAddress = PAGE_ROUND_UP(LastKernelAddress);
-   LastKernelAddress = ((ULONG)LastKernelAddress + (Reserved * PAGE_SIZE));
-   LastPhysKernelAddress = (PVOID)PAGE_ROUND_UP(LastPhysKernelAddress);
-   LastPhysKernelAddress = (char*)LastPhysKernelAddress + (Reserved * PAGE_SIZE);
+   LastKernelAddress = ((ULONG_PTR)LastKernelAddress + (Reserved * PAGE_SIZE));
+   LastPhysKernelAddress = (ULONG_PTR)PAGE_ROUND_UP(LastPhysKernelAddress);
+   LastPhysKernelAddress = (ULONG_PTR)LastPhysKernelAddress + (Reserved * PAGE_SIZE);
 
    MmStats.NrTotalPages = 0;
    MmStats.NrSystemPages = 0;
@@ -349,7 +349,7 @@
    LastPage = MmPageArraySize;
    for (i = 0; i < Reserved; i++)
    {
-      PVOID Address = (char*)(ULONG)MmPageArray + (i * PAGE_SIZE);
+      PVOID Address = (char*)MmPageArray + (i * PAGE_SIZE);
       ULONG j, start, end;
       if (!MmIsPagePresent(NULL, Address))
       {

Modified: trunk/reactos/ntoskrnl/mm/kmap.c
--- trunk/reactos/ntoskrnl/mm/kmap.c	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/mm/kmap.c	2005-01-12 10:05:31 UTC (rev 12950)
@@ -32,7 +32,7 @@
 ExUnmapPage(PVOID Addr)
 {
    KIRQL oldIrql;
-   ULONG Base = ((char*)Addr - (char*)MM_KERNEL_MAP_BASE) / PAGE_SIZE;
+   ULONG_PTR Base = ((ULONG_PTR)Addr - (ULONG_PTR)MM_KERNEL_MAP_BASE) / PAGE_SIZE;
 
    DPRINT("ExUnmapPage(Addr %x)\n",Addr);
 
@@ -93,12 +93,12 @@
 {
    KIRQL oldlvl;
    PVOID Addr;
-   ULONG Base;
+   ULONG_PTR Base;
    NTSTATUS Status;
 
    KeAcquireSpinLock(&AllocMapLock, &oldlvl);
    Base = RtlFindClearBitsAndSet(&AllocMap, 1, AllocMapHint);
-   if (Base != 0xFFFFFFFF)
+   if (Base != (ULONG_PTR)-1)
    {
       AllocMapHint = Base + 1;
       KeReleaseSpinLock(&AllocMapLock, oldlvl);
@@ -131,7 +131,7 @@
 MiFreeNonPagedPoolRegion(PVOID Addr, ULONG Count, BOOLEAN Free)
 {
    ULONG i;
-   ULONG Base = ((char*)Addr - (char*)MM_KERNEL_MAP_BASE) / PAGE_SIZE;
+   ULONG_PTR Base = ((char*)Addr - (char*)MM_KERNEL_MAP_BASE) / PAGE_SIZE;
    KIRQL oldlvl;
 
    for (i = 0; i < Count; i++)
@@ -154,12 +154,12 @@
  * FUNCTION: Allocates a region of pages within the nonpaged pool area
  */
 {
-   ULONG Base;
+   ULONG_PTR Base;
    KIRQL oldlvl;
 
    KeAcquireSpinLock(&AllocMapLock, &oldlvl);
    Base = RtlFindClearBitsAndSet(&AllocMap, nr_pages, AllocMapHint);
-   if (Base == 0xFFFFFFFF)
+   if (Base == (ULONG_PTR)-1)
    {
       DbgPrint("CRITICAL: Out of non-paged pool space\n");
       KEBUGCHECK(0);

Modified: trunk/reactos/ntoskrnl/mm/marea.c
--- trunk/reactos/ntoskrnl/mm/marea.c	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/mm/marea.c	2005-01-12 10:05:31 UTC (rev 12950)
@@ -188,7 +188,7 @@
         Node != NULL;
         Node = MmIterateNextNode(Node))
    {
-      DbgPrint("Start %x End %x Attributes %x\n",
+      DbgPrint("Start %p End %p Attributes %x\n",
                Node->StartingAddress, Node->EndingAddress,
                Node->Attributes);
    }
@@ -203,7 +203,7 @@
 {
    PMEMORY_AREA Node = AddressSpace->MemoryAreaRoot;
 
-   DPRINT("MmLocateMemoryAreaByAddress(AddressSpace %x, Address %x)\n",
+   DPRINT("MmLocateMemoryAreaByAddress(AddressSpace %p, Address %p)\n",
            AddressSpace, Address);
 
    if (!(KdDebugState & KD_DEBUG_SCREEN))
@@ -217,13 +217,13 @@
          Node = Node->RightChild;
       else
       {
-         DPRINT("MmLocateMemoryAreaByAddress(%x): %x [%x - %x]\n",
+         DPRINT("MmLocateMemoryAreaByAddress(%p): %p [%p - %p]\n",
                 Address, Node, Node->StartingAddress, Node->EndingAddress);
          return Node;
       }
    }
 
-   DPRINT("MmLocateMemoryAreaByAddress(%x): 0\n", Address);
+   DPRINT("MmLocateMemoryAreaByAddress(%p): 0\n", Address);
    return NULL;
 }
 
@@ -250,24 +250,24 @@
       if (Node->StartingAddress >= Address &&
           Node->StartingAddress < Extent)
       {
-         DPRINT("MmLocateMemoryAreaByRegion(%x - %x): %x - %x\n",
-                Address, Address + Length, Node->StartingAddress,
+         DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n",
+                Address, (ULONG_PTR)Address + Length, Node->StartingAddress,
                 Node->EndingAddress);
          return Node;
       }
       if (Node->EndingAddress > Address &&
           Node->EndingAddress < Extent)
       {
-         DPRINT("MmLocateMemoryAreaByRegion(%x - %x): %x - %x\n",
-                Address, Address + Length, Node->StartingAddress,
+         DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n",
+                Address, (ULONG_PTR)Address + Length, Node->StartingAddress,
                 Node->EndingAddress);
          return Node;
       }
       if (Node->StartingAddress <= Address &&
           Node->EndingAddress >= Extent)
       {
-         DPRINT("MmLocateMemoryAreaByRegion(%x - %x): %x - %x\n",
-                Address, Address + Length, Node->StartingAddress,
+         DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n",
+                Address, (ULONG_PTR)Address + Length, Node->StartingAddress,
                 Node->EndingAddress);
          return Node;
       }
@@ -417,9 +417,9 @@
    Node = AddressSpace->MemoryAreaRoot;
    do
    {
-      DPRINT("marea->EndingAddress: %x Node->StartingAddress: %x\n",
+      DPRINT("marea->EndingAddress: %p Node->StartingAddress: %p\n",
              marea->EndingAddress, Node->StartingAddress);
-      DPRINT("marea->StartingAddress: %x Node->EndingAddress: %x\n",
+      DPRINT("marea->StartingAddress: %p Node->EndingAddress: %p\n",
              marea->StartingAddress, Node->EndingAddress);
       ASSERT(marea->EndingAddress <= Node->StartingAddress ||
              marea->StartingAddress >= Node->EndingAddress);
@@ -467,7 +467,7 @@
 
    MmVerifyMemoryAreas(AddressSpace);
 
-   DPRINT("LowestAddress: %x HighestAddress: %x\n",
+   DPRINT("LowestAddress: %p HighestAddress: %p\n",
           AddressSpace->LowestAddress, HighestAddress);
 
    AlignedAddress = MM_ROUND_UP(AddressSpace->LowestAddress, Granularity);
@@ -475,9 +475,9 @@
    /* Special case for empty tree. */
    if (AddressSpace->MemoryAreaRoot == NULL)
    {
-      if (HighestAddress - AlignedAddress >= Length)
+      if ((ULONG_PTR)HighestAddress - (ULONG_PTR)AlignedAddress >= Length)
       {
-         DPRINT("MmFindGapBottomUp: %x\n", AlignedAddress);
+         DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress);
          return AlignedAddress;
       }
       DPRINT("MmFindGapBottomUp: 0\n");
@@ -497,9 +497,9 @@
 
       AlignedAddress = MM_ROUND_UP(PreviousNode->EndingAddress, Granularity);
       if (Node->StartingAddress > AlignedAddress &&
-          Node->StartingAddress - AlignedAddress >= Length)
+          (ULONG_PTR)Node->StartingAddress - (ULONG_PTR)AlignedAddress >= Length)
       {
-         DPRINT("MmFindGapBottomUp: %x\n", AlignedAddress);
+         DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress);
          return AlignedAddress;
       }
 
@@ -508,18 +508,18 @@
 
    /* Check if there is enough space after the last memory area. */
    AlignedAddress = MM_ROUND_UP(PreviousNode->EndingAddress, Granularity);
-   if (HighestAddress - AlignedAddress >= Length)
+   if ((ULONG_PTR)HighestAddress - (ULONG_PTR)AlignedAddress >= Length)
    {
-      DPRINT("MmFindGapBottomUp: %x\n", AlignedAddress);
+      DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress);
       return AlignedAddress;
    }
 
    /* Check if there is enough space before the first memory area. */
    AlignedAddress = MM_ROUND_UP(AddressSpace->LowestAddress, Granularity);
    if (FirstNode->StartingAddress > AlignedAddress &&
-       FirstNode->StartingAddress - AlignedAddress >= Length)
+       (ULONG_PTR)FirstNode->StartingAddress - (ULONG_PTR)AlignedAddress >= Length)
    {
-      DPRINT("MmFindGapBottomUp: %x\n", AlignedAddress);
+      DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress);
       return AlignedAddress;
    }
 
@@ -542,10 +542,10 @@
 
    MmVerifyMemoryAreas(AddressSpace);
 
-   DPRINT("LowestAddress: %x HighestAddress: %x\n",
+   DPRINT("LowestAddress: %p HighestAddress: %p\n",
           AddressSpace->LowestAddress, HighestAddress);
 
-   AlignedAddress = MM_ROUND_DOWN(HighestAddress - Length + 1, Granularity);
+   AlignedAddress = MM_ROUND_DOWN((ULONG_PTR)HighestAddress - Length + 1, Granularity);
 
    /* Check for overflow. */
    if (AlignedAddress > HighestAddress)
@@ -556,7 +556,7 @@
    {
       if (AlignedAddress >= (PVOID)AddressSpace->LowestAddress)
       {
-         DPRINT("MmFindGapTopDown: %x\n", AlignedAddress);
+         DPRINT("MmFindGapTopDown: %p\n", AlignedAddress);
          return AlignedAddress;
       }
       DPRINT("MmFindGapTopDown: 0\n");
@@ -569,7 +569,7 @@
    /* Check if there is enough space after the last memory area. */
    if (Node->EndingAddress <= AlignedAddress)
    {
-      DPRINT("MmFindGapTopDown: %x\n", AlignedAddress);
+      DPRINT("MmFindGapTopDown: %p\n", AlignedAddress);
       return AlignedAddress;
    }
 
@@ -581,7 +581,7 @@
       if (Node == NULL)
          break;
 
-      AlignedAddress = MM_ROUND_DOWN(PreviousNode->StartingAddress - Length + 1, Granularity);
+      AlignedAddress = MM_ROUND_DOWN((ULONG_PTR)PreviousNode->StartingAddress - Length + 1, Granularity);
 
       /* Check for overflow. */
       if (AlignedAddress > PreviousNode->StartingAddress)
@@ -589,14 +589,14 @@
       
       if (Node->EndingAddress <= AlignedAddress)
       {
-         DPRINT("MmFindGapTopDown: %x\n", AlignedAddress);
+         DPRINT("MmFindGapTopDown: %p\n", AlignedAddress);
          return AlignedAddress;
       }
 
       PreviousNode = Node;
    }
 
-   AlignedAddress = MM_ROUND_DOWN(PreviousNode->StartingAddress - Length + 1, Granularity);
+   AlignedAddress = MM_ROUND_DOWN((ULONG_PTR)PreviousNode->StartingAddress - Length + 1, Granularity);
 
    /* Check for overflow. */
    if (AlignedAddress > PreviousNode->StartingAddress)
@@ -604,7 +604,7 @@
 
    if (AlignedAddress >= (PVOID)AddressSpace->LowestAddress)
    {
-      DPRINT("MmFindGapTopDown: %x\n", AlignedAddress);
+      DPRINT("MmFindGapTopDown: %p\n", AlignedAddress);
       return AlignedAddress;
    }
 
@@ -675,13 +675,15 @@
 
    if (RightNeighbour)
    {
-      DPRINT("MmFindGapAtAddress: %x [%x]\n", Address, RightNeighbour->StartingAddress - Address);
-      return RightNeighbour->StartingAddress - Address;
+      DPRINT("MmFindGapAtAddress: %p [%p]\n", Address,
+             (ULONG_PTR)RightNeighbour->StartingAddress - (ULONG_PTR)Address);
+      return (ULONG_PTR)RightNeighbour->StartingAddress - (ULONG_PTR)Address;
    }
    else
    {
-      DPRINT("MmFindGapAtAddress: %x [%x]\n", Address, HighestAddress - Address);
-      return HighestAddress - Address;
+      DPRINT("MmFindGapAtAddress: %p [%p]\n", Address,
+             (ULONG_PTR)HighestAddress - (ULONG_PTR)Address);
+      return (ULONG_PTR)HighestAddress - (ULONG_PTR)Address;
    }
 }
 
@@ -726,7 +728,7 @@
    PVOID FreePageContext)
 {
    PMEMORY_AREA *ParentReplace;
-   PVOID Address;
+   ULONG_PTR Address;
    PVOID EndAddress;
    PEPROCESS CurrentProcess = PsGetCurrentProcess();
 
@@ -737,7 +739,9 @@
    }
 
    EndAddress = MM_ROUND_UP(MemoryArea->EndingAddress, PAGE_SIZE); 
-   for (Address = MemoryArea->StartingAddress; Address < EndAddress; Address += PAGE_SIZE)
+   for (Address = (ULONG_PTR)MemoryArea->StartingAddress;
+        Address < (ULONG_PTR)EndAddress;
+        Address += PAGE_SIZE)
    {
       if (MemoryArea->Type == MEMORY_AREA_IO_MAPPING)
       {
@@ -866,8 +870,8 @@
 {
    PMEMORY_AREA MemoryArea;
 
-   DPRINT("MmFreeMemoryArea(AddressSpace %x, BaseAddress %x, "
-          "FreePageContext %d)\n", AddressSpace, BaseAddress,
+   DPRINT("MmFreeMemoryArea(AddressSpace %p, BaseAddress %p, "
+          "FreePageContext %p)\n", AddressSpace, BaseAddress,
           FreePageContext);
 
    MmVerifyMemoryAreas(AddressSpace);
@@ -926,9 +930,9 @@
    ULONG tmpLength;
    PMEMORY_AREA MemoryArea;
 
-   DPRINT("MmCreateMemoryArea(Type %d, BaseAddress %x, "
-          "*BaseAddress %x, Length %x, Attributes %x, TopDown: %x, "
-          "FixedAddress %x, Result %x)\n",
+   DPRINT("MmCreateMemoryArea(Type %d, BaseAddress %p, "
+          "*BaseAddress %p, Length %p, Attributes %x, TopDown: %x, "
+          "FixedAddress %x, Result %p)\n",
           Type, BaseAddress, *BaseAddress, Length, Attributes, TopDown,
           FixedAddress, Result);
 
@@ -988,7 +992,7 @@
    RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA));
    MemoryArea->Type = Type;
    MemoryArea->StartingAddress = *BaseAddress;
-   MemoryArea->EndingAddress = *BaseAddress + tmpLength;
+   MemoryArea->EndingAddress = (PVOID)((ULONG_PTR)*BaseAddress + tmpLength);
    MemoryArea->Attributes = Attributes;
    MemoryArea->LockCount = 0;
    MemoryArea->Process = Process;
@@ -999,7 +1003,7 @@
 
    *Result = MemoryArea;
 
-   DPRINT("MmCreateMemoryArea() succeeded (%x)\n", *BaseAddress);
+   DPRINT("MmCreateMemoryArea() succeeded (%p)\n", *BaseAddress);
    return STATUS_SUCCESS;
 }
 

Modified: trunk/reactos/ntoskrnl/mm/mdl.c
--- trunk/reactos/ntoskrnl/mm/mdl.c	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/mm/mdl.c	2005-01-12 10:05:31 UTC (rev 12950)
@@ -98,11 +98,11 @@
 PVOID
 MmGetMdlPageAddress(PMDL Mdl, PVOID Offset)
 {
-   PULONG MdlPages;
+   PPFN_NUMBER MdlPages;
 
-   MdlPages = (PULONG)(Mdl + 1);
+   MdlPages = (PPFN_NUMBER)(Mdl + 1);
 
-   return((PVOID)MdlPages[((ULONG)Offset) / PAGE_SIZE]);
+   return((PVOID)MdlPages[((ULONG_PTR)Offset) / PAGE_SIZE]);
 }
 
 
@@ -123,8 +123,8 @@
  */
 {
    ULONG i;
-   PULONG MdlPages;
-   PFN_TYPE Page;
+   PPFN_NUMBER MdlPages;
+   PFN_NUMBER Page;
 
    /* 
     * MmProbeAndLockPages MUST have been called to lock this mdl!
@@ -161,7 +161,7 @@
    }
 
 
-   MdlPages = (PULONG)(Mdl + 1);
+   MdlPages = (PPFN_NUMBER)(Mdl + 1);
    for (i=0; i<(PAGE_ROUND_UP(Mdl->ByteCount+Mdl->ByteOffset)/PAGE_SIZE); i++)
    {
       Page = MdlPages[i];
@@ -422,7 +422,7 @@
        
       if (!MmIsPagePresent(NULL, Address))
       {
-         Status = MmNotPresentFault(Mode, (ULONG)Address, TRUE);
+         Status = MmNotPresentFault(Mode, (ULONG_PTR)Address, TRUE);
          if (!NT_SUCCESS(Status))
          {
             for (j = 0; j < i; j++)
@@ -442,7 +442,7 @@
       if ((Operation == IoWriteAccess || Operation == IoModifyAccess) &&
           (!(MmGetPageProtect(NULL, (PVOID)Address) & PAGE_READWRITE)))
       {
-         Status = MmAccessFault(Mode, (ULONG)Address, TRUE);
+         Status = MmAccessFault(Mode, (ULONG_PTR)Address, TRUE);
          if (!NT_SUCCESS(Status))
          {
             for (j = 0; j < i; j++)
@@ -541,7 +541,7 @@
     * mdl buffer must (at least) be in kernel space, thou this doesn't 
     * necesarely mean that the buffer in within _nonpaged_ kernel space...
     */
-   ASSERT((ULONG)Mdl->StartVa >= KERNEL_BASE);
+   ASSERT((ULONG_PTR)Mdl->StartVa >= KERNEL_BASE);
    
    PageCount = PAGE_ROUND_UP(Mdl->ByteOffset + Mdl->ByteCount) / PAGE_SIZE;
    MdlPages = (PPFN_TYPE)(Mdl + 1);

Modified: trunk/reactos/ntoskrnl/mm/mm.c
--- trunk/reactos/ntoskrnl/mm/mm.c	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/mm/mm.c	2005-01-12 10:05:31 UTC (rev 12950)
@@ -55,7 +55,7 @@
 
   if (ExGetPreviousMode() == UserMode)
     {
-      if ((ULONG)Dest >= KERNEL_BASE)
+      if ((ULONG_PTR)Dest >= KERNEL_BASE)
    {
      return(STATUS_ACCESS_VIOLATION);
    }
@@ -76,7 +76,7 @@
 
   if (ExGetPreviousMode() == UserMode)
     {
-      if ((ULONG)Src >= KERNEL_BASE)
+      if ((ULONG_PTR)Src >= KERNEL_BASE)
    {
      return(STATUS_ACCESS_VIOLATION);
    }
@@ -177,7 +177,7 @@
    MEMORY_AREA* MemoryArea;
    PMADDRESS_SPACE AddressSpace;
 
-   if ((ULONG)VirtualAddress >= KERNEL_BASE)
+   if ((ULONG_PTR)VirtualAddress >= KERNEL_BASE)
    {
       AddressSpace = MmGetKernelAddressSpace();
    }
@@ -200,7 +200,7 @@
 }
 
 NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
-                       ULONG Address, /* FiN TODO: Should be ULONG_PTR! */
+                       ULONG_PTR Address,
                        BOOLEAN FromMdl)
 {
    PMADDRESS_SPACE AddressSpace;
@@ -322,7 +322,7 @@
 }
 
 NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
-                           ULONG Address, /* FiN TODO: Should be ULONG_PTR! */
+                           ULONG_PTR Address,
                            BOOLEAN FromMdl)
 {
    PMADDRESS_SPACE AddressSpace;

Modified: trunk/reactos/ntoskrnl/mm/mminit.c
--- trunk/reactos/ntoskrnl/mm/mminit.c	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/mm/mminit.c	2005-01-12 10:05:31 UTC (rev 12950)
@@ -72,7 +72,7 @@
 {}
 
 VOID INIT_FUNCTION
-MmInitVirtualMemory(ULONG LastKernelAddress,
+MmInitVirtualMemory(ULONG_PTR LastKernelAddress,
                     ULONG KernelLength)
 /*
  * FUNCTION: Intialize the memory areas list
@@ -133,7 +133,7 @@
                       BoundaryAddressMultiple);
 
    BaseAddress = (PVOID)KERNEL_BASE;
-   Length = PAGE_ROUND_UP(((ULONG)&_text_end__)) - KERNEL_BASE;
+   Length = PAGE_ROUND_UP(((ULONG_PTR)&_text_end__)) - KERNEL_BASE;
    ParamLength = ParamLength - Length;
 
    /*
@@ -151,10 +151,10 @@
                       FALSE,
                       BoundaryAddressMultiple);
 
-   BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&_text_end__));
+   BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG_PTR)&_text_end__));
    ASSERT(BaseAddress == (PVOID)&_init_start__);
-   Length = PAGE_ROUND_UP(((ULONG)&_init_end__)) -
-            PAGE_ROUND_UP(((ULONG)&_text_end__));
+   Length = PAGE_ROUND_UP(((ULONG_PTR)&_init_end__)) -
+            PAGE_ROUND_UP(((ULONG_PTR)&_text_end__));
    ParamLength = ParamLength - Length;
 
    MmCreateMemoryArea(NULL,
@@ -168,11 +168,11 @@
                       FALSE,
                       BoundaryAddressMultiple);
 
-   Length = PAGE_ROUND_UP(((ULONG)&_bss_end__)) -
-            PAGE_ROUND_UP(((ULONG)&_init_end__));
+   Length = PAGE_ROUND_UP(((ULONG_PTR)&_bss_end__)) -
+            PAGE_ROUND_UP(((ULONG_PTR)&_init_end__));
    ParamLength = ParamLength - Length;
    DPRINT("Length %x\n",Length);
-   BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&_init_end__));
+   BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG_PTR)&_init_end__));
    DPRINT("BaseAddress %x\n",BaseAddress);
 
    /*
@@ -190,8 +190,8 @@
                       FALSE,
                       BoundaryAddressMultiple);
 
-   BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&_bss_end__));
-   Length = LastKernelAddress - (ULONG)BaseAddress;
+   BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG_PTR)&_bss_end__));
+   Length = LastKernelAddress - (ULONG_PTR)BaseAddress;
    MmCreateMemoryArea(NULL,
                       MmGetKernelAddressSpace(),
                       MEMORY_AREA_SYSTEM,
@@ -277,9 +277,9 @@
 }
 
 VOID INIT_FUNCTION
-MmInit1(ULONG FirstKrnlPhysAddr,
-        ULONG LastKrnlPhysAddr,
-        ULONG LastKernelAddress,
+MmInit1(ULONG_PTR FirstKrnlPhysAddr,
+        ULONG_PTR LastKrnlPhysAddr,
+        ULONG_PTR LastKernelAddress,
         PADDRESS_RANGE BIOSMemoryMap,
         ULONG AddressRangeCount,
         ULONG MaxMem)
@@ -289,12 +289,13 @@
 {
    ULONG i;
    ULONG kernel_len;
+   ULONG_PTR MappingAddress;
 #ifndef CONFIG_SMP
-
    extern unsigned int unmap_me, unmap_me2, unmap_me3;
 #endif
+   extern unsigned int pagetable_start, pagetable_end;
 
-   DPRINT("MmInit1(FirstKrnlPhysAddr, %x, LastKrnlPhysAddr %x, LastKernelAddress %x)\n",
+   DPRINT("MmInit1(FirstKrnlPhysAddr, %p, LastKrnlPhysAddr %p, LastKernelAddress %p)\n",
           FirstKrnlPhysAddr,
           LastKrnlPhysAddr,
           LastKernelAddress);
@@ -383,8 +384,9 @@
 
    DbgPrint("Used memory %dKb\n", (MmStats.NrTotalPages * PAGE_SIZE) / 1024);
 
-   LastKernelAddress = (ULONG)MmInitializePageList((PVOID)FirstKrnlPhysAddr,
-                       (PVOID)LastKrnlPhysAddr,
+   LastKernelAddress = (ULONG_PTR)MmInitializePageList(
+                       FirstKrnlPhysAddr,
+                       LastKrnlPhysAddr,
                        MmStats.NrTotalPages,
                        PAGE_ROUND_UP(LastKernelAddress),
                        BIOSMemoryMap,
@@ -405,15 +407,18 @@
 
    DPRINT("Invalidating between %x and %x\n",
           LastKernelAddress, KERNEL_BASE + 0x00600000);
-   for (i=(LastKernelAddress); i<KERNEL_BASE + 0x00600000; i+=PAGE_SIZE)
+   for (MappingAddress = LastKernelAddress;
+        MappingAddress < KERNEL_BASE + 0x00600000;
+        MappingAddress += PAGE_SIZE)
    {
-      MmRawDeleteVirtualMapping((PVOID)(i));
+      MmRawDeleteVirtualMapping((PVOID)MappingAddress);
    }
 
-   extern unsigned int pagetable_start, pagetable_end;
-   for (i = (ULONG_PTR)&pagetable_start; i < (ULONG_PTR)&pagetable_end; i += PAGE_SIZE)
+   for (MappingAddress = (ULONG_PTR)&pagetable_start;
+        MappingAddress < (ULONG_PTR)&pagetable_end;
+        MappingAddress += PAGE_SIZE)
    {
-      MmDeleteVirtualMapping(NULL, (PVOID)i, FALSE, NULL, NULL);
+      MmDeleteVirtualMapping(NULL, (PVOID)MappingAddress, FALSE, NULL, NULL);
    }
 
    DPRINT("Almost done MmInit()\n");

Modified: trunk/reactos/ntoskrnl/mm/npool.c
--- trunk/reactos/ntoskrnl/mm/npool.c	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/mm/npool.c	2005-01-12 10:05:31 UTC (rev 12950)
@@ -1235,11 +1235,11 @@
 {
    NTSTATUS Status;
    PFN_TYPE Page[32];
-   ULONG StartIndex, EndIndex;
+   ULONG_PTR StartIndex, EndIndex;
    ULONG i, j, k;
    
-   StartIndex =  (ULONG)((char*)(PVOID)PAGE_ROUND_UP((ULONG)((char*)blk + BLOCK_HDR_SIZE)) - (char*)MiNonPagedPoolStart) / PAGE_SIZE;
-   EndIndex = (ULONG)((char*)PAGE_ROUND_UP(end) - (char*)MiNonPagedPoolStart) / PAGE_SIZE;
+   StartIndex = (ULONG_PTR)(PAGE_ROUND_UP((ULONG_PTR)blk + BLOCK_HDR_SIZE - (ULONG_PTR)MiNonPagedPoolStart)) / PAGE_SIZE;
+   EndIndex = ((ULONG_PTR)PAGE_ROUND_UP(end) - (ULONG_PTR)MiNonPagedPoolStart) / PAGE_SIZE;
 
 
    for (i = StartIndex; i < EndIndex; i++)
@@ -1266,7 +1266,7 @@
 	    }
 	 }
          Status = MmCreateVirtualMapping(NULL,
-	                                 MiNonPagedPoolStart + i * PAGE_SIZE,
+	                                 (PVOID)((ULONG_PTR)MiNonPagedPoolStart + i * PAGE_SIZE),
                                          PAGE_READWRITE|PAGE_SYSTEM,
                                          Page,
                                          k);
@@ -1333,12 +1333,12 @@
              * from alignment. If not, calculate forward to the next alignment
              * and see if we allocate there...
              */
-            new_size = (ULONG)aligned_addr - (ULONG)addr + size;
-            if ((ULONG)aligned_addr - (ULONG)addr < BLOCK_HDR_SIZE)
+            new_size = (ULONG_PTR)aligned_addr - (ULONG_PTR)addr + size;
+            if ((ULONG_PTR)aligned_addr - (ULONG_PTR)addr < BLOCK_HDR_SIZE)
             {
                /* not enough room for a free block header, add some more bytes */
                aligned_addr = MM_ROUND_UP(block_to_address((BLOCK_HDR*)((char*)current + BLOCK_HDR_SIZE)), alignment);
-               new_size = (ULONG)aligned_addr - (ULONG)addr + size;
+               new_size = (ULONG_PTR)aligned_addr - (ULONG_PTR)addr + size;
             }
             if (current->Size >= new_size &&
                   (best == NULL || current->Size < best->Size))
@@ -1382,9 +1382,9 @@
           * if size-aligned, break off the preceding bytes into their own block...
           */
          previous = current;
-         previous_size = (ULONG)blk - (ULONG)previous - BLOCK_HDR_SIZE;
+         previous_size = (ULONG_PTR)blk - (ULONG_PTR)previous - BLOCK_HDR_SIZE;
          current = blk;
-         current_size -= ((ULONG)current - (ULONG)previous);
+         current_size -= ((ULONG_PTR)current - (ULONG_PTR)previous);
       }
    }
 
@@ -1393,7 +1393,7 @@
    if (current_size >= size + BLOCK_HDR_SIZE + MM_POOL_ALIGNMENT)
    {
       /* create a new free block after our block, if the memory size is >= 4 byte for this block */
-      next = (BLOCK_HDR*)((ULONG)current + size + BLOCK_HDR_SIZE);
+      next = (BLOCK_HDR*)((ULONG_PTR)current + size + BLOCK_HDR_SIZE);
       next_size = current_size - size - BLOCK_HDR_SIZE;
       current_size = size;
       end = (char*)next + BLOCK_HDR_SIZE;
@@ -1828,9 +1828,9 @@
    /* the second block is the first free block */
    blk = (BLOCK_HDR*)((char*)blk + BLOCK_HDR_SIZE + blk->Size);
    memset(blk, 0, BLOCK_HDR_SIZE);
-   memset((char*)blk + BLOCK_HDR_SIZE, 0x0cc, MiNonPagedPoolNrOfPages * PAGE_SIZE - ((ULONG)blk + BLOCK_HDR_SIZE - (ULONG)MiNonPagedPoolStart));
+   memset((char*)blk + BLOCK_HDR_SIZE, 0x0cc, MiNonPagedPoolNrOfPages * PAGE_SIZE - ((ULONG_PTR)blk + BLOCK_HDR_SIZE - (ULONG_PTR)MiNonPagedPoolStart));
    blk->Magic = BLOCK_HDR_FREE_MAGIC;
-   blk->Size = MiNonPagedPoolLength - ((ULONG)blk + BLOCK_HDR_SIZE - (ULONG)MiNonPagedPoolStart);
+   blk->Size = MiNonPagedPoolLength - ((ULONG_PTR)blk + BLOCK_HDR_SIZE - (ULONG_PTR)MiNonPagedPoolStart);
    blk->previous = (BLOCK_HDR*)MiNonPagedPoolStart;
    add_to_free_list(blk);
 #endif

Modified: trunk/reactos/ntoskrnl/mm/pagefile.c
--- trunk/reactos/ntoskrnl/mm/pagefile.c	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/mm/pagefile.c	2005-01-12 10:05:31 UTC (rev 12950)
@@ -532,7 +532,7 @@
    Headers->BugCheckParameters[3] = BugCodeParameter4;
    Headers->FaultingStackBase = (PVOID)Thread->Tcb.StackLimit;
    Headers->FaultingStackSize =
-   StackSize = (ULONG_PTR)(Thread->Tcb.StackBase - Thread->Tcb.StackLimit);
+   StackSize = (ULONG_PTR)Thread->Tcb.StackBase - (ULONG_PTR)Thread->Tcb.StackLimit;
    Headers->PhysicalMemorySize = MmStats.NrTotalPages * PAGE_SIZE;
 
    /* Initialize the dump device. */

Modified: trunk/reactos/ntoskrnl/mm/pageop.c
--- trunk/reactos/ntoskrnl/mm/pageop.c	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/mm/pageop.c	2005-01-12 10:05:31 UTC (rev 12950)
@@ -70,7 +70,7 @@
 MmCheckForPageOp(PMEMORY_AREA MArea, ULONG Pid, PVOID Address,
                  PMM_SECTION_SEGMENT Segment, ULONG Offset)
 {
-   ULONG Hash;
+   ULONG_PTR Hash;
    KIRQL oldIrql;
    PMM_PAGEOP PageOp;
 
@@ -79,11 +79,11 @@
     */
    if (MArea->Type == MEMORY_AREA_SECTION_VIEW)
    {
-      Hash = (((ULONG)Segment) | (((ULONG)Offset) / PAGE_SIZE));
+      Hash = (((ULONG_PTR)Segment) | (((ULONG_PTR)Offset) / PAGE_SIZE));
    }
    else
    {
-      Hash = (((ULONG)Pid) | (((ULONG)Address) / PAGE_SIZE));
+      Hash = (((ULONG_PTR)Pid) | (((ULONG_PTR)Address) / PAGE_SIZE));
    }
    Hash = Hash % PAGEOP_HASH_TABLE_SIZE;
 
@@ -137,7 +137,7 @@
  * pid, address pair.      
  */
 {
-   ULONG Hash;
+   ULONG_PTR Hash;
    KIRQL oldIrql;
    PMM_PAGEOP PageOp;
 
@@ -146,11 +146,11 @@
     */
    if (MArea->Type == MEMORY_AREA_SECTION_VIEW)
    {
-      Hash = (((ULONG)Segment) | (((ULONG)Offset) / PAGE_SIZE));
+      Hash = (((ULONG_PTR)Segment) | (((ULONG_PTR)Offset) / PAGE_SIZE));
    }
    else
    {
-      Hash = (((ULONG)Pid) | (((ULONG)Address) / PAGE_SIZE));
+      Hash = (((ULONG_PTR)Pid) | (((ULONG_PTR)Address) / PAGE_SIZE));
    }
    Hash = Hash % PAGEOP_HASH_TABLE_SIZE;
 

Modified: trunk/reactos/ntoskrnl/mm/section.c
--- trunk/reactos/ntoskrnl/mm/section.c	2005-01-12 10:05:05 UTC (rev 12949)
+++ trunk/reactos/ntoskrnl/mm/section.c	2005-01-12 10:05:31 UTC (rev 12950)
@@ -3265,8 +3265,8 @@
          return(Status);
       }
 
-      if (0 != InterlockedCompareExchangeUL(&FileObject->SectionObjectPointer->ImageSectionObject,
-                                            ImageSectionObject, 0))
+      if (NULL != InterlockedCompareExchangePointer(&FileObject->SectionObjectPointer->ImageSectionObject,
+                                                    ImageSectionObject, NULL))
       {
          /*
           * An other thread has initialized the some image in the background
@@ -4089,7 +4089,7 @@
          KEBUGCHECK(0);
       }
       Status = MmCreateVirtualMapping (NULL,
-                                       (PVOID)(Result + (i * PAGE_SIZE)),
+                                       (PVOID)((ULONG_PTR)Result + (i * PAGE_SIZE)),
                                        PAGE_READWRITE,
                                        &Page,
                                        1);
@@ -4201,9 +4201,9 @@
       {
          if (!(SectionSegments[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD))
          {
-            ULONG MaxExtent;
-            MaxExtent = (ULONG)((char*)SectionSegments[i].VirtualAddress +
-                                SectionSegments[i].Length);
+            ULONG_PTR MaxExtent;
+            MaxExtent = (ULONG_PTR)SectionSegments[i].VirtualAddress +
+                        SectionSegments[i].Length;
             ImageSize = max(ImageSize, MaxExtent);
          }
       }