[HAL/NDK]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 18 Sep 2011 13:11:45 +0000 (13:11 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 18 Sep 2011 13:11:45 +0000 (13:11 +0000)
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler

svn path=/trunk/; revision=53734

102 files changed:
reactos/drivers/video/videoprt/interrupt.c
reactos/hal/halarm/generic/pic.c
reactos/hal/halx86/apic/apic.c
reactos/hal/halx86/mp/mpsirql.c
reactos/hal/halx86/up/pic.c
reactos/include/asm/trapamd64.inc
reactos/include/ndk/extypes.h
reactos/include/ndk/halfuncs.h
reactos/include/ndk/ketypes.h
reactos/include/ndk/ldrfuncs.h
reactos/include/ndk/mmtypes.h
reactos/include/reactos/arc/arc.h
reactos/include/reactos/drivers/ntddrdsk.h
reactos/ntoskrnl/config/cmapi.c
reactos/ntoskrnl/config/cmboot.c
reactos/ntoskrnl/config/cminit.c
reactos/ntoskrnl/config/cmkcbncb.c
reactos/ntoskrnl/config/cmvalche.c
reactos/ntoskrnl/config/cmwraprs.c
reactos/ntoskrnl/config/i386/cmhardwr.c
reactos/ntoskrnl/ex/callback.c
reactos/ntoskrnl/ex/handle.c
reactos/ntoskrnl/ex/init.c
reactos/ntoskrnl/ex/lookas.c
reactos/ntoskrnl/ex/profile.c
reactos/ntoskrnl/ex/pushlock.c
reactos/ntoskrnl/ex/sysinfo.c
reactos/ntoskrnl/fsrtl/fastio.c
reactos/ntoskrnl/fstub/disksup.c
reactos/ntoskrnl/fstub/halstub.c
reactos/ntoskrnl/include/internal/amd64/ke.h
reactos/ntoskrnl/include/internal/amd64/mm.h
reactos/ntoskrnl/include/internal/io.h
reactos/ntoskrnl/include/internal/kd64.h
reactos/ntoskrnl/include/internal/ke.h
reactos/ntoskrnl/include/internal/mm.h
reactos/ntoskrnl/include/internal/ob.h
reactos/ntoskrnl/include/internal/rtl.h
reactos/ntoskrnl/io/iomgr/arcname.c
reactos/ntoskrnl/io/iomgr/bootlog.c
reactos/ntoskrnl/io/iomgr/deviface.c
reactos/ntoskrnl/io/iomgr/driver.c
reactos/ntoskrnl/io/iomgr/error.c
reactos/ntoskrnl/io/iomgr/file.c
reactos/ntoskrnl/io/iomgr/iofunc.c
reactos/ntoskrnl/io/iomgr/iomdl.c
reactos/ntoskrnl/io/iomgr/irp.c
reactos/ntoskrnl/io/iomgr/util.c
reactos/ntoskrnl/io/pnpmgr/pnpinit.c
reactos/ntoskrnl/io/pnpmgr/pnpmgr.c
reactos/ntoskrnl/io/pnpmgr/pnpres.c
reactos/ntoskrnl/io/pnpmgr/pnproot.c
reactos/ntoskrnl/io/pnpmgr/pnputil.c
reactos/ntoskrnl/kd64/kdapi.c
reactos/ntoskrnl/kd64/kddata.c
reactos/ntoskrnl/kd64/kdinit.c
reactos/ntoskrnl/kd64/kdtrap.c
reactos/ntoskrnl/ke/amd64/cpu.c
reactos/ntoskrnl/ke/amd64/except.c
reactos/ntoskrnl/ke/amd64/krnlinit.c
reactos/ntoskrnl/ke/arm/cpu.c
reactos/ntoskrnl/ke/bug.c
reactos/ntoskrnl/ke/gate.c
reactos/ntoskrnl/ke/i386/cpu.c
reactos/ntoskrnl/ke/krnlinit.c
reactos/ntoskrnl/ke/powerpc/cpu.c
reactos/ntoskrnl/ke/procobj.c
reactos/ntoskrnl/ke/profobj.c
reactos/ntoskrnl/ke/thrdschd.c
reactos/ntoskrnl/ke/wait.c
reactos/ntoskrnl/lpc/send.c
reactos/ntoskrnl/mm/ARM3/iosup.c
reactos/ntoskrnl/mm/ARM3/mdlsup.c
reactos/ntoskrnl/mm/ARM3/miarm.h
reactos/ntoskrnl/mm/ARM3/mminit.c
reactos/ntoskrnl/mm/ARM3/mmsup.c
reactos/ntoskrnl/mm/ARM3/ncache.c
reactos/ntoskrnl/mm/ARM3/pagfault.c
reactos/ntoskrnl/mm/ARM3/pfnlist.c
reactos/ntoskrnl/mm/ARM3/pool.c
reactos/ntoskrnl/mm/ARM3/procsup.c
reactos/ntoskrnl/mm/ARM3/section.c
reactos/ntoskrnl/mm/ARM3/sysldr.c
reactos/ntoskrnl/mm/ARM3/syspte.c
reactos/ntoskrnl/mm/ARM3/vadnode.c
reactos/ntoskrnl/mm/ARM3/virtual.c
reactos/ntoskrnl/mm/amd64/init.c
reactos/ntoskrnl/mm/anonmem.c
reactos/ntoskrnl/mm/balance.c
reactos/ntoskrnl/mm/freelist.c
reactos/ntoskrnl/mm/marea.c
reactos/ntoskrnl/mm/pagefile.c
reactos/ntoskrnl/mm/pageop.c
reactos/ntoskrnl/mm/region.c
reactos/ntoskrnl/mm/rmap.c
reactos/ntoskrnl/ob/obref.c
reactos/ntoskrnl/ob/obsecure.c
reactos/ntoskrnl/po/power.c
reactos/ntoskrnl/ps/kill.c
reactos/ntoskrnl/ps/process.c
reactos/ntoskrnl/ps/query.c
reactos/ntoskrnl/ps/thread.c

index 961e6ea..b244f53 100644 (file)
@@ -125,7 +125,7 @@ VideoPortEnableInterrupt(IN PVOID HwDeviceExtension)
     }
 
     /* Re-enable the interrupt and return */
-    InterruptValid = HalEnableSystemInterrupt((UCHAR)DeviceExtension->InterruptVector,
+    InterruptValid = HalEnableSystemInterrupt(DeviceExtension->InterruptVector,
                                               0,
                                               DeviceExtension->InterruptLevel);
 
@@ -162,8 +162,7 @@ VideoPortDisableInterrupt(IN PVOID HwDeviceExtension)
     }
 
     /* Disable the interrupt and return */
-    HalDisableSystemInterrupt((UCHAR)DeviceExtension->InterruptVector,
-                              0);
+    HalDisableSystemInterrupt(DeviceExtension->InterruptVector, 0);
     return NO_ERROR;
 #else
     /* FIXME: Function still present? If so what to use instead of HalDisableSystemInterrupt? */
index 5be8c3f..09ce08a 100644 (file)
@@ -234,10 +234,10 @@ KfLowerIrql(IN KIRQL NewIrql)
     ARM_STATUS_REGISTER Flags;
     PKIPCR Pcr = (PKIPCR)KeGetPcr();
     ULONG InterruptMask;
-    
+
     /* Disableinterrupts */
     Flags = KeArmStatusRegisterGet();
-    _disable();    
+    _disable();
     
 #ifdef IRQL_DEBUG
     /* Validate correct lower */
@@ -292,7 +292,7 @@ HalClearSoftwareInterrupt(IN KIRQL Irql)
  */
 BOOLEAN
 NTAPI
-HalEnableSystemInterrupt(IN UCHAR Vector,
+HalEnableSystemInterrupt(IN ULONG Vector,
                          IN KIRQL Irql,
                          IN KINTERRUPT_MODE InterruptMode)
 {
@@ -306,7 +306,7 @@ HalEnableSystemInterrupt(IN UCHAR Vector,
  */
 VOID
 NTAPI
-HalDisableSystemInterrupt(IN UCHAR Vector,
+HalDisableSystemInterrupt(IN ULONG Vector,
                           IN KIRQL Irql)
 {
     UNIMPLEMENTED;
@@ -319,7 +319,7 @@ HalDisableSystemInterrupt(IN UCHAR Vector,
 BOOLEAN
 NTAPI
 HalBeginSystemInterrupt(IN KIRQL Irql,
-                        IN UCHAR Vector,
+                        IN ULONG Vector,
                         OUT PKIRQL OldIrql)
 {
     UNIMPLEMENTED;
index 5bd18d2..3caba22 100644 (file)
@@ -670,7 +670,7 @@ HalClearSoftwareInterrupt(
 BOOLEAN
 NTAPI
 HalEnableSystemInterrupt(
-    IN UCHAR Vector,
+    IN ULONG Vector,
     IN KIRQL Irql,
     IN KINTERRUPT_MODE InterruptMode)
 {
@@ -724,12 +724,13 @@ HalEnableSystemInterrupt(
 VOID
 NTAPI
 HalDisableSystemInterrupt(
-    IN UCHAR Vector,
+    IN ULONG Vector,
     IN KIRQL Irql)
 {
     IOAPIC_REDIRECTION_REGISTER ReDirReg;
     UCHAR Index;
     ASSERT(Irql <= HIGH_LEVEL);
+    ASSERT(Vector < RTL_NUMBER_OF(HalpVectorToIndex));
 
     Index = HalpVectorToIndex[Vector];
 
@@ -748,7 +749,7 @@ BOOLEAN
 NTAPI
 HalBeginSystemInterrupt(
     IN KIRQL Irql,
-    IN UCHAR Vector,
+    IN ULONG Vector,
     OUT PKIRQL OldIrql)
 {
     KIRQL CurrentIrql;
index 643369a..604b07b 100644 (file)
@@ -68,7 +68,7 @@ VOID KeSetCurrentIrql (KIRQL NewIrql)
     }
 }
 
-VOID 
+VOID
 HalpLowerIrql(KIRQL NewIrql, BOOLEAN FromHalEndSystemInterrupt)
 {
   ULONG Flags;
@@ -101,7 +101,7 @@ HalpLowerIrql(KIRQL NewIrql, BOOLEAN FromHalEndSystemInterrupt)
     {
       return;
     }
-  if (KeGetCurrentThread () != NULL && 
+  if (KeGetCurrentThread () != NULL &&
       KeGetCurrentThread ()->ApcState.KernelApcPending)
     {
       _enable();
@@ -166,7 +166,7 @@ KfRaiseIrql (KIRQL  NewIrql)
 {
   KIRQL OldIrql;
   ULONG Flags;
+
   Flags = __readeflags();
   _disable();
 
@@ -242,12 +242,12 @@ KeRaiseIrqlToSynchLevel (VOID)
 
 BOOLEAN NTAPI
 HalBeginSystemInterrupt (KIRQL Irql,
-                        UCHAR Vector,
+                        ULONG Vector,
                         PKIRQL OldIrql)
 {
   ULONG Flags;
   DPRINT("Vector (0x%X)  Irql (0x%X)\n", Vector, Irql);
-  
+
   if (KeGetCurrentIrql () >= Irql)
   {
     DPRINT1("current irql %d, new irql %d\n", KeGetCurrentIrql(), Irql);
@@ -285,10 +285,10 @@ HalEndSystemInterrupt (KIRQL Irql,
   APICSendEOI();
   HalpLowerIrql (Irql, TRUE);
 }
-  
+
 VOID
 NTAPI
-HalDisableSystemInterrupt(UCHAR Vector,
+HalDisableSystemInterrupt(ULONG Vector,
                          KIRQL Irql)
 {
   ULONG irq;
@@ -296,7 +296,7 @@ HalDisableSystemInterrupt(UCHAR Vector,
   DPRINT ("Vector (0x%X)\n", Vector);
 
   if (Vector < FIRST_DEVICE_VECTOR ||
-      Vector >= FIRST_DEVICE_VECTOR + NUMBER_DEVICE_VECTORS)  
+      Vector >= FIRST_DEVICE_VECTOR + NUMBER_DEVICE_VECTORS)
   {
     DPRINT1("Not a device interrupt, vector=%x\n", Vector);
     ASSERT(FALSE);
@@ -306,19 +306,19 @@ HalDisableSystemInterrupt(UCHAR Vector,
   irq = VECTOR2IRQ (Vector);
   IOAPICMaskIrq (irq);
 
-  return;  
+  return;
 }
 
 
 BOOLEAN NTAPI
-HalEnableSystemInterrupt (UCHAR Vector,
+HalEnableSystemInterrupt (ULONG Vector,
                          KIRQL Irql,
                          KINTERRUPT_MODE InterruptMode)
 {
   ULONG irq;
 
   if (Vector < FIRST_DEVICE_VECTOR ||
-      Vector >= FIRST_DEVICE_VECTOR + NUMBER_DEVICE_VECTORS) 
+      Vector >= FIRST_DEVICE_VECTOR + NUMBER_DEVICE_VECTORS)
   {
     DPRINT("Not a device interrupt\n");
     return FALSE;
@@ -344,7 +344,7 @@ HalRequestSoftwareInterrupt(IN KIRQL Request)
     case DISPATCH_LEVEL:
       __writefsbyte(FIELD_OFFSET(KIPCR, HalReserved[HAL_DPC_REQUEST]), 1);
       break;
-      
+
     default:
       ASSERT(FALSE);
   }
index 2c8ca5e..ba4c94e 100644 (file)
@@ -44,7 +44,7 @@
  *   IRQ2 since the line was asserted by the slave when it received the spurious
  *   IRQ15!
  *
- * - When the 80287/80387 math co-processor generates an FPU/NPX trap, this is 
+ * - When the 80287/80387 math co-processor generates an FPU/NPX trap, this is
  *   connected to IRQ13, so we have to clear the busy latch on the NPX port.
  */
 PHAL_DISMISS_INTERRUPT HalpSpecialDismissTable[16] =
@@ -1096,7 +1096,7 @@ HalpHardwareInterruptLevel(VOID)
  */
 BOOLEAN
 NTAPI
-HalEnableSystemInterrupt(IN UCHAR Vector,
+HalEnableSystemInterrupt(IN ULONG Vector,
                          IN KIRQL Irql,
                          IN KINTERRUPT_MODE InterruptMode)
 {
@@ -1139,7 +1139,7 @@ HalEnableSystemInterrupt(IN UCHAR Vector,
  */
 VOID
 NTAPI
-HalDisableSystemInterrupt(IN UCHAR Vector,
+HalDisableSystemInterrupt(IN ULONG Vector,
                           IN KIRQL Irql)
 {
     ULONG IrqMask;
@@ -1175,7 +1175,7 @@ HalDisableSystemInterrupt(IN UCHAR Vector,
 BOOLEAN
 NTAPI
 HalBeginSystemInterrupt(IN KIRQL Irql,
-                        IN UCHAR Vector,
+                        IN ULONG Vector,
                         OUT PKIRQL OldIrql)
 {
     ULONG Irq;
@@ -1218,21 +1218,21 @@ HalEndSystemInterrupt(IN KIRQL OldIrql,
                 Mask.Both = Pcr->IDR;
                 __outbyte(PIC1_DATA_PORT, Mask.Master);
                 __outbyte(PIC2_DATA_PORT, Mask.Slave);
-            
+                
                 /* Now check if this specific interrupt is already in-service */
                 PendingIrqMask = (1 << PendingIrql);
                 if (Pcr->IrrActive & PendingIrqMask) return;
-                    
+                
                 /* Set active bit otherwise, and clear it from IRR */
                 Pcr->IrrActive |= PendingIrqMask;
                 Pcr->IRR ^= PendingIrqMask;
-            
+                
                 /* Handle delayed hardware interrupt */
                 SWInterruptHandlerTable[PendingIrql]();
-            
+                
                 /* Handling complete */
                 Pcr->IrrActive ^= PendingIrqMask;
-            
+                
                 /* Check if there's still interrupts pending */
                 PendingIrqlMask = Pcr->IRR & FindHigherIrqlMask[Pcr->Irql];
                 if (!PendingIrqlMask) break;
@@ -1275,7 +1275,7 @@ _HalpApcInterruptHandler(IN PKTRAP_FRAME TrapFrame)
     HalpEndSoftwareInterrupt(CurrentIrql, TrapFrame);
 
     /* Exit the interrupt */
-    KiEoiHelper(TrapFrame); 
+    KiEoiHelper(TrapFrame);
 }
 
 VOID
@@ -1374,7 +1374,7 @@ HalpDispatchInterrupt2(VOID)
             /* Clear IRR bit */
             Pcr->IRR ^= (1 << PendingIrql);
         }
-    
+
         /* Now handle pending interrupt */
         SWInterruptHandlerTable[PendingIrql]();
     }
index 7aa09a1..23df5b5 100644 (file)
@@ -10,6 +10,19 @@ TF_IRQL                 = HEX(20)
 TF_SAVE_ALL             = (TF_VOLATILES OR TF_NONVOLATILES OR TF_XMM OR TF_SEGMENTS)\r
 TF_HAS_ERROR_CODE       = HEX(40)\r
 TF_SEND_EOI             = HEX(80)\r
+//TF_SYSTEMSERVICE        = (TRAPFLAG_VOLATILES or TRAPFLAG_DEBUG)\r
+\r
+/*\r
+ * Stack Layout:\r
+ * |-------------------|\r
+ * | KTRAP_FRAME       |\r
+ * |-------------------| <- rbp\r
+ * | EXCEPTION_RECORD  |\r
+ * |-------------------|\r
+ * | KEXCEPTION_FRAME  |\r
+ * |-------------------| <- rsp\r
+ *\r
+ */\r
 \r
 /*\r
  * EnterTrap - Allocate KTRAP_FRAME_LENGTH and save registers to it\r
index 19dd221..412b57b 100644 (file)
@@ -588,7 +588,7 @@ typedef struct _HANDLE_TABLE_ENTRY
 typedef struct _HANDLE_TABLE
 {
 #if (NTDDI_VERSION >= NTDDI_WINXP)
-    ULONG TableCode;
+    ULONG_PTR TableCode;
 #else
     PHANDLE_TABLE_ENTRY **Table;
 #endif
index b3faf17..b55810d 100644 (file)
@@ -133,7 +133,7 @@ BOOLEAN
 NTAPI
 HalBeginSystemInterrupt(
     KIRQL Irql,
-    UCHAR Vector,
+    ULONG Vector,
     PKIRQL OldIrql
 );
 
@@ -147,7 +147,7 @@ NTHALAPI
 VOID
 NTAPI
 HalDisableSystemInterrupt(
-    UCHAR Vector,
+    ULONG Vector,
     KIRQL Irql
 );
 
@@ -155,7 +155,7 @@ NTHALAPI
 BOOLEAN
 NTAPI
 HalEnableSystemInterrupt(
-    UCHAR Vector,
+    ULONG Vector,
     KIRQL Irql,
     KINTERRUPT_MODE InterruptMode
 );
@@ -221,7 +221,7 @@ NTAPI
 HalAdjustResourceList(
     IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList
 );
-    
+
 //
 // Environment Functions
 //
index 9792c10..b7823f5 100644 (file)
@@ -554,7 +554,11 @@ typedef struct _KDPC_DATA
 {
     LIST_ENTRY DpcListHead;
     ULONG_PTR DpcLock;
+#ifdef _M_AMD64
+    volatile LONG DpcQueueDepth;
+#else
     volatile ULONG DpcQueueDepth;
+#endif
     ULONG DpcCount;
 } KDPC_DATA, *PKDPC_DATA;
 
@@ -935,10 +939,10 @@ typedef struct _KPROCESS
     DISPATCHER_HEADER Header;
     LIST_ENTRY ProfileListHead;
 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
-    ULONG DirectoryTableBase;
+    ULONG_PTR DirectoryTableBase;
     ULONG Unused0;
 #else
-    ULONG DirectoryTableBase[2];
+    ULONG_PTR DirectoryTableBase[2];
 #endif
 #if defined(_M_IX86)
     KGDTENTRY LdtDescriptor;
index 1bf8a83..3c67e06 100644 (file)
@@ -105,7 +105,7 @@ BOOLEAN
 NTAPI
 LdrVerifyMappedImageMatchesChecksum(
     IN PVOID BaseAddress,
-    IN ULONG NumberOfBytes,
+    IN SIZE_T NumberOfBytes,
     IN ULONG FileLength
 );
 
index 1c1f440..7d9160e 100644 (file)
@@ -317,11 +317,18 @@ typedef struct _SECTION_IMAGE_INFORMATION
 {
     PVOID TransferAddress;
     ULONG ZeroBits;
-    ULONG MaximumStackSize;
-    ULONG CommittedStackSize;
+    SIZE_T MaximumStackSize;
+    SIZE_T CommittedStackSize;
     ULONG SubSystemType;
-    USHORT SubSystemMinorVersion;
-    USHORT SubSystemMajorVersion;
+    union
+    {
+        struct
+        {
+            USHORT SubSystemMinorVersion;
+            USHORT SubSystemMajorVersion;
+        };
+        ULONG SubSystemVersion;
+    };
     ULONG GpValue;
     USHORT ImageCharacteristics;
     USHORT DllCharacteristics;
@@ -638,8 +645,8 @@ typedef struct _MM_AVL_TABLE
 //
 typedef struct _MMADDRESS_LIST
 {
-    ULONG StartVpn;
-    ULONG EndVpn;
+    ULONG_PTR StartVpn;
+    ULONG_PTR EndVpn;
 } MMADDRESS_LIST, *PMMADDRESS_LIST;
 
 //
@@ -647,13 +654,17 @@ typedef struct _MMADDRESS_LIST
 //
 typedef struct _MMVAD_FLAGS
 {
-    ULONG CommitCharge:19;
-    ULONG NoChange:1;
-    ULONG VadType:3;
-    ULONG MemCommit:1;
-    ULONG Protection:5;
-    ULONG Spare:2;
-    ULONG PrivateMemory:1;
+#ifdef _WIN64
+    ULONG_PTR CommitCharge:51;
+#else
+    ULONG_PTR CommitCharge:19;
+#endif
+    ULONG_PTR NoChange:1;
+    ULONG_PTR VadType:3;
+    ULONG_PTR MemCommit:1;
+    ULONG_PTR Protection:5;
+    ULONG_PTR Spare:2;
+    ULONG_PTR PrivateMemory:1;
 } MMVAD_FLAGS, *PMMVAD_FLAGS;
 
 //
@@ -684,11 +695,11 @@ typedef struct _MMVAD
     } u1;
     struct _MMVAD *LeftChild;
     struct _MMVAD *RightChild;
-    ULONG StartingVpn;
-    ULONG EndingVpn;
+    ULONG_PTR StartingVpn;
+    ULONG_PTR EndingVpn;
     union
     {
-        ULONG LongFlags;
+        ULONG_PTR LongFlags;
         MMVAD_FLAGS VadFlags;
     } u;
     PCONTROL_AREA ControlArea;
@@ -713,11 +724,11 @@ typedef struct _MMVAD_LONG
     } u1;
     PMMVAD LeftChild;
     PMMVAD RightChild;
-    ULONG StartingVpn;
-    ULONG EndingVpn;
+    ULONG_PTR StartingVpn;
+    ULONG_PTR EndingVpn;
     union
     {
-        ULONG LongFlags;
+        ULONG_PTR LongFlags;
         MMVAD_FLAGS VadFlags;
     } u;
     PCONTROL_AREA ControlArea;
@@ -752,11 +763,11 @@ typedef struct _MMVAD_SHORT
     } u1;
     PMMVAD LeftChild;
     PMMVAD RightChild;
-    ULONG StartingVpn;
-    ULONG EndingVpn;
+    ULONG_PTR StartingVpn;
+    ULONG_PTR EndingVpn;
     union
     {
-        ULONG LongFlags;
+        ULONG_PTR LongFlags;
         MMVAD_FLAGS VadFlags;
     } u;
 } MMVAD_SHORT, *PMMVAD_SHORT;
index dcb5b2a..08c8e0c 100644 (file)
@@ -134,16 +134,16 @@ typedef struct _TIMEINFO
 typedef struct _MEMORY_DESCRIPTOR
 {
     MEMORY_TYPE MemoryType;
-    ULONG BasePage;
-    ULONG PageCount;
+    PFN_NUMBER BasePage;
+    PFN_NUMBER PageCount;
 } MEMORY_DESCRIPTOR, *PMEMORY_DESCRIPTOR;
 
 typedef struct _MEMORY_ALLOCATION_DESCRIPTOR
 {
     LIST_ENTRY ListEntry;
     TYPE_OF_MEMORY MemoryType;
-    ULONG BasePage;
-    ULONG PageCount;
+    PFN_NUMBER BasePage;
+    PFN_NUMBER PageCount;
 } MEMORY_ALLOCATION_DESCRIPTOR, *PMEMORY_ALLOCATION_DESCRIPTOR;
 
 typedef struct _BOOT_DRIVER_LIST_ENTRY
index 205252f..4ea67c3 100644 (file)
@@ -20,7 +20,7 @@ extern "C" {
 // This guid identifies a RAM disk volume
 //
 DEFINE_GUID(RAMDISK_BOOTDISK_GUID, 0xd9b257fc, 0x684e, 0x4dcb, 0x79, 0xab, 0xf6, 0xa2, 0xcf, 0x03, 0x50, 0xb7);
-    
+
 //
 // Device Name - this string is the name of the device.  It is the name
 // that should be passed to NtOpenFile when accessing the device.
@@ -43,7 +43,7 @@ DEFINE_GUID(RAMDISK_BOOTDISK_GUID, 0xd9b257fc, 0x684e, 0x4dcb, 0x79, 0xab, 0xf6,
 #define RAMDISK_MEMORY_MAPPED_DISK        2 // Loaded from the registry
 #define RAMDISK_BOOT_DISK                 3 // Used as a boot device
 #define RAMDISK_WIM_DISK                  4 // Used as an installation device
-    
+
 //
 // Options when creating a ramdisk
 //
@@ -73,12 +73,12 @@ typedef struct _RAMDISK_CREATE_INPUT
         struct
         {
             ULONG ViewCount;
-            ULONG ViewLength;
+            SIZE_T ViewLength;
             WCHAR FileName[ANYSIZE_ARRAY];
         };
         struct
         {
-            ULONG BasePage;
+            ULONG_PTR BasePage;
             WCHAR DriveLetter;
         };
         PVOID BaseAddress;
index 4db60d7..cc5ca6a 100644 (file)
@@ -75,7 +75,7 @@ CmpIsHiveAlreadyLoaded(IN HANDLE KeyHandle,
      ObDereferenceObject(KeyBody);
      return Loaded;
  }
+
 BOOLEAN
 NTAPI
 CmpDoFlushAll(IN BOOLEAN ForceFlush)
@@ -1099,7 +1099,7 @@ DoAgain:
                                           ResultLength,
                                           &Status);
             if (Result == SearchNeedExclusiveLock)
-            {            
+            {
                 /* Release the value cell */
                 if (CellToRelease != HCELL_NIL)
                 {
@@ -1181,7 +1181,7 @@ DoAgain:
         Kcb->ValueCache.Count = Parent->ValueList.Count;
     }
 
-    /* Make sure the index is valid */    
+    /* Make sure the index is valid */
     if (Index >= Kcb->ValueCache.Count)
     {
         /* Release the cell and fail */
@@ -1552,7 +1552,7 @@ CmDeleteKey(IN PCM_KEY_BODY KeyBody)
             if (Parent)
             {
                 /* Update the maximum name length */
-                Kcb->ParentKcb->KcbMaxNameLen = Parent->MaxNameLen;
+                Kcb->ParentKcb->KcbMaxNameLen = (USHORT)Parent->MaxNameLen;
                 
                 /* Make sure we're dirty */
                 ASSERT(HvIsCellDirty(Hive, ParentCell));
@@ -1824,9 +1824,8 @@ CmCountOpenSubKeys(IN PCM_KEY_CONTROL_BLOCK RootKcb,
     PCM_KEY_HASH Entry;
     PCM_KEY_CONTROL_BLOCK CachedKcb;
     PCM_KEY_CONTROL_BLOCK ParentKcb;
-    USHORT ParentKeyCount;
-    USHORT j;
-    ULONG i;
+    ULONG ParentKeyCount;
+    ULONG i, j;
     ULONG SubKeys = 0;
 
     DPRINT("CmCountOpenSubKeys() called\n");
index 6af7e3c..73f6d0a 100644 (file)
@@ -191,9 +191,9 @@ CmpAddDriverToList(IN PHHIVE Hive,
     PBOOT_DRIVER_NODE DriverNode;
     PBOOT_DRIVER_LIST_ENTRY DriverEntry;
     PCM_KEY_NODE Node;
-    ULONG NameLength, Length;
-    HCELL_INDEX ValueCell, TagCell;    
-    PCM_KEY_VALUE Value;
+    ULONG Length;
+    USHORT NameLength;
+    HCELL_INDEX ValueCell, TagCell;    PCM_KEY_VALUE Value;
     PUNICODE_STRING FileName, RegistryString;
     UNICODE_STRING UnicodeString;
     PULONG ErrorControl;
@@ -212,7 +212,7 @@ CmpAddDriverToList(IN PHHIVE Hive,
     ASSERT(Node);
     
     /* Get the name from the cell */
-    DriverNode->Name.Length = Node->Flags & KEY_COMP_NAME ? 
+    DriverNode->Name.Length = Node->Flags & KEY_COMP_NAME ?
                               CmpCompressedNameSize(Node->Name, Node->NameLength) :
                               Node->NameLength;
     DriverNode->Name.MaximumLength = DriverNode->Name.Length;
@@ -246,14 +246,14 @@ CmpAddDriverToList(IN PHHIVE Hive,
         /* Allocate the path name */
         FileName = &DriverEntry->FilePath;
         FileName->Length = 0;
-        FileName->MaximumLength = Length;
+        FileName->MaximumLength = (USHORT)Length;
         FileName->Buffer = CmpAllocate(Length, FALSE,TAG_CM);
         if (!FileName->Buffer) return FALSE;
 
         /* Write the path name */
         RtlAppendUnicodeToString(FileName, L"System32\\Drivers\\");
         RtlAppendUnicodeStringToString(FileName, &DriverNode->Name);
-        RtlAppendUnicodeToString(FileName, L".sys");        
+        RtlAppendUnicodeToString(FileName, L".sys");
     }
     else
     {
@@ -264,11 +264,11 @@ CmpAddDriverToList(IN PHHIVE Hive,
         /* Allocate and setup the path name */
         FileName = &DriverEntry->FilePath;
         Buffer = (PWCHAR)CmpValueToData(Hive, Value, &Length);
-        FileName->MaximumLength = FileName->Length = Length;
+        FileName->MaximumLength = FileName->Length = (USHORT)Length;
         FileName->Buffer = CmpAllocate(Length, FALSE, TAG_CM);
         
-        /* Transfer the data */  
-        if (!(FileName->Buffer) || !(Buffer)) return FALSE;        
+        /* Transfer the data */
+        if (!(FileName->Buffer) || !(Buffer)) return FALSE;
         RtlCopyMemory(FileName->Buffer, Buffer, Length);
     }
     
@@ -286,7 +286,7 @@ CmpAddDriverToList(IN PHHIVE Hive,
     /* The entry is done, add it */
     InsertHeadList(BootDriverListHead, &DriverEntry->Link);
     
-    /* Now find error control settings */    
+    /* Now find error control settings */
     RtlInitUnicodeString(&UnicodeString, L"ErrorControl");
     ValueCell = CmpFindValueByName(Hive, Node, &UnicodeString);
     if (ValueCell == HCELL_NIL)
@@ -321,7 +321,7 @@ CmpAddDriverToList(IN PHHIVE Hive,
         /* Copy it into the node */
         DriverNode->Group.Buffer = (PWCHAR)CmpValueToData(Hive, Value, &Length);
         if (!DriverNode->Group.Buffer) return FALSE;
-        DriverNode->Group.Length = Length - sizeof(UNICODE_NULL);
+        DriverNode->Group.Length = (USHORT)Length - sizeof(UNICODE_NULL);
         DriverNode->Group.MaximumLength = DriverNode->Group.Length;
     }
     
@@ -522,7 +522,7 @@ CmpDoSort(IN PLIST_ENTRY DriverListHead,
 
         /* This is our cleaned up string for this specific group */
         ASSERT(End != NULL);
-        GroupName.Length = (End - Current) * sizeof(WCHAR);
+        GroupName.Length = (USHORT)(End - Current) * sizeof(WCHAR);
         GroupName.MaximumLength = GroupName.Length;
         GroupName.Buffer = Current;
 
@@ -546,7 +546,7 @@ CmpDoSort(IN PLIST_ENTRY DriverListHead,
                 RemoveEntryList(&CurrentNode->ListEntry.Link);
                 InsertHeadList(DriverListHead, &CurrentNode->ListEntry.Link);
             }
-        }        
+        }
         
         /* Move on */
         Current--;
@@ -599,7 +599,7 @@ CmpSortDriverList(IN PHHIVE Hive,
     /* Copy it into a buffer */
     DependList.Buffer = (PWCHAR)CmpValueToData(Hive, ListNode, &Length);
     if (!DependList.Buffer) return FALSE;
-    DependList.Length = DependList.MaximumLength = Length - sizeof(UNICODE_NULL);
+    DependList.Length = DependList.MaximumLength = (USHORT)Length - sizeof(UNICODE_NULL);
     
     /* And start the recurive sort algorithm */
     return CmpDoSort(DriverListHead, &DependList);
@@ -756,7 +756,7 @@ CmpIsSafe(IN PHHIVE Hive,
             /* Compose the search 'key' */
             Name.Buffer = (PWCHAR)CmpValueToData(Hive, KeyValue, &Length);
             if (!Name.Buffer) return FALSE;
-            Name.Length = Length - sizeof(UNICODE_NULL);
+            Name.Length = (USHORT)Length - sizeof(UNICODE_NULL);
             Name.MaximumLength = Name.Length;
             /* Search for corresponding key in the Safe Boot key */
             CellIndex = CmpFindSubKeyByName(Hive, SafeBootNode, &Name);
@@ -807,7 +807,7 @@ CmpIsSafe(IN PHHIVE Hive,
             if (!Name.Buffer) return FALSE;
             ++Name.Buffer;
             /* Length of the base name must be >=1 */
-            Name.Length = Length - ((PUCHAR)Name.Buffer - (PUCHAR)OriginalName)
+            Name.Length = (USHORT)Length - (USHORT)((PUCHAR)Name.Buffer - (PUCHAR)OriginalName)
                                  - sizeof(UNICODE_NULL);
             if(Name.Length < 1) return FALSE;
             Name.MaximumLength = Name.Length;
index 6d85ef7..9f75676 100644 (file)
@@ -265,7 +265,7 @@ CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName,
     if (Extension)
     {
         /* Update the name length */
-        Length += wcslen(Extension) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
+        Length += (USHORT)wcslen(Extension) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
 
         /* Allocate the buffer for the full name */
         NameBuffer = ExAllocatePoolWithTag(PagedPool, Length, TAG_CM);
@@ -407,7 +407,7 @@ CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName,
     }
 
     /* Get the disposition */
-    *PrimaryDisposition = IoStatusBlock.Information;
+    *PrimaryDisposition = (ULONG)IoStatusBlock.Information;
     if (IoStatusBlock.Information != FILE_CREATED)
     {
         /* Check how large the file is */
@@ -570,7 +570,7 @@ CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName,
         }
 
         /* Return the disposition */
-        *LogDisposition = IoStatusBlock.Information;
+        *LogDisposition = (ULONG)IoStatusBlock.Information;
     }
 
     /* We're done, close handles and free buffers */
index 8fb6afb..77e4e83 100644 (file)
@@ -153,7 +153,8 @@ CmpGetNameControlBlock(IN PUNICODE_STRING NodeName)
     ULONG i;
     BOOLEAN IsCompressed = TRUE, Found = FALSE;
     PCM_NAME_HASH HashEntry;
-    ULONG Length, NcbSize;
+    ULONG NcbSize;
+    USHORT Length;
 
     /* Loop the name */
     p = NodeName->Buffer;
@@ -519,7 +520,7 @@ NTAPI
 CmpCleanUpSubKeyInfo(IN PCM_KEY_CONTROL_BLOCK Kcb)
 {
     PCM_KEY_NODE KeyNode;
-    
+
     /* Sanity check */
     ASSERT((CmpIsKcbLockedExclusive(Kcb) == TRUE) ||
            (CmpTestRegistryLockExclusive() == TRUE));
@@ -533,7 +534,7 @@ CmpCleanUpSubKeyInfo(IN PCM_KEY_CONTROL_BLOCK Kcb)
             /* Kill it */
             CmpFree(Kcb->IndexHint, 0);
         }
-        
+
         /* Remove subkey flags */
         Kcb->ExtFlags &= ~(CM_KCB_NO_SUBKEY | CM_KCB_SUBKEY_ONE | CM_KCB_SUBKEY_HINT);
     }
@@ -581,7 +582,7 @@ CmpDereferenceKeyControlBlock(IN PCM_KEY_CONTROL_BLOCK Kcb)
     /* Get the ref count and update it */
     OldRefCount = *(PLONG)&Kcb->RefCount;
     NewRefCount = OldRefCount - 1;
-   
+
     /* Check if we still have references */
     if ((NewRefCount & 0xFFFF) > 0)
     {
@@ -594,7 +595,7 @@ CmpDereferenceKeyControlBlock(IN PCM_KEY_CONTROL_BLOCK Kcb)
             return;
         }
     }
-    
+
     /* Save the key */
     ConvKey = Kcb->ConvKey;
 
@@ -901,7 +902,8 @@ NTAPI
 CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
 {
     PUNICODE_STRING KeyName;
-    ULONG NameLength, i;
+    ULONG i;
+    USHORT NameLength;
     PCM_KEY_CONTROL_BLOCK MyKcb;
     PCM_KEY_NODE KeyNode;
     BOOLEAN DeletedKey = FALSE;
index 9f24c7e..e82d9d6 100644 (file)
@@ -75,7 +75,7 @@ CmpGetValueListFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb,
             /* We need the exclusive lock */
             return SearchNeedExclusiveLock;
         }
-                
+
         /* Select the value list as our cell, and get the actual list array */
         CellToRelease = ChildList->ValueList;
         *CellData = (PCELL_DATA)HvGetCell(Hive, CellToRelease);
@@ -688,7 +688,7 @@ CmpCompareNewValueDataAgainstKCBCache(IN PCM_KEY_CONTROL_BLOCK Kcb,
     PVOID Buffer;
     HCELL_INDEX ValueCellToRelease = HCELL_NIL, CellToRelease = HCELL_NIL;
     BOOLEAN IsSmall;
-    ULONG CompareResult;
+    ULONG_PTR CompareResult;
     PAGED_CODE();
 
     /* Check if this is a symlink */
index 9d88428..a3948b9 100644 (file)
@@ -84,7 +84,7 @@ CmpFileRead(IN PHHIVE RegistryHive,
 
     _FileOffset.QuadPart = *FileOffset;
     Status = ZwReadFile(HiveHandle, 0, 0, 0, &IoStatusBlock,
-                       Buffer, BufferLength, &_FileOffset, 0);
+                       Buffer, (ULONG)BufferLength, &_FileOffset, 0);
     return NT_SUCCESS(Status) ? TRUE : FALSE;
 }
 
@@ -104,7 +104,7 @@ CmpFileWrite(IN PHHIVE RegistryHive,
 
     _FileOffset.QuadPart = *FileOffset;
     Status = ZwWriteFile(HiveHandle, 0, 0, 0, &IoStatusBlock,
-                       Buffer, BufferLength, &_FileOffset, 0);
+                       Buffer, (ULONG)BufferLength, &_FileOffset, 0);
     return NT_SUCCESS(Status) ? TRUE : FALSE;
 }
 
index ac31d33..7ee7852 100644 (file)
@@ -374,7 +374,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
             }
 
             /* Save the ID string length now that we've created it */
-            ConfigData.ComponentEntry.IdentifierLength = strlen(Buffer) + 1;
+            ConfigData.ComponentEntry.IdentifierLength = (ULONG)strlen(Buffer) + 1;
 
             /* Initialize the registry configuration node for it */
             Status = CmpInitializeRegistryNode(&ConfigData,
@@ -400,7 +400,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
                 if (Prcb->CpuType == 3) strcpy(Buffer, "80387");
 
                 /* Save the ID string length now that we've created it */
-                ConfigData.ComponentEntry.IdentifierLength = strlen(Buffer) + 1;
+                ConfigData.ComponentEntry.IdentifierLength = (ULONG)strlen(Buffer) + 1;
 
                 /* Initialize the registry configuration node for it */
                 Status = CmpInitializeRegistryNode(&ConfigData,
@@ -722,8 +722,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
     /* Now prepare for Video BIOS Mapping of 32KB */
     BaseAddress = 0;
     ViewSize = 8 * PAGE_SIZE;
-    ViewBase.LowPart = VideoRomBase;
-    ViewBase.HighPart = 0;
+    ViewBase.QuadPart = VideoRomBase;
 
     /* Map it */
     Status = ZwMapViewOfSection(SectionHandle,
index 15a30ae..d420d3d 100644 (file)
@@ -173,7 +173,7 @@ ExCompareExchangeCallBack(IN OUT PEX_CALLBACK CallBack,
 {
     EX_FAST_REF OldValue;
     PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
-    ULONG_PTR Count;
+    ULONG Count;
 
     /* Check that we have a new block */
     if (NewBlock)
@@ -187,7 +187,7 @@ ExCompareExchangeCallBack(IN OUT PEX_CALLBACK CallBack,
             return FALSE;
         }
     }
-    
+
     /* Do the swap */
     OldValue = ExCompareSwapFastReference(&CallBack->RoutineBlock,
                                           NewBlock,
index 1fe2bb1..438c7fb 100644 (file)
@@ -36,8 +36,8 @@ NTAPI
 ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable,
                           IN EXHANDLE LookupHandle)
 {
-    ULONG i, j, k, TableLevel, NextHandle;
-    ULONG_PTR TableBase;
+    ULONG TableLevel, NextHandle;
+    ULONG_PTR i, j, k, TableBase;
     PHANDLE_TABLE_ENTRY Entry = NULL;
     EXHANDLE Handle = LookupHandle;
     PUCHAR Level1, Level2, Level3;
@@ -1147,7 +1147,7 @@ ExDupHandleTable(IN PEPROCESS Process,
                 /* Free this entry */
                 NewEntry->Object = NULL;
                 NewEntry->NextFreeTableEntry = NewTable->FirstFree;
-                NewTable->FirstFree = Handle.Value;
+                NewTable->FirstFree = (ULONG)Handle.Value;
             }
 
             /* Increase the handle value and move to the next entry */
index f017d41..1864bc0 100644 (file)
@@ -211,7 +211,7 @@ ExpInitNls(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
     PLIST_ENTRY ListHead, NextEntry;
     PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
     ULONG NlsTablesEncountered = 0;
-    ULONG NlsTableSizes[3]; /* 3 NLS tables */
+    SIZE_T NlsTableSizes[3]; /* 3 NLS tables */
 
     /* Check if this is boot-time phase 0 initialization */
     if (!ExpInitializationPhase)
@@ -418,8 +418,8 @@ ExpLoadInitialProcess(IN PINIT_BUFFER InitBuffer,
     }
 
     /* Setup the basic header, and give the process the low 1MB to itself */
-    ProcessParams->Length = Size;
-    ProcessParams->MaximumLength = Size;
+    ProcessParams->Length = (ULONG)Size;
+    ProcessParams->MaximumLength = (ULONG)Size;
     ProcessParams->Flags = RTL_USER_PROCESS_PARAMETERS_NORMALIZED |
                            RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB;
 
@@ -837,7 +837,7 @@ VOID
 NTAPI
 INIT_FUNCTION
 ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
-             IN ULONG PagesToDestroy,
+             IN ULONG_PTR PagesToDestroy,
              IN TYPE_OF_MEMORY MemoryType)
 {
     PLIST_ENTRY ListEntry;
@@ -993,10 +993,10 @@ ExpInitializeExecutive(IN ULONG Cpu,
     NlsData = LoaderBlock->NlsData;
     ExpNlsTableBase = NlsData->AnsiCodePageData;
     ExpAnsiCodePageDataOffset = 0;
-    ExpOemCodePageDataOffset = ((ULONG_PTR)NlsData->OemCodePageData -
-                                (ULONG_PTR)NlsData->AnsiCodePageData);
-    ExpUnicodeCaseTableDataOffset = ((ULONG_PTR)NlsData->UnicodeCodePageData -
-                                     (ULONG_PTR)NlsData->AnsiCodePageData);
+    ExpOemCodePageDataOffset = (ULONG)((ULONG_PTR)NlsData->OemCodePageData -
+                                       (ULONG_PTR)NlsData->AnsiCodePageData);
+    ExpUnicodeCaseTableDataOffset = (ULONG)((ULONG_PTR)NlsData->UnicodeCodePageData -
+                                            (ULONG_PTR)NlsData->AnsiCodePageData);
 
     /* Initialize the NLS Tables */
     RtlInitNlsTables((PVOID)((ULONG_PTR)ExpNlsTableBase +
@@ -1084,8 +1084,13 @@ ExpInitializeExecutive(IN ULONG Cpu,
     }
 
     /* Set system ranges */
+#ifdef _M_AMD64
+    SharedUserData->Reserved1 = MM_HIGHEST_USER_ADDRESS_WOW64;
+    SharedUserData->Reserved3 = MM_SYSTEM_RANGE_START_WOW64;
+#else
     SharedUserData->Reserved1 = (ULONG_PTR)MmHighestUserAddress;
     SharedUserData->Reserved3 = (ULONG_PTR)MmSystemRangeStart;
+#endif
 
     /* Make a copy of the NLS Tables */
     ExpInitNls(LoaderBlock);
index a82ecec..eb72423 100644 (file)
@@ -235,7 +235,7 @@ ExInitializeNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside,
     Lookaside->L.FreeMisses = 0;
     Lookaside->L.Type = NonPagedPool | Flags;
     Lookaside->L.Tag = Tag;
-    Lookaside->L.Size = Size;
+    Lookaside->L.Size = (ULONG)Size;
     Lookaside->L.Depth = 4;
     Lookaside->L.MaximumDepth = 256;
     Lookaside->L.LastTotalAllocates = 0;
@@ -287,7 +287,7 @@ ExInitializePagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside,
     Lookaside->L.FreeMisses = 0;
     Lookaside->L.Type = PagedPool | Flags;
     Lookaside->L.Tag = Tag;
-    Lookaside->L.Size = Size;
+    Lookaside->L.Size = (ULONG)Size;
     Lookaside->L.Depth = 4;
     Lookaside->L.MaximumDepth = 256;
     Lookaside->L.LastTotalAllocates = 0;
index adf8221..173d4d6 100644 (file)
@@ -489,7 +489,7 @@ NtQueryIntervalProfile(IN KPROFILE_SOURCE ProfileSource,
     }
 
     /* Query the Interval */
-    ReturnInterval = KeQueryIntervalProfile(ProfileSource);
+    ReturnInterval = (ULONG)KeQueryIntervalProfile(ProfileSource);
 
     /* Enter SEH block for return */
     _SEH2_TRY
index 18ef8d6..e62b774 100644 (file)
@@ -117,7 +117,7 @@ ExfWakePushLock(PEX_PUSH_LOCK PushLock,
         {
             /* Get the last wait block */
             LastWaitBlock = WaitBlock->Last;
-        
+
             /* Check if we found it */
             if (LastWaitBlock)
             {
@@ -534,7 +534,7 @@ ExfAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
                 WaitBlock->Last = WaitBlock;
 
                 /* Set the share count */
-                WaitBlock->ShareCount = OldValue.Shared;
+                WaitBlock->ShareCount = (LONG)OldValue.Shared;
 
                 /* Check if someone is sharing this pushlock */
                 if (OldValue.Shared > 1)
@@ -879,7 +879,7 @@ ExfReleasePushLock(PEX_PUSH_LOCK PushLock)
                 }
             }
             
-            /* 
+            /*
              * If nobody was waiting on the block, then we possibly reduced the number
              * of times the pushlock was shared, and we unlocked it.
              * If someone was waiting, and more then one person is waiting, then we
@@ -1015,7 +1015,7 @@ ExfReleasePushLockShared(PEX_PUSH_LOCK PushLock)
         if (InterlockedDecrement(&WaitBlock->ShareCount) > 0) return;
     }
 
-    /* 
+    /*
      * If nobody was waiting on the block, then we possibly reduced the number
      * of times the pushlock was shared, and we unlocked it.
      * If someone was waiting, and more then one person is waiting, then we
index 6c1a017..400a2a2 100644 (file)
@@ -88,7 +88,7 @@ ExpQueryModuleInformation(IN PLIST_ENTRY KernelModeList,
                 }
 
                 /* Set the offset */
-                ModuleInfo->OffsetToFileName = p - ModuleName.Buffer;
+                ModuleInfo->OffsetToFileName = (USHORT)(p - ModuleName.Buffer);
             }
             else
             {
@@ -478,8 +478,8 @@ QSI_DEF(SystemBasicInformation)
     Sbi->TimerResolution = KeMaximumIncrement;
     Sbi->PageSize = PAGE_SIZE;
     Sbi->NumberOfPhysicalPages = MmNumberOfPhysicalPages;
-    Sbi->LowestPhysicalPageNumber = MmLowestPhysicalPage;
-    Sbi->HighestPhysicalPageNumber = MmHighestPhysicalPage;
+    Sbi->LowestPhysicalPageNumber = (ULONG)MmLowestPhysicalPage;
+    Sbi->HighestPhysicalPageNumber = (ULONG)MmHighestPhysicalPage;
     Sbi->AllocationGranularity = MM_VIRTMEM_GRANULARITY; /* hard coded on Intel? */
     Sbi->MinimumUserModeAddress = 0x10000; /* Top of 64k */
     Sbi->MaximumUserModeAddress = (ULONG_PTR)MmHighestUserAddress;
@@ -542,7 +542,7 @@ QSI_DEF(SystemPerformanceInformation)
     Spi->IoWriteOperationCount = IoWriteOperationCount;
     Spi->IoOtherOperationCount = IoOtherOperationCount;
 
-    Spi->AvailablePages = MmAvailablePages;
+    Spi->AvailablePages = (ULONG)MmAvailablePages;
     /*
      *   Add up all the used "Committed" memory + pagefile.
      *   Not sure this is right. 8^\
@@ -759,7 +759,7 @@ QSI_DEF(SystemProcessInformation)
             }
             if (!ImageNameLength && Process != PsIdleProcess && Process->ImageFileName)
             {
-              ImageNameLength = strlen(Process->ImageFileName) * sizeof(WCHAR);
+              ImageNameLength = (USHORT)strlen(Process->ImageFileName) * sizeof(WCHAR);
             }
 
             /* Round up the image name length as NT does */
@@ -1781,9 +1781,9 @@ QSI_DEF(SystemRangeStartInformation)
     if (Size != sizeof(ULONG_PTR)) return STATUS_INFO_LENGTH_MISMATCH;
 
     *(PULONG_PTR)Buffer = (ULONG_PTR)MmSystemRangeStart;
-    
+
     if (ReqSize) *ReqSize = sizeof(ULONG_PTR);
-    
+
     return STATUS_SUCCESS;
 }
 
index 1b6c21c..53995a1 100644 (file)
@@ -199,7 +199,7 @@ FsRtlCopyRead(IN PFILE_OBJECT FileObject,
             if (IoStatus->Status != STATUS_END_OF_FILE)
             {
                 ASSERT((ULONGLONG)FcbHeader->FileSize.QuadPart >=
-                       (FileOffset->QuadPart + IoStatus->Information));
+                      ((ULONGLONG)FileOffset->QuadPart + IoStatus->Information));
             }
         }
         else
@@ -219,7 +219,7 @@ FsRtlCopyRead(IN PFILE_OBJECT FileObject,
             if (Result == TRUE)
             {
                 ASSERT((IoStatus->Status == STATUS_END_OF_FILE) ||
-                       ((FileOffset->QuadPart + IoStatus->Information) <=
+                       (((ULONGLONG)FileOffset->QuadPart + IoStatus->Information) <=
                         (ULONGLONG)FcbHeader->FileSize.QuadPart));
             }
         }
index 72643f8..d8c284f 100644 (file)
@@ -1374,7 +1374,9 @@ FstubFixupEfiPartition(IN PPARTITION_DESCRIPTOR PartitionDescriptor,
     if (PartitionLength > MaxOffset)
     {
         /* Resize partition to its maximum real length */
-        PartitionDescriptor->PartitionLengthLsb0 = MaxOffset - PartitionDescriptor->StartingSectorLsb0;
+#pragma message("--> FIXME: FstubFixupEfiPartition is most likeley broken!")
+        PartitionDescriptor->PartitionLengthLsb0 =
+            (UCHAR)(MaxOffset - PartitionDescriptor->StartingSectorLsb0);
     }
 }
 
index a89ce80..99cc28c 100644 (file)
@@ -72,7 +72,7 @@ NTAPI
 xHalVectorToIDTEntry(IN ULONG Vector)
 {
     /* Return the vector */
-    return Vector;
+    return (UCHAR)Vector;
 }
 
 VOID
index 8e473e9..54ee876 100644 (file)
@@ -250,7 +250,7 @@ KiUserTrap(IN PKTRAP_FRAME TrapFrame)
     return !!(TrapFrame->SegCs & MODE_MASK);
 }
 
-#define Ki386PerfEnd(x)
+#define Ki386PerfEnd()
 
 struct _KPCR;
 
@@ -319,6 +319,16 @@ KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine,
 // HACK
 extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount;
 
+// win64 uses DMA macros, this one is not defined
+NTHALAPI
+NTSTATUS
+NTAPI
+HalAllocateAdapterChannel(
+  IN PADAPTER_OBJECT  AdapterObject,
+  IN PWAIT_CONTEXT_BLOCK  Wcb,
+  IN ULONG  NumberOfMapRegisters,
+  IN PDRIVER_CONTROL  ExecutionRoutine);
+
 #endif /* __NTOSKRNL_INCLUDE_INTERNAL_AMD64_KE_H */
 
 /* EOF */
index 8c5db54..a922fe0 100644 (file)
@@ -59,6 +59,9 @@
 #define MM_HIGHEST_VAD_ADDRESS \
     (PVOID)((ULONG_PTR)MM_HIGHEST_USER_ADDRESS - (16 * PAGE_SIZE))
 
+#define MM_HIGHEST_USER_ADDRESS_WOW64 0x7FFEFFFF
+#define MM_SYSTEM_RANGE_START_WOW64   0x80000000
+
 PULONG64
 FORCEINLINE
 MmGetPageDirectory(VOID)
@@ -145,9 +148,9 @@ MiIsPdeForAddressValid(PVOID Address)
 #define MiPdeToPte(PDE) ((PMMPTE)MiPteToAddress(PDE))
 #define MiPteToPde(PTE) ((PMMPDE)MiAddressToPte(PTE))
 
-#define ADDR_TO_PAGE_TABLE(v) (((ULONG_PTR)(v)) / (512 * PAGE_SIZE))
-#define ADDR_TO_PDE_OFFSET(v) ((((ULONG_PTR)(v)) / (512 * PAGE_SIZE)))
-#define ADDR_TO_PTE_OFFSET(v)  ((((ULONG_PTR)(v)) % (512 * PAGE_SIZE)) / PAGE_SIZE)
+#define ADDR_TO_PAGE_TABLE(v) ((ULONG)(((ULONG_PTR)(v)) / (512 * PAGE_SIZE)))
+#define ADDR_TO_PDE_OFFSET(v) ((ULONG)((((ULONG_PTR)(v)) / (512 * PAGE_SIZE))))
+#define ADDR_TO_PTE_OFFSET(v)  ((ULONG)((((ULONG_PTR)(v)) % (512 * PAGE_SIZE)) / PAGE_SIZE))
 
 #define MiGetPdeOffset ADDR_TO_PDE_OFFSET
 
index c4ca69d..69122da 100644 (file)
@@ -416,7 +416,7 @@ typedef struct _BOOT_DRIVER_NODE
     ULONG Tag;
     ULONG ErrorControl;
 } BOOT_DRIVER_NODE, *PBOOT_DRIVER_NODE;
+
 //
 // List of Bus Type GUIDs
 //
@@ -536,7 +536,7 @@ NTSTATUS
 NTAPI
 PipCallDriverAddDevice(
     IN PDEVICE_NODE DeviceNode,
-    IN BOOLEAN LoadDriver,     
+    IN BOOLEAN LoadDriver,
     IN PDRIVER_OBJECT DriverObject
 );
 
@@ -618,7 +618,7 @@ NTAPI
 IopInitiatePnpIrp(
     IN PDEVICE_OBJECT DeviceObject,
     IN PIO_STATUS_BLOCK IoStatusBlock,
-    IN ULONG MinorFunction,
+    IN UCHAR MinorFunction,
     IN PIO_STACK_LOCATION Stack
 );
 
@@ -743,7 +743,7 @@ PnpRegSzToString(
     IN ULONG RegSzLength,
     OUT PUSHORT StringLength OPTIONAL
 );
-                                               
+
 //
 // Initialization Routines
 //
index 405aed1..444afbb 100644 (file)
@@ -523,6 +523,6 @@ extern KD_BREAKPOINT_TYPE KdpBreakpointInstruction;
 extern BOOLEAN KdpOweBreakpoint;
 extern BOOLEAN BreakpointsSuspended;
 extern ULONG KdpNumInternalBreakpoints;
-extern ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
+extern ULONG_PTR KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
 extern ULONG TraceDataBuffer[40];
 extern ULONG TraceDataBufferPosition;
index 1dbb1f4..48ee7df 100644 (file)
@@ -87,9 +87,9 @@ extern PVOID KeRaiseUserExceptionDispatcher;
 extern LARGE_INTEGER KeBootTime;
 extern ULONGLONG KeBootTimeBias;
 extern BOOLEAN ExCmosClockIsSane;
-extern ULONG KeProcessorArchitecture;
-extern ULONG KeProcessorLevel;
-extern ULONG KeProcessorRevision;
+extern USHORT KeProcessorArchitecture;
+extern USHORT KeProcessorLevel;
+extern USHORT KeProcessorRevision;
 extern ULONG KeFeatureBits;
 extern KNODE KiNode0;
 extern PKNODE KeNodeBlock[1];
@@ -125,7 +125,7 @@ extern LIST_ENTRY KiStackInSwapListHead;
 extern KEVENT KiSwapEvent;
 extern PKPRCB KiProcessorBlock[];
 extern ULONG KiMask32Array[MAXIMUM_PRIORITY];
-extern ULONG KiIdleSummary;
+extern ULONG_PTR KiIdleSummary;
 extern PVOID KeUserApcDispatcher;
 extern PVOID KeUserCallbackDispatcher;
 extern PVOID KeUserExceptionDispatcher;
@@ -450,7 +450,7 @@ KeInitializeProfile(
     struct _KPROFILE* Profile,
     struct _KPROCESS* Process,
     PVOID ImageBase,
-    ULONG ImageSize,
+    SIZE_T ImageSize,
     ULONG BucketSize,
     KPROFILE_SOURCE ProfileSource,
     KAFFINITY Affinity
@@ -628,7 +628,7 @@ VOID
 FASTCALL
 KiUnlinkThread(
     IN PKTHREAD Thread,
-    IN NTSTATUS WaitStatus
+    IN LONG_PTR WaitStatus
 );
 
 VOID
@@ -653,7 +653,7 @@ KeInitializeProcess(
     struct _KPROCESS *Process,
     KPRIORITY Priority,
     KAFFINITY Affinity,
-    PULONG DirectoryTableBase,
+    PULONG_PTR DirectoryTableBase,
     IN BOOLEAN Enable
 );
 
index 803dc81..8bedbcd 100644 (file)
@@ -7,12 +7,12 @@
 struct _EPROCESS;
 
 extern PMMSUPPORT MmKernelAddressSpace;
-extern PFN_NUMBER MiFreeSwapPages;
-extern PFN_NUMBER MiUsedSwapPages;
+extern PFN_COUNT MiFreeSwapPages;
+extern PFN_COUNT MiUsedSwapPages;
 extern SIZE_T MmTotalPagedPoolQuota;
 extern SIZE_T MmTotalNonPagedPoolQuota;
 extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
-extern PFN_NUMBER MmNumberOfPhysicalPages;
+extern PFN_COUNT MmNumberOfPhysicalPages;
 extern UCHAR MmDisablePagingExecutive;
 extern PFN_NUMBER MmLowestPhysicalPage;
 extern PFN_NUMBER MmHighestPhysicalPage;
@@ -50,7 +50,7 @@ struct _KTRAP_FRAME;
 struct _EPROCESS;
 struct _MM_RMAP_ENTRY;
 struct _MM_PAGEOP;
-typedef ULONG SWAPENTRY;
+typedef ULONG_PTR SWAPENTRY;
 
 //
 // MmDbgCopyMemory Flags
@@ -207,7 +207,7 @@ typedef struct _MM_SECTION_SEGMENT
     LONG FileOffset;           /* start offset into the file for image sections */
     ULONG_PTR VirtualAddress;  /* dtart offset into the address range for image sections */
     ULONG RawLength;           /* length of the segment which is part of the mapped file */
-    ULONG Length;                      /* absolute length of the segment */
+    SIZE_T Length;                     /* absolute length of the segment */
     ULONG Protection;
     FAST_MUTEX Lock;           /* lock which protects the page directory */
     ULONG ReferenceCount;
@@ -464,7 +464,7 @@ typedef struct _MM_REGION
 {
     ULONG Type;
     ULONG Protect;
-    ULONG Length;
+    SIZE_T Length;
     LIST_ENTRY RegionListEntry;
 } MM_REGION, *PMM_REGION;
 
@@ -472,7 +472,7 @@ typedef struct _MM_REGION
 typedef struct _MMFREE_POOL_ENTRY
 {
     LIST_ENTRY List;
-    PFN_NUMBER Size;
+    PFN_COUNT Size;
     ULONG Signature;
     struct _MMFREE_POOL_ENTRY *Owner;
 } MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY;
@@ -499,7 +499,7 @@ typedef VOID
 (*PMM_ALTER_REGION_FUNC)(
     PMMSUPPORT AddressSpace,
     PVOID BaseAddress,
-    ULONG Length,
+    SIZE_T Length,
     ULONG OldType,
     ULONG OldProtect,
     ULONG NewType,
@@ -545,7 +545,7 @@ MmCreateMemoryArea(
     PMMSUPPORT AddressSpace,
     ULONG Type,
     PVOID *BaseAddress,
-    ULONG_PTR Length,
+    SIZE_T Length,
     ULONG Protection,
     PMEMORY_AREA *Result,
     BOOLEAN FixedAddress,
@@ -594,14 +594,14 @@ NTAPI
 MmLocateMemoryAreaByRegion(
     PMMSUPPORT AddressSpace,
     PVOID Address,
-    ULONG_PTR Length
+    SIZE_T Length
 );
 
 PVOID
 NTAPI
 MmFindGap(
     PMMSUPPORT AddressSpace,
-    ULONG_PTR Length,
+    SIZE_T Length,
     ULONG_PTR Granularity,
     BOOLEAN TopDown
 );
@@ -617,7 +617,7 @@ MmReleaseMemoryAreaIfDecommitted(
 VOID
 NTAPI
 MmMapMemoryArea(PVOID BaseAddress,
-                ULONG Length,
+                SIZE_T Length,
                 ULONG Consumer,
                 ULONG Protection);
 
@@ -940,7 +940,7 @@ MmProtectAnonMem(
     PMMSUPPORT AddressSpace,
     PMEMORY_AREA MemoryArea,
     PVOID BaseAddress,
-    ULONG Length,
+    SIZE_T Length,
     ULONG Protect,
     PULONG OldProtect
 );
@@ -1536,7 +1536,7 @@ MmAlterRegion(
     PVOID BaseAddress,
     PLIST_ENTRY RegionListHead,
     PVOID StartAddress,
-    ULONG Length,
+    SIZE_T Length,
     ULONG NewType,
     ULONG NewProtect,
     PMM_ALTER_REGION_FUNC AlterFunc
@@ -1584,7 +1584,7 @@ MmGetFileNameForSection(
 PVOID
 NTAPI
 MmAllocateSection(
-    IN ULONG Length,
+    IN SIZE_T Length,
     PVOID BaseAddress
 );
 
@@ -1603,7 +1603,7 @@ MmProtectSectionView(
     PMMSUPPORT AddressSpace,
     PMEMORY_AREA MemoryArea,
     PVOID BaseAddress,
-    ULONG Length,
+    SIZE_T Length,
     ULONG Protect,
     PULONG OldProtect
 );
index cd69095..3c8ad1e 100644 (file)
@@ -57,7 +57,7 @@
 // Identifies a Kernel Handle
 //
 #define KERNEL_HANDLE_FLAG                              \
-    (1 << ((sizeof(HANDLE) * 8) - 1))
+    ((ULONG_PTR)1 << ((sizeof(HANDLE) * 8) - 1))
 #define ObIsKernelHandle(Handle, ProcessorMode)         \
     (((ULONG_PTR)(Handle) & KERNEL_HANDLE_FLAG) &&      \
     ((ProcessorMode) == KernelMode))
index 4a2f0b4..597134a 100644 (file)
@@ -1,6 +1,9 @@
 #pragma once
 
 #ifdef _WIN64
+VOID
+NTAPI
+RtlInitializeSListHead(IN PSLIST_HEADER ListHead);
 #define InitializeSListHead RtlInitializeSListHead
 #endif
 
index a49fdfc..58457d2 100644 (file)
@@ -44,7 +44,7 @@ IopCreateArcNames(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
     CHAR Buffer[128];
     ANSI_STRING ArcSystemString, ArcString;
     BOOLEAN SingleDisk;
-    ULONG Length;
+    SIZE_T Length;
     NTSTATUS Status;
     BOOLEAN FoundBoot = FALSE;
 
index 308fa65..19affc9 100644 (file)
@@ -129,7 +129,7 @@ IopBootLog(PUNICODE_STRING DriverName,
                            0,
                            REG_SZ,
                            (PVOID)Buffer,
-                           (wcslen(Buffer) + 1) * sizeof(WCHAR));
+                           (ULONG)(wcslen(Buffer) + 1) * sizeof(WCHAR));
     ZwClose(BootLogKey);
     ZwClose(ControlSetKey);
 
@@ -191,8 +191,8 @@ IopWriteLogFile(PWSTR LogText)
                              NULL,
                              NULL,
                              &IoStatusBlock,
-                             (PVOID)LogText,
-                             wcslen(LogText) * sizeof(WCHAR),
+                             LogText,
+                             (ULONG)wcslen(LogText) * sizeof(WCHAR),
                              NULL,
                              NULL);
         if (!NT_SUCCESS(Status))
index 6d6adcf..912a0ec 100644 (file)
@@ -332,7 +332,7 @@ IopOpenInterfaceKey(IN CONST GUID *InterfaceClassGuid,
     }
 
     KeyName.Length = 0;
-    KeyName.MaximumLength = LocalMachine.Length + (wcslen(REGSTR_PATH_DEVICE_CLASSES) + 1) * sizeof(WCHAR) + GuidString.Length;
+    KeyName.MaximumLength = LocalMachine.Length + ((USHORT)wcslen(REGSTR_PATH_DEVICE_CLASSES) + 1) * sizeof(WCHAR) + GuidString.Length;
     KeyName.Buffer = ExAllocatePool(PagedPool, KeyName.MaximumLength);
     if (!KeyName.Buffer)
     {
@@ -736,7 +736,8 @@ IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid,
             if (ReturnBuffer.Length + KeyName.Length + sizeof(WCHAR) > ReturnBuffer.MaximumLength)
             {
                 PWSTR NewBuffer;
-                ReturnBuffer.MaximumLength = max(ReturnBuffer.MaximumLength * 2, ReturnBuffer.Length + KeyName.Length + 2 * sizeof(WCHAR));
+                ReturnBuffer.MaximumLength = (USHORT)max(ReturnBuffer.MaximumLength * 2,
+                                                 ReturnBuffer.Length + KeyName.Length + 2 * sizeof(WCHAR));
                 NewBuffer = ExAllocatePool(PagedPool, ReturnBuffer.MaximumLength);
                 if (!NewBuffer)
                 {
@@ -756,11 +757,11 @@ IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid,
                 DPRINT("RtlAppendUnicodeStringToString() failed with status 0x%08lx\n", Status);
                 goto cleanup;
             }
-            /* RtlAppendUnicodeStringToString added a NULL at the end of the    
-            * destination string, but didn't increase the Length field.         
-            * Do it for it.     
-            */          
-           ReturnBuffer.Length += sizeof(WCHAR);
+            /* RtlAppendUnicodeStringToString added a NULL at the end of the
+             * destination string, but didn't increase the Length field.
+             * Do it for it.
+             */
+            ReturnBuffer.Length += sizeof(WCHAR);
 
 NextReferenceString:
             ExFreePool(ReferenceBi);
@@ -946,7 +947,7 @@ IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject,
     /* Create base key name for this interface: HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses\{GUID} */
     ASSERT(((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode);
     InstancePath = &((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode->InstancePath;
-    BaseKeyName.Length = wcslen(BaseKeyString) * sizeof(WCHAR);
+    BaseKeyName.Length = (USHORT)wcslen(BaseKeyString) * sizeof(WCHAR);
     BaseKeyName.MaximumLength = BaseKeyName.Length
         + GuidString.Length;
     BaseKeyName.Buffer = ExAllocatePool(
@@ -1309,7 +1310,7 @@ IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName,
         DPRINT1("IoGetDeviceObjectPointer() failed with status 0x%08lx\n", Status);
         return Status;
     }
-    
+
     Status = RtlGUIDFromString(&GuidString, &DeviceGuid);
     if (!NT_SUCCESS(Status))
     {
index 1689f02..161ffa4 100644 (file)
@@ -548,7 +548,7 @@ IopAttachFilterDriversCallback(
       DPRINT("Filter Driver: %S (%wZ)\n", Filters, &DeviceNode->InstancePath);
       ServiceName.Buffer = Filters;
       ServiceName.MaximumLength =
-      ServiceName.Length = wcslen(Filters) * sizeof(WCHAR);
+      ServiceName.Length = (USHORT)wcslen(Filters) * sizeof(WCHAR);
 
       /* Load and initialize the filter driver */
       Status = IopLoadServiceModule(&ServiceName, &ModuleObject);
@@ -840,7 +840,7 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
    FileExtension = wcsrchr(ServiceName.Buffer, '.');
    if (FileExtension != NULL)
    {
-      ServiceName.Length -= wcslen(FileExtension) * sizeof(WCHAR);
+      ServiceName.Length -= (USHORT)wcslen(FileExtension) * sizeof(WCHAR);
       FileExtension[0] = 0;
    }
 
@@ -1168,7 +1168,7 @@ IopUnloadDriver(PUNICODE_STRING DriverServiceName, BOOLEAN UnloadPnpDrivers)
     * Construct the driver object name
     */
 
-   ObjectName.Length = (wcslen(Start) + 8) * sizeof(WCHAR);
+   ObjectName.Length = ((USHORT)wcslen(Start) + 8) * sizeof(WCHAR);
    ObjectName.MaximumLength = ObjectName.Length + sizeof(WCHAR);
    ObjectName.Buffer = ExAllocatePool(PagedPool, ObjectName.MaximumLength);
    if (!ObjectName.Buffer) return STATUS_INSUFFICIENT_RESOURCES;
@@ -1942,7 +1942,7 @@ IopLoadUnloadDriver(PLOAD_UNLOAD_PARAMS LoadParams)
                (VOID)KeSetEvent(&LoadParams->Event, 0, FALSE);
                return;
            }
-           
+
            /* Initialize and start device */
            IopInitializeDevice(DeviceNode, DriverObject);
            Status = IopStartDevice(DeviceNode);
index 4060e65..0fa5f56 100644 (file)
@@ -217,8 +217,8 @@ IopLogWorker(IN PVOID Parameter)
         StringBuffer = ALIGN_UP_POINTER(StringBuffer, WCHAR);
 
         /* Set the offset for the driver's name to the current buffer */
-        ErrorMessage->DriverNameOffset = (ULONG_PTR)(StringBuffer -
-                                                 (ULONG_PTR)ErrorMessage);
+        ErrorMessage->DriverNameOffset = (ULONG)(StringBuffer -
+                                                (PCHAR)ErrorMessage);
 
         /* Check how much space we have left for the device string */
         RemainingLength = (ULONG)((ULONG_PTR)Message +
@@ -258,7 +258,7 @@ IopLogWorker(IN PVOID Parameter)
         {
             /* Use default name */
             DriverNameString.Buffer = L"Application Popup";
-            DriverNameLength = wcslen(DriverNameString.Buffer) * sizeof(WCHAR);
+            DriverNameLength = (ULONG)wcslen(DriverNameString.Buffer) * sizeof(WCHAR);
         }
 
         /* Check if we have a driver name by here */
index 745a964..4898352 100644 (file)
@@ -1281,7 +1281,7 @@ IopSecurityFile(IN PVOID ObjectBody,
         _SEH2_TRY
         {
             /* Return length */
-            *BufferLength = IoStatusBlock.Information;
+            *BufferLength = (ULONG)IoStatusBlock.Information;
         }
         _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
         {
@@ -1394,9 +1394,9 @@ IopQueryNameFile(IN PVOID ObjectBody,
     /* Now calculate the new lengths left */
     FileLength = LocalReturnLength -
                  FIELD_OFFSET(FILE_NAME_INFORMATION, FileName);
-    LocalReturnLength = (ULONG_PTR)p -
-                        (ULONG_PTR)ObjectNameInfo +
-                        LocalFileInfo->FileNameLength;
+    LocalReturnLength = (ULONG)((ULONG_PTR)p -
+                                (ULONG_PTR)ObjectNameInfo +
+                                LocalFileInfo->FileNameLength);
 
     /* Write the Name and null-terminate it */
     RtlCopyMemory(p, LocalFileInfo->FileName, FileLength);
@@ -1408,7 +1408,7 @@ IopQueryNameFile(IN PVOID ObjectBody,
     *ReturnLength = LocalReturnLength;
 
     /* Setup the length and maximum length */
-    FileLength = (ULONG_PTR)p - (ULONG_PTR)ObjectNameInfo;
+    FileLength = (ULONG)((ULONG_PTR)p - (ULONG_PTR)ObjectNameInfo);
     ObjectNameInfo->Name.Length = (USHORT)FileLength -
                                           sizeof(OBJECT_NAME_INFORMATION);
     ObjectNameInfo->Name.MaximumLength = (USHORT)ObjectNameInfo->Name.Length +
index 49976c6..a440022 100644 (file)
@@ -630,7 +630,7 @@ IopQueryDeviceInformation(IN PFILE_OBJECT FileObject,
     }
 
     /* Return the Length and Status. ReturnedLength is NOT optional */
-    *ReturnedLength = IoStatusBlock.Information;
+    *ReturnedLength = (ULONG)IoStatusBlock.Information;
     return Status;
 }
 
index c6ca981..9810cc1 100644 (file)
@@ -132,8 +132,8 @@ IoBuildPartialMdl(IN PMDL SourceMdl,
     TargetMdl->MappedSystemVa = (PCHAR)SourceMdl->MappedSystemVa + Offset;
 
     /* Now do the copy */
-    Offset = ((ULONG_PTR)TargetMdl->StartVa - (ULONG_PTR)SourceMdl->StartVa) >>
-             PAGE_SHIFT;
+    Offset = (ULONG)(((ULONG_PTR)TargetMdl->StartVa -
+                      (ULONG_PTR)SourceMdl->StartVa) >> PAGE_SHIFT);
     SourcePages += Offset;
     RtlCopyMemory(TargetPages, SourcePages, Length * sizeof(PFN_NUMBER));
 }
index 2e25a40..91596ba 100644 (file)
@@ -1832,7 +1832,7 @@ NTAPI
 IoIs32bitProcess(
     IN PIRP Irp OPTIONAL)
 {
-#pragma message "IoIs32bitProcess is hardcoded to FALSE"
+    UNIMPLEMENTED;
     return FALSE;
 }
 #endif
index e2c0bce..747b9b2 100644 (file)
@@ -186,7 +186,7 @@ IoCheckEaBufferValidity(IN PFILE_FULL_EA_INFORMATION EaBuffer,
             EaBufferEnd->EaNameLength + EaBufferEnd->EaValueLength +
             FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]) + 1;
 
-        if (IntEaLength >= NextEaBufferOffset)
+        if ((ULONG)IntEaLength >= NextEaBufferOffset)
         {
             /* is the EaBufferName terminated with zero? */
             if (EaBufferEnd->EaName[EaBufferEnd->EaNameLength]==0)
index 7811632..a89f8a7 100644 (file)
@@ -21,7 +21,7 @@ typedef struct _IOPNP_DEVICE_EXTENSION
 } IOPNP_DEVICE_EXTENSION, *PIOPNP_DEVICE_EXTENSION;
 
 PUNICODE_STRING PiInitGroupOrderTable;
-ULONG PiInitGroupOrderTableCount;
+USHORT PiInitGroupOrderTableCount;
 INTERFACE_TYPE PnpDefaultInterfaceType;
 
 /* FUNCTIONS ******************************************************************/
@@ -90,7 +90,7 @@ PiInitCacheGroupInformation(VOID)
                 
                 /* Cache it for later */
                 PiInitGroupOrderTable = GroupTable;
-                PiInitGroupOrderTableCount = Count;
+                PiInitGroupOrderTableCount = (USHORT)Count;
             }
             else
             {
@@ -113,7 +113,7 @@ PpInitGetGroupOrderIndex(IN HANDLE ServiceHandle)
 {
     NTSTATUS Status;
     PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
-    ULONG i;
+    USHORT i;
     PVOID Buffer;
     UNICODE_STRING Group;
     PAGED_CODE();
@@ -135,7 +135,7 @@ PpInitGetGroupOrderIndex(IN HANDLE ServiceHandle)
     /* Convert to unicode string */
     Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset);
     PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &Group.Length);
-    Group.MaximumLength = KeyValueInformation->DataLength;
+    Group.MaximumLength = (USHORT)KeyValueInformation->DataLength;
     Group.Buffer = Buffer;
     
     /* Loop the groups */
@@ -162,7 +162,8 @@ PipGetDriverTagPriority(IN HANDLE ServiceHandle)
     PVOID Buffer;
     UNICODE_STRING Group;
     PULONG GroupOrder;
-    ULONG i = -1, Count, Tag = 0;
+    ULONG Count, Tag = 0;
+    USHORT i = -1;
     UNICODE_STRING GroupString =
     RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet"
                         L"\\Control\\ServiceGroupOrder");
@@ -182,7 +183,7 @@ PipGetDriverTagPriority(IN HANDLE ServiceHandle)
         /* Convert to unicode string */
         Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset);
         PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &Group.Length);
-        Group.MaximumLength = KeyValueInformation->DataLength;
+        Group.MaximumLength = (USHORT)KeyValueInformation->DataLength;
         Group.Buffer = Buffer;
     }
 
@@ -246,9 +247,9 @@ Quickie:
 NTSTATUS
 NTAPI
 PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
-                       IN BOOLEAN LoadDriver,     
+                       IN BOOLEAN LoadDriver,
                        IN PDRIVER_OBJECT DriverObject)
-{ 
+{
     NTSTATUS Status;
     HANDLE EnumRootKey, SubKey, ControlKey, ClassKey, PropertiesKey;
     UNICODE_STRING ClassGuid, Properties;
@@ -290,7 +291,7 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
         /* Convert to unicode string */
         Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset);
         PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &ClassGuid.Length);
-        ClassGuid.MaximumLength = KeyValueInformation->DataLength;
+        ClassGuid.MaximumLength = (USHORT)KeyValueInformation->DataLength;
         ClassGuid.Buffer = Buffer;
         
         /* Open the key */
@@ -483,7 +484,7 @@ IopInitializePlugPlayServices(VOID)
     
     /* Report the device to the user-mode pnp manager */
     IopQueueTargetDeviceEvent(&GUID_DEVICE_ARRIVAL,
-                              &IopRootDeviceNode->InstancePath);   
+                              &IopRootDeviceNode->InstancePath);
     
     /* Initialize the Bus Type GUID List */
     PnpBusTypeGuidList = ExAllocatePool(PagedPool, sizeof(IO_BUS_TYPE_GUID_LIST));
index 2eff988..7791743 100644 (file)
@@ -94,7 +94,7 @@ IopInitializeDevice(PDEVICE_NODE DeviceNode,
       DriverObject, DeviceNode->PhysicalDeviceObject);
    if (!NT_SUCCESS(Status))
    {
-      DPRINT1("%wZ->AddDevice(%wZ) failed with status 0x%x\n", 
+      DPRINT1("%wZ->AddDevice(%wZ) failed with status 0x%x\n",
               &DriverObject->DriverName,
               &DeviceNode->InstancePath,
               Status);
@@ -146,7 +146,7 @@ IopSendEject(IN PDEVICE_OBJECT DeviceObject)
     Stack.MajorFunction = IRP_MJ_PNP;
     Stack.MinorFunction = IRP_MN_EJECT;
     
-    return IopSynchronousCall(DeviceObject, &Stack, &Dummy); 
+    return IopSynchronousCall(DeviceObject, &Stack, &Dummy);
 }
 
 static
@@ -932,7 +932,7 @@ NTSTATUS
 NTAPI
 IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject,
                   IN OUT PIO_STATUS_BLOCK IoStatusBlock,
-                  IN ULONG MinorFunction,
+                  IN UCHAR MinorFunction,
                   IN PIO_STACK_LOCATION Stack OPTIONAL)
 {
     IO_STACK_LOCATION IoStackLocation;
@@ -1044,7 +1044,7 @@ IopCreateDeviceKeyPath(IN PCUNICODE_STRING RegistryPath,
     OBJECT_ATTRIBUTES ObjectAttributes;
     UNICODE_STRING KeyName;
     LPCWSTR Current, Last;
-    ULONG dwLength;
+    USHORT Length;
     NTSTATUS Status;
 
     /* Assume failure */
@@ -1076,8 +1076,8 @@ IopCreateDeviceKeyPath(IN PCUNICODE_STRING RegistryPath,
         }
 
         /* Prepare relative key name */
-        dwLength = (ULONG_PTR)Current - (ULONG_PTR)KeyName.Buffer;
-        KeyName.MaximumLength = KeyName.Length = dwLength;
+        Length = (USHORT)((ULONG_PTR)Current - (ULONG_PTR)KeyName.Buffer);
+        KeyName.MaximumLength = KeyName.Length = Length;
         DPRINT("Create '%wZ'\n", &KeyName);
 
         /* Open key */
@@ -1324,7 +1324,7 @@ IopGetParentIdPrefix(PDEVICE_NODE DeviceNode,
                           0,
                           REG_SZ,
                           (PVOID)KeyValue.Buffer,
-                          (wcslen(KeyValue.Buffer) + 1) * sizeof(WCHAR));
+                          ((ULONG)wcslen(KeyValue.Buffer) + 1) * sizeof(WCHAR));
 
 cleanup:
    if (NT_SUCCESS(Status))
@@ -1370,7 +1370,7 @@ IopQueryHardwareIds(PDEVICE_NODE DeviceNode,
       while (*Ptr)
       {
          DPRINT("  %S\n", Ptr);
-         Length = wcslen(Ptr) + 1;
+         Length = (ULONG)wcslen(Ptr) + 1;
 
          Ptr += Length;
          TotalLength += Length;
@@ -1430,7 +1430,7 @@ IopQueryCompatibleIds(PDEVICE_NODE DeviceNode,
       while (*Ptr)
       {
          DPRINT("  %S\n", Ptr);
-         Length = wcslen(Ptr) + 1;
+         Length = (ULONG)wcslen(Ptr) + 1;
 
          Ptr += Length;
          TotalLength += Length;
@@ -1678,7 +1678,7 @@ IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
                                 0,
                                 REG_SZ,
                                 (PVOID)IoStatusBlock.Information,
-                                (wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
+                                ((ULONG)wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
       }
       else
       {
@@ -1718,7 +1718,7 @@ IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
          0,
          REG_SZ,
          (PVOID)IoStatusBlock.Information,
-         (wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
+         ((ULONG)wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
       if (!NT_SUCCESS(Status))
       {
          DPRINT1("ZwSetValueKey() failed (Status %lx)\n", Status);
@@ -2920,7 +2920,8 @@ IopCreateRegistryKeyEx(OUT PHANDLE Handle,
                        OUT PULONG Disposition OPTIONAL)
 {
     OBJECT_ATTRIBUTES ObjectAttributes;
-    ULONG KeyDisposition, RootHandleIndex = 0, i = 1, NestedCloseLevel = 0, Length;
+    ULONG KeyDisposition, RootHandleIndex = 0, i = 1, NestedCloseLevel = 0;
+    USHORT Length;
     HANDLE HandleArray[2];
     BOOLEAN Recursing = TRUE;
     PWCHAR pp, p, p1;
@@ -2968,7 +2969,7 @@ IopCreateRegistryKeyEx(OUT PHANDLE Handle,
             
             /* Process the parent key name */
             for (p = p1; ((p < pp) && (*p != OBJ_NAME_PATH_SEPARATOR)); p++);
-            Length = (p - p1) * sizeof(WCHAR);
+            Length = (USHORT)(p - p1) * sizeof(WCHAR);
             
             /* Is there a parent name? */
             if (Length)
@@ -3455,7 +3456,7 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject,
     {
         case DevicePropertyBusTypeGuid:
 
-            /* Get the GUID from the internal cache */        
+            /* Get the GUID from the internal cache */
             Status = PnpBusTypeGuidGet(DeviceNode->ChildBusTypeIndex, &BusTypeGuid);
             if (!NT_SUCCESS(Status)) return Status;
 
@@ -3497,7 +3498,7 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject,
             NullTerminate = TRUE;
 
             /* This is the format of the returned data */
-            PIP_RETURN_DATA((EnumeratorNameEnd - DeviceInstanceName) * sizeof(WCHAR),
+            PIP_RETURN_DATA((ULONG)(EnumeratorNameEnd - DeviceInstanceName) * sizeof(WCHAR),
                             DeviceInstanceName);
             
         case DevicePropertyAddress:
@@ -3586,18 +3587,18 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject,
         case DevicePropertyRemovalPolicy:
             PIP_UNIMPLEMENTED();
         case DevicePropertyInstallState:
-            PIP_UNIMPLEMENTED();        
+            PIP_UNIMPLEMENTED();
         case DevicePropertyResourceRequirements:
-            PIP_UNIMPLEMENTED();        
+            PIP_UNIMPLEMENTED();
         case DevicePropertyAllocatedResources:
-            PIP_UNIMPLEMENTED();        
+            PIP_UNIMPLEMENTED();
         default:
             return STATUS_INVALID_PARAMETER_2;
     }
     
     /* Having a registry value name implies registry data */
     if (ValueName)
-    {   
+    {
         /* We know up-front how much data to expect */
         *ResultLength = BufferLength;
         
index 7c69a59..e8013c1 100644 (file)
@@ -72,7 +72,7 @@ IopFindMemoryResource(
    IN PIO_RESOURCE_DESCRIPTOR IoDesc,
    OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
 {
-   ULONGLONG Start;
+   LONGLONG Start;
    CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
 
    ASSERT(IoDesc->Type == CmDesc->Type);
@@ -87,7 +87,8 @@ IopFindMemoryResource(
 
         if (IopCheckDescriptorForConflict(CmDesc, &ConflictingDesc))
         {
-            Start += ConflictingDesc.u.Memory.Start.QuadPart + ConflictingDesc.u.Memory.Length;
+            Start += ConflictingDesc.u.Memory.Start.QuadPart +
+                     ConflictingDesc.u.Memory.Length;
         }
         else
         {
@@ -104,7 +105,7 @@ IopFindPortResource(
    IN PIO_RESOURCE_DESCRIPTOR IoDesc,
    OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
 {
-   ULONGLONG Start;
+   LONGLONG Start;
    CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
 
    ASSERT(IoDesc->Type == CmDesc->Type);
@@ -524,7 +525,7 @@ IopUpdateControlKeyWithResources(IN PDEVICE_NODE DeviceNode)
    ZwClose(ControlKey);
 
    if (!NT_SUCCESS(Status))
-       return Status; 
+       return Status;
 
    return STATUS_SUCCESS;
 }
@@ -647,7 +648,7 @@ IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2
           }
           
           NameU.Length = 0;
-          NameU.MaximumLength = OldLength + TranslatedSuffix.Length;
+          NameU.MaximumLength = (USHORT)OldLength + TranslatedSuffix.Length;
           
           Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
                                        DevicePropertyPhysicalDeviceObjectName,
@@ -673,7 +674,7 @@ IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2
           ASSERT(FALSE);
       }
       
-      NameU.Length = OldLength;
+      NameU.Length = (USHORT)OldLength;
 
       RtlAppendUnicodeStringToString(&NameU, &RawSuffix);
 
@@ -691,7 +692,7 @@ IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2
       }
 
       /* "Remove" the suffix by setting the length back to what it used to be */
-      NameU.Length = OldLength;
+      NameU.Length = (USHORT)OldLength;
 
       RtlAppendUnicodeStringToString(&NameU, &TranslatedSuffix);
 
@@ -985,7 +986,6 @@ IopCheckForResourceConflict(
       }
    }
 
-        
 ByeBye:
 
    return Result;
@@ -1036,7 +1036,7 @@ IopDetectResourceConflict(
               goto cleanup;
           }
 
-          Status = ZwEnumerateKey(ResourceMapKey, 
+          Status = ZwEnumerateKey(ResourceMapKey,
                                   ChildKeyIndex1,
                                   KeyBasicInformation,
                                   KeyInformation,
@@ -1050,7 +1050,7 @@ IopDetectResourceConflict(
           goto cleanup;
 
       KeyName.Buffer = KeyInformation->Name;
-      KeyName.MaximumLength = KeyName.Length = KeyInformation->NameLength;
+      KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
       InitializeObjectAttributes(&ObjectAttributes,
                                  &KeyName,
                                  OBJ_CASE_INSENSITIVE,
@@ -1063,7 +1063,7 @@ IopDetectResourceConflict(
 
       while (TRUE)
       {
-          Status = ZwEnumerateKey(ChildKey2, 
+          Status = ZwEnumerateKey(ChildKey2,
                                   ChildKeyIndex2,
                                   KeyBasicInformation,
                                   NULL,
@@ -1095,7 +1095,7 @@ IopDetectResourceConflict(
               goto cleanup;
 
           KeyName.Buffer = KeyInformation->Name;
-          KeyName.MaximumLength = KeyName.Length = KeyInformation->NameLength;
+          KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
           InitializeObjectAttributes(&ObjectAttributes,
                                      &KeyName,
                                      OBJ_CASE_INSENSITIVE,
index 2393a2a..c4b5965 100644 (file)
@@ -339,7 +339,7 @@ QueryStringCallback(
         return STATUS_SUCCESS;
     }
 
-    Source.MaximumLength = Source.Length = ValueLength;
+    Source.MaximumLength = Source.Length = (USHORT)ValueLength;
     Source.Buffer = ValueData;
 
     return RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, &Source, Destination);
@@ -667,7 +667,7 @@ PnpRootQueryDeviceRelations(
     {
         /* Get the entry */
         Device = CONTAINING_RECORD(NextEntry, PNPROOT_DEVICE, ListEntry);
-    
+
         if (!Device->Pdo)
         {
             /* Create a physical device object for the
@@ -1240,7 +1240,7 @@ PnpRootDriverEntry(
     DPRINT("PnpRootDriverEntry(%p %wZ)\n", DriverObject, RegistryPath);
 
     IopRootDriverObject = DriverObject;
-    
+
     DriverObject->DriverExtension->AddDevice = PnpRootAddDevice;
 
     DriverObject->MajorFunction[IRP_MJ_PNP] = PnpRootPnpControl;
index 9bbccac..2da7354 100644 (file)
@@ -49,7 +49,8 @@ PnpRegMultiSzToUnicodeStrings(IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation
                               OUT PULONG UnicodeStringCount)
 {
     PWCHAR p, pp, ps;
-    ULONG i = 0, n;
+    ULONG i = 0;
+    SIZE_T n;
     ULONG Count = 0;
     
     /* Validate the key information */
@@ -114,8 +115,8 @@ PnpRegMultiSzToUnicodeStrings(IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation
             RtlCopyMemory((*UnicodeStringList)[i].Buffer, ps, n);
             
             /* Set the lengths */
-            (*UnicodeStringList)[i].MaximumLength = n;
-            (*UnicodeStringList)[i].Length = n - sizeof(UNICODE_NULL);
+            (*UnicodeStringList)[i].MaximumLength = (USHORT)n;
+            (*UnicodeStringList)[i].Length = (USHORT)(n - sizeof(UNICODE_NULL));
             
             /* One more entry done */
             i++;
@@ -156,8 +157,8 @@ PnpRegMultiSzToUnicodeStrings(IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation
         (*UnicodeStringList)[i].Buffer[n / sizeof(WCHAR)] = UNICODE_NULL;
         
         /* Set the lenghts */
-        (*UnicodeStringList)[i].Length = n;
-        (*UnicodeStringList)[i].MaximumLength = n + sizeof(UNICODE_NULL);
+        (*UnicodeStringList)[i].Length = (USHORT)n;
+        (*UnicodeStringList)[i].MaximumLength = (USHORT)(n + sizeof(UNICODE_NULL));
     }
     
     /* And we're done */
@@ -178,7 +179,7 @@ PnpRegSzToString(IN PWCHAR RegSzData,
     for (p = RegSzData; p < pp; p++) if (!*p) break;
     
     /* Return it */
-    if (StringLength) *StringLength = (p - RegSzData) * sizeof(WCHAR);
+    if (StringLength) *StringLength = (USHORT)(p - RegSzData) * sizeof(WCHAR);
     return TRUE;
 }
 
index a3ce60d..04673d0 100644 (file)
@@ -316,7 +316,7 @@ DumpTraceData(IN PSTRING TraceData)
     TraceDataBuffer[0] = TraceDataBufferPosition;
 
     /* Setup the trace data */
-    TraceData->Length = TraceDataBufferPosition * sizeof(ULONG);
+    TraceData->Length = (USHORT)(TraceDataBufferPosition * sizeof(ULONG));
     TraceData->Buffer = (PCHAR)TraceDataBuffer;
 
     /* Reset the buffer location */
@@ -351,7 +351,7 @@ KdpSetCommonState(IN ULONG NewState,
                         0,
                         MMDBG_COPY_UNSAFE,
                         &InstructionCount);
-    WaitStateChange->ControlReport.InstructionCount = InstructionCount;
+    WaitStateChange->ControlReport.InstructionCount = (USHORT)InstructionCount;
 
     /* Clear all the breakpoints in this region */
     HadBreakpoints =
@@ -433,7 +433,8 @@ KdpReadVirtualMemory(IN PDBGKD_MANIPULATE_STATE64 State,
                                               &Length);
 
     /* Return the actual length read */
-    Data->Length = ReadMemory->ActualBytesRead = Length;
+    ReadMemory->ActualBytesRead = Length;
+    Data->Length = (USHORT)Length;
 
     /* Send the packet */
     KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
@@ -524,7 +525,8 @@ KdpReadPhysicalmemory(IN PDBGKD_MANIPULATE_STATE64 State,
                                               &Length);
 
     /* Return the actual length read */
-    Data->Length = ReadMemory->ActualBytesRead = Length;
+    ReadMemory->ActualBytesRead = Length;
+    Data->Length = (USHORT)Length;
 
     /* Send the packet */
     KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
@@ -614,7 +616,8 @@ KdpReadControlSpace(IN PDBGKD_MANIPULATE_STATE64 State,
                                                  &Length);
 
     /* Return the actual length read */
-    Data->Length = ReadMemory->ActualBytesRead = Length;
+    ReadMemory->ActualBytesRead = Length;
+    Data->Length = (USHORT)Length;
 
     /* Send the reply */
     KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
@@ -851,7 +854,8 @@ KdpGetBusData(IN PDBGKD_MANIPULATE_STATE64 State,
                                             &Length);
 
     /* Return the actual length read */
-    Data->Length = GetBusData->Length = Length;
+    GetBusData->Length = Length;
+    Data->Length = (USHORT)Length;
 
     /* Send the reply */
     KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
@@ -909,7 +913,7 @@ KdpReadIoSpace(IN PDBGKD_MANIPULATE_STATE64 State,
 
     /*
      * Clear the value so 1 or 2 byte reads
-     * don't leave the higher bits unmodified 
+     * don't leave the higher bits unmodified
      */
     ReadIo->DataValue = 0;
 
@@ -976,7 +980,7 @@ KdpReadIoSpaceExtended(IN PDBGKD_MANIPULATE_STATE64 State,
 
     /*
      * Clear the value so 1 or 2 byte reads
-     * don't leave the higher bits unmodified 
+     * don't leave the higher bits unmodified
      */
     ReadIoExtended->DataValue = 0;
 
@@ -1085,7 +1089,7 @@ KdpSendWaitContinue(IN ULONG PacketType,
     Data.MaximumLength = sizeof(KdpMessageBuffer);
     Data.Buffer = KdpMessageBuffer;
 
-    /* 
+    /*
      * Reset the context state to ensure the debugger has received
      * the current context before it sets it
      */
@@ -1418,7 +1422,7 @@ KdpReportLoadSymbolsStateChange(IN PSTRING PathName,
 
             /* Set up the data */
             Data.Buffer = KdpPathBuffer;
-            Data.Length = PathNameLength;
+            Data.Length = (USHORT)PathNameLength;
             ExtraData = &Data;
         }
         else
@@ -1506,7 +1510,7 @@ KdpReportCommandStringStateChange(IN PSTRING NameString,
         /* Now set up the header and the data */
         Header.Length = sizeof(DBGKD_ANY_WAIT_STATE_CHANGE);
         Header.Buffer = (PCHAR)&WaitStateChange;
-        Data.Length = TotalLength;
+        Data.Length = (USHORT)TotalLength;
         Data.Buffer = KdpMessageBuffer;
 
         /* Send State Change packet and wait for a reply */
index 901ffb2..092efce 100644 (file)
@@ -101,7 +101,7 @@ ULONG KdpNumInternalBreakpoints;
 //
 // Symbol Data
 //
-ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
+ULONG_PTR KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
 
 //
 // Tracepoint Data
index 9fb10a8..e45bdc6 100644 (file)
@@ -79,7 +79,8 @@ KdInitSystem(IN ULONG BootPhase,
     STRING ImageName;
     PLDR_DATA_TABLE_ENTRY LdrEntry;
     PLIST_ENTRY NextEntry;
-    ULONG i, j, Length, DebugOptionLength;
+    ULONG i, j, Length;
+    SIZE_T DebugOptionLength;
     CHAR NameBuffer[256];
     PWCHAR Name;
 
@@ -209,8 +210,7 @@ KdInitSystem(IN ULONG BootPhase,
                         }
 
                         /* Calculate the length of the current option */
-                        DebugOptionLength = ((ULONG_PTR)DebugOptionEnd -
-                                             (ULONG_PTR)DebugOptionStart);
+                        DebugOptionLength = (DebugOptionEnd - DebugOptionStart);
 
                        /*
                         * Break out if we reached the last option
@@ -224,7 +224,7 @@ KdInitSystem(IN ULONG BootPhase,
                         {
                             /*
                              * Disable the debugger, but
-                             * allow it to be reenabled 
+                             * allow it to be reenabled
                              */
                             DisableKdAfterInit = TRUE;
                             BlockEnable = FALSE;
@@ -246,7 +246,7 @@ KdInitSystem(IN ULONG BootPhase,
                         }
 
                         /*
-                         * If there are more options then 
+                         * If there are more options then
                          * the next character should be a comma
                          */
                         if (*DebugOptionEnd != ',')
index 5de193b..2f99d2e 100644 (file)
@@ -91,7 +91,7 @@ KdpReport(IN PKTRAP_FRAME TrapFrame,
     }
     else if (SecondChanceException == FALSE)
     {
-        /* 
+        /*
          * This isn't a debug exception and the stop-on-exception flag isn't
          * set, so don't bother
          */
@@ -275,7 +275,7 @@ KdpStub(IN PKTRAP_FRAME TrapFrame,
         IN KPROCESSOR_MODE PreviousMode,
         IN BOOLEAN SecondChanceException)
 {
-    ULONG ExceptionCommand = ExceptionRecord->ExceptionInformation[0];
+    ULONG_PTR ExceptionCommand = ExceptionRecord->ExceptionInformation[0];
 
     /* Check if this was a breakpoint due to DbgPrint or Load/UnloadSymbols */
     if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
index 2551b5e..3ec6ee5 100644 (file)
@@ -27,15 +27,10 @@ KTSS64 KiBootTss;
 /* CPU Features and Flags */
 ULONG KeI386CpuType;
 ULONG KeI386CpuStep;
-ULONG KeProcessorArchitecture;
-ULONG KeProcessorLevel;
-ULONG KeProcessorRevision;
-ULONG KeFeatureBits;
 ULONG KeI386MachineType;
 ULONG KeI386NpxPresent = 1;
 ULONG KeLargestCacheLine = 0x40;
 ULONG KiDmaIoCoherency = 0;
-KAFFINITY KeActiveProcessors = 1;
 BOOLEAN KiSMTProcessorsPresent;
 
 /* Freeze data */
index 9784559..8925d56 100644 (file)
@@ -277,8 +277,8 @@ KiGeneralProtectionFaultHandler(
 
     /* Check for RDMSR/WRMSR */
     if ((Instructions[0] == 0xF) &&            // 2-byte opcode
-        (((Instructions[1] >> 8) == 0x30) ||        // RDMSR
-         ((Instructions[2] >> 8) == 0x32)))         // WRMSR
+        ((Instructions[1] == 0x30) ||        // RDMSR
+         (Instructions[1] == 0x32)))         // WRMSR
     {
         /* Unknown CPU MSR, so raise an access violation */
         return STATUS_ACCESS_VIOLATION;
index 4d7ae9c..e8e75e4 100644 (file)
@@ -141,7 +141,7 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
                    IN PKPRCB Prcb,
                    IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 {
-    ULONG PageDirectory[2];
+    ULONG_PTR PageDirectory[2];
     PVOID DpcStack;
     ULONG i;
 
index df47540..fa3fbae 100644 (file)
@@ -18,11 +18,6 @@ ULONG KeFixedTbEntries;
 ULONG KiDmaIoCoherency;
 ULONG KeIcacheFlushCount = 0;
 ULONG KeDcacheFlushCount;
-ULONG KeActiveProcessors;
-ULONG KeProcessorArchitecture;
-ULONG KeProcessorLevel;
-ULONG KeProcessorRevision;
-ULONG KeFeatureBits;
 ULONG KeLargestCacheLine = 64; // FIXME: It depends
 
 /* FUNCTIONS ******************************************************************/
index 54a7528..0561738 100644 (file)
@@ -235,7 +235,8 @@ FASTCALL
 KeRosDumpStackFrameArray(IN PULONG_PTR Frames,
                          IN ULONG FrameCount)
 {
-    ULONG i, Addr;
+    ULONG i;
+    ULONG_PTR Addr;
     BOOLEAN InSystem;
     PVOID p;
 
@@ -438,6 +439,7 @@ KeGetBugMessageText(IN ULONG BugCheckCode,
     ULONG_PTR MessageEntry;
     PCHAR BugCode;
     BOOLEAN Result = FALSE;
+    USHORT Length;
 
     /* Make sure we're not bugchecking too early */
     if (!KiBugCodeMessages) return Result;
@@ -464,16 +466,16 @@ KeGetBugMessageText(IN ULONG BugCheckCode,
 
             /* Get the final Code */
             BugCode = (PCHAR)((PMESSAGE_RESOURCE_ENTRY)MessageEntry)->Text;
-            i = strlen(BugCode);
+            Length = (USHORT)strlen(BugCode);
 
-            /* Handle newlines */
-            while ((i > 0) && ((BugCode[i] == '\n') ||
-                               (BugCode[i] == '\r') ||
-                               (BugCode[i] == ANSI_NULL)))
+            /* Handle trailing newlines */
+            while ((Length > 0) && ((BugCode[Length] == '\n') ||
+                                    (BugCode[Length] == '\r') ||
+                                    (BugCode[Length] == ANSI_NULL)))
             {
                 /* Check if we have a string to return */
-                if (!OutputString) BugCode[i] = ANSI_NULL;
-                i--;
+                if (!OutputString) BugCode[Length] = ANSI_NULL;
+                Length--;
             }
 
             /* Check if caller wants an output string */
@@ -481,8 +483,8 @@ KeGetBugMessageText(IN ULONG BugCheckCode,
             {
                 /* Return it in the OutputString */
                 OutputString->Buffer = BugCode;
-                OutputString->Length = (USHORT)i + 1;
-                OutputString->MaximumLength = (USHORT)i + 1;
+                OutputString->Length = Length + 1;
+                OutputString->MaximumLength = Length + 1;
             }
             else
             {
@@ -724,7 +726,7 @@ KiDisplayBlueScreen(IN ULONG MessageId,
     if (MessageId == BUGCODE_PSS_MESSAGE)
     {
         /* It is, so get the bug code string as well */
-        KeGetBugMessageText(KiBugCheckData[0], NULL);
+        KeGetBugMessageText((ULONG)KiBugCheckData[0], NULL);
         InbvDisplayString("\r\n\r\n");
     }
 
@@ -1414,7 +1416,7 @@ KeRegisterNmiCallback(IN PNMI_CALLBACK CallbackRoutine,
 NTSTATUS
 NTAPI
 KeDeregisterNmiCallback(PVOID Handle)
-{      
+{
     UNIMPLEMENTED;
     return STATUS_UNSUCCESSFUL;
 }
index 15619ab..2a94e73 100644 (file)
@@ -34,7 +34,7 @@ KeWaitForGate(IN PKGATE Gate,
     KLOCK_QUEUE_HANDLE ApcLock;
     PKTHREAD Thread = KeGetCurrentThread();
     PKWAIT_BLOCK GateWaitBlock;
-    NTSTATUS Status;
+    LONG_PTR Status;
     PKQUEUE Queue;
     ASSERT_GATE(Gate);
     ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
index fbe9ea8..9df29de 100644 (file)
@@ -23,10 +23,6 @@ UCHAR KiNMITSS[KTSS_IO_MAPS];
 /* CPU Features and Flags */
 ULONG KeI386CpuType;
 ULONG KeI386CpuStep;
-ULONG KeProcessorArchitecture;
-ULONG KeProcessorLevel;
-ULONG KeProcessorRevision;
-ULONG KeFeatureBits;
 ULONG KiFastSystemCallDisable = 1;
 ULONG KeI386NpxPresent = 0;
 ULONG KiMXCsrMask = 0;
@@ -41,7 +37,6 @@ ULONG KeDcacheFlushCount = 0;
 ULONG KeIcacheFlushCount = 0;
 ULONG KiDmaIoCoherency = 0;
 ULONG KePrefetchNTAGranularity = 32;
-KAFFINITY KeActiveProcessors = 1;
 BOOLEAN KiI386PentiumLockErrataPresent;
 BOOLEAN KiSMTProcessorsPresent;
 
@@ -109,17 +104,21 @@ RDMSR(IN ULONG Register)
 
 /* NSC/Cyrix CPU indexed register access macros */
 static __inline
-ULONG
+UCHAR
 getCx86(UCHAR reg)
 {
     WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22, reg);
     return READ_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23);
 }
 
-#define setCx86(reg, data) do { \
-   WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22,(reg)); \
-   WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23,(data)); \
-} while (0)
+static __inline
+void
+setCx86(UCHAR reg, UCHAR data)
+{
+    WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22, reg);
+    WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23, data);
+}
+
 
 /* FUNCTIONS *****************************************************************/
 
@@ -260,7 +259,8 @@ KiGetFeatureBits(VOID)
     PKPRCB Prcb = KeGetCurrentPrcb();
     ULONG Vendor;
     ULONG FeatureBits = KF_WORKING_PTE;
-    ULONG Reg[4], Dummy, Ccr1;
+    ULONG Reg[4], Dummy;
+    UCHAR Ccr1;
     BOOLEAN ExtendedCPUID = TRUE;
     ULONG CpuFeatures = 0;
 
@@ -513,8 +513,8 @@ KiGetCacheInformation(VOID)
     ULONG Data[4], Dummy;
     ULONG CacheRequests = 0, i;
     ULONG CurrentRegister;
-    UCHAR RegisterByte;
-    ULONG Size, Associativity = 0, CacheLine = 64, CurrentSize = 0;
+    UCHAR RegisterByte, Associativity = 0;
+    ULONG Size, CacheLine = 64, CurrentSize = 0;
     BOOLEAN FirstPass = TRUE;
 
     /* Set default L2 size */
@@ -745,7 +745,7 @@ KiGetCacheInformation(VOID)
                     CacheLine = Data[2] & 0xFF;
 
                     /* Hardcode associativity */
-                    RegisterByte = Data[2] >> 12;
+                    RegisterByte = (Data[2] >> 12) & 0xFF;
                     switch (RegisterByte)
                     {
                         case 2:
index 3a1bdb3..128d90f 100644 (file)
 
 /* GLOBALS *******************************************************************/
 
+/* Portable CPU Features and Flags */
+USHORT KeProcessorArchitecture;
+USHORT KeProcessorLevel;
+USHORT KeProcessorRevision;
+ULONG KeFeatureBits;
+KAFFINITY KeActiveProcessors = 1;
+
 /* System call count */
 ULONG KiServiceLimit = NUMBER_OF_SYSCALLS;
 
index 8b98a3d..14631da 100644 (file)
 /* GLOBALS *******************************************************************/
 
 /* CPU Features and Flags */
-ULONG KeProcessorArchitecture;
-ULONG KeProcessorLevel;
-ULONG KeProcessorRevision;
-ULONG KeFeatureBits;
 ULONG KeLargestCacheLine = 0x40;
 ULONG KeDcacheFlushCount = 0;
 ULONG KeIcacheFlushCount = 0;
 ULONG KiDmaIoCoherency = 0;
-KAFFINITY KeActiveProcessors = 1;
 BOOLEAN KiSMTProcessorsPresent;
 
 /* CPU Signatures */
index 5b14949..4dd4a00 100644 (file)
@@ -115,7 +115,7 @@ NTAPI
 KeInitializeProcess(IN OUT PKPROCESS Process,
                     IN KPRIORITY Priority,
                     IN KAFFINITY Affinity,
-                    IN PULONG DirectoryTableBase,
+                    IN PULONG_PTR DirectoryTableBase,
                     IN BOOLEAN Enable)
 {
 #ifdef CONFIG_SMP
index 6347c03..60ab5b1 100644 (file)
@@ -28,7 +28,7 @@ NTAPI
 KeInitializeProfile(PKPROFILE Profile,
                     PKPROCESS Process,
                     PVOID ImageBase,
-                    ULONG ImageSize,
+                    SIZE_T ImageSize,
                     ULONG BucketSize,
                     KPROFILE_SOURCE ProfileSource,
                     KAFFINITY Affinity)
@@ -270,7 +270,7 @@ KeSetIntervalProfile(IN KPROFILE_SOURCE ProfileSource,
     if (ProfileSource == ProfileTime)
     {
         /* Set the interval through HAL */
-        KiProfileTimeInterval = HalSetProfileInterval(Interval);
+        KiProfileTimeInterval = (ULONG)HalSetProfileInterval(Interval);
     }
     else if (ProfileSource == ProfileAlignmentFixup)
     {
index 14e22ba..ee418c7 100644 (file)
 #define NDEBUG
 #include <debug.h>
 
+#ifdef _WIN64
+# define InterlockedOrSetMember(Destination, SetMember) \
+    InterlockedOr64((PLONG64)Destination, SetMember);
+#else
+# define InterlockedOrSetMember(Destination, SetMember) \
+    InterlockedOr((PLONG)Destination, SetMember);
+#endif
+
 /* GLOBALS *******************************************************************/
 
-ULONG KiIdleSummary;
-ULONG KiIdleSMTSummary;
+ULONG_PTR KiIdleSummary;
+ULONG_PTR KiIdleSMTSummary;
 
 /* FUNCTIONS *****************************************************************/
 
@@ -321,7 +329,7 @@ KiSelectNextThread(IN PKPRCB Prcb)
         Thread = Prcb->IdleThread;
 
         /* Enable idle scheduling */
-        InterlockedOr((PLONG) &KiIdleSummary, Prcb->SetMember);
+        InterlockedOrSetMember(&KiIdleSummary, Prcb->SetMember);
         Prcb->IdleSchedule = TRUE;
 
         /* FIXME: SMT support */
@@ -370,7 +378,7 @@ KiSwapThread(IN PKTHREAD CurrentThread,
         else
         {
             /* Set the idle summary */
-            InterlockedOr((PLONG)&KiIdleSummary, Prcb->SetMember);
+            InterlockedOrSetMember(&KiIdleSummary, Prcb->SetMember);
 
             /* Schedule the idle thread */
             NextThread = Prcb->IdleThread;
index 79e350b..2591cd1 100644 (file)
@@ -53,7 +53,7 @@ KiWaitTest(IN PVOID ObjectPointer,
 VOID
 FASTCALL
 KiUnlinkThread(IN PKTHREAD Thread,
-               IN NTSTATUS WaitStatus)
+               IN LONG_PTR WaitStatus)
 {
     PKWAIT_BLOCK WaitBlock;
     PKTIMER Timer;
@@ -351,7 +351,7 @@ KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode,
             ASSERT(Thread->WaitIrql <= DISPATCH_LEVEL);
             KiSetThreadSwapBusy(Thread);
             KxInsertTimer(Timer, Hand);
-            WaitStatus = KiSwapThread(Thread, KeGetCurrentPrcb());
+            WaitStatus = (NTSTATUS)KiSwapThread(Thread, KeGetCurrentPrcb());
 
             /* Check if were swapped ok */
             if (WaitStatus != STATUS_KERNEL_APC)
@@ -454,7 +454,7 @@ KeWaitForSingleObject(IN PVOID Object,
                     {
                         /* It has a normal signal state. Unwait and return */
                         KiSatisfyMutantWait(CurrentObject, Thread);
-                        WaitStatus = Thread->WaitStatus;
+                        WaitStatus = (NTSTATUS)Thread->WaitStatus;
                         goto DontWait;
                     }
                     else
@@ -524,7 +524,7 @@ KeWaitForSingleObject(IN PVOID Object,
             }
 
             /* Do the actual swap */
-            WaitStatus = KiSwapThread(Thread, KeGetCurrentPrcb());
+            WaitStatus = (NTSTATUS)KiSwapThread(Thread, KeGetCurrentPrcb());
 
             /* Check if we were executing an APC */
             if (WaitStatus != STATUS_KERNEL_APC) return WaitStatus;
@@ -661,7 +661,7 @@ KeWaitForMultipleObjects(IN ULONG Count,
                             {
                                 /* Normal signal state, unwait it and return */
                                 KiSatisfyMutantWait(CurrentObject, Thread);
-                                WaitStatus = Thread->WaitStatus | Index;
+                                WaitStatus = (NTSTATUS)Thread->WaitStatus | Index;
                                 goto DontWait;
                             }
                             else
@@ -737,7 +737,7 @@ KeWaitForMultipleObjects(IN ULONG Count,
                     } while(WaitBlock != WaitBlockArray);
 
                     /* Set the wait status and get out */
-                    WaitStatus = Thread->WaitStatus;
+                    WaitStatus = (NTSTATUS)Thread->WaitStatus;
                     goto DontWait;
                 }
             }
@@ -807,7 +807,7 @@ KeWaitForMultipleObjects(IN ULONG Count,
             }
 
             /* Swap the thread */
-            WaitStatus = KiSwapThread(Thread, KeGetCurrentPrcb());
+            WaitStatus = (NTSTATUS)KiSwapThread(Thread, KeGetCurrentPrcb());
 
             /* Check if we were executing an APC */
             if (WaitStatus != STATUS_KERNEL_APC) return WaitStatus;
index 5bcc884..8bf0efa 100644 (file)
@@ -182,7 +182,7 @@ LpcRequestWaitReplyPort(IN PVOID PortObject,
     PETHREAD Thread = PsGetCurrentThread();
     BOOLEAN Callback = FALSE;
     PKSEMAPHORE Semaphore;
-    ULONG MessageType;
+    USHORT MessageType;
     PAGED_CODE();
 
     Port = (PLPCP_PORT_OBJECT)PortObject;
index f70269f..739cebc 100644 (file)
@@ -49,7 +49,8 @@ MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress,
              IN MEMORY_CACHING_TYPE CacheType)
 {
 
-    PFN_NUMBER Pfn, PageCount;
+    PFN_NUMBER Pfn;
+    PFN_COUNT PageCount;
     PMMPTE PointerPte;
     PVOID BaseAddress;
     MMPTE TempPte;
@@ -191,7 +192,8 @@ NTAPI
 MmUnmapIoSpace(IN PVOID BaseAddress,
                IN SIZE_T NumberOfBytes)
 {
-    PFN_NUMBER PageCount, Pfn;
+    PFN_NUMBER Pfn;
+    PFN_COUNT PageCount;
     PMMPTE PointerPte;
 
     //
index 9931765..5a9f0fe 100644 (file)
@@ -318,7 +318,7 @@ MmMapLockedPagesSpecifyCache(IN PMDL Mdl,
 {
     PVOID Base;
     PPFN_NUMBER MdlPages, LastPage;
-    PFN_NUMBER PageCount;
+    PFN_COUNT PageCount;
     BOOLEAN IsIoMapping;
     MI_PFN_CACHE_ATTRIBUTE CacheAttribute;
     PMMPTE PointerPte;
@@ -491,7 +491,7 @@ MmUnmapLockedPages(IN PVOID BaseAddress,
                    IN PMDL Mdl)
 {
     PVOID Base;
-    PFN_NUMBER PageCount;
+    PFN_COUNT PageCount, ExtraPageCount;
     PPFN_NUMBER MdlPages;
     PMMPTE PointerPte;
 
@@ -538,14 +538,16 @@ MmUnmapLockedPages(IN PVOID BaseAddress,
             //
             // Get the MDL page array
             //
-            MdlPages = (PPFN_NUMBER)(Mdl + 1);
-            MdlPages += PageCount;
+            MdlPages = MmGetMdlPfnArray(Mdl);
+
+            /* Number of extra pages stored after the PFN array */
+            ExtraPageCount = (PFN_COUNT)*(MdlPages + PageCount);
 
             //
             // Do the math
             //
-            PageCount += *MdlPages;
-            PointerPte -= *MdlPages;
+            PageCount += ExtraPageCount;
+            PointerPte -= ExtraPageCount;
             ASSERT(PointerPte >= MmSystemPtesStart[SystemPteSpace]);
             ASSERT(PointerPte <= MmSystemPtesEnd[SystemPteSpace]);
 
@@ -553,7 +555,7 @@ MmUnmapLockedPages(IN PVOID BaseAddress,
             // Get the new base address
             //
             BaseAddress = (PVOID)((ULONG_PTR)BaseAddress -
-                                  (*MdlPages << PAGE_SHIFT));
+                                  (ExtraPageCount << PAGE_SHIFT));
         }
 
         //
@@ -1251,7 +1253,7 @@ MmUnlockPages(IN PMDL Mdl)
             //
             ASSERT(Process->NumberOfLockedPages > 0);
             InterlockedExchangeAddSizeT(&Process->NumberOfLockedPages,
-                                        -PageCount);
+                                        -(LONG_PTR)PageCount);
         }
 
         //
@@ -1272,7 +1274,7 @@ MmUnlockPages(IN PMDL Mdl)
         //
         ASSERT(Process->NumberOfLockedPages > 0);
         InterlockedExchangeAddSizeT(&Process->NumberOfLockedPages,
-                                    -PageCount);
+                                    -(LONG_PTR)PageCount);
     }
 
     //
index 2907a77..561f677 100644 (file)
@@ -230,7 +230,7 @@ extern const ULONG MmProtectToValue[32];
 #define COLORED_LIST_HEAD ((1 << 25) - 1) // 0x1FFFFFF
 #elif defined(_M_AMD64)
 #define LIST_HEAD 0xFFFFFFFFFFFFFFFFLL
-#define COLORED_LIST_HEAD ((1 << 57) - 1) // 0x1FFFFFFFFFFFFFFLL
+#define COLORED_LIST_HEAD ((1ULL << 57) - 1) // 0x1FFFFFFFFFFFFFFLL
 #else
 #error Define these please!
 #endif
@@ -302,10 +302,10 @@ typedef struct _POOL_HEADER
         struct
         {
 #ifdef _M_AMD64
-            ULONG PreviousSize:8;
-            ULONG PoolIndex:8;
-            ULONG BlockSize:8;
-            ULONG PoolType:8;
+            USHORT PreviousSize:8;
+            USHORT PoolIndex:8;
+            USHORT BlockSize:8;
+            USHORT PoolType:8;
 #else
             USHORT PreviousSize:9;
             USHORT PoolIndex:7;
@@ -368,14 +368,14 @@ typedef enum _MI_PFN_CACHE_ATTRIBUTE
 
 typedef struct _PHYSICAL_MEMORY_RUN
 {
-    ULONG BasePage;
-    ULONG PageCount;
+    PFN_NUMBER BasePage;
+    PFN_NUMBER PageCount;
 } PHYSICAL_MEMORY_RUN, *PPHYSICAL_MEMORY_RUN;
 
 typedef struct _PHYSICAL_MEMORY_DESCRIPTOR
 {
     ULONG NumberOfRuns;
-    ULONG NumberOfPages;
+    PFN_NUMBER NumberOfPages;
     PHYSICAL_MEMORY_RUN Run[1];
 } PHYSICAL_MEMORY_DESCRIPTOR, *PPHYSICAL_MEMORY_DESCRIPTOR;
 
@@ -489,7 +489,7 @@ extern SIZE_T MmDefaultMaximumNonPagedPool;
 extern ULONG MmMaxAdditionNonPagedPoolPerMb;
 extern ULONG MmSecondaryColors;
 extern ULONG MmSecondaryColorMask;
-extern ULONG_PTR MmNumberOfSystemPtes;
+extern ULONG MmNumberOfSystemPtes;
 extern ULONG MmMaximumNonPagedPoolPercent;
 extern ULONG MmLargeStackSize;
 extern PMMCOLOR_TABLES MmFreePagesByColor[FreePageList + 1];
@@ -509,7 +509,7 @@ extern PFN_NUMBER MiLowNonPagedPoolThreshold;
 extern PFN_NUMBER MiHighNonPagedPoolThreshold;
 extern PFN_NUMBER MmMinimumFreePages;
 extern PFN_NUMBER MmPlentyFreePages;
-extern PFN_NUMBER MiExpansionPoolPagesInitialCharge;
+extern PFN_COUNT MiExpansionPoolPagesInitialCharge;
 extern PFN_NUMBER MmResidentAvailablePages;
 extern PFN_NUMBER MmResidentAvailableAtInit;
 extern ULONG MmTotalFreeSystemPtes[MaximumPtePoolTypes];
@@ -565,7 +565,7 @@ FORCEINLINE
 VOID
 MI_MAKE_HARDWARE_PTE_KERNEL(IN PMMPTE NewPte,
                             IN PMMPTE MappingPte,
-                            IN ULONG ProtectionMask,
+                            IN ULONG_PTR ProtectionMask,
                             IN PFN_NUMBER PageFrameNumber)
 {
     /* Only valid for kernel, non-session PTEs */
@@ -588,7 +588,7 @@ FORCEINLINE
 VOID
 MI_MAKE_HARDWARE_PTE(IN PMMPTE NewPte,
                      IN PMMPTE MappingPte,
-                     IN ULONG ProtectionMask,
+                     IN ULONG_PTR ProtectionMask,
                      IN PFN_NUMBER PageFrameNumber)
 {
     /* Set the protection and page */
@@ -604,7 +604,7 @@ FORCEINLINE
 VOID
 MI_MAKE_HARDWARE_PTE_USER(IN PMMPTE NewPte,
                           IN PMMPTE MappingPte,
-                          IN ULONG ProtectionMask,
+                          IN ULONG_PTR ProtectionMask,
                           IN PFN_NUMBER PageFrameNumber)
 {
     /* Only valid for kernel, non-session PTEs */
@@ -1160,7 +1160,7 @@ MiInsertPageInFreeList(
     IN PFN_NUMBER PageFrameIndex
 );
 
-PFN_NUMBER
+PFN_COUNT
 NTAPI
 MiDeleteSystemPageableVm(
     IN PMMPTE PointerPte,
index 74831fe..751d521 100644 (file)
@@ -176,7 +176,7 @@ PMMWSL MmSystemCacheWorkingSetList = MI_SYSTEM_CACHE_WS_START;
 // On systems with more than 32MB, this number is then doubled, and further
 // aligned up to a PDE boundary (4MB).
 //
-ULONG_PTR MmNumberOfSystemPtes;
+PFN_COUNT MmNumberOfSystemPtes;
 
 //
 // This is how many pages the PFN database will take up
@@ -206,7 +206,8 @@ PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock;
 //
 // This is where we keep track of the most basic physical layout markers
 //
-PFN_NUMBER MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage = -1;
+PFN_NUMBER MmHighestPhysicalPage, MmLowestPhysicalPage = -1;
+PFN_COUNT MmNumberOfPhysicalPages;
 
 //
 // The total number of pages mapped by the boot loader, which include the kernel
@@ -230,7 +231,10 @@ PVOID MmSystemRangeStart;
 PMMPTE MiHighestUserPte;
 PMMPDE MiHighestUserPde;
 #if (_MI_PAGING_LEVELS >= 3)
-/* We need the highest PPE and PXE addresses */
+PMMPTE MiHighestUserPpe;
+#if (_MI_PAGING_LEVELS >= 4)
+PMMPTE MiHighestUserPxe;
+#endif
 #endif
 
 /* These variables define the system cache address space */
@@ -555,7 +559,7 @@ NTAPI
 INIT_FUNCTION
 MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 {
-    ULONG FreePage, FreePageCount, PagesLeft, BasePage, PageCount;
+    PFN_NUMBER FreePage, FreePageCount, PagesLeft, BasePage, PageCount;
     PLIST_ENTRY NextEntry;
     PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
     PMMPTE PointerPte, LastPte;
@@ -1557,12 +1561,14 @@ MiBuildPagedPool(VOID)
 {
     PMMPTE PointerPte;
     PMMPDE PointerPde;
-    MMPTE TempPte = ValidKernelPte;
     MMPDE TempPde = ValidKernelPde;
     PFN_NUMBER PageFrameIndex;
     KIRQL OldIrql;
-    ULONG Size, BitMapSize;
+    SIZE_T Size;
+    ULONG BitMapSize;
 #if (_MI_PAGING_LEVELS == 2)
+    MMPTE TempPte = ValidKernelPte;
+
     //
     // Get the page frame number for the system page directory
     //
@@ -1704,7 +1710,7 @@ MiBuildPagedPool(VOID)
     //
     Size = Size * 1024;
     ASSERT(Size == MmSizeOfPagedPoolInPages);
-    BitMapSize = Size;
+    BitMapSize = (ULONG)Size;
     Size = sizeof(RTL_BITMAP) + (((Size + 31) / 32) * sizeof(ULONG));
 
     //
@@ -1770,7 +1776,7 @@ MiDbgDumpMemoryDescriptors(VOID)
 {
     PLIST_ENTRY NextEntry;
     PMEMORY_ALLOCATION_DESCRIPTOR Md;
-    ULONG TotalPages = 0;
+    PFN_NUMBER TotalPages = 0;
     PCHAR
     MemType[] =
     {
@@ -1812,7 +1818,7 @@ MiDbgDumpMemoryDescriptors(VOID)
         TotalPages += Md->PageCount;
     }
 
-    DPRINT1("Total: %08lX (%d MB)\n", TotalPages, (TotalPages * PAGE_SIZE) / 1024 / 1024);
+    DPRINT1("Total: %08lX (%d MB)\n", (ULONG)TotalPages, (ULONG)(TotalPages * PAGE_SIZE) / 1024 / 1024);
 }
 
 BOOLEAN
@@ -1864,8 +1870,10 @@ MmArmInitSystem(IN ULONG Phase,
         MiHighestUserPte = MiAddressToPte(MmHighestUserAddress);
         MiHighestUserPde = MiAddressToPde(MmHighestUserAddress);
 #if (_MI_PAGING_LEVELS >= 3)
-        /* We need the highest PPE and PXE addresses */
-        ASSERT(FALSE);
+        MiHighestUserPpe = MiAddressToPpe(MmHighestUserAddress);
+#if (_MI_PAGING_LEVELS >= 4)
+        MiHighestUserPxe = MiAddressToPxe(MmHighestUserAddress);
+#endif
 #endif
         //
         // Get the size of the boot loader's image allocations and then round
@@ -2063,7 +2071,7 @@ MmArmInitSystem(IN ULONG Phase,
         //
         RtlInitializeBitMap(&MiPfnBitMap,
                             Bitmap,
-                            MmHighestPhysicalPage + 1);
+                            (ULONG)MmHighestPhysicalPage + 1);
         RtlClearAllBits(&MiPfnBitMap);
 
         //
@@ -2087,7 +2095,7 @@ MmArmInitSystem(IN ULONG Phase,
                 //
                 // Set the bits in the PFN bitmap
                 //
-                RtlSetBits(&MiPfnBitMap, Run->BasePage, Run->PageCount);
+                RtlSetBits(&MiPfnBitMap, (ULONG)Run->BasePage, (ULONG)Run->PageCount);
             }
         }
 
index 579fd87..0ec4999 100644 (file)
@@ -136,7 +136,7 @@ NTAPI
 MmIsThisAnNtAsSystem(VOID)
 {
     /* Return if this is a server system */
-    return MmProductType;
+    return MmProductType & 0xFF;
 }
 
 /*
index 45ebce6..8b3b300 100644 (file)
@@ -24,7 +24,8 @@ PVOID
 NTAPI
 MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes)
 {
-    PFN_NUMBER PageCount, MdlPageCount, PageFrameIndex;
+    PFN_COUNT PageCount, MdlPageCount;
+    PFN_NUMBER PageFrameIndex;
     PHYSICAL_ADDRESS LowAddress, HighAddress, SkipBytes;
     MI_PFN_CACHE_ATTRIBUTE CacheAttribute;
     PMDL Mdl;
@@ -37,7 +38,7 @@ MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes)
     // Get the page count
     //
     ASSERT(NumberOfBytes != 0);
-    PageCount = BYTES_TO_PAGES(NumberOfBytes);
+    PageCount = (PFN_COUNT)BYTES_TO_PAGES(NumberOfBytes);
 
     //
     // Use the MDL allocator for simplicity, so setup the parameters
@@ -173,7 +174,7 @@ MmFreeNonCachedMemory(IN PVOID BaseAddress,
 {
     PMDL Mdl;
     PMMPTE PointerPte;
-    PFN_NUMBER PageCount;
+    PFN_COUNT PageCount;
 
     //
     // Sanity checks
@@ -184,7 +185,7 @@ MmFreeNonCachedMemory(IN PVOID BaseAddress,
     //
     // Get the page count
     //
-    PageCount = BYTES_TO_PAGES(NumberOfBytes);
+    PageCount = (PFN_COUNT)BYTES_TO_PAGES(NumberOfBytes);
 
     //
     // Get the first PTE
index 646f77c..6337244 100644 (file)
@@ -80,7 +80,7 @@ MiCheckVirtualAddress(IN PVOID VirtualAddress,
     {
         /* This must be a TEB/PEB VAD */
         ASSERT(Vad->u.VadFlags.MemCommit == TRUE);
-        *ProtectCode = Vad->u.VadFlags.Protection;
+        *ProtectCode = (ULONG)Vad->u.VadFlags.Protection;
         return NULL;
     }
     else
@@ -95,7 +95,7 @@ MiCheckVirtualAddress(IN PVOID VirtualAddress,
         ASSERT(PointerPte != NULL);
 
         /* Return the Prototype PTE and the protection for the page mapping */
-        *ProtectCode = Vad->u.VadFlags.Protection;
+        *ProtectCode = (ULONG)Vad->u.VadFlags.Protection;
         return PointerPte;
     }
 }
@@ -347,7 +347,7 @@ MiCompleteProtoPteFault(IN BOOLEAN StoreInstruction,
 {
     MMPTE TempPte;
     PMMPTE OriginalPte;
-    ULONG Protection;
+    ULONG_PTR Protection;
     PFN_NUMBER PageFrameIndex;
 
     /* Must be called with an valid prototype PTE, with the PFN lock held */
@@ -942,7 +942,7 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction,
     }
 
     /* Get protection and check if it's a prototype PTE */
-    ProtectionCode = TempPte.u.Soft.Protection;
+    ProtectionCode = (ULONG)TempPte.u.Soft.Protection;
     ASSERT(TempPte.u.Soft.Prototype == 0);
 
     /* Check for non-demand zero PTE */
index 5e32af3..334fd61 100644 (file)
@@ -226,7 +226,7 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex,
     PMMPFNLIST ListHead;
     MMLISTS ListName;
     PFN_NUMBER OldFlink, OldBlink;
-    ULONG OldColor, OldCache;
+    USHORT OldColor, OldCache;
     PMMCOLOR_TABLES ColorTable;
 
     /* Make sure PFN lock is held */
index 89817aa..e31cc1e 100644 (file)
@@ -18,7 +18,7 @@
 /* GLOBALS ********************************************************************/
 
 LIST_ENTRY MmNonPagedPoolFreeListHead[MI_MAX_FREE_PAGE_LISTS];
-PFN_NUMBER MmNumberOfFreeNonPagedPool, MiExpansionPoolPagesInitialCharge;
+PFN_COUNT MmNumberOfFreeNonPagedPool, MiExpansionPoolPagesInitialCharge;
 PVOID MmNonPagedPoolEnd0;
 PFN_NUMBER MiStartOfInitialPoolFrame, MiEndOfInitialPoolFrame;
 KGUARDED_MUTEX MmPagedPoolMutex;
@@ -272,7 +272,7 @@ INIT_FUNCTION
 MiInitializeNonPagedPool(VOID)
 {
     ULONG i;
-    PFN_NUMBER PoolPages;
+    PFN_COUNT PoolPages;
     PMMFREE_POOL_ENTRY FreeEntry, FirstEntry;
     PMMPTE PointerPte;
     PAGED_CODE();
@@ -291,7 +291,7 @@ MiInitializeNonPagedPool(VOID)
     //
     // Calculate how many pages the initial nonpaged pool has
     //
-    PoolPages = BYTES_TO_PAGES(MmSizeOfNonPagedPoolInBytes);
+    PoolPages = (PFN_COUNT)BYTES_TO_PAGES(MmSizeOfNonPagedPoolInBytes);
     MmNumberOfFreeNonPagedPool = PoolPages;
 
     //
@@ -351,7 +351,7 @@ MiInitializeNonPagedPool(VOID)
     //
     // Calculate the size of the expansion region alone
     //
-    MiExpansionPoolPagesInitialCharge =
+    MiExpansionPoolPagesInitialCharge = (PFN_COUNT)
     BYTES_TO_PAGES(MmMaximumNonPagedPoolInBytes - MmSizeOfNonPagedPoolInBytes);
 
     //
@@ -374,7 +374,8 @@ NTAPI
 MiAllocatePoolPages(IN POOL_TYPE PoolType,
                     IN SIZE_T SizeInBytes)
 {
-    PFN_NUMBER SizeInPages, PageFrameNumber, PageTableCount;
+    PFN_NUMBER PageFrameNumber;
+    PFN_COUNT SizeInPages, PageTableCount;
     ULONG i;
     KIRQL OldIrql;
     PLIST_ENTRY NextEntry, NextHead, LastHead;
@@ -391,7 +392,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
     //
     // Figure out how big the allocation is in pages
     //
-    SizeInPages = BYTES_TO_PAGES(SizeInBytes);
+    SizeInPages = (PFN_COUNT)BYTES_TO_PAGES(SizeInBytes);
 
     //
     // Handle paged pool
@@ -440,9 +441,9 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
                 //
                 // We can only support this much then
                 //
-                PageTableCount = (PMMPDE)MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool) -
-                                         MmPagedPoolInfo.NextPdeForPagedPoolExpansion +
-                                         1;
+                PointerPde = MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool);
+                PageTableCount = (PFN_COUNT)(PointerPde + 1 -
+                                 MmPagedPoolInfo.NextPdeForPagedPoolExpansion);
                 ASSERT(PageTableCount < i);
                 i = PageTableCount;
             }
@@ -515,7 +516,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
             //
             // These pages are now available, clear their availablity bits
             //
-            EndAllocation = (MmPagedPoolInfo.NextPdeForPagedPoolExpansion -
+            EndAllocation = (ULONG)(MmPagedPoolInfo.NextPdeForPagedPoolExpansion -
                              (PMMPDE)MiAddressToPte(MmPagedPoolInfo.FirstPteForPagedPool)) *
                              PTE_COUNT;
             RtlClearBits(MmPagedPoolInfo.PagedPoolAllocationMap,
@@ -823,10 +824,11 @@ MiFreePoolPages(IN PVOID StartingVa)
 {
     PMMPTE PointerPte, StartPte;
     PMMPFN Pfn1, StartPfn;
-    PFN_NUMBER FreePages, NumberOfPages;
+    PFN_COUNT FreePages, NumberOfPages;
     KIRQL OldIrql;
     PMMFREE_POOL_ENTRY FreeEntry, NextEntry, LastEntry;
     ULONG i, End;
+    ULONG_PTR Offset;
 
     //
     // Handle paged pool
@@ -837,7 +839,8 @@ MiFreePoolPages(IN PVOID StartingVa)
         // Calculate the offset from the beginning of paged pool, and convert it
         // into pages
         //
-        i = ((ULONG_PTR)StartingVa - (ULONG_PTR)MmPagedPoolStart) >> PAGE_SHIFT;
+        Offset = (ULONG_PTR)StartingVa - (ULONG_PTR)MmPagedPoolStart;
+        i = (ULONG)(Offset >> PAGE_SHIFT);
         End = i;
 
         //
@@ -904,7 +907,7 @@ MiFreePoolPages(IN PVOID StartingVa)
     //
     // Now we know how many pages we have
     //
-    NumberOfPages = PointerPte - StartPte + 1;
+    NumberOfPages = (PFN_COUNT)(PointerPte - StartPte + 1);
 
     //
     // Acquire the nonpaged pool lock
index 074196f..1d7ba0a 100644 (file)
@@ -220,7 +220,8 @@ MmDeleteKernelStack(IN PVOID StackBase,
                     IN BOOLEAN GuiStack)
 {
     PMMPTE PointerPte;
-    PFN_NUMBER StackPages, PageFrameNumber;//, PageTableFrameNumber;
+    PFN_NUMBER PageFrameNumber;//, PageTableFrameNumber;
+    PFN_COUNT StackPages;
     PMMPFN Pfn1;//, Pfn2;
     ULONG i;
     KIRQL OldIrql;
@@ -293,7 +294,7 @@ NTAPI
 MmCreateKernelStack(IN BOOLEAN GuiStack,
                     IN UCHAR Node)
 {
-    PFN_NUMBER StackPtes, StackPages;
+    PFN_COUNT StackPtes, StackPages;
     PMMPTE PointerPte, StackPte;
     PVOID BaseAddress;
     MMPTE TempPte, InvalidPte;
@@ -576,7 +577,7 @@ MmCreatePeb(IN PEPROCESS Process,
     // Attach to Process
     //
     KeAttachProcess(&Process->Pcb);
-    
+
     //
     // Map NLS Tables
     //
@@ -1113,7 +1114,7 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
     PMMPFN Pfn1;
 
     /* Choose a process color */
-    Process->NextPageColor = RtlRandom(&MmProcessColorSeed);
+    Process->NextPageColor = (USHORT)RtlRandom(&MmProcessColorSeed);
 
     /* Setup the hyperspace lock */
     KeInitializeSpinLock(&Process->HyperSpaceLock);
index 5af2288..d5c3329 100644 (file)
@@ -181,7 +181,7 @@ MiInitializeSystemSpaceMap(IN PVOID InputSession OPTIONAL)
     ASSERT(Session->SystemSpaceBitMap);
     RtlInitializeBitMap(Session->SystemSpaceBitMap,
                         (PULONG)(Session->SystemSpaceBitMap + 1),
-                        MmSystemViewSize / MI_SYSTEM_VIEW_BUCKET_SIZE);
+                        (ULONG)(MmSystemViewSize / MI_SYSTEM_VIEW_BUCKET_SIZE));
 
     /* Set system space fully empty to begin with */
     RtlClearAllBits(Session->SystemSpaceBitMap);
@@ -401,7 +401,7 @@ MiLocateSubsection(IN PMMVAD Vad,
 {
     PSUBSECTION Subsection;
     PCONTROL_AREA ControlArea;
-    ULONG PteOffset;
+    ULONG_PTR PteOffset;
 
     /* Get the control area */
     ControlArea = Vad->ControlArea;
@@ -418,7 +418,7 @@ MiLocateSubsection(IN PMMVAD Vad,
     ASSERT(Vad->FirstPrototypePte < &Subsection->SubsectionBase[Subsection->PtesInSubsection]);
 
     /* Compute the PTE offset */
-    PteOffset = (ULONG_PTR)Vpn - Vad->StartingVpn;
+    PteOffset = Vpn - Vad->StartingVpn;
     PteOffset += Vad->FirstPrototypePte - Subsection->SubsectionBase;
 
     /* Again, we only support single-subsection segments */
@@ -619,7 +619,7 @@ MiMapViewInSystemSpace(IN PVOID Section,
     }
 
     /* Get the number of 64K buckets required for this mapping */
-    Buckets = *ViewSize / MI_SYSTEM_VIEW_BUCKET_SIZE;
+    Buckets = (ULONG)(*ViewSize / MI_SYSTEM_VIEW_BUCKET_SIZE);
     if (*ViewSize & (MI_SYSTEM_VIEW_BUCKET_SIZE - 1)) Buckets++;
 
     /* Check if the view is more than 4GB large */
@@ -660,7 +660,7 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
                        IN PSECTION Section,
                        IN SECTION_INHERIT InheritDisposition,
                        IN ULONG ProtectionMask,
-                       IN ULONG CommitSize,
+                       IN SIZE_T CommitSize,
                        IN ULONG_PTR ZeroBits,
                        IN ULONG AllocationType)
 {
@@ -701,7 +701,7 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
     {
         /* The caller did not, so pick a 64K aligned view size based on the offset */
         SectionOffset->LowPart &= ~(_64K - 1);
-        *ViewSize = Section->SizeOfSection.QuadPart - SectionOffset->QuadPart;
+        *ViewSize = (SIZE_T)(Section->SizeOfSection.QuadPart - SectionOffset->QuadPart);
     }
     else
     {
@@ -719,7 +719,7 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
     if (*ViewSize >= 0x80000000) return STATUS_INVALID_VIEW_SIZE;
 
     /* Within this section, figure out which PTEs will describe the view */
-    PteOffset = SectionOffset->QuadPart >> PAGE_SHIFT;
+    PteOffset = (PFN_NUMBER)(SectionOffset->QuadPart >> PAGE_SHIFT);
 
     /* The offset must be in this segment's PTE chunk and it must be valid */
     ASSERT(PteOffset < Segment->TotalNumberOfPtes);
@@ -778,7 +778,7 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
     Vad->EndingVpn = EndingAddress >> PAGE_SHIFT;
     Vad->ControlArea = ControlArea;
     Vad->u.VadFlags.Protection = ProtectionMask;
-    Vad->u2.VadFlags2.FileOffset = SectionOffset->QuadPart >> 16;
+    Vad->u2.VadFlags2.FileOffset = (ULONG)(SectionOffset->QuadPart >> 16);
     Vad->u2.VadFlags2.Inherit = (InheritDisposition == ViewShare);
     if ((AllocationType & SEC_NO_CHANGE) || (Section->u.Flags.NoChange))
     {
@@ -825,7 +825,7 @@ MiCreatePagingFileMap(OUT PSEGMENT *Segment,
                       IN ULONG AllocationAttributes)
 {
     SIZE_T SizeLimit;
-    PFN_NUMBER PteCount;
+    PFN_COUNT PteCount;
     PMMPTE PointerPte;
     MMPTE TempPte;
     PCONTROL_AREA ControlArea;
@@ -848,7 +848,7 @@ MiCreatePagingFileMap(OUT PSEGMENT *Segment,
     if (*MaximumSize > SizeLimit) return STATUS_SECTION_TOO_BIG;
 
     /* Calculate how many Prototype PTEs will be needed */
-    PteCount = (*MaximumSize + PAGE_SIZE - 1) >> PAGE_SHIFT;
+    PteCount = (PFN_COUNT)((*MaximumSize + PAGE_SIZE - 1) >> PAGE_SHIFT);
 
     /* For commited memory, we must have a valid protection mask */
     if (AllocationAttributes & SEC_COMMIT) ASSERT(ProtectionMask != 0);
@@ -914,7 +914,11 @@ MiCreatePagingFileMap(OUT PSEGMENT *Segment,
     NewSegment->SegmentPteTemplate.u.Soft.Protection = ProtectionMask;
 
     /* Write out the prototype PTEs, for now they're simply demand zero */
+#ifdef _WIN64
+    RtlFillMemoryUlonglong(PointerPte, PteCount * sizeof(MMPTE), TempPte.u.Long);
+#else
     RtlFillMemoryUlong(PointerPte, PteCount * sizeof(MMPTE), TempPte.u.Long);
+#endif
     return STATUS_SUCCESS;
 }
 
@@ -1246,14 +1250,16 @@ MmMapViewOfArm3Section(IN PVOID SectionObject,
 #endif
 
     /* Check if the offset and size would cause an overflow */
-    if ((SectionOffset->QuadPart + *ViewSize) < SectionOffset->QuadPart)
+    if (((ULONG64)SectionOffset->QuadPart + *ViewSize) <
+         (ULONG64)SectionOffset->QuadPart)
     {
         DPRINT1("Section offset overflows\n");
         return STATUS_INVALID_VIEW_SIZE;
     }
 
     /* Check if the offset and size are bigger than the section itself */
-    if ((SectionOffset->QuadPart + *ViewSize) > Section->SizeOfSection.QuadPart)
+    if (((ULONG64)SectionOffset->QuadPart + *ViewSize) >
+         (ULONG64)Section->SizeOfSection.QuadPart)
     {
         DPRINT1("Section offset is larger than section\n");
         return STATUS_INVALID_VIEW_SIZE;
@@ -1263,7 +1269,7 @@ MmMapViewOfArm3Section(IN PVOID SectionObject,
     if (!(*ViewSize))
     {
         /* Compute it for the caller */
-        *ViewSize = Section->SizeOfSection.QuadPart - SectionOffset->QuadPart;
+        *ViewSize = (SIZE_T)(Section->SizeOfSection.QuadPart - SectionOffset->QuadPart);
 
         /* Check if it's larger than 4GB or overflows into kernel-mode */
         if ((*ViewSize > 0xFFFFFFFF) ||
@@ -1282,7 +1288,7 @@ MmMapViewOfArm3Section(IN PVOID SectionObject,
     }
 
     /* Check if the view size is larger than the section */
-    if (*ViewSize > Section->SizeOfSection.QuadPart)
+    if (*ViewSize > (ULONG64)Section->SizeOfSection.QuadPart)
     {
         DPRINT1("The view is larger than the section\n");
         return STATUS_INVALID_VIEW_SIZE;
index 51d5cec..878ada1 100644 (file)
@@ -95,7 +95,7 @@ MiLoadImageSection(IN OUT PVOID *SectionPtr,
     KAPC_STATE ApcState;
     LARGE_INTEGER SectionOffset = {{0, 0}};
     BOOLEAN LoadSymbols = FALSE;
-    PFN_NUMBER PteCount;
+    PFN_COUNT PteCount;
     PMMPTE PointerPte, LastPte;
     PVOID DriverBase;
     MMPTE TempPte;
@@ -324,7 +324,7 @@ MmCallDllInitialize(IN PLDR_DATA_TABLE_ENTRY LdrEntry,
     if (wcschr(ImportName.Buffer, L'.'))
     {
         /* Remove the extension */
-        ImportName.Length = (wcschr(ImportName.Buffer, L'.') -
+        ImportName.Length = (USHORT)(wcschr(ImportName.Buffer, L'.') -
             ImportName.Buffer) * sizeof(WCHAR);
     }
 
@@ -690,7 +690,7 @@ MiSnapThunk(IN PVOID DllBase,
     ULONG ForwardExportSize;
     PIMAGE_EXPORT_DIRECTORY ForwardExportDirectory;
     PIMAGE_IMPORT_BY_NAME ForwardName;
-    ULONG ForwardLength;
+    SIZE_T ForwardLength;
     IMAGE_THUNK_DATA ForwardThunk;
     PAGED_CODE();
 
@@ -797,9 +797,9 @@ MiSnapThunk(IN PVOID DllBase,
 
             /* Build the forwarder name */
             DllName.Buffer = (PCHAR)Address->u1.Function;
-            DllName.Length = strchr(DllName.Buffer, '.') -
-                             DllName.Buffer +
-                             sizeof(ANSI_NULL);
+            DllName.Length = (USHORT)(strchr(DllName.Buffer, '.') -
+                                      DllName.Buffer) +
+                                      sizeof(WCHAR);
             DllName.MaximumLength = DllName.Length;
 
             /* Convert it */
@@ -1377,7 +1377,7 @@ MiReloadBootLoadedDrivers(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
     PVOID DllBase, NewImageAddress;
     NTSTATUS Status;
     PMMPTE PointerPte, StartPte, LastPte;
-    PFN_NUMBER PteCount;
+    PFN_COUNT PteCount;
     PMMPFN Pfn1;
     MMPTE TempPte, OldPte;
 
@@ -1666,7 +1666,7 @@ MiBuildImportsForBootDrivers(VOID)
         /* Scan the thunks */
         for (i = 0, DllBase = 0, DllEnd = 0; i < ImportSize; i++, ImageThunk++)
 #else
-        i = DllBase = DllEnd = 0;
+        DllBase = DllEnd = i = 0;
         while ((ImportDescriptor->Name) &&
                (ImportDescriptor->OriginalFirstThunk))
         {
@@ -2277,7 +2277,8 @@ MiSetPagingOfDriver(IN PMMPTE PointerPte,
 {
     PVOID ImageBase;
     PETHREAD CurrentThread = PsGetCurrentThread();
-    PFN_NUMBER PageCount = 0, PageFrameIndex;
+    PFN_COUNT PageCount = 0;
+    PFN_NUMBER PageFrameIndex;
     PMMPFN Pfn1;
     PAGED_CODE();
 
index fd59826..ca722b5 100644 (file)
@@ -73,7 +73,7 @@ MI_GET_CLUSTER_SIZE(IN PMMPTE Pte)
     // Then read the size from the trailing PTE
     //
     Pte++;
-    return Pte->u.List.NextEntry;
+    return (ULONG)Pte->u.List.NextEntry;
 }
 
 PMMPTE
@@ -270,7 +270,7 @@ MiReleaseSystemPtes(IN PMMPTE StartingPte,
                     IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
 {
     KIRQL OldIrql;
-    ULONG_PTR ClusterSize;
+    ULONG ClusterSize;
     PMMPTE PreviousPte, NextPte, InsertPte;
 
     //
index 0d6fbd6..2ef1028 100644 (file)
@@ -370,7 +370,7 @@ MiFindEmptyAddressRangeDownTree(IN SIZE_T Length,
                                 OUT PMMADDRESS_NODE *Parent)
 {
     PMMADDRESS_NODE Node, LowestNode, Child;
-    ULONG LowVpn, HighVpn;
+    ULONG_PTR LowVpn, HighVpn;
     PFN_NUMBER PageCount;
 
     /* Sanity checks */
index fb07198..52d88b8 100644 (file)
@@ -107,14 +107,14 @@ MiMakeSystemAddressValidPfn(IN PVOID VirtualAddress,
     return LockChange;
 }
 
-PFN_NUMBER
+PFN_COUNT
 NTAPI
 MiDeleteSystemPageableVm(IN PMMPTE PointerPte,
                          IN PFN_NUMBER PageCount,
                          IN ULONG Flags,
                          OUT PPFN_NUMBER ValidPages)
 {
-    PFN_NUMBER ActualPages = 0;
+    PFN_COUNT ActualPages = 0;
     PETHREAD CurrentThread = PsGetCurrentThread();
     PMMPFN Pfn1;
     //PMMPFN Pfn2;
@@ -2350,7 +2350,8 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle,
     PMMVAD Vad = NULL;
     PVOID Address, NextAddress;
     BOOLEAN Found = FALSE;
-    ULONG NewProtect, NewState, BaseVpn;
+    ULONG NewProtect, NewState;
+    ULONG_PTR BaseVpn;
     MEMORY_BASIC_INFORMATION MemoryInfo;
     KAPC_STATE ApcState;
     KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
@@ -2666,7 +2667,7 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle,
             _SEH2_TRY
             {
                 RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer);
-                SectionName->SectionFileName.MaximumLength = MemoryInformationLength;
+                SectionName->SectionFileName.MaximumLength = (USHORT)MemoryInformationLength;
                 RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName);
 
                 if (ReturnLength) *ReturnLength = ModuleFileName.Length;
@@ -2681,7 +2682,7 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle,
         else
         {
             RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer);
-            SectionName->SectionFileName.MaximumLength = MemoryInformationLength;
+            SectionName->SectionFileName.MaximumLength = (USHORT)MemoryInformationLength;
             RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName);
 
             if (ReturnLength) *ReturnLength = ModuleFileName.Length;
index bf2dad4..ceff2dc 100644 (file)
@@ -134,7 +134,7 @@ MiEvaluateMemoryDescriptors(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
         }
 
         /* Add this to the total of pages */
-        MmNumberOfPhysicalPages += Descriptor->PageCount;
+        MmNumberOfPhysicalPages += (PFN_COUNT)Descriptor->PageCount;
 
         /* Check if this is the new lowest page */
         if (Descriptor->BasePage < MmLowestPhysicalPage)
@@ -535,7 +535,7 @@ MiBuildNonPagedPool(VOID)
     ASSERT(IS_PAGE_ALIGNED(MmNonPagedPoolExpansionStart));
 
     /* Map the nonpaged pool */
-    PageCount = (MmSizeOfNonPagedPoolInBytes + PAGE_SIZE - 1) / PAGE_SIZE;
+    PageCount = (PFN_COUNT)((MmSizeOfNonPagedPoolInBytes + PAGE_SIZE - 1) / PAGE_SIZE);
     MxMapPageRange(MmNonPagedPoolStart, PageCount);
 
     /* Loop the non paged pool extension PTEs */
@@ -575,9 +575,9 @@ MiBuildSystemPteSpace()
         MmNonPagedSystemStart = (PVOID)MI_NON_PAGED_SYSTEM_START_MIN;
 
         /* Reduce the amount of system PTEs to reach this point */
-        MmNumberOfSystemPtes = ((ULONG64)MmPfnDatabase -
+        MmNumberOfSystemPtes = (ULONG)(((ULONG64)MmPfnDatabase -
                                 (ULONG64)MmNonPagedSystemStart) >>
-                                PAGE_SHIFT;
+                                PAGE_SHIFT);
         MmNumberOfSystemPtes--;
         ASSERT(MmNumberOfSystemPtes > 1000);
     }
@@ -615,7 +615,7 @@ MiBuildPhysicalMemoryBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
     PFN_NUMBER NextPage = -1;
     PULONG Bitmap;
     ULONG Runs = 0;
-    ULONG Size;
+    ULONG_PTR Size;
 
     /* Calculate size for the PFN bitmap */
     Size = ROUND_UP(MmHighestPhysicalPage + 1, sizeof(ULONG));
@@ -640,7 +640,9 @@ MiBuildPhysicalMemoryBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
     }
 
     /* Initialize the bitmap and clear all bits */
-    RtlInitializeBitMap(&MiPfnBitMap, Bitmap, MmHighestPhysicalPage + 1);
+    RtlInitializeBitMap(&MiPfnBitMap,
+                        Bitmap,
+                        (ULONG)MmHighestPhysicalPage + 1);
     RtlClearAllBits(&MiPfnBitMap);
 
     /* Loop the memory descriptors */
@@ -674,7 +676,9 @@ MiBuildPhysicalMemoryBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
         }
 
         /* Set the bits in the PFN bitmap */
-        RtlSetBits(&MiPfnBitMap, Descriptor->BasePage, Descriptor->PageCount);
+        RtlSetBits(&MiPfnBitMap,
+                   (ULONG)Descriptor->BasePage,
+                   (ULONG)Descriptor->PageCount);
 
         /* Set the next page */
         NextPage = Descriptor->BasePage + Descriptor->PageCount;
@@ -765,7 +769,7 @@ MiBuildPagedPool_x(VOID)
     // into a 4-byte aligned bitmap.
 
     /* The size of the bitmap in bits is the size in pages */
-    BitMapSize = MmSizeOfPagedPoolInPages;
+    BitMapSize = (ULONG)MmSizeOfPagedPoolInPages;
 
     /* Calculate buffer size in bytes, aligned to 32 bits */
     Size = sizeof(RTL_BITMAP) + ROUND_UP(BitMapSize, 32) / 8;
index 70211e5..1eeae31 100644 (file)
@@ -358,7 +358,7 @@ MmNotPresentFaultVirtualMemory(PMMSUPPORT AddressSpace,
 static VOID
 MmModifyAttributes(PMMSUPPORT AddressSpace,
                    PVOID BaseAddress,
-                   ULONG RegionSize,
+                   SIZE_T RegionSize,
                    ULONG OldType,
                    ULONG OldProtect,
                    ULONG NewType,
@@ -510,7 +510,7 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
    PVOID BaseAddress;
    ULONG RegionSize;
    PVOID PBaseAddress;
-   ULONG PRegionSize;
+   ULONG_PTR PRegionSize;
    PHYSICAL_ADDRESS BoundaryAddressMultiple;
     PEPROCESS CurrentProcess = PsGetCurrentProcess();
     KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
@@ -979,7 +979,7 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
    PEPROCESS Process;
    PMMSUPPORT AddressSpace;
    PVOID BaseAddress, PBaseAddress;
-   ULONG RegionSize, PRegionSize;
+   SIZE_T RegionSize, PRegionSize;
     PEPROCESS CurrentProcess = PsGetCurrentProcess();
     KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
     KAPC_STATE ApcState;
@@ -1123,13 +1123,13 @@ NTAPI
 MmProtectAnonMem(PMMSUPPORT AddressSpace,
                  PMEMORY_AREA MemoryArea,
                  PVOID BaseAddress,
-                 ULONG Length,
+                 SIZE_T Length,
                  ULONG Protect,
                  PULONG OldProtect)
 {
    PMM_REGION Region;
    NTSTATUS Status = STATUS_SUCCESS;
-   ULONG LengthCount = 0;
+   ULONG_PTR LengthCount = 0;
 
    /* Search all Regions in MemoryArea up to Length */
    /* Every Region up to Length must be committed for success */
@@ -1137,7 +1137,7 @@ MmProtectAnonMem(PMMSUPPORT AddressSpace,
    {
       Region = MmFindRegion(MemoryArea->StartingAddress,
                             &MemoryArea->Data.VirtualMemoryData.RegionListHead,
-                            (PVOID)((ULONG_PTR)BaseAddress + (ULONG_PTR)LengthCount), NULL);
+                            (PVOID)((ULONG_PTR)BaseAddress + LengthCount), NULL);
 
       /* If a Region was found and it is committed */
       if ((Region) && (Region->Type == MEM_COMMIT))
index 17edb8e..4835a4d 100644 (file)
@@ -62,7 +62,7 @@ MmInitializeBalancer(ULONG NrAvailablePages, ULONG NrSystemPages)
    MiMinimumAvailablePages = 64;
     if ((NrAvailablePages + NrSystemPages) >= 8192)
     {
-        MiMemoryConsumers[MC_CACHE].PagesTarget = NrAvailablePages / 4 * 3;   
+        MiMemoryConsumers[MC_CACHE].PagesTarget = NrAvailablePages / 4 * 3;
     }
     else if ((NrAvailablePages + NrSystemPages) >= 4096)
     {
@@ -70,7 +70,7 @@ MmInitializeBalancer(ULONG NrAvailablePages, ULONG NrSystemPages)
     }
     else
     {
-        MiMemoryConsumers[MC_CACHE].PagesTarget = NrAvailablePages / 8;        
+        MiMemoryConsumers[MC_CACHE].PagesTarget = NrAvailablePages / 8;
     }
    MiMemoryConsumers[MC_USER].PagesTarget = NrAvailablePages - MiMinimumAvailablePages;
 }
@@ -196,7 +196,7 @@ MmRebalanceMemoryConsumers(VOID)
    ULONG NrFreedPages;
    NTSTATUS Status;
 
-   Target = (MiMinimumAvailablePages - MmAvailablePages) + MiPagesRequired;
+   Target = (ULONG)(MiMinimumAvailablePages - MmAvailablePages) + MiPagesRequired;
    Target = max(Target, (LONG) MiMinimumPagesPerRun);
 
    for (i = 0; i < MC_MAXIMUM && Target > 0; i++)
index b909751..c4cf0e2 100644 (file)
@@ -38,7 +38,7 @@ SIZE_T MmSharedCommit;
 SIZE_T MmDriverCommit;
 SIZE_T MmProcessCommit;
 SIZE_T MmPagedPoolCommit;
-SIZE_T MmPeakCommitment; 
+SIZE_T MmPeakCommitment;
 SIZE_T MmtotalCommitLimitMaximum;
 
 static RTL_BITMAP MiUserPfnBitMap;
@@ -60,7 +60,7 @@ MiInitializeUserPfnBitmap(VOID)
     /* Initialize it and clear all the bits to begin with */
     RtlInitializeBitMap(&MiUserPfnBitMap,
                         Bitmap,
-                        MmHighestPhysicalPage + 1);
+                        (ULONG)MmHighestPhysicalPage + 1);
     RtlClearAllBits(&MiUserPfnBitMap);
 }
 
@@ -93,7 +93,7 @@ MmInsertLRULastUserPage(PFN_NUMBER Pfn)
     ASSERT(Pfn != 0);
     ASSERT_IS_ROS_PFN(MiGetPfnEntry(Pfn));
     OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
-    RtlSetBit(&MiUserPfnBitMap, Pfn);
+    RtlSetBit(&MiUserPfnBitMap, (ULONG)Pfn);
     KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
 }
 
@@ -106,7 +106,7 @@ MmGetLRUNextUserPage(PFN_NUMBER PreviousPfn)
     
     /* Find the next user page */
     OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
-    Position = RtlFindSetBits(&MiUserPfnBitMap, 1, PreviousPfn + 1);
+    Position = RtlFindSetBits(&MiUserPfnBitMap, 1, (ULONG)PreviousPfn + 1);
     KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
     if (Position == 0xFFFFFFFF) return 0;
     
@@ -123,7 +123,7 @@ MmRemoveLRUUserPage(PFN_NUMBER Page)
     /* Unset the page as a user page */
     ASSERT(Page != 0);
     ASSERT_IS_ROS_PFN(MiGetPfnEntry(Page));
-    RtlClearBit(&MiUserPfnBitMap, Page);
+    RtlClearBit(&MiUserPfnBitMap, (ULONG)Page);
 }
 
 BOOLEAN
@@ -170,7 +170,7 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
     //
     // Convert, and normalize, the high address into a PFN
     //
-    HighPage = (PFN_NUMBER)(HighAddress.QuadPart >> PAGE_SHIFT);    
+    HighPage = (PFN_NUMBER)(HighAddress.QuadPart >> PAGE_SHIFT);
     if (HighPage > MmHighestPhysicalPage) HighPage = MmHighestPhysicalPage;
     
     //
@@ -378,7 +378,7 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
     // We're done, mark the pages as locked
     //
     Mdl->Process = NULL;
-    Mdl->MdlFlags |= MDL_PAGES_LOCKED; 
+    Mdl->MdlFlags |= MDL_PAGES_LOCKED;
     return Mdl;
 }
 
index 86c9b01..fb3265e 100644 (file)
@@ -881,7 +881,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
 {
    PVOID EndAddress;
    ULONG Granularity;
-   ULONG tmpLength;
+   ULONG_PTR tmpLength;
    PMEMORY_AREA MemoryArea;
 
    DPRINT("MmCreateMemoryArea(Type %d, BaseAddress %p, "
@@ -980,7 +980,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
 
 VOID NTAPI
 MmMapMemoryArea(PVOID BaseAddress,
-                ULONG Length,
+                SIZE_T Length,
                 ULONG Consumer,
                 ULONG Protection)
 {
index cfa5d9c..0a6be61 100644 (file)
@@ -81,17 +81,17 @@ static ULONG MiPagingFileCount;
 ULONG MmNumberOfPagingFiles;
 
 /* Number of pages that are available for swapping */
-PFN_NUMBER MiFreeSwapPages;
+PFN_COUNT MiFreeSwapPages;
 
 /* Number of pages that have been allocated for swapping */
-PFN_NUMBER MiUsedSwapPages;
+PFN_COUNT MiUsedSwapPages;
 
 BOOLEAN MmZeroPageFile;
 
 /*
  * Number of pages that have been reserved for swapping but not yet allocated
  */
-static PFN_NUMBER MiReservedSwapPages;
+static PFN_COUNT MiReservedSwapPages;
 
 /*
  * Ratio between reserved and available swap pages, e.g. setting this to five
@@ -124,7 +124,7 @@ NTAPI
 MmBuildMdlFromPages(PMDL Mdl, PPFN_NUMBER Pages)
 {
     memcpy(Mdl + 1, Pages, sizeof(PFN_NUMBER) * (PAGE_ROUND_UP(Mdl->ByteOffset+Mdl->ByteCount)/PAGE_SIZE));
-    
+
     /* FIXME: this flag should be set by the caller perhaps? */
     Mdl->MdlFlags |= MDL_IO_PAGE_READ;
 }
@@ -219,7 +219,8 @@ NTSTATUS
 NTAPI
 MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
 {
-   ULONG i, offset;
+   ULONG i;
+   ULONG_PTR offset;
    LARGE_INTEGER file_offset;
    IO_STATUS_BLOCK Iosb;
    NTSTATUS Status;
@@ -269,7 +270,7 @@ MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
       KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
       Status = Iosb.Status;
    }
-    
+
    if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
    {
       MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
@@ -281,7 +282,8 @@ NTSTATUS
 NTAPI
 MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
 {
-   ULONG i, offset;
+   ULONG i;
+   ULONG_PTR offset;
    LARGE_INTEGER file_offset;
    IO_STATUS_BLOCK Iosb;
    NTSTATUS Status;
@@ -421,7 +423,7 @@ NTAPI
 MmFreeSwapPage(SWAPENTRY Entry)
 {
    ULONG i;
-   ULONG off;
+   ULONG_PTR off;
    KIRQL oldIrql;
 
    i = FILE_FROM_ENTRY(Entry);
index 02a84e3..51d6a9b 100644 (file)
@@ -227,7 +227,7 @@ MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address,
    }
    PageOp->ReferenceCount = 1;
    PageOp->Next = MmPageOpHashTable[Hash];
-   PageOp->Hash = Hash;
+   PageOp->Hash = (ULONG)Hash;
    PageOp->Thread = PsGetCurrentThread();
    PageOp->Abandoned = FALSE;
    PageOp->Status = STATUS_PENDING;
index 413d96b..eb71540 100644 (file)
@@ -32,13 +32,13 @@ InsertAfterEntry(PLIST_ENTRY Previous,
 
 static PMM_REGION
 MmSplitRegion(PMM_REGION InitialRegion, PVOID InitialBaseAddress,
-              PVOID StartAddress, ULONG Length, ULONG NewType,
+              PVOID StartAddress, SIZE_T Length, ULONG NewType,
               ULONG NewProtect, PMMSUPPORT AddressSpace,
               PMM_ALTER_REGION_FUNC AlterFunc)
 {
    PMM_REGION NewRegion1;
    PMM_REGION NewRegion2;
-   ULONG InternalLength;
+   SIZE_T InternalLength;
 
    /* Allocate this in front otherwise the failure case is too difficult. */
    NewRegion2 = ExAllocatePoolWithTag(NonPagedPool, sizeof(MM_REGION),
@@ -106,7 +106,7 @@ MmSplitRegion(PMM_REGION InitialRegion, PVOID InitialBaseAddress,
 NTSTATUS
 NTAPI
 MmAlterRegion(PMMSUPPORT AddressSpace, PVOID BaseAddress,
-              PLIST_ENTRY RegionListHead, PVOID StartAddress, ULONG Length,
+              PLIST_ENTRY RegionListHead, PVOID StartAddress, SIZE_T Length,
               ULONG NewType, ULONG NewProtect, PMM_ALTER_REGION_FUNC AlterFunc)
 {
    PMM_REGION InitialRegion;
@@ -115,7 +115,7 @@ MmAlterRegion(PMMSUPPORT AddressSpace, PVOID BaseAddress,
    PLIST_ENTRY CurrentEntry;
    PMM_REGION CurrentRegion = NULL;
    PVOID CurrentBaseAddress;
-   ULONG RemainingLength;
+   SIZE_T RemainingLength;
 
    /*
     * Find the first region containing part of the range of addresses to
@@ -143,7 +143,7 @@ MmAlterRegion(PMMSUPPORT AddressSpace, PVOID BaseAddress,
    else
    {
       NewRegion = InitialRegion;
-      if(((ULONG_PTR)InitialBaseAddress + NewRegion->Length) < 
+      if(((ULONG_PTR)InitialBaseAddress + NewRegion->Length) <
             ((ULONG_PTR)StartAddress + Length))
          RemainingLength = ((ULONG_PTR)StartAddress + Length) - ((ULONG_PTR)InitialBaseAddress + NewRegion->Length);
       else
index a475334..7007ed4 100644 (file)
@@ -112,8 +112,8 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page)
    Type = MemoryArea->Type;
    if (Type == MEMORY_AREA_SECTION_VIEW)
    {
-      Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
-             + MemoryArea->Data.SectionData.ViewOffset;
+      Offset = (ULONG)((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
+               + MemoryArea->Data.SectionData.ViewOffset);
 
       /*
        * Get or create a pageop
@@ -247,7 +247,7 @@ MmIsDirtyPageRmap(PFN_NUMBER Page)
    {
          if (
 #ifdef NEWCC
-             !RMAP_IS_SEGMENT(current_entry->Address) && 
+             !RMAP_IS_SEGMENT(current_entry->Address) &&
 #endif
                  MmIsDirtyPage(current_entry->Process, current_entry->Address))
       {
@@ -290,7 +290,7 @@ MmInsertRmap(PFN_NUMBER Page, PEPROCESS Process,
 
    if (
 #ifdef NEWCC
-       !RMAP_IS_SEGMENT(Address) && 
+       !RMAP_IS_SEGMENT(Address) &&
 #endif
           MmGetPfnForProcess(Process, Address) != Page)
    {
@@ -323,7 +323,7 @@ MmInsertRmap(PFN_NUMBER Page, PEPROCESS Process,
    MmSetRmapListHeadPage(Page, new_entry);
    ExReleaseFastMutex(&RmapListLock);
 #ifdef NEWCC
-   if (!RMAP_IS_SEGMENT(Address)) 
+   if (!RMAP_IS_SEGMENT(Address))
 #endif
    {
           if (Process == NULL)
@@ -365,7 +365,7 @@ MmDeleteAllRmaps(PFN_NUMBER Page, PVOID Context,
       previous_entry = current_entry;
       current_entry = current_entry->Next;
 #ifdef NEWCC
-         if (!RMAP_IS_SEGMENT(previous_entry->Address)) 
+         if (!RMAP_IS_SEGMENT(previous_entry->Address))
 #endif
          {
                  if (DeleteMapping)
@@ -383,9 +383,9 @@ MmDeleteAllRmaps(PFN_NUMBER Page, PVOID Context,
                  {
                          (void)InterlockedExchangeAddUL(&Process->Vm.WorkingSetSize, -PAGE_SIZE);
                  }
-         } 
+         }
 #ifdef NEWCC
-         else 
+         else
          {
                  ExFreeToNPagedLookasideList(&RmapLookasideList, previous_entry);
          }
index f86a905..00e2188 100644 (file)
@@ -178,7 +178,7 @@ ObFastReplaceObject(IN PEX_FAST_REF FastRef,
 {
     EX_FAST_REF OldValue;
     PVOID OldObject;
-    ULONG_PTR Count;
+    ULONG Count;
 
     /* Check if we were given an object and reference it 7 times */
     if (Object) ObReferenceObjectEx(Object, MAX_FAST_REFS);
index 2571fc6..28014b4 100644 (file)
@@ -60,7 +60,7 @@ NTAPI
 ObDeassignSecurity(IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor)
 {
     EX_FAST_REF FastRef;
-    ULONG_PTR Count;
+    ULONG Count;
     PSECURITY_DESCRIPTOR OldSecurityDescriptor;
     
     /* Get the fast reference and capture it */
@@ -126,7 +126,7 @@ ObSetSecurityDescriptorInfo(IN PVOID Object,
     PSECURITY_DESCRIPTOR OldDescriptor, NewDescriptor, CachedDescriptor;
     PEX_FAST_REF FastRef;
     EX_FAST_REF OldValue;
-    ULONG_PTR Count;
+    ULONG Count;
     PAGED_CODE();
 
     /* Get the object header */
index 85839a9..f249309 100644 (file)
@@ -226,7 +226,7 @@ PopSetSystemPowerState(SYSTEM_POWER_STATE PowerState, POWER_ACTION PowerAction)
     POWER_STATE_TRAVERSE_CONTEXT PowerContext;
     
     Status = IopGetSystemPowerDeviceObject(&DeviceObject);
-    if (!NT_SUCCESS(Status)) 
+    if (!NT_SUCCESS(Status))
     {
         DPRINT1("No system power driver available\n");
         Fdo = NULL;
@@ -787,7 +787,7 @@ NtSetThreadExecutionState(IN EXECUTION_STATE esFlags,
     PreviousState = Thread->PowerState | ES_CONTINUOUS;
 
     /* Check if we need to update the power state */
-    if (esFlags & ES_CONTINUOUS) Thread->PowerState = esFlags;
+    if (esFlags & ES_CONTINUOUS) Thread->PowerState = (UCHAR)esFlags;
 
     /* Protect the write back to user mode */
     _SEH2_TRY
@@ -822,12 +822,12 @@ NtSetSystemPowerState(IN POWER_ACTION SystemAction,
         (MinSystemState <= PowerSystemUnspecified) ||
         (SystemAction > PowerActionWarmEject) ||
         (SystemAction < PowerActionReserved) ||
-        (Flags & ~(POWER_ACTION_QUERY_ALLOWED  |  
-                   POWER_ACTION_UI_ALLOWED     | 
-                   POWER_ACTION_OVERRIDE_APPS  | 
-                   POWER_ACTION_LIGHTEST_FIRST | 
-                   POWER_ACTION_LOCK_CONSOLE   | 
-                   POWER_ACTION_DISABLE_WAKES  | 
+        (Flags & ~(POWER_ACTION_QUERY_ALLOWED  |
+                   POWER_ACTION_UI_ALLOWED     |
+                   POWER_ACTION_OVERRIDE_APPS  |
+                   POWER_ACTION_LIGHTEST_FIRST |
+                   POWER_ACTION_LOCK_CONSOLE   |
+                   POWER_ACTION_DISABLE_WAKES  |
                    POWER_ACTION_CRITICAL)))
     {
         DPRINT1("NtSetSystemPowerState: Bad parameters!\n");
index 7efbc76..ada581e 100644 (file)
@@ -202,7 +202,7 @@ PspReapRoutine(IN PVOID Context)
         /* Remove magic value, keep looping if it got changed */
     } while (InterlockedCompareExchangePointer(&PspReaperListHead.Flink,
                                                0,
-                                               1) != (PVOID)1);
+                                               (PVOID)1) != (PVOID)1);
 }
 
 VOID
@@ -405,7 +405,7 @@ PspExitThread(IN NTSTATUS ExitStatus)
     PEPROCESS CurrentProcess;
     PETHREAD Thread, OtherThread, PreviousThread = NULL;
     PVOID DeallocationStack;
-    ULONG Dummy;
+    SIZE_T Dummy;
     BOOLEAN Last = FALSE;
     PTERMINATION_PORT TerminationPort, NextPort;
     PLIST_ENTRY FirstEntry, CurrentEntry;
index d65e4ed..c37d9e5 100644 (file)
@@ -348,7 +348,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
     PDEBUG_OBJECT DebugObject;
     PSECTION_OBJECT SectionObject;
     NTSTATUS Status, AccessStatus;
-    ULONG DirectoryTableBase[2] = {0,0};
+    ULONG_PTR DirectoryTableBase[2] = {0,0};
     KAFFINITY Affinity;
     HANDLE_TABLE_ENTRY CidEntry;
     PETHREAD CurrentThread = PsGetCurrentThread();
index 6b6c268..740cbfa 100644 (file)
@@ -1293,10 +1293,10 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
     KAFFINITY Affinity = 0, CombinedAffinity;
     PVOID Address = NULL;
     PEPROCESS Process;
-    ULONG DisableBoost = 0;
-    ULONG IdealProcessor = 0;
+    ULONG_PTR DisableBoost = 0;
+    ULONG_PTR IdealProcessor = 0;
     PTEB Teb;
-    ULONG TlsIndex = 0;
+    ULONG_PTR TlsIndex = 0;
     PVOID *ExpansionSlots;
     PETHREAD ProcThread;
     PAGED_CODE();
index 38459a3..a6fa7d4 100644 (file)
@@ -100,9 +100,9 @@ PspUserThreadStartup(IN PKSTART_ROUTINE StartRoutine,
         /* Generate a new cookie */
         KeQuerySystemTime(&SystemTime);
         Prcb = KeGetCurrentPrcb();
-        NewCookie = Prcb->MmPageFaultCount ^ Prcb->InterruptTime ^
+        NewCookie = (Prcb->MmPageFaultCount ^ Prcb->InterruptTime ^
                     SystemTime.u.LowPart ^ SystemTime.u.HighPart ^
-                    (ULONG_PTR)&SystemTime;
+                    (ULONG)(ULONG_PTR)&SystemTime);
 
         /* Set the new cookie*/
         InterlockedCompareExchange((LONG*)&SharedUserData->Cookie,