[HAL/NDK]

- 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
This commit is contained in:
Timo Kreuzer 2011-09-18 13:11:45 +00:00
parent be62192d9e
commit 87779aa572
102 changed files with 590 additions and 498 deletions

View file

@ -125,7 +125,7 @@ VideoPortEnableInterrupt(IN PVOID HwDeviceExtension)
} }
/* Re-enable the interrupt and return */ /* Re-enable the interrupt and return */
InterruptValid = HalEnableSystemInterrupt((UCHAR)DeviceExtension->InterruptVector, InterruptValid = HalEnableSystemInterrupt(DeviceExtension->InterruptVector,
0, 0,
DeviceExtension->InterruptLevel); DeviceExtension->InterruptLevel);
@ -162,8 +162,7 @@ VideoPortDisableInterrupt(IN PVOID HwDeviceExtension)
} }
/* Disable the interrupt and return */ /* Disable the interrupt and return */
HalDisableSystemInterrupt((UCHAR)DeviceExtension->InterruptVector, HalDisableSystemInterrupt(DeviceExtension->InterruptVector, 0);
0);
return NO_ERROR; return NO_ERROR;
#else #else
/* FIXME: Function still present? If so what to use instead of HalDisableSystemInterrupt? */ /* FIXME: Function still present? If so what to use instead of HalDisableSystemInterrupt? */

View file

@ -292,7 +292,7 @@ HalClearSoftwareInterrupt(IN KIRQL Irql)
*/ */
BOOLEAN BOOLEAN
NTAPI NTAPI
HalEnableSystemInterrupt(IN UCHAR Vector, HalEnableSystemInterrupt(IN ULONG Vector,
IN KIRQL Irql, IN KIRQL Irql,
IN KINTERRUPT_MODE InterruptMode) IN KINTERRUPT_MODE InterruptMode)
{ {
@ -306,7 +306,7 @@ HalEnableSystemInterrupt(IN UCHAR Vector,
*/ */
VOID VOID
NTAPI NTAPI
HalDisableSystemInterrupt(IN UCHAR Vector, HalDisableSystemInterrupt(IN ULONG Vector,
IN KIRQL Irql) IN KIRQL Irql)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
@ -319,7 +319,7 @@ HalDisableSystemInterrupt(IN UCHAR Vector,
BOOLEAN BOOLEAN
NTAPI NTAPI
HalBeginSystemInterrupt(IN KIRQL Irql, HalBeginSystemInterrupt(IN KIRQL Irql,
IN UCHAR Vector, IN ULONG Vector,
OUT PKIRQL OldIrql) OUT PKIRQL OldIrql)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;

View file

@ -670,7 +670,7 @@ HalClearSoftwareInterrupt(
BOOLEAN BOOLEAN
NTAPI NTAPI
HalEnableSystemInterrupt( HalEnableSystemInterrupt(
IN UCHAR Vector, IN ULONG Vector,
IN KIRQL Irql, IN KIRQL Irql,
IN KINTERRUPT_MODE InterruptMode) IN KINTERRUPT_MODE InterruptMode)
{ {
@ -724,12 +724,13 @@ HalEnableSystemInterrupt(
VOID VOID
NTAPI NTAPI
HalDisableSystemInterrupt( HalDisableSystemInterrupt(
IN UCHAR Vector, IN ULONG Vector,
IN KIRQL Irql) IN KIRQL Irql)
{ {
IOAPIC_REDIRECTION_REGISTER ReDirReg; IOAPIC_REDIRECTION_REGISTER ReDirReg;
UCHAR Index; UCHAR Index;
ASSERT(Irql <= HIGH_LEVEL); ASSERT(Irql <= HIGH_LEVEL);
ASSERT(Vector < RTL_NUMBER_OF(HalpVectorToIndex));
Index = HalpVectorToIndex[Vector]; Index = HalpVectorToIndex[Vector];
@ -748,7 +749,7 @@ BOOLEAN
NTAPI NTAPI
HalBeginSystemInterrupt( HalBeginSystemInterrupt(
IN KIRQL Irql, IN KIRQL Irql,
IN UCHAR Vector, IN ULONG Vector,
OUT PKIRQL OldIrql) OUT PKIRQL OldIrql)
{ {
KIRQL CurrentIrql; KIRQL CurrentIrql;

View file

@ -242,7 +242,7 @@ KeRaiseIrqlToSynchLevel (VOID)
BOOLEAN NTAPI BOOLEAN NTAPI
HalBeginSystemInterrupt (KIRQL Irql, HalBeginSystemInterrupt (KIRQL Irql,
UCHAR Vector, ULONG Vector,
PKIRQL OldIrql) PKIRQL OldIrql)
{ {
ULONG Flags; ULONG Flags;
@ -288,7 +288,7 @@ HalEndSystemInterrupt (KIRQL Irql,
VOID VOID
NTAPI NTAPI
HalDisableSystemInterrupt(UCHAR Vector, HalDisableSystemInterrupt(ULONG Vector,
KIRQL Irql) KIRQL Irql)
{ {
ULONG irq; ULONG irq;
@ -311,7 +311,7 @@ HalDisableSystemInterrupt(UCHAR Vector,
BOOLEAN NTAPI BOOLEAN NTAPI
HalEnableSystemInterrupt (UCHAR Vector, HalEnableSystemInterrupt (ULONG Vector,
KIRQL Irql, KIRQL Irql,
KINTERRUPT_MODE InterruptMode) KINTERRUPT_MODE InterruptMode)
{ {

View file

@ -1096,7 +1096,7 @@ HalpHardwareInterruptLevel(VOID)
*/ */
BOOLEAN BOOLEAN
NTAPI NTAPI
HalEnableSystemInterrupt(IN UCHAR Vector, HalEnableSystemInterrupt(IN ULONG Vector,
IN KIRQL Irql, IN KIRQL Irql,
IN KINTERRUPT_MODE InterruptMode) IN KINTERRUPT_MODE InterruptMode)
{ {
@ -1139,7 +1139,7 @@ HalEnableSystemInterrupt(IN UCHAR Vector,
*/ */
VOID VOID
NTAPI NTAPI
HalDisableSystemInterrupt(IN UCHAR Vector, HalDisableSystemInterrupt(IN ULONG Vector,
IN KIRQL Irql) IN KIRQL Irql)
{ {
ULONG IrqMask; ULONG IrqMask;
@ -1175,7 +1175,7 @@ HalDisableSystemInterrupt(IN UCHAR Vector,
BOOLEAN BOOLEAN
NTAPI NTAPI
HalBeginSystemInterrupt(IN KIRQL Irql, HalBeginSystemInterrupt(IN KIRQL Irql,
IN UCHAR Vector, IN ULONG Vector,
OUT PKIRQL OldIrql) OUT PKIRQL OldIrql)
{ {
ULONG Irq; ULONG Irq;

View file

@ -10,6 +10,19 @@ TF_IRQL = HEX(20)
TF_SAVE_ALL = (TF_VOLATILES OR TF_NONVOLATILES OR TF_XMM OR TF_SEGMENTS) TF_SAVE_ALL = (TF_VOLATILES OR TF_NONVOLATILES OR TF_XMM OR TF_SEGMENTS)
TF_HAS_ERROR_CODE = HEX(40) TF_HAS_ERROR_CODE = HEX(40)
TF_SEND_EOI = HEX(80) TF_SEND_EOI = HEX(80)
//TF_SYSTEMSERVICE = (TRAPFLAG_VOLATILES or TRAPFLAG_DEBUG)
/*
* Stack Layout:
* |-------------------|
* | KTRAP_FRAME |
* |-------------------| <- rbp
* | EXCEPTION_RECORD |
* |-------------------|
* | KEXCEPTION_FRAME |
* |-------------------| <- rsp
*
*/
/* /*
* EnterTrap - Allocate KTRAP_FRAME_LENGTH and save registers to it * EnterTrap - Allocate KTRAP_FRAME_LENGTH and save registers to it

View file

@ -588,7 +588,7 @@ typedef struct _HANDLE_TABLE_ENTRY
typedef struct _HANDLE_TABLE typedef struct _HANDLE_TABLE
{ {
#if (NTDDI_VERSION >= NTDDI_WINXP) #if (NTDDI_VERSION >= NTDDI_WINXP)
ULONG TableCode; ULONG_PTR TableCode;
#else #else
PHANDLE_TABLE_ENTRY **Table; PHANDLE_TABLE_ENTRY **Table;
#endif #endif

View file

@ -133,7 +133,7 @@ BOOLEAN
NTAPI NTAPI
HalBeginSystemInterrupt( HalBeginSystemInterrupt(
KIRQL Irql, KIRQL Irql,
UCHAR Vector, ULONG Vector,
PKIRQL OldIrql PKIRQL OldIrql
); );
@ -147,7 +147,7 @@ NTHALAPI
VOID VOID
NTAPI NTAPI
HalDisableSystemInterrupt( HalDisableSystemInterrupt(
UCHAR Vector, ULONG Vector,
KIRQL Irql KIRQL Irql
); );
@ -155,7 +155,7 @@ NTHALAPI
BOOLEAN BOOLEAN
NTAPI NTAPI
HalEnableSystemInterrupt( HalEnableSystemInterrupt(
UCHAR Vector, ULONG Vector,
KIRQL Irql, KIRQL Irql,
KINTERRUPT_MODE InterruptMode KINTERRUPT_MODE InterruptMode
); );

View file

@ -554,7 +554,11 @@ typedef struct _KDPC_DATA
{ {
LIST_ENTRY DpcListHead; LIST_ENTRY DpcListHead;
ULONG_PTR DpcLock; ULONG_PTR DpcLock;
#ifdef _M_AMD64
volatile LONG DpcQueueDepth;
#else
volatile ULONG DpcQueueDepth; volatile ULONG DpcQueueDepth;
#endif
ULONG DpcCount; ULONG DpcCount;
} KDPC_DATA, *PKDPC_DATA; } KDPC_DATA, *PKDPC_DATA;
@ -935,10 +939,10 @@ typedef struct _KPROCESS
DISPATCHER_HEADER Header; DISPATCHER_HEADER Header;
LIST_ENTRY ProfileListHead; LIST_ENTRY ProfileListHead;
#if (NTDDI_VERSION >= NTDDI_LONGHORN) #if (NTDDI_VERSION >= NTDDI_LONGHORN)
ULONG DirectoryTableBase; ULONG_PTR DirectoryTableBase;
ULONG Unused0; ULONG Unused0;
#else #else
ULONG DirectoryTableBase[2]; ULONG_PTR DirectoryTableBase[2];
#endif #endif
#if defined(_M_IX86) #if defined(_M_IX86)
KGDTENTRY LdtDescriptor; KGDTENTRY LdtDescriptor;

View file

@ -105,7 +105,7 @@ BOOLEAN
NTAPI NTAPI
LdrVerifyMappedImageMatchesChecksum( LdrVerifyMappedImageMatchesChecksum(
IN PVOID BaseAddress, IN PVOID BaseAddress,
IN ULONG NumberOfBytes, IN SIZE_T NumberOfBytes,
IN ULONG FileLength IN ULONG FileLength
); );

View file

@ -317,11 +317,18 @@ typedef struct _SECTION_IMAGE_INFORMATION
{ {
PVOID TransferAddress; PVOID TransferAddress;
ULONG ZeroBits; ULONG ZeroBits;
ULONG MaximumStackSize; SIZE_T MaximumStackSize;
ULONG CommittedStackSize; SIZE_T CommittedStackSize;
ULONG SubSystemType; ULONG SubSystemType;
union
{
struct
{
USHORT SubSystemMinorVersion; USHORT SubSystemMinorVersion;
USHORT SubSystemMajorVersion; USHORT SubSystemMajorVersion;
};
ULONG SubSystemVersion;
};
ULONG GpValue; ULONG GpValue;
USHORT ImageCharacteristics; USHORT ImageCharacteristics;
USHORT DllCharacteristics; USHORT DllCharacteristics;
@ -638,8 +645,8 @@ typedef struct _MM_AVL_TABLE
// //
typedef struct _MMADDRESS_LIST typedef struct _MMADDRESS_LIST
{ {
ULONG StartVpn; ULONG_PTR StartVpn;
ULONG EndVpn; ULONG_PTR EndVpn;
} MMADDRESS_LIST, *PMMADDRESS_LIST; } MMADDRESS_LIST, *PMMADDRESS_LIST;
// //
@ -647,13 +654,17 @@ typedef struct _MMADDRESS_LIST
// //
typedef struct _MMVAD_FLAGS typedef struct _MMVAD_FLAGS
{ {
ULONG CommitCharge:19; #ifdef _WIN64
ULONG NoChange:1; ULONG_PTR CommitCharge:51;
ULONG VadType:3; #else
ULONG MemCommit:1; ULONG_PTR CommitCharge:19;
ULONG Protection:5; #endif
ULONG Spare:2; ULONG_PTR NoChange:1;
ULONG PrivateMemory: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; } MMVAD_FLAGS, *PMMVAD_FLAGS;
// //
@ -684,11 +695,11 @@ typedef struct _MMVAD
} u1; } u1;
struct _MMVAD *LeftChild; struct _MMVAD *LeftChild;
struct _MMVAD *RightChild; struct _MMVAD *RightChild;
ULONG StartingVpn; ULONG_PTR StartingVpn;
ULONG EndingVpn; ULONG_PTR EndingVpn;
union union
{ {
ULONG LongFlags; ULONG_PTR LongFlags;
MMVAD_FLAGS VadFlags; MMVAD_FLAGS VadFlags;
} u; } u;
PCONTROL_AREA ControlArea; PCONTROL_AREA ControlArea;
@ -713,11 +724,11 @@ typedef struct _MMVAD_LONG
} u1; } u1;
PMMVAD LeftChild; PMMVAD LeftChild;
PMMVAD RightChild; PMMVAD RightChild;
ULONG StartingVpn; ULONG_PTR StartingVpn;
ULONG EndingVpn; ULONG_PTR EndingVpn;
union union
{ {
ULONG LongFlags; ULONG_PTR LongFlags;
MMVAD_FLAGS VadFlags; MMVAD_FLAGS VadFlags;
} u; } u;
PCONTROL_AREA ControlArea; PCONTROL_AREA ControlArea;
@ -752,11 +763,11 @@ typedef struct _MMVAD_SHORT
} u1; } u1;
PMMVAD LeftChild; PMMVAD LeftChild;
PMMVAD RightChild; PMMVAD RightChild;
ULONG StartingVpn; ULONG_PTR StartingVpn;
ULONG EndingVpn; ULONG_PTR EndingVpn;
union union
{ {
ULONG LongFlags; ULONG_PTR LongFlags;
MMVAD_FLAGS VadFlags; MMVAD_FLAGS VadFlags;
} u; } u;
} MMVAD_SHORT, *PMMVAD_SHORT; } MMVAD_SHORT, *PMMVAD_SHORT;

View file

@ -134,16 +134,16 @@ typedef struct _TIMEINFO
typedef struct _MEMORY_DESCRIPTOR typedef struct _MEMORY_DESCRIPTOR
{ {
MEMORY_TYPE MemoryType; MEMORY_TYPE MemoryType;
ULONG BasePage; PFN_NUMBER BasePage;
ULONG PageCount; PFN_NUMBER PageCount;
} MEMORY_DESCRIPTOR, *PMEMORY_DESCRIPTOR; } MEMORY_DESCRIPTOR, *PMEMORY_DESCRIPTOR;
typedef struct _MEMORY_ALLOCATION_DESCRIPTOR typedef struct _MEMORY_ALLOCATION_DESCRIPTOR
{ {
LIST_ENTRY ListEntry; LIST_ENTRY ListEntry;
TYPE_OF_MEMORY MemoryType; TYPE_OF_MEMORY MemoryType;
ULONG BasePage; PFN_NUMBER BasePage;
ULONG PageCount; PFN_NUMBER PageCount;
} MEMORY_ALLOCATION_DESCRIPTOR, *PMEMORY_ALLOCATION_DESCRIPTOR; } MEMORY_ALLOCATION_DESCRIPTOR, *PMEMORY_ALLOCATION_DESCRIPTOR;
typedef struct _BOOT_DRIVER_LIST_ENTRY typedef struct _BOOT_DRIVER_LIST_ENTRY

View file

@ -73,12 +73,12 @@ typedef struct _RAMDISK_CREATE_INPUT
struct struct
{ {
ULONG ViewCount; ULONG ViewCount;
ULONG ViewLength; SIZE_T ViewLength;
WCHAR FileName[ANYSIZE_ARRAY]; WCHAR FileName[ANYSIZE_ARRAY];
}; };
struct struct
{ {
ULONG BasePage; ULONG_PTR BasePage;
WCHAR DriveLetter; WCHAR DriveLetter;
}; };
PVOID BaseAddress; PVOID BaseAddress;

View file

@ -1552,7 +1552,7 @@ CmDeleteKey(IN PCM_KEY_BODY KeyBody)
if (Parent) if (Parent)
{ {
/* Update the maximum name length */ /* Update the maximum name length */
Kcb->ParentKcb->KcbMaxNameLen = Parent->MaxNameLen; Kcb->ParentKcb->KcbMaxNameLen = (USHORT)Parent->MaxNameLen;
/* Make sure we're dirty */ /* Make sure we're dirty */
ASSERT(HvIsCellDirty(Hive, ParentCell)); ASSERT(HvIsCellDirty(Hive, ParentCell));
@ -1824,9 +1824,8 @@ CmCountOpenSubKeys(IN PCM_KEY_CONTROL_BLOCK RootKcb,
PCM_KEY_HASH Entry; PCM_KEY_HASH Entry;
PCM_KEY_CONTROL_BLOCK CachedKcb; PCM_KEY_CONTROL_BLOCK CachedKcb;
PCM_KEY_CONTROL_BLOCK ParentKcb; PCM_KEY_CONTROL_BLOCK ParentKcb;
USHORT ParentKeyCount; ULONG ParentKeyCount;
USHORT j; ULONG i, j;
ULONG i;
ULONG SubKeys = 0; ULONG SubKeys = 0;
DPRINT("CmCountOpenSubKeys() called\n"); DPRINT("CmCountOpenSubKeys() called\n");

View file

@ -191,9 +191,9 @@ CmpAddDriverToList(IN PHHIVE Hive,
PBOOT_DRIVER_NODE DriverNode; PBOOT_DRIVER_NODE DriverNode;
PBOOT_DRIVER_LIST_ENTRY DriverEntry; PBOOT_DRIVER_LIST_ENTRY DriverEntry;
PCM_KEY_NODE Node; PCM_KEY_NODE Node;
ULONG NameLength, Length; ULONG Length;
HCELL_INDEX ValueCell, TagCell; USHORT NameLength;
PCM_KEY_VALUE Value; HCELL_INDEX ValueCell, TagCell; PCM_KEY_VALUE Value;
PUNICODE_STRING FileName, RegistryString; PUNICODE_STRING FileName, RegistryString;
UNICODE_STRING UnicodeString; UNICODE_STRING UnicodeString;
PULONG ErrorControl; PULONG ErrorControl;
@ -246,7 +246,7 @@ CmpAddDriverToList(IN PHHIVE Hive,
/* Allocate the path name */ /* Allocate the path name */
FileName = &DriverEntry->FilePath; FileName = &DriverEntry->FilePath;
FileName->Length = 0; FileName->Length = 0;
FileName->MaximumLength = Length; FileName->MaximumLength = (USHORT)Length;
FileName->Buffer = CmpAllocate(Length, FALSE,TAG_CM); FileName->Buffer = CmpAllocate(Length, FALSE,TAG_CM);
if (!FileName->Buffer) return FALSE; if (!FileName->Buffer) return FALSE;
@ -264,7 +264,7 @@ CmpAddDriverToList(IN PHHIVE Hive,
/* Allocate and setup the path name */ /* Allocate and setup the path name */
FileName = &DriverEntry->FilePath; FileName = &DriverEntry->FilePath;
Buffer = (PWCHAR)CmpValueToData(Hive, Value, &Length); Buffer = (PWCHAR)CmpValueToData(Hive, Value, &Length);
FileName->MaximumLength = FileName->Length = Length; FileName->MaximumLength = FileName->Length = (USHORT)Length;
FileName->Buffer = CmpAllocate(Length, FALSE, TAG_CM); FileName->Buffer = CmpAllocate(Length, FALSE, TAG_CM);
/* Transfer the data */ /* Transfer the data */
@ -321,7 +321,7 @@ CmpAddDriverToList(IN PHHIVE Hive,
/* Copy it into the node */ /* Copy it into the node */
DriverNode->Group.Buffer = (PWCHAR)CmpValueToData(Hive, Value, &Length); DriverNode->Group.Buffer = (PWCHAR)CmpValueToData(Hive, Value, &Length);
if (!DriverNode->Group.Buffer) return FALSE; 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; 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 */ /* This is our cleaned up string for this specific group */
ASSERT(End != NULL); ASSERT(End != NULL);
GroupName.Length = (End - Current) * sizeof(WCHAR); GroupName.Length = (USHORT)(End - Current) * sizeof(WCHAR);
GroupName.MaximumLength = GroupName.Length; GroupName.MaximumLength = GroupName.Length;
GroupName.Buffer = Current; GroupName.Buffer = Current;
@ -599,7 +599,7 @@ CmpSortDriverList(IN PHHIVE Hive,
/* Copy it into a buffer */ /* Copy it into a buffer */
DependList.Buffer = (PWCHAR)CmpValueToData(Hive, ListNode, &Length); DependList.Buffer = (PWCHAR)CmpValueToData(Hive, ListNode, &Length);
if (!DependList.Buffer) return FALSE; 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 */ /* And start the recurive sort algorithm */
return CmpDoSort(DriverListHead, &DependList); return CmpDoSort(DriverListHead, &DependList);
@ -756,7 +756,7 @@ CmpIsSafe(IN PHHIVE Hive,
/* Compose the search 'key' */ /* Compose the search 'key' */
Name.Buffer = (PWCHAR)CmpValueToData(Hive, KeyValue, &Length); Name.Buffer = (PWCHAR)CmpValueToData(Hive, KeyValue, &Length);
if (!Name.Buffer) return FALSE; if (!Name.Buffer) return FALSE;
Name.Length = Length - sizeof(UNICODE_NULL); Name.Length = (USHORT)Length - sizeof(UNICODE_NULL);
Name.MaximumLength = Name.Length; Name.MaximumLength = Name.Length;
/* Search for corresponding key in the Safe Boot key */ /* Search for corresponding key in the Safe Boot key */
CellIndex = CmpFindSubKeyByName(Hive, SafeBootNode, &Name); CellIndex = CmpFindSubKeyByName(Hive, SafeBootNode, &Name);
@ -807,7 +807,7 @@ CmpIsSafe(IN PHHIVE Hive,
if (!Name.Buffer) return FALSE; if (!Name.Buffer) return FALSE;
++Name.Buffer; ++Name.Buffer;
/* Length of the base name must be >=1 */ /* 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); - sizeof(UNICODE_NULL);
if(Name.Length < 1) return FALSE; if(Name.Length < 1) return FALSE;
Name.MaximumLength = Name.Length; Name.MaximumLength = Name.Length;

View file

@ -265,7 +265,7 @@ CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName,
if (Extension) if (Extension)
{ {
/* Update the name length */ /* 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 */ /* Allocate the buffer for the full name */
NameBuffer = ExAllocatePoolWithTag(PagedPool, Length, TAG_CM); NameBuffer = ExAllocatePoolWithTag(PagedPool, Length, TAG_CM);
@ -407,7 +407,7 @@ CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName,
} }
/* Get the disposition */ /* Get the disposition */
*PrimaryDisposition = IoStatusBlock.Information; *PrimaryDisposition = (ULONG)IoStatusBlock.Information;
if (IoStatusBlock.Information != FILE_CREATED) if (IoStatusBlock.Information != FILE_CREATED)
{ {
/* Check how large the file is */ /* Check how large the file is */
@ -570,7 +570,7 @@ CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName,
} }
/* Return the disposition */ /* Return the disposition */
*LogDisposition = IoStatusBlock.Information; *LogDisposition = (ULONG)IoStatusBlock.Information;
} }
/* We're done, close handles and free buffers */ /* We're done, close handles and free buffers */

View file

@ -153,7 +153,8 @@ CmpGetNameControlBlock(IN PUNICODE_STRING NodeName)
ULONG i; ULONG i;
BOOLEAN IsCompressed = TRUE, Found = FALSE; BOOLEAN IsCompressed = TRUE, Found = FALSE;
PCM_NAME_HASH HashEntry; PCM_NAME_HASH HashEntry;
ULONG Length, NcbSize; ULONG NcbSize;
USHORT Length;
/* Loop the name */ /* Loop the name */
p = NodeName->Buffer; p = NodeName->Buffer;
@ -901,7 +902,8 @@ NTAPI
CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb) CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
{ {
PUNICODE_STRING KeyName; PUNICODE_STRING KeyName;
ULONG NameLength, i; ULONG i;
USHORT NameLength;
PCM_KEY_CONTROL_BLOCK MyKcb; PCM_KEY_CONTROL_BLOCK MyKcb;
PCM_KEY_NODE KeyNode; PCM_KEY_NODE KeyNode;
BOOLEAN DeletedKey = FALSE; BOOLEAN DeletedKey = FALSE;

View file

@ -688,7 +688,7 @@ CmpCompareNewValueDataAgainstKCBCache(IN PCM_KEY_CONTROL_BLOCK Kcb,
PVOID Buffer; PVOID Buffer;
HCELL_INDEX ValueCellToRelease = HCELL_NIL, CellToRelease = HCELL_NIL; HCELL_INDEX ValueCellToRelease = HCELL_NIL, CellToRelease = HCELL_NIL;
BOOLEAN IsSmall; BOOLEAN IsSmall;
ULONG CompareResult; ULONG_PTR CompareResult;
PAGED_CODE(); PAGED_CODE();
/* Check if this is a symlink */ /* Check if this is a symlink */

View file

@ -84,7 +84,7 @@ CmpFileRead(IN PHHIVE RegistryHive,
_FileOffset.QuadPart = *FileOffset; _FileOffset.QuadPart = *FileOffset;
Status = ZwReadFile(HiveHandle, 0, 0, 0, &IoStatusBlock, Status = ZwReadFile(HiveHandle, 0, 0, 0, &IoStatusBlock,
Buffer, BufferLength, &_FileOffset, 0); Buffer, (ULONG)BufferLength, &_FileOffset, 0);
return NT_SUCCESS(Status) ? TRUE : FALSE; return NT_SUCCESS(Status) ? TRUE : FALSE;
} }
@ -104,7 +104,7 @@ CmpFileWrite(IN PHHIVE RegistryHive,
_FileOffset.QuadPart = *FileOffset; _FileOffset.QuadPart = *FileOffset;
Status = ZwWriteFile(HiveHandle, 0, 0, 0, &IoStatusBlock, Status = ZwWriteFile(HiveHandle, 0, 0, 0, &IoStatusBlock,
Buffer, BufferLength, &_FileOffset, 0); Buffer, (ULONG)BufferLength, &_FileOffset, 0);
return NT_SUCCESS(Status) ? TRUE : FALSE; return NT_SUCCESS(Status) ? TRUE : FALSE;
} }

View file

@ -374,7 +374,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
} }
/* Save the ID string length now that we've created it */ /* 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 */ /* Initialize the registry configuration node for it */
Status = CmpInitializeRegistryNode(&ConfigData, Status = CmpInitializeRegistryNode(&ConfigData,
@ -400,7 +400,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
if (Prcb->CpuType == 3) strcpy(Buffer, "80387"); if (Prcb->CpuType == 3) strcpy(Buffer, "80387");
/* Save the ID string length now that we've created it */ /* 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 */ /* Initialize the registry configuration node for it */
Status = CmpInitializeRegistryNode(&ConfigData, Status = CmpInitializeRegistryNode(&ConfigData,
@ -722,8 +722,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
/* Now prepare for Video BIOS Mapping of 32KB */ /* Now prepare for Video BIOS Mapping of 32KB */
BaseAddress = 0; BaseAddress = 0;
ViewSize = 8 * PAGE_SIZE; ViewSize = 8 * PAGE_SIZE;
ViewBase.LowPart = VideoRomBase; ViewBase.QuadPart = VideoRomBase;
ViewBase.HighPart = 0;
/* Map it */ /* Map it */
Status = ZwMapViewOfSection(SectionHandle, Status = ZwMapViewOfSection(SectionHandle,

View file

@ -173,7 +173,7 @@ ExCompareExchangeCallBack(IN OUT PEX_CALLBACK CallBack,
{ {
EX_FAST_REF OldValue; EX_FAST_REF OldValue;
PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock; PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
ULONG_PTR Count; ULONG Count;
/* Check that we have a new block */ /* Check that we have a new block */
if (NewBlock) if (NewBlock)

View file

@ -36,8 +36,8 @@ NTAPI
ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable,
IN EXHANDLE LookupHandle) IN EXHANDLE LookupHandle)
{ {
ULONG i, j, k, TableLevel, NextHandle; ULONG TableLevel, NextHandle;
ULONG_PTR TableBase; ULONG_PTR i, j, k, TableBase;
PHANDLE_TABLE_ENTRY Entry = NULL; PHANDLE_TABLE_ENTRY Entry = NULL;
EXHANDLE Handle = LookupHandle; EXHANDLE Handle = LookupHandle;
PUCHAR Level1, Level2, Level3; PUCHAR Level1, Level2, Level3;
@ -1147,7 +1147,7 @@ ExDupHandleTable(IN PEPROCESS Process,
/* Free this entry */ /* Free this entry */
NewEntry->Object = NULL; NewEntry->Object = NULL;
NewEntry->NextFreeTableEntry = NewTable->FirstFree; NewEntry->NextFreeTableEntry = NewTable->FirstFree;
NewTable->FirstFree = Handle.Value; NewTable->FirstFree = (ULONG)Handle.Value;
} }
/* Increase the handle value and move to the next entry */ /* Increase the handle value and move to the next entry */

View file

@ -211,7 +211,7 @@ ExpInitNls(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
PLIST_ENTRY ListHead, NextEntry; PLIST_ENTRY ListHead, NextEntry;
PMEMORY_ALLOCATION_DESCRIPTOR MdBlock; PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
ULONG NlsTablesEncountered = 0; 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 */ /* Check if this is boot-time phase 0 initialization */
if (!ExpInitializationPhase) if (!ExpInitializationPhase)
@ -418,8 +418,8 @@ ExpLoadInitialProcess(IN PINIT_BUFFER InitBuffer,
} }
/* Setup the basic header, and give the process the low 1MB to itself */ /* Setup the basic header, and give the process the low 1MB to itself */
ProcessParams->Length = Size; ProcessParams->Length = (ULONG)Size;
ProcessParams->MaximumLength = Size; ProcessParams->MaximumLength = (ULONG)Size;
ProcessParams->Flags = RTL_USER_PROCESS_PARAMETERS_NORMALIZED | ProcessParams->Flags = RTL_USER_PROCESS_PARAMETERS_NORMALIZED |
RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB; RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB;
@ -837,7 +837,7 @@ VOID
NTAPI NTAPI
INIT_FUNCTION INIT_FUNCTION
ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
IN ULONG PagesToDestroy, IN ULONG_PTR PagesToDestroy,
IN TYPE_OF_MEMORY MemoryType) IN TYPE_OF_MEMORY MemoryType)
{ {
PLIST_ENTRY ListEntry; PLIST_ENTRY ListEntry;
@ -993,9 +993,9 @@ ExpInitializeExecutive(IN ULONG Cpu,
NlsData = LoaderBlock->NlsData; NlsData = LoaderBlock->NlsData;
ExpNlsTableBase = NlsData->AnsiCodePageData; ExpNlsTableBase = NlsData->AnsiCodePageData;
ExpAnsiCodePageDataOffset = 0; ExpAnsiCodePageDataOffset = 0;
ExpOemCodePageDataOffset = ((ULONG_PTR)NlsData->OemCodePageData - ExpOemCodePageDataOffset = (ULONG)((ULONG_PTR)NlsData->OemCodePageData -
(ULONG_PTR)NlsData->AnsiCodePageData); (ULONG_PTR)NlsData->AnsiCodePageData);
ExpUnicodeCaseTableDataOffset = ((ULONG_PTR)NlsData->UnicodeCodePageData - ExpUnicodeCaseTableDataOffset = (ULONG)((ULONG_PTR)NlsData->UnicodeCodePageData -
(ULONG_PTR)NlsData->AnsiCodePageData); (ULONG_PTR)NlsData->AnsiCodePageData);
/* Initialize the NLS Tables */ /* Initialize the NLS Tables */
@ -1084,8 +1084,13 @@ ExpInitializeExecutive(IN ULONG Cpu,
} }
/* Set system ranges */ /* 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->Reserved1 = (ULONG_PTR)MmHighestUserAddress;
SharedUserData->Reserved3 = (ULONG_PTR)MmSystemRangeStart; SharedUserData->Reserved3 = (ULONG_PTR)MmSystemRangeStart;
#endif
/* Make a copy of the NLS Tables */ /* Make a copy of the NLS Tables */
ExpInitNls(LoaderBlock); ExpInitNls(LoaderBlock);

View file

@ -235,7 +235,7 @@ ExInitializeNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside,
Lookaside->L.FreeMisses = 0; Lookaside->L.FreeMisses = 0;
Lookaside->L.Type = NonPagedPool | Flags; Lookaside->L.Type = NonPagedPool | Flags;
Lookaside->L.Tag = Tag; Lookaside->L.Tag = Tag;
Lookaside->L.Size = Size; Lookaside->L.Size = (ULONG)Size;
Lookaside->L.Depth = 4; Lookaside->L.Depth = 4;
Lookaside->L.MaximumDepth = 256; Lookaside->L.MaximumDepth = 256;
Lookaside->L.LastTotalAllocates = 0; Lookaside->L.LastTotalAllocates = 0;
@ -287,7 +287,7 @@ ExInitializePagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside,
Lookaside->L.FreeMisses = 0; Lookaside->L.FreeMisses = 0;
Lookaside->L.Type = PagedPool | Flags; Lookaside->L.Type = PagedPool | Flags;
Lookaside->L.Tag = Tag; Lookaside->L.Tag = Tag;
Lookaside->L.Size = Size; Lookaside->L.Size = (ULONG)Size;
Lookaside->L.Depth = 4; Lookaside->L.Depth = 4;
Lookaside->L.MaximumDepth = 256; Lookaside->L.MaximumDepth = 256;
Lookaside->L.LastTotalAllocates = 0; Lookaside->L.LastTotalAllocates = 0;

View file

@ -489,7 +489,7 @@ NtQueryIntervalProfile(IN KPROFILE_SOURCE ProfileSource,
} }
/* Query the Interval */ /* Query the Interval */
ReturnInterval = KeQueryIntervalProfile(ProfileSource); ReturnInterval = (ULONG)KeQueryIntervalProfile(ProfileSource);
/* Enter SEH block for return */ /* Enter SEH block for return */
_SEH2_TRY _SEH2_TRY

View file

@ -534,7 +534,7 @@ ExfAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
WaitBlock->Last = WaitBlock; WaitBlock->Last = WaitBlock;
/* Set the share count */ /* Set the share count */
WaitBlock->ShareCount = OldValue.Shared; WaitBlock->ShareCount = (LONG)OldValue.Shared;
/* Check if someone is sharing this pushlock */ /* Check if someone is sharing this pushlock */
if (OldValue.Shared > 1) if (OldValue.Shared > 1)

View file

@ -88,7 +88,7 @@ ExpQueryModuleInformation(IN PLIST_ENTRY KernelModeList,
} }
/* Set the offset */ /* Set the offset */
ModuleInfo->OffsetToFileName = p - ModuleName.Buffer; ModuleInfo->OffsetToFileName = (USHORT)(p - ModuleName.Buffer);
} }
else else
{ {
@ -478,8 +478,8 @@ QSI_DEF(SystemBasicInformation)
Sbi->TimerResolution = KeMaximumIncrement; Sbi->TimerResolution = KeMaximumIncrement;
Sbi->PageSize = PAGE_SIZE; Sbi->PageSize = PAGE_SIZE;
Sbi->NumberOfPhysicalPages = MmNumberOfPhysicalPages; Sbi->NumberOfPhysicalPages = MmNumberOfPhysicalPages;
Sbi->LowestPhysicalPageNumber = MmLowestPhysicalPage; Sbi->LowestPhysicalPageNumber = (ULONG)MmLowestPhysicalPage;
Sbi->HighestPhysicalPageNumber = MmHighestPhysicalPage; Sbi->HighestPhysicalPageNumber = (ULONG)MmHighestPhysicalPage;
Sbi->AllocationGranularity = MM_VIRTMEM_GRANULARITY; /* hard coded on Intel? */ Sbi->AllocationGranularity = MM_VIRTMEM_GRANULARITY; /* hard coded on Intel? */
Sbi->MinimumUserModeAddress = 0x10000; /* Top of 64k */ Sbi->MinimumUserModeAddress = 0x10000; /* Top of 64k */
Sbi->MaximumUserModeAddress = (ULONG_PTR)MmHighestUserAddress; Sbi->MaximumUserModeAddress = (ULONG_PTR)MmHighestUserAddress;
@ -542,7 +542,7 @@ QSI_DEF(SystemPerformanceInformation)
Spi->IoWriteOperationCount = IoWriteOperationCount; Spi->IoWriteOperationCount = IoWriteOperationCount;
Spi->IoOtherOperationCount = IoOtherOperationCount; Spi->IoOtherOperationCount = IoOtherOperationCount;
Spi->AvailablePages = MmAvailablePages; Spi->AvailablePages = (ULONG)MmAvailablePages;
/* /*
* Add up all the used "Committed" memory + pagefile. * Add up all the used "Committed" memory + pagefile.
* Not sure this is right. 8^\ * Not sure this is right. 8^\
@ -759,7 +759,7 @@ QSI_DEF(SystemProcessInformation)
} }
if (!ImageNameLength && Process != PsIdleProcess && Process->ImageFileName) 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 */ /* Round up the image name length as NT does */

View file

@ -199,7 +199,7 @@ FsRtlCopyRead(IN PFILE_OBJECT FileObject,
if (IoStatus->Status != STATUS_END_OF_FILE) if (IoStatus->Status != STATUS_END_OF_FILE)
{ {
ASSERT((ULONGLONG)FcbHeader->FileSize.QuadPart >= ASSERT((ULONGLONG)FcbHeader->FileSize.QuadPart >=
(FileOffset->QuadPart + IoStatus->Information)); ((ULONGLONG)FileOffset->QuadPart + IoStatus->Information));
} }
} }
else else
@ -219,7 +219,7 @@ FsRtlCopyRead(IN PFILE_OBJECT FileObject,
if (Result == TRUE) if (Result == TRUE)
{ {
ASSERT((IoStatus->Status == STATUS_END_OF_FILE) || ASSERT((IoStatus->Status == STATUS_END_OF_FILE) ||
((FileOffset->QuadPart + IoStatus->Information) <= (((ULONGLONG)FileOffset->QuadPart + IoStatus->Information) <=
(ULONGLONG)FcbHeader->FileSize.QuadPart)); (ULONGLONG)FcbHeader->FileSize.QuadPart));
} }
} }

View file

@ -1374,7 +1374,9 @@ FstubFixupEfiPartition(IN PPARTITION_DESCRIPTOR PartitionDescriptor,
if (PartitionLength > MaxOffset) if (PartitionLength > MaxOffset)
{ {
/* Resize partition to its maximum real length */ /* 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);
} }
} }

View file

@ -72,7 +72,7 @@ NTAPI
xHalVectorToIDTEntry(IN ULONG Vector) xHalVectorToIDTEntry(IN ULONG Vector)
{ {
/* Return the vector */ /* Return the vector */
return Vector; return (UCHAR)Vector;
} }
VOID VOID

View file

@ -250,7 +250,7 @@ KiUserTrap(IN PKTRAP_FRAME TrapFrame)
return !!(TrapFrame->SegCs & MODE_MASK); return !!(TrapFrame->SegCs & MODE_MASK);
} }
#define Ki386PerfEnd(x) #define Ki386PerfEnd()
struct _KPCR; struct _KPCR;
@ -319,6 +319,16 @@ KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine,
// HACK // HACK
extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount; 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 */ #endif /* __NTOSKRNL_INCLUDE_INTERNAL_AMD64_KE_H */
/* EOF */ /* EOF */

View file

@ -59,6 +59,9 @@
#define MM_HIGHEST_VAD_ADDRESS \ #define MM_HIGHEST_VAD_ADDRESS \
(PVOID)((ULONG_PTR)MM_HIGHEST_USER_ADDRESS - (16 * PAGE_SIZE)) (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 PULONG64
FORCEINLINE FORCEINLINE
MmGetPageDirectory(VOID) MmGetPageDirectory(VOID)
@ -145,9 +148,9 @@ MiIsPdeForAddressValid(PVOID Address)
#define MiPdeToPte(PDE) ((PMMPTE)MiPteToAddress(PDE)) #define MiPdeToPte(PDE) ((PMMPTE)MiPteToAddress(PDE))
#define MiPteToPde(PTE) ((PMMPDE)MiAddressToPte(PTE)) #define MiPteToPde(PTE) ((PMMPDE)MiAddressToPte(PTE))
#define ADDR_TO_PAGE_TABLE(v) (((ULONG_PTR)(v)) / (512 * PAGE_SIZE)) #define ADDR_TO_PAGE_TABLE(v) ((ULONG)(((ULONG_PTR)(v)) / (512 * PAGE_SIZE)))
#define ADDR_TO_PDE_OFFSET(v) ((((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_PTR)(v)) % (512 * PAGE_SIZE)) / PAGE_SIZE) #define ADDR_TO_PTE_OFFSET(v) ((ULONG)((((ULONG_PTR)(v)) % (512 * PAGE_SIZE)) / PAGE_SIZE))
#define MiGetPdeOffset ADDR_TO_PDE_OFFSET #define MiGetPdeOffset ADDR_TO_PDE_OFFSET

View file

@ -618,7 +618,7 @@ NTAPI
IopInitiatePnpIrp( IopInitiatePnpIrp(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIO_STATUS_BLOCK IoStatusBlock, IN PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG MinorFunction, IN UCHAR MinorFunction,
IN PIO_STACK_LOCATION Stack IN PIO_STACK_LOCATION Stack
); );

View file

@ -523,6 +523,6 @@ extern KD_BREAKPOINT_TYPE KdpBreakpointInstruction;
extern BOOLEAN KdpOweBreakpoint; extern BOOLEAN KdpOweBreakpoint;
extern BOOLEAN BreakpointsSuspended; extern BOOLEAN BreakpointsSuspended;
extern ULONG KdpNumInternalBreakpoints; extern ULONG KdpNumInternalBreakpoints;
extern ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd; extern ULONG_PTR KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
extern ULONG TraceDataBuffer[40]; extern ULONG TraceDataBuffer[40];
extern ULONG TraceDataBufferPosition; extern ULONG TraceDataBufferPosition;

View file

@ -87,9 +87,9 @@ extern PVOID KeRaiseUserExceptionDispatcher;
extern LARGE_INTEGER KeBootTime; extern LARGE_INTEGER KeBootTime;
extern ULONGLONG KeBootTimeBias; extern ULONGLONG KeBootTimeBias;
extern BOOLEAN ExCmosClockIsSane; extern BOOLEAN ExCmosClockIsSane;
extern ULONG KeProcessorArchitecture; extern USHORT KeProcessorArchitecture;
extern ULONG KeProcessorLevel; extern USHORT KeProcessorLevel;
extern ULONG KeProcessorRevision; extern USHORT KeProcessorRevision;
extern ULONG KeFeatureBits; extern ULONG KeFeatureBits;
extern KNODE KiNode0; extern KNODE KiNode0;
extern PKNODE KeNodeBlock[1]; extern PKNODE KeNodeBlock[1];
@ -125,7 +125,7 @@ extern LIST_ENTRY KiStackInSwapListHead;
extern KEVENT KiSwapEvent; extern KEVENT KiSwapEvent;
extern PKPRCB KiProcessorBlock[]; extern PKPRCB KiProcessorBlock[];
extern ULONG KiMask32Array[MAXIMUM_PRIORITY]; extern ULONG KiMask32Array[MAXIMUM_PRIORITY];
extern ULONG KiIdleSummary; extern ULONG_PTR KiIdleSummary;
extern PVOID KeUserApcDispatcher; extern PVOID KeUserApcDispatcher;
extern PVOID KeUserCallbackDispatcher; extern PVOID KeUserCallbackDispatcher;
extern PVOID KeUserExceptionDispatcher; extern PVOID KeUserExceptionDispatcher;
@ -450,7 +450,7 @@ KeInitializeProfile(
struct _KPROFILE* Profile, struct _KPROFILE* Profile,
struct _KPROCESS* Process, struct _KPROCESS* Process,
PVOID ImageBase, PVOID ImageBase,
ULONG ImageSize, SIZE_T ImageSize,
ULONG BucketSize, ULONG BucketSize,
KPROFILE_SOURCE ProfileSource, KPROFILE_SOURCE ProfileSource,
KAFFINITY Affinity KAFFINITY Affinity
@ -628,7 +628,7 @@ VOID
FASTCALL FASTCALL
KiUnlinkThread( KiUnlinkThread(
IN PKTHREAD Thread, IN PKTHREAD Thread,
IN NTSTATUS WaitStatus IN LONG_PTR WaitStatus
); );
VOID VOID
@ -653,7 +653,7 @@ KeInitializeProcess(
struct _KPROCESS *Process, struct _KPROCESS *Process,
KPRIORITY Priority, KPRIORITY Priority,
KAFFINITY Affinity, KAFFINITY Affinity,
PULONG DirectoryTableBase, PULONG_PTR DirectoryTableBase,
IN BOOLEAN Enable IN BOOLEAN Enable
); );

View file

@ -7,12 +7,12 @@
struct _EPROCESS; struct _EPROCESS;
extern PMMSUPPORT MmKernelAddressSpace; extern PMMSUPPORT MmKernelAddressSpace;
extern PFN_NUMBER MiFreeSwapPages; extern PFN_COUNT MiFreeSwapPages;
extern PFN_NUMBER MiUsedSwapPages; extern PFN_COUNT MiUsedSwapPages;
extern SIZE_T MmTotalPagedPoolQuota; extern SIZE_T MmTotalPagedPoolQuota;
extern SIZE_T MmTotalNonPagedPoolQuota; extern SIZE_T MmTotalNonPagedPoolQuota;
extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress; extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
extern PFN_NUMBER MmNumberOfPhysicalPages; extern PFN_COUNT MmNumberOfPhysicalPages;
extern UCHAR MmDisablePagingExecutive; extern UCHAR MmDisablePagingExecutive;
extern PFN_NUMBER MmLowestPhysicalPage; extern PFN_NUMBER MmLowestPhysicalPage;
extern PFN_NUMBER MmHighestPhysicalPage; extern PFN_NUMBER MmHighestPhysicalPage;
@ -50,7 +50,7 @@ struct _KTRAP_FRAME;
struct _EPROCESS; struct _EPROCESS;
struct _MM_RMAP_ENTRY; struct _MM_RMAP_ENTRY;
struct _MM_PAGEOP; struct _MM_PAGEOP;
typedef ULONG SWAPENTRY; typedef ULONG_PTR SWAPENTRY;
// //
// MmDbgCopyMemory Flags // MmDbgCopyMemory Flags
@ -207,7 +207,7 @@ typedef struct _MM_SECTION_SEGMENT
LONG FileOffset; /* start offset into the file for image sections */ LONG FileOffset; /* start offset into the file for image sections */
ULONG_PTR VirtualAddress; /* dtart offset into the address range 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 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; ULONG Protection;
FAST_MUTEX Lock; /* lock which protects the page directory */ FAST_MUTEX Lock; /* lock which protects the page directory */
ULONG ReferenceCount; ULONG ReferenceCount;
@ -464,7 +464,7 @@ typedef struct _MM_REGION
{ {
ULONG Type; ULONG Type;
ULONG Protect; ULONG Protect;
ULONG Length; SIZE_T Length;
LIST_ENTRY RegionListEntry; LIST_ENTRY RegionListEntry;
} MM_REGION, *PMM_REGION; } MM_REGION, *PMM_REGION;
@ -472,7 +472,7 @@ typedef struct _MM_REGION
typedef struct _MMFREE_POOL_ENTRY typedef struct _MMFREE_POOL_ENTRY
{ {
LIST_ENTRY List; LIST_ENTRY List;
PFN_NUMBER Size; PFN_COUNT Size;
ULONG Signature; ULONG Signature;
struct _MMFREE_POOL_ENTRY *Owner; struct _MMFREE_POOL_ENTRY *Owner;
} MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY; } MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY;
@ -499,7 +499,7 @@ typedef VOID
(*PMM_ALTER_REGION_FUNC)( (*PMM_ALTER_REGION_FUNC)(
PMMSUPPORT AddressSpace, PMMSUPPORT AddressSpace,
PVOID BaseAddress, PVOID BaseAddress,
ULONG Length, SIZE_T Length,
ULONG OldType, ULONG OldType,
ULONG OldProtect, ULONG OldProtect,
ULONG NewType, ULONG NewType,
@ -545,7 +545,7 @@ MmCreateMemoryArea(
PMMSUPPORT AddressSpace, PMMSUPPORT AddressSpace,
ULONG Type, ULONG Type,
PVOID *BaseAddress, PVOID *BaseAddress,
ULONG_PTR Length, SIZE_T Length,
ULONG Protection, ULONG Protection,
PMEMORY_AREA *Result, PMEMORY_AREA *Result,
BOOLEAN FixedAddress, BOOLEAN FixedAddress,
@ -594,14 +594,14 @@ NTAPI
MmLocateMemoryAreaByRegion( MmLocateMemoryAreaByRegion(
PMMSUPPORT AddressSpace, PMMSUPPORT AddressSpace,
PVOID Address, PVOID Address,
ULONG_PTR Length SIZE_T Length
); );
PVOID PVOID
NTAPI NTAPI
MmFindGap( MmFindGap(
PMMSUPPORT AddressSpace, PMMSUPPORT AddressSpace,
ULONG_PTR Length, SIZE_T Length,
ULONG_PTR Granularity, ULONG_PTR Granularity,
BOOLEAN TopDown BOOLEAN TopDown
); );
@ -617,7 +617,7 @@ MmReleaseMemoryAreaIfDecommitted(
VOID VOID
NTAPI NTAPI
MmMapMemoryArea(PVOID BaseAddress, MmMapMemoryArea(PVOID BaseAddress,
ULONG Length, SIZE_T Length,
ULONG Consumer, ULONG Consumer,
ULONG Protection); ULONG Protection);
@ -940,7 +940,7 @@ MmProtectAnonMem(
PMMSUPPORT AddressSpace, PMMSUPPORT AddressSpace,
PMEMORY_AREA MemoryArea, PMEMORY_AREA MemoryArea,
PVOID BaseAddress, PVOID BaseAddress,
ULONG Length, SIZE_T Length,
ULONG Protect, ULONG Protect,
PULONG OldProtect PULONG OldProtect
); );
@ -1536,7 +1536,7 @@ MmAlterRegion(
PVOID BaseAddress, PVOID BaseAddress,
PLIST_ENTRY RegionListHead, PLIST_ENTRY RegionListHead,
PVOID StartAddress, PVOID StartAddress,
ULONG Length, SIZE_T Length,
ULONG NewType, ULONG NewType,
ULONG NewProtect, ULONG NewProtect,
PMM_ALTER_REGION_FUNC AlterFunc PMM_ALTER_REGION_FUNC AlterFunc
@ -1584,7 +1584,7 @@ MmGetFileNameForSection(
PVOID PVOID
NTAPI NTAPI
MmAllocateSection( MmAllocateSection(
IN ULONG Length, IN SIZE_T Length,
PVOID BaseAddress PVOID BaseAddress
); );
@ -1603,7 +1603,7 @@ MmProtectSectionView(
PMMSUPPORT AddressSpace, PMMSUPPORT AddressSpace,
PMEMORY_AREA MemoryArea, PMEMORY_AREA MemoryArea,
PVOID BaseAddress, PVOID BaseAddress,
ULONG Length, SIZE_T Length,
ULONG Protect, ULONG Protect,
PULONG OldProtect PULONG OldProtect
); );

View file

@ -57,7 +57,7 @@
// Identifies a Kernel Handle // Identifies a Kernel Handle
// //
#define KERNEL_HANDLE_FLAG \ #define KERNEL_HANDLE_FLAG \
(1 << ((sizeof(HANDLE) * 8) - 1)) ((ULONG_PTR)1 << ((sizeof(HANDLE) * 8) - 1))
#define ObIsKernelHandle(Handle, ProcessorMode) \ #define ObIsKernelHandle(Handle, ProcessorMode) \
(((ULONG_PTR)(Handle) & KERNEL_HANDLE_FLAG) && \ (((ULONG_PTR)(Handle) & KERNEL_HANDLE_FLAG) && \
((ProcessorMode) == KernelMode)) ((ProcessorMode) == KernelMode))

View file

@ -1,6 +1,9 @@
#pragma once #pragma once
#ifdef _WIN64 #ifdef _WIN64
VOID
NTAPI
RtlInitializeSListHead(IN PSLIST_HEADER ListHead);
#define InitializeSListHead RtlInitializeSListHead #define InitializeSListHead RtlInitializeSListHead
#endif #endif

View file

@ -44,7 +44,7 @@ IopCreateArcNames(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
CHAR Buffer[128]; CHAR Buffer[128];
ANSI_STRING ArcSystemString, ArcString; ANSI_STRING ArcSystemString, ArcString;
BOOLEAN SingleDisk; BOOLEAN SingleDisk;
ULONG Length; SIZE_T Length;
NTSTATUS Status; NTSTATUS Status;
BOOLEAN FoundBoot = FALSE; BOOLEAN FoundBoot = FALSE;

View file

@ -129,7 +129,7 @@ IopBootLog(PUNICODE_STRING DriverName,
0, 0,
REG_SZ, REG_SZ,
(PVOID)Buffer, (PVOID)Buffer,
(wcslen(Buffer) + 1) * sizeof(WCHAR)); (ULONG)(wcslen(Buffer) + 1) * sizeof(WCHAR));
ZwClose(BootLogKey); ZwClose(BootLogKey);
ZwClose(ControlSetKey); ZwClose(ControlSetKey);
@ -191,8 +191,8 @@ IopWriteLogFile(PWSTR LogText)
NULL, NULL,
NULL, NULL,
&IoStatusBlock, &IoStatusBlock,
(PVOID)LogText, LogText,
wcslen(LogText) * sizeof(WCHAR), (ULONG)wcslen(LogText) * sizeof(WCHAR),
NULL, NULL,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))

View file

@ -332,7 +332,7 @@ IopOpenInterfaceKey(IN CONST GUID *InterfaceClassGuid,
} }
KeyName.Length = 0; 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); KeyName.Buffer = ExAllocatePool(PagedPool, KeyName.MaximumLength);
if (!KeyName.Buffer) if (!KeyName.Buffer)
{ {
@ -736,7 +736,8 @@ IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid,
if (ReturnBuffer.Length + KeyName.Length + sizeof(WCHAR) > ReturnBuffer.MaximumLength) if (ReturnBuffer.Length + KeyName.Length + sizeof(WCHAR) > ReturnBuffer.MaximumLength)
{ {
PWSTR NewBuffer; 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); NewBuffer = ExAllocatePool(PagedPool, ReturnBuffer.MaximumLength);
if (!NewBuffer) if (!NewBuffer)
{ {
@ -946,7 +947,7 @@ IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject,
/* Create base key name for this interface: HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses\{GUID} */ /* Create base key name for this interface: HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses\{GUID} */
ASSERT(((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode); ASSERT(((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode);
InstancePath = &((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode->InstancePath; 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 BaseKeyName.MaximumLength = BaseKeyName.Length
+ GuidString.Length; + GuidString.Length;
BaseKeyName.Buffer = ExAllocatePool( BaseKeyName.Buffer = ExAllocatePool(

View file

@ -548,7 +548,7 @@ IopAttachFilterDriversCallback(
DPRINT("Filter Driver: %S (%wZ)\n", Filters, &DeviceNode->InstancePath); DPRINT("Filter Driver: %S (%wZ)\n", Filters, &DeviceNode->InstancePath);
ServiceName.Buffer = Filters; ServiceName.Buffer = Filters;
ServiceName.MaximumLength = ServiceName.MaximumLength =
ServiceName.Length = wcslen(Filters) * sizeof(WCHAR); ServiceName.Length = (USHORT)wcslen(Filters) * sizeof(WCHAR);
/* Load and initialize the filter driver */ /* Load and initialize the filter driver */
Status = IopLoadServiceModule(&ServiceName, &ModuleObject); Status = IopLoadServiceModule(&ServiceName, &ModuleObject);
@ -840,7 +840,7 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
FileExtension = wcsrchr(ServiceName.Buffer, '.'); FileExtension = wcsrchr(ServiceName.Buffer, '.');
if (FileExtension != NULL) if (FileExtension != NULL)
{ {
ServiceName.Length -= wcslen(FileExtension) * sizeof(WCHAR); ServiceName.Length -= (USHORT)wcslen(FileExtension) * sizeof(WCHAR);
FileExtension[0] = 0; FileExtension[0] = 0;
} }
@ -1168,7 +1168,7 @@ IopUnloadDriver(PUNICODE_STRING DriverServiceName, BOOLEAN UnloadPnpDrivers)
* Construct the driver object name * 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.MaximumLength = ObjectName.Length + sizeof(WCHAR);
ObjectName.Buffer = ExAllocatePool(PagedPool, ObjectName.MaximumLength); ObjectName.Buffer = ExAllocatePool(PagedPool, ObjectName.MaximumLength);
if (!ObjectName.Buffer) return STATUS_INSUFFICIENT_RESOURCES; if (!ObjectName.Buffer) return STATUS_INSUFFICIENT_RESOURCES;

View file

@ -217,8 +217,8 @@ IopLogWorker(IN PVOID Parameter)
StringBuffer = ALIGN_UP_POINTER(StringBuffer, WCHAR); StringBuffer = ALIGN_UP_POINTER(StringBuffer, WCHAR);
/* Set the offset for the driver's name to the current buffer */ /* Set the offset for the driver's name to the current buffer */
ErrorMessage->DriverNameOffset = (ULONG_PTR)(StringBuffer - ErrorMessage->DriverNameOffset = (ULONG)(StringBuffer -
(ULONG_PTR)ErrorMessage); (PCHAR)ErrorMessage);
/* Check how much space we have left for the device string */ /* Check how much space we have left for the device string */
RemainingLength = (ULONG)((ULONG_PTR)Message + RemainingLength = (ULONG)((ULONG_PTR)Message +
@ -258,7 +258,7 @@ IopLogWorker(IN PVOID Parameter)
{ {
/* Use default name */ /* Use default name */
DriverNameString.Buffer = L"Application Popup"; 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 */ /* Check if we have a driver name by here */

View file

@ -1281,7 +1281,7 @@ IopSecurityFile(IN PVOID ObjectBody,
_SEH2_TRY _SEH2_TRY
{ {
/* Return length */ /* Return length */
*BufferLength = IoStatusBlock.Information; *BufferLength = (ULONG)IoStatusBlock.Information;
} }
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{ {
@ -1394,9 +1394,9 @@ IopQueryNameFile(IN PVOID ObjectBody,
/* Now calculate the new lengths left */ /* Now calculate the new lengths left */
FileLength = LocalReturnLength - FileLength = LocalReturnLength -
FIELD_OFFSET(FILE_NAME_INFORMATION, FileName); FIELD_OFFSET(FILE_NAME_INFORMATION, FileName);
LocalReturnLength = (ULONG_PTR)p - LocalReturnLength = (ULONG)((ULONG_PTR)p -
(ULONG_PTR)ObjectNameInfo + (ULONG_PTR)ObjectNameInfo +
LocalFileInfo->FileNameLength; LocalFileInfo->FileNameLength);
/* Write the Name and null-terminate it */ /* Write the Name and null-terminate it */
RtlCopyMemory(p, LocalFileInfo->FileName, FileLength); RtlCopyMemory(p, LocalFileInfo->FileName, FileLength);
@ -1408,7 +1408,7 @@ IopQueryNameFile(IN PVOID ObjectBody,
*ReturnLength = LocalReturnLength; *ReturnLength = LocalReturnLength;
/* Setup the length and maximum length */ /* 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 - ObjectNameInfo->Name.Length = (USHORT)FileLength -
sizeof(OBJECT_NAME_INFORMATION); sizeof(OBJECT_NAME_INFORMATION);
ObjectNameInfo->Name.MaximumLength = (USHORT)ObjectNameInfo->Name.Length + ObjectNameInfo->Name.MaximumLength = (USHORT)ObjectNameInfo->Name.Length +

View file

@ -630,7 +630,7 @@ IopQueryDeviceInformation(IN PFILE_OBJECT FileObject,
} }
/* Return the Length and Status. ReturnedLength is NOT optional */ /* Return the Length and Status. ReturnedLength is NOT optional */
*ReturnedLength = IoStatusBlock.Information; *ReturnedLength = (ULONG)IoStatusBlock.Information;
return Status; return Status;
} }

View file

@ -132,8 +132,8 @@ IoBuildPartialMdl(IN PMDL SourceMdl,
TargetMdl->MappedSystemVa = (PCHAR)SourceMdl->MappedSystemVa + Offset; TargetMdl->MappedSystemVa = (PCHAR)SourceMdl->MappedSystemVa + Offset;
/* Now do the copy */ /* Now do the copy */
Offset = ((ULONG_PTR)TargetMdl->StartVa - (ULONG_PTR)SourceMdl->StartVa) >> Offset = (ULONG)(((ULONG_PTR)TargetMdl->StartVa -
PAGE_SHIFT; (ULONG_PTR)SourceMdl->StartVa) >> PAGE_SHIFT);
SourcePages += Offset; SourcePages += Offset;
RtlCopyMemory(TargetPages, SourcePages, Length * sizeof(PFN_NUMBER)); RtlCopyMemory(TargetPages, SourcePages, Length * sizeof(PFN_NUMBER));
} }

View file

@ -1832,7 +1832,7 @@ NTAPI
IoIs32bitProcess( IoIs32bitProcess(
IN PIRP Irp OPTIONAL) IN PIRP Irp OPTIONAL)
{ {
#pragma message "IoIs32bitProcess is hardcoded to FALSE" UNIMPLEMENTED;
return FALSE; return FALSE;
} }
#endif #endif

View file

@ -186,7 +186,7 @@ IoCheckEaBufferValidity(IN PFILE_FULL_EA_INFORMATION EaBuffer,
EaBufferEnd->EaNameLength + EaBufferEnd->EaValueLength + EaBufferEnd->EaNameLength + EaBufferEnd->EaValueLength +
FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]) + 1; FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]) + 1;
if (IntEaLength >= NextEaBufferOffset) if ((ULONG)IntEaLength >= NextEaBufferOffset)
{ {
/* is the EaBufferName terminated with zero? */ /* is the EaBufferName terminated with zero? */
if (EaBufferEnd->EaName[EaBufferEnd->EaNameLength]==0) if (EaBufferEnd->EaName[EaBufferEnd->EaNameLength]==0)

View file

@ -21,7 +21,7 @@ typedef struct _IOPNP_DEVICE_EXTENSION
} IOPNP_DEVICE_EXTENSION, *PIOPNP_DEVICE_EXTENSION; } IOPNP_DEVICE_EXTENSION, *PIOPNP_DEVICE_EXTENSION;
PUNICODE_STRING PiInitGroupOrderTable; PUNICODE_STRING PiInitGroupOrderTable;
ULONG PiInitGroupOrderTableCount; USHORT PiInitGroupOrderTableCount;
INTERFACE_TYPE PnpDefaultInterfaceType; INTERFACE_TYPE PnpDefaultInterfaceType;
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/
@ -90,7 +90,7 @@ PiInitCacheGroupInformation(VOID)
/* Cache it for later */ /* Cache it for later */
PiInitGroupOrderTable = GroupTable; PiInitGroupOrderTable = GroupTable;
PiInitGroupOrderTableCount = Count; PiInitGroupOrderTableCount = (USHORT)Count;
} }
else else
{ {
@ -113,7 +113,7 @@ PpInitGetGroupOrderIndex(IN HANDLE ServiceHandle)
{ {
NTSTATUS Status; NTSTATUS Status;
PKEY_VALUE_FULL_INFORMATION KeyValueInformation; PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
ULONG i; USHORT i;
PVOID Buffer; PVOID Buffer;
UNICODE_STRING Group; UNICODE_STRING Group;
PAGED_CODE(); PAGED_CODE();
@ -135,7 +135,7 @@ PpInitGetGroupOrderIndex(IN HANDLE ServiceHandle)
/* Convert to unicode string */ /* Convert to unicode string */
Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset); Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset);
PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &Group.Length); PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &Group.Length);
Group.MaximumLength = KeyValueInformation->DataLength; Group.MaximumLength = (USHORT)KeyValueInformation->DataLength;
Group.Buffer = Buffer; Group.Buffer = Buffer;
/* Loop the groups */ /* Loop the groups */
@ -162,7 +162,8 @@ PipGetDriverTagPriority(IN HANDLE ServiceHandle)
PVOID Buffer; PVOID Buffer;
UNICODE_STRING Group; UNICODE_STRING Group;
PULONG GroupOrder; PULONG GroupOrder;
ULONG i = -1, Count, Tag = 0; ULONG Count, Tag = 0;
USHORT i = -1;
UNICODE_STRING GroupString = UNICODE_STRING GroupString =
RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet" RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet"
L"\\Control\\ServiceGroupOrder"); L"\\Control\\ServiceGroupOrder");
@ -182,7 +183,7 @@ PipGetDriverTagPriority(IN HANDLE ServiceHandle)
/* Convert to unicode string */ /* Convert to unicode string */
Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset); Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset);
PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &Group.Length); PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &Group.Length);
Group.MaximumLength = KeyValueInformation->DataLength; Group.MaximumLength = (USHORT)KeyValueInformation->DataLength;
Group.Buffer = Buffer; Group.Buffer = Buffer;
} }
@ -290,7 +291,7 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
/* Convert to unicode string */ /* Convert to unicode string */
Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset); Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset);
PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &ClassGuid.Length); PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &ClassGuid.Length);
ClassGuid.MaximumLength = KeyValueInformation->DataLength; ClassGuid.MaximumLength = (USHORT)KeyValueInformation->DataLength;
ClassGuid.Buffer = Buffer; ClassGuid.Buffer = Buffer;
/* Open the key */ /* Open the key */

View file

@ -932,7 +932,7 @@ NTSTATUS
NTAPI NTAPI
IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject, IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject,
IN OUT PIO_STATUS_BLOCK IoStatusBlock, IN OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG MinorFunction, IN UCHAR MinorFunction,
IN PIO_STACK_LOCATION Stack OPTIONAL) IN PIO_STACK_LOCATION Stack OPTIONAL)
{ {
IO_STACK_LOCATION IoStackLocation; IO_STACK_LOCATION IoStackLocation;
@ -1044,7 +1044,7 @@ IopCreateDeviceKeyPath(IN PCUNICODE_STRING RegistryPath,
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName; UNICODE_STRING KeyName;
LPCWSTR Current, Last; LPCWSTR Current, Last;
ULONG dwLength; USHORT Length;
NTSTATUS Status; NTSTATUS Status;
/* Assume failure */ /* Assume failure */
@ -1076,8 +1076,8 @@ IopCreateDeviceKeyPath(IN PCUNICODE_STRING RegistryPath,
} }
/* Prepare relative key name */ /* Prepare relative key name */
dwLength = (ULONG_PTR)Current - (ULONG_PTR)KeyName.Buffer; Length = (USHORT)((ULONG_PTR)Current - (ULONG_PTR)KeyName.Buffer);
KeyName.MaximumLength = KeyName.Length = dwLength; KeyName.MaximumLength = KeyName.Length = Length;
DPRINT("Create '%wZ'\n", &KeyName); DPRINT("Create '%wZ'\n", &KeyName);
/* Open key */ /* Open key */
@ -1324,7 +1324,7 @@ IopGetParentIdPrefix(PDEVICE_NODE DeviceNode,
0, 0,
REG_SZ, REG_SZ,
(PVOID)KeyValue.Buffer, (PVOID)KeyValue.Buffer,
(wcslen(KeyValue.Buffer) + 1) * sizeof(WCHAR)); ((ULONG)wcslen(KeyValue.Buffer) + 1) * sizeof(WCHAR));
cleanup: cleanup:
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
@ -1370,7 +1370,7 @@ IopQueryHardwareIds(PDEVICE_NODE DeviceNode,
while (*Ptr) while (*Ptr)
{ {
DPRINT(" %S\n", Ptr); DPRINT(" %S\n", Ptr);
Length = wcslen(Ptr) + 1; Length = (ULONG)wcslen(Ptr) + 1;
Ptr += Length; Ptr += Length;
TotalLength += Length; TotalLength += Length;
@ -1430,7 +1430,7 @@ IopQueryCompatibleIds(PDEVICE_NODE DeviceNode,
while (*Ptr) while (*Ptr)
{ {
DPRINT(" %S\n", Ptr); DPRINT(" %S\n", Ptr);
Length = wcslen(Ptr) + 1; Length = (ULONG)wcslen(Ptr) + 1;
Ptr += Length; Ptr += Length;
TotalLength += Length; TotalLength += Length;
@ -1678,7 +1678,7 @@ IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
0, 0,
REG_SZ, REG_SZ,
(PVOID)IoStatusBlock.Information, (PVOID)IoStatusBlock.Information,
(wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR)); ((ULONG)wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
} }
else else
{ {
@ -1718,7 +1718,7 @@ IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
0, 0,
REG_SZ, REG_SZ,
(PVOID)IoStatusBlock.Information, (PVOID)IoStatusBlock.Information,
(wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR)); ((ULONG)wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("ZwSetValueKey() failed (Status %lx)\n", Status); DPRINT1("ZwSetValueKey() failed (Status %lx)\n", Status);
@ -2920,7 +2920,8 @@ IopCreateRegistryKeyEx(OUT PHANDLE Handle,
OUT PULONG Disposition OPTIONAL) OUT PULONG Disposition OPTIONAL)
{ {
OBJECT_ATTRIBUTES ObjectAttributes; 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]; HANDLE HandleArray[2];
BOOLEAN Recursing = TRUE; BOOLEAN Recursing = TRUE;
PWCHAR pp, p, p1; PWCHAR pp, p, p1;
@ -2968,7 +2969,7 @@ IopCreateRegistryKeyEx(OUT PHANDLE Handle,
/* Process the parent key name */ /* Process the parent key name */
for (p = p1; ((p < pp) && (*p != OBJ_NAME_PATH_SEPARATOR)); p++); 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? */ /* Is there a parent name? */
if (Length) if (Length)
@ -3497,7 +3498,7 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject,
NullTerminate = TRUE; NullTerminate = TRUE;
/* This is the format of the returned data */ /* This is the format of the returned data */
PIP_RETURN_DATA((EnumeratorNameEnd - DeviceInstanceName) * sizeof(WCHAR), PIP_RETURN_DATA((ULONG)(EnumeratorNameEnd - DeviceInstanceName) * sizeof(WCHAR),
DeviceInstanceName); DeviceInstanceName);
case DevicePropertyAddress: case DevicePropertyAddress:

View file

@ -72,7 +72,7 @@ IopFindMemoryResource(
IN PIO_RESOURCE_DESCRIPTOR IoDesc, IN PIO_RESOURCE_DESCRIPTOR IoDesc,
OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
{ {
ULONGLONG Start; LONGLONG Start;
CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
ASSERT(IoDesc->Type == CmDesc->Type); ASSERT(IoDesc->Type == CmDesc->Type);
@ -87,7 +87,8 @@ IopFindMemoryResource(
if (IopCheckDescriptorForConflict(CmDesc, &ConflictingDesc)) 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 else
{ {
@ -104,7 +105,7 @@ IopFindPortResource(
IN PIO_RESOURCE_DESCRIPTOR IoDesc, IN PIO_RESOURCE_DESCRIPTOR IoDesc,
OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
{ {
ULONGLONG Start; LONGLONG Start;
CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
ASSERT(IoDesc->Type == CmDesc->Type); ASSERT(IoDesc->Type == CmDesc->Type);
@ -647,7 +648,7 @@ IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2
} }
NameU.Length = 0; NameU.Length = 0;
NameU.MaximumLength = OldLength + TranslatedSuffix.Length; NameU.MaximumLength = (USHORT)OldLength + TranslatedSuffix.Length;
Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject, Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
DevicePropertyPhysicalDeviceObjectName, DevicePropertyPhysicalDeviceObjectName,
@ -673,7 +674,7 @@ IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2
ASSERT(FALSE); ASSERT(FALSE);
} }
NameU.Length = OldLength; NameU.Length = (USHORT)OldLength;
RtlAppendUnicodeStringToString(&NameU, &RawSuffix); 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 */ /* "Remove" the suffix by setting the length back to what it used to be */
NameU.Length = OldLength; NameU.Length = (USHORT)OldLength;
RtlAppendUnicodeStringToString(&NameU, &TranslatedSuffix); RtlAppendUnicodeStringToString(&NameU, &TranslatedSuffix);
@ -985,7 +986,6 @@ IopCheckForResourceConflict(
} }
} }
ByeBye: ByeBye:
return Result; return Result;
@ -1050,7 +1050,7 @@ IopDetectResourceConflict(
goto cleanup; goto cleanup;
KeyName.Buffer = KeyInformation->Name; KeyName.Buffer = KeyInformation->Name;
KeyName.MaximumLength = KeyName.Length = KeyInformation->NameLength; KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
&KeyName, &KeyName,
OBJ_CASE_INSENSITIVE, OBJ_CASE_INSENSITIVE,
@ -1095,7 +1095,7 @@ IopDetectResourceConflict(
goto cleanup; goto cleanup;
KeyName.Buffer = KeyInformation->Name; KeyName.Buffer = KeyInformation->Name;
KeyName.MaximumLength = KeyName.Length = KeyInformation->NameLength; KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
&KeyName, &KeyName,
OBJ_CASE_INSENSITIVE, OBJ_CASE_INSENSITIVE,

View file

@ -339,7 +339,7 @@ QueryStringCallback(
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
Source.MaximumLength = Source.Length = ValueLength; Source.MaximumLength = Source.Length = (USHORT)ValueLength;
Source.Buffer = ValueData; Source.Buffer = ValueData;
return RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, &Source, Destination); return RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, &Source, Destination);

View file

@ -49,7 +49,8 @@ PnpRegMultiSzToUnicodeStrings(IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation
OUT PULONG UnicodeStringCount) OUT PULONG UnicodeStringCount)
{ {
PWCHAR p, pp, ps; PWCHAR p, pp, ps;
ULONG i = 0, n; ULONG i = 0;
SIZE_T n;
ULONG Count = 0; ULONG Count = 0;
/* Validate the key information */ /* Validate the key information */
@ -114,8 +115,8 @@ PnpRegMultiSzToUnicodeStrings(IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation
RtlCopyMemory((*UnicodeStringList)[i].Buffer, ps, n); RtlCopyMemory((*UnicodeStringList)[i].Buffer, ps, n);
/* Set the lengths */ /* Set the lengths */
(*UnicodeStringList)[i].MaximumLength = n; (*UnicodeStringList)[i].MaximumLength = (USHORT)n;
(*UnicodeStringList)[i].Length = n - sizeof(UNICODE_NULL); (*UnicodeStringList)[i].Length = (USHORT)(n - sizeof(UNICODE_NULL));
/* One more entry done */ /* One more entry done */
i++; i++;
@ -156,8 +157,8 @@ PnpRegMultiSzToUnicodeStrings(IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation
(*UnicodeStringList)[i].Buffer[n / sizeof(WCHAR)] = UNICODE_NULL; (*UnicodeStringList)[i].Buffer[n / sizeof(WCHAR)] = UNICODE_NULL;
/* Set the lenghts */ /* Set the lenghts */
(*UnicodeStringList)[i].Length = n; (*UnicodeStringList)[i].Length = (USHORT)n;
(*UnicodeStringList)[i].MaximumLength = n + sizeof(UNICODE_NULL); (*UnicodeStringList)[i].MaximumLength = (USHORT)(n + sizeof(UNICODE_NULL));
} }
/* And we're done */ /* And we're done */
@ -178,7 +179,7 @@ PnpRegSzToString(IN PWCHAR RegSzData,
for (p = RegSzData; p < pp; p++) if (!*p) break; for (p = RegSzData; p < pp; p++) if (!*p) break;
/* Return it */ /* Return it */
if (StringLength) *StringLength = (p - RegSzData) * sizeof(WCHAR); if (StringLength) *StringLength = (USHORT)(p - RegSzData) * sizeof(WCHAR);
return TRUE; return TRUE;
} }

View file

@ -316,7 +316,7 @@ DumpTraceData(IN PSTRING TraceData)
TraceDataBuffer[0] = TraceDataBufferPosition; TraceDataBuffer[0] = TraceDataBufferPosition;
/* Setup the trace data */ /* Setup the trace data */
TraceData->Length = TraceDataBufferPosition * sizeof(ULONG); TraceData->Length = (USHORT)(TraceDataBufferPosition * sizeof(ULONG));
TraceData->Buffer = (PCHAR)TraceDataBuffer; TraceData->Buffer = (PCHAR)TraceDataBuffer;
/* Reset the buffer location */ /* Reset the buffer location */
@ -351,7 +351,7 @@ KdpSetCommonState(IN ULONG NewState,
0, 0,
MMDBG_COPY_UNSAFE, MMDBG_COPY_UNSAFE,
&InstructionCount); &InstructionCount);
WaitStateChange->ControlReport.InstructionCount = InstructionCount; WaitStateChange->ControlReport.InstructionCount = (USHORT)InstructionCount;
/* Clear all the breakpoints in this region */ /* Clear all the breakpoints in this region */
HadBreakpoints = HadBreakpoints =
@ -433,7 +433,8 @@ KdpReadVirtualMemory(IN PDBGKD_MANIPULATE_STATE64 State,
&Length); &Length);
/* Return the actual length read */ /* Return the actual length read */
Data->Length = ReadMemory->ActualBytesRead = Length; ReadMemory->ActualBytesRead = Length;
Data->Length = (USHORT)Length;
/* Send the packet */ /* Send the packet */
KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE, KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
@ -524,7 +525,8 @@ KdpReadPhysicalmemory(IN PDBGKD_MANIPULATE_STATE64 State,
&Length); &Length);
/* Return the actual length read */ /* Return the actual length read */
Data->Length = ReadMemory->ActualBytesRead = Length; ReadMemory->ActualBytesRead = Length;
Data->Length = (USHORT)Length;
/* Send the packet */ /* Send the packet */
KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE, KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
@ -614,7 +616,8 @@ KdpReadControlSpace(IN PDBGKD_MANIPULATE_STATE64 State,
&Length); &Length);
/* Return the actual length read */ /* Return the actual length read */
Data->Length = ReadMemory->ActualBytesRead = Length; ReadMemory->ActualBytesRead = Length;
Data->Length = (USHORT)Length;
/* Send the reply */ /* Send the reply */
KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE, KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
@ -851,7 +854,8 @@ KdpGetBusData(IN PDBGKD_MANIPULATE_STATE64 State,
&Length); &Length);
/* Return the actual length read */ /* Return the actual length read */
Data->Length = GetBusData->Length = Length; GetBusData->Length = Length;
Data->Length = (USHORT)Length;
/* Send the reply */ /* Send the reply */
KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE, KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
@ -1418,7 +1422,7 @@ KdpReportLoadSymbolsStateChange(IN PSTRING PathName,
/* Set up the data */ /* Set up the data */
Data.Buffer = KdpPathBuffer; Data.Buffer = KdpPathBuffer;
Data.Length = PathNameLength; Data.Length = (USHORT)PathNameLength;
ExtraData = &Data; ExtraData = &Data;
} }
else else
@ -1506,7 +1510,7 @@ KdpReportCommandStringStateChange(IN PSTRING NameString,
/* Now set up the header and the data */ /* Now set up the header and the data */
Header.Length = sizeof(DBGKD_ANY_WAIT_STATE_CHANGE); Header.Length = sizeof(DBGKD_ANY_WAIT_STATE_CHANGE);
Header.Buffer = (PCHAR)&WaitStateChange; Header.Buffer = (PCHAR)&WaitStateChange;
Data.Length = TotalLength; Data.Length = (USHORT)TotalLength;
Data.Buffer = KdpMessageBuffer; Data.Buffer = KdpMessageBuffer;
/* Send State Change packet and wait for a reply */ /* Send State Change packet and wait for a reply */

View file

@ -101,7 +101,7 @@ ULONG KdpNumInternalBreakpoints;
// //
// Symbol Data // Symbol Data
// //
ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd; ULONG_PTR KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
// //
// Tracepoint Data // Tracepoint Data

View file

@ -79,7 +79,8 @@ KdInitSystem(IN ULONG BootPhase,
STRING ImageName; STRING ImageName;
PLDR_DATA_TABLE_ENTRY LdrEntry; PLDR_DATA_TABLE_ENTRY LdrEntry;
PLIST_ENTRY NextEntry; PLIST_ENTRY NextEntry;
ULONG i, j, Length, DebugOptionLength; ULONG i, j, Length;
SIZE_T DebugOptionLength;
CHAR NameBuffer[256]; CHAR NameBuffer[256];
PWCHAR Name; PWCHAR Name;
@ -209,8 +210,7 @@ KdInitSystem(IN ULONG BootPhase,
} }
/* Calculate the length of the current option */ /* Calculate the length of the current option */
DebugOptionLength = ((ULONG_PTR)DebugOptionEnd - DebugOptionLength = (DebugOptionEnd - DebugOptionStart);
(ULONG_PTR)DebugOptionStart);
/* /*
* Break out if we reached the last option * Break out if we reached the last option

View file

@ -275,7 +275,7 @@ KdpStub(IN PKTRAP_FRAME TrapFrame,
IN KPROCESSOR_MODE PreviousMode, IN KPROCESSOR_MODE PreviousMode,
IN BOOLEAN SecondChanceException) 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 */ /* Check if this was a breakpoint due to DbgPrint or Load/UnloadSymbols */
if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) && if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&

View file

@ -27,15 +27,10 @@ KTSS64 KiBootTss;
/* CPU Features and Flags */ /* CPU Features and Flags */
ULONG KeI386CpuType; ULONG KeI386CpuType;
ULONG KeI386CpuStep; ULONG KeI386CpuStep;
ULONG KeProcessorArchitecture;
ULONG KeProcessorLevel;
ULONG KeProcessorRevision;
ULONG KeFeatureBits;
ULONG KeI386MachineType; ULONG KeI386MachineType;
ULONG KeI386NpxPresent = 1; ULONG KeI386NpxPresent = 1;
ULONG KeLargestCacheLine = 0x40; ULONG KeLargestCacheLine = 0x40;
ULONG KiDmaIoCoherency = 0; ULONG KiDmaIoCoherency = 0;
KAFFINITY KeActiveProcessors = 1;
BOOLEAN KiSMTProcessorsPresent; BOOLEAN KiSMTProcessorsPresent;
/* Freeze data */ /* Freeze data */

View file

@ -277,8 +277,8 @@ KiGeneralProtectionFaultHandler(
/* Check for RDMSR/WRMSR */ /* Check for RDMSR/WRMSR */
if ((Instructions[0] == 0xF) && // 2-byte opcode if ((Instructions[0] == 0xF) && // 2-byte opcode
(((Instructions[1] >> 8) == 0x30) || // RDMSR ((Instructions[1] == 0x30) || // RDMSR
((Instructions[2] >> 8) == 0x32))) // WRMSR (Instructions[1] == 0x32))) // WRMSR
{ {
/* Unknown CPU MSR, so raise an access violation */ /* Unknown CPU MSR, so raise an access violation */
return STATUS_ACCESS_VIOLATION; return STATUS_ACCESS_VIOLATION;

View file

@ -141,7 +141,7 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
IN PKPRCB Prcb, IN PKPRCB Prcb,
IN PLOADER_PARAMETER_BLOCK LoaderBlock) IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{ {
ULONG PageDirectory[2]; ULONG_PTR PageDirectory[2];
PVOID DpcStack; PVOID DpcStack;
ULONG i; ULONG i;

View file

@ -18,11 +18,6 @@ ULONG KeFixedTbEntries;
ULONG KiDmaIoCoherency; ULONG KiDmaIoCoherency;
ULONG KeIcacheFlushCount = 0; ULONG KeIcacheFlushCount = 0;
ULONG KeDcacheFlushCount; ULONG KeDcacheFlushCount;
ULONG KeActiveProcessors;
ULONG KeProcessorArchitecture;
ULONG KeProcessorLevel;
ULONG KeProcessorRevision;
ULONG KeFeatureBits;
ULONG KeLargestCacheLine = 64; // FIXME: It depends ULONG KeLargestCacheLine = 64; // FIXME: It depends
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/

View file

@ -235,7 +235,8 @@ FASTCALL
KeRosDumpStackFrameArray(IN PULONG_PTR Frames, KeRosDumpStackFrameArray(IN PULONG_PTR Frames,
IN ULONG FrameCount) IN ULONG FrameCount)
{ {
ULONG i, Addr; ULONG i;
ULONG_PTR Addr;
BOOLEAN InSystem; BOOLEAN InSystem;
PVOID p; PVOID p;
@ -438,6 +439,7 @@ KeGetBugMessageText(IN ULONG BugCheckCode,
ULONG_PTR MessageEntry; ULONG_PTR MessageEntry;
PCHAR BugCode; PCHAR BugCode;
BOOLEAN Result = FALSE; BOOLEAN Result = FALSE;
USHORT Length;
/* Make sure we're not bugchecking too early */ /* Make sure we're not bugchecking too early */
if (!KiBugCodeMessages) return Result; if (!KiBugCodeMessages) return Result;
@ -464,16 +466,16 @@ KeGetBugMessageText(IN ULONG BugCheckCode,
/* Get the final Code */ /* Get the final Code */
BugCode = (PCHAR)((PMESSAGE_RESOURCE_ENTRY)MessageEntry)->Text; BugCode = (PCHAR)((PMESSAGE_RESOURCE_ENTRY)MessageEntry)->Text;
i = strlen(BugCode); Length = (USHORT)strlen(BugCode);
/* Handle newlines */ /* Handle trailing newlines */
while ((i > 0) && ((BugCode[i] == '\n') || while ((Length > 0) && ((BugCode[Length] == '\n') ||
(BugCode[i] == '\r') || (BugCode[Length] == '\r') ||
(BugCode[i] == ANSI_NULL))) (BugCode[Length] == ANSI_NULL)))
{ {
/* Check if we have a string to return */ /* Check if we have a string to return */
if (!OutputString) BugCode[i] = ANSI_NULL; if (!OutputString) BugCode[Length] = ANSI_NULL;
i--; Length--;
} }
/* Check if caller wants an output string */ /* Check if caller wants an output string */
@ -481,8 +483,8 @@ KeGetBugMessageText(IN ULONG BugCheckCode,
{ {
/* Return it in the OutputString */ /* Return it in the OutputString */
OutputString->Buffer = BugCode; OutputString->Buffer = BugCode;
OutputString->Length = (USHORT)i + 1; OutputString->Length = Length + 1;
OutputString->MaximumLength = (USHORT)i + 1; OutputString->MaximumLength = Length + 1;
} }
else else
{ {
@ -724,7 +726,7 @@ KiDisplayBlueScreen(IN ULONG MessageId,
if (MessageId == BUGCODE_PSS_MESSAGE) if (MessageId == BUGCODE_PSS_MESSAGE)
{ {
/* It is, so get the bug code string as well */ /* It is, so get the bug code string as well */
KeGetBugMessageText(KiBugCheckData[0], NULL); KeGetBugMessageText((ULONG)KiBugCheckData[0], NULL);
InbvDisplayString("\r\n\r\n"); InbvDisplayString("\r\n\r\n");
} }

View file

@ -34,7 +34,7 @@ KeWaitForGate(IN PKGATE Gate,
KLOCK_QUEUE_HANDLE ApcLock; KLOCK_QUEUE_HANDLE ApcLock;
PKTHREAD Thread = KeGetCurrentThread(); PKTHREAD Thread = KeGetCurrentThread();
PKWAIT_BLOCK GateWaitBlock; PKWAIT_BLOCK GateWaitBlock;
NTSTATUS Status; LONG_PTR Status;
PKQUEUE Queue; PKQUEUE Queue;
ASSERT_GATE(Gate); ASSERT_GATE(Gate);
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL); ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);

View file

@ -23,10 +23,6 @@ UCHAR KiNMITSS[KTSS_IO_MAPS];
/* CPU Features and Flags */ /* CPU Features and Flags */
ULONG KeI386CpuType; ULONG KeI386CpuType;
ULONG KeI386CpuStep; ULONG KeI386CpuStep;
ULONG KeProcessorArchitecture;
ULONG KeProcessorLevel;
ULONG KeProcessorRevision;
ULONG KeFeatureBits;
ULONG KiFastSystemCallDisable = 1; ULONG KiFastSystemCallDisable = 1;
ULONG KeI386NpxPresent = 0; ULONG KeI386NpxPresent = 0;
ULONG KiMXCsrMask = 0; ULONG KiMXCsrMask = 0;
@ -41,7 +37,6 @@ ULONG KeDcacheFlushCount = 0;
ULONG KeIcacheFlushCount = 0; ULONG KeIcacheFlushCount = 0;
ULONG KiDmaIoCoherency = 0; ULONG KiDmaIoCoherency = 0;
ULONG KePrefetchNTAGranularity = 32; ULONG KePrefetchNTAGranularity = 32;
KAFFINITY KeActiveProcessors = 1;
BOOLEAN KiI386PentiumLockErrataPresent; BOOLEAN KiI386PentiumLockErrataPresent;
BOOLEAN KiSMTProcessorsPresent; BOOLEAN KiSMTProcessorsPresent;
@ -109,17 +104,21 @@ RDMSR(IN ULONG Register)
/* NSC/Cyrix CPU indexed register access macros */ /* NSC/Cyrix CPU indexed register access macros */
static __inline static __inline
ULONG UCHAR
getCx86(UCHAR reg) getCx86(UCHAR reg)
{ {
WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22, reg); WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22, reg);
return READ_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23); return READ_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23);
} }
#define setCx86(reg, data) do { \ static __inline
WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22,(reg)); \ void
WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23,(data)); \ setCx86(UCHAR reg, UCHAR data)
} while (0) {
WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22, reg);
WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23, data);
}
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -260,7 +259,8 @@ KiGetFeatureBits(VOID)
PKPRCB Prcb = KeGetCurrentPrcb(); PKPRCB Prcb = KeGetCurrentPrcb();
ULONG Vendor; ULONG Vendor;
ULONG FeatureBits = KF_WORKING_PTE; ULONG FeatureBits = KF_WORKING_PTE;
ULONG Reg[4], Dummy, Ccr1; ULONG Reg[4], Dummy;
UCHAR Ccr1;
BOOLEAN ExtendedCPUID = TRUE; BOOLEAN ExtendedCPUID = TRUE;
ULONG CpuFeatures = 0; ULONG CpuFeatures = 0;
@ -513,8 +513,8 @@ KiGetCacheInformation(VOID)
ULONG Data[4], Dummy; ULONG Data[4], Dummy;
ULONG CacheRequests = 0, i; ULONG CacheRequests = 0, i;
ULONG CurrentRegister; ULONG CurrentRegister;
UCHAR RegisterByte; UCHAR RegisterByte, Associativity = 0;
ULONG Size, Associativity = 0, CacheLine = 64, CurrentSize = 0; ULONG Size, CacheLine = 64, CurrentSize = 0;
BOOLEAN FirstPass = TRUE; BOOLEAN FirstPass = TRUE;
/* Set default L2 size */ /* Set default L2 size */
@ -745,7 +745,7 @@ KiGetCacheInformation(VOID)
CacheLine = Data[2] & 0xFF; CacheLine = Data[2] & 0xFF;
/* Hardcode associativity */ /* Hardcode associativity */
RegisterByte = Data[2] >> 12; RegisterByte = (Data[2] >> 12) & 0xFF;
switch (RegisterByte) switch (RegisterByte)
{ {
case 2: case 2:

View file

@ -15,6 +15,13 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
/* Portable CPU Features and Flags */
USHORT KeProcessorArchitecture;
USHORT KeProcessorLevel;
USHORT KeProcessorRevision;
ULONG KeFeatureBits;
KAFFINITY KeActiveProcessors = 1;
/* System call count */ /* System call count */
ULONG KiServiceLimit = NUMBER_OF_SYSCALLS; ULONG KiServiceLimit = NUMBER_OF_SYSCALLS;

View file

@ -15,15 +15,10 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
/* CPU Features and Flags */ /* CPU Features and Flags */
ULONG KeProcessorArchitecture;
ULONG KeProcessorLevel;
ULONG KeProcessorRevision;
ULONG KeFeatureBits;
ULONG KeLargestCacheLine = 0x40; ULONG KeLargestCacheLine = 0x40;
ULONG KeDcacheFlushCount = 0; ULONG KeDcacheFlushCount = 0;
ULONG KeIcacheFlushCount = 0; ULONG KeIcacheFlushCount = 0;
ULONG KiDmaIoCoherency = 0; ULONG KiDmaIoCoherency = 0;
KAFFINITY KeActiveProcessors = 1;
BOOLEAN KiSMTProcessorsPresent; BOOLEAN KiSMTProcessorsPresent;
/* CPU Signatures */ /* CPU Signatures */

View file

@ -115,7 +115,7 @@ NTAPI
KeInitializeProcess(IN OUT PKPROCESS Process, KeInitializeProcess(IN OUT PKPROCESS Process,
IN KPRIORITY Priority, IN KPRIORITY Priority,
IN KAFFINITY Affinity, IN KAFFINITY Affinity,
IN PULONG DirectoryTableBase, IN PULONG_PTR DirectoryTableBase,
IN BOOLEAN Enable) IN BOOLEAN Enable)
{ {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP

View file

@ -28,7 +28,7 @@ NTAPI
KeInitializeProfile(PKPROFILE Profile, KeInitializeProfile(PKPROFILE Profile,
PKPROCESS Process, PKPROCESS Process,
PVOID ImageBase, PVOID ImageBase,
ULONG ImageSize, SIZE_T ImageSize,
ULONG BucketSize, ULONG BucketSize,
KPROFILE_SOURCE ProfileSource, KPROFILE_SOURCE ProfileSource,
KAFFINITY Affinity) KAFFINITY Affinity)
@ -270,7 +270,7 @@ KeSetIntervalProfile(IN KPROFILE_SOURCE ProfileSource,
if (ProfileSource == ProfileTime) if (ProfileSource == ProfileTime)
{ {
/* Set the interval through HAL */ /* Set the interval through HAL */
KiProfileTimeInterval = HalSetProfileInterval(Interval); KiProfileTimeInterval = (ULONG)HalSetProfileInterval(Interval);
} }
else if (ProfileSource == ProfileAlignmentFixup) else if (ProfileSource == ProfileAlignmentFixup)
{ {

View file

@ -12,10 +12,18 @@
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
#ifdef _WIN64
# define InterlockedOrSetMember(Destination, SetMember) \
InterlockedOr64((PLONG64)Destination, SetMember);
#else
# define InterlockedOrSetMember(Destination, SetMember) \
InterlockedOr((PLONG)Destination, SetMember);
#endif
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
ULONG KiIdleSummary; ULONG_PTR KiIdleSummary;
ULONG KiIdleSMTSummary; ULONG_PTR KiIdleSMTSummary;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -321,7 +329,7 @@ KiSelectNextThread(IN PKPRCB Prcb)
Thread = Prcb->IdleThread; Thread = Prcb->IdleThread;
/* Enable idle scheduling */ /* Enable idle scheduling */
InterlockedOr((PLONG) &KiIdleSummary, Prcb->SetMember); InterlockedOrSetMember(&KiIdleSummary, Prcb->SetMember);
Prcb->IdleSchedule = TRUE; Prcb->IdleSchedule = TRUE;
/* FIXME: SMT support */ /* FIXME: SMT support */
@ -370,7 +378,7 @@ KiSwapThread(IN PKTHREAD CurrentThread,
else else
{ {
/* Set the idle summary */ /* Set the idle summary */
InterlockedOr((PLONG)&KiIdleSummary, Prcb->SetMember); InterlockedOrSetMember(&KiIdleSummary, Prcb->SetMember);
/* Schedule the idle thread */ /* Schedule the idle thread */
NextThread = Prcb->IdleThread; NextThread = Prcb->IdleThread;

View file

@ -53,7 +53,7 @@ KiWaitTest(IN PVOID ObjectPointer,
VOID VOID
FASTCALL FASTCALL
KiUnlinkThread(IN PKTHREAD Thread, KiUnlinkThread(IN PKTHREAD Thread,
IN NTSTATUS WaitStatus) IN LONG_PTR WaitStatus)
{ {
PKWAIT_BLOCK WaitBlock; PKWAIT_BLOCK WaitBlock;
PKTIMER Timer; PKTIMER Timer;
@ -351,7 +351,7 @@ KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode,
ASSERT(Thread->WaitIrql <= DISPATCH_LEVEL); ASSERT(Thread->WaitIrql <= DISPATCH_LEVEL);
KiSetThreadSwapBusy(Thread); KiSetThreadSwapBusy(Thread);
KxInsertTimer(Timer, Hand); KxInsertTimer(Timer, Hand);
WaitStatus = KiSwapThread(Thread, KeGetCurrentPrcb()); WaitStatus = (NTSTATUS)KiSwapThread(Thread, KeGetCurrentPrcb());
/* Check if were swapped ok */ /* Check if were swapped ok */
if (WaitStatus != STATUS_KERNEL_APC) if (WaitStatus != STATUS_KERNEL_APC)
@ -454,7 +454,7 @@ KeWaitForSingleObject(IN PVOID Object,
{ {
/* It has a normal signal state. Unwait and return */ /* It has a normal signal state. Unwait and return */
KiSatisfyMutantWait(CurrentObject, Thread); KiSatisfyMutantWait(CurrentObject, Thread);
WaitStatus = Thread->WaitStatus; WaitStatus = (NTSTATUS)Thread->WaitStatus;
goto DontWait; goto DontWait;
} }
else else
@ -524,7 +524,7 @@ KeWaitForSingleObject(IN PVOID Object,
} }
/* Do the actual swap */ /* Do the actual swap */
WaitStatus = KiSwapThread(Thread, KeGetCurrentPrcb()); WaitStatus = (NTSTATUS)KiSwapThread(Thread, KeGetCurrentPrcb());
/* Check if we were executing an APC */ /* Check if we were executing an APC */
if (WaitStatus != STATUS_KERNEL_APC) return WaitStatus; if (WaitStatus != STATUS_KERNEL_APC) return WaitStatus;
@ -661,7 +661,7 @@ KeWaitForMultipleObjects(IN ULONG Count,
{ {
/* Normal signal state, unwait it and return */ /* Normal signal state, unwait it and return */
KiSatisfyMutantWait(CurrentObject, Thread); KiSatisfyMutantWait(CurrentObject, Thread);
WaitStatus = Thread->WaitStatus | Index; WaitStatus = (NTSTATUS)Thread->WaitStatus | Index;
goto DontWait; goto DontWait;
} }
else else
@ -737,7 +737,7 @@ KeWaitForMultipleObjects(IN ULONG Count,
} while(WaitBlock != WaitBlockArray); } while(WaitBlock != WaitBlockArray);
/* Set the wait status and get out */ /* Set the wait status and get out */
WaitStatus = Thread->WaitStatus; WaitStatus = (NTSTATUS)Thread->WaitStatus;
goto DontWait; goto DontWait;
} }
} }
@ -807,7 +807,7 @@ KeWaitForMultipleObjects(IN ULONG Count,
} }
/* Swap the thread */ /* Swap the thread */
WaitStatus = KiSwapThread(Thread, KeGetCurrentPrcb()); WaitStatus = (NTSTATUS)KiSwapThread(Thread, KeGetCurrentPrcb());
/* Check if we were executing an APC */ /* Check if we were executing an APC */
if (WaitStatus != STATUS_KERNEL_APC) return WaitStatus; if (WaitStatus != STATUS_KERNEL_APC) return WaitStatus;

View file

@ -182,7 +182,7 @@ LpcRequestWaitReplyPort(IN PVOID PortObject,
PETHREAD Thread = PsGetCurrentThread(); PETHREAD Thread = PsGetCurrentThread();
BOOLEAN Callback = FALSE; BOOLEAN Callback = FALSE;
PKSEMAPHORE Semaphore; PKSEMAPHORE Semaphore;
ULONG MessageType; USHORT MessageType;
PAGED_CODE(); PAGED_CODE();
Port = (PLPCP_PORT_OBJECT)PortObject; Port = (PLPCP_PORT_OBJECT)PortObject;

View file

@ -49,7 +49,8 @@ MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress,
IN MEMORY_CACHING_TYPE CacheType) IN MEMORY_CACHING_TYPE CacheType)
{ {
PFN_NUMBER Pfn, PageCount; PFN_NUMBER Pfn;
PFN_COUNT PageCount;
PMMPTE PointerPte; PMMPTE PointerPte;
PVOID BaseAddress; PVOID BaseAddress;
MMPTE TempPte; MMPTE TempPte;
@ -191,7 +192,8 @@ NTAPI
MmUnmapIoSpace(IN PVOID BaseAddress, MmUnmapIoSpace(IN PVOID BaseAddress,
IN SIZE_T NumberOfBytes) IN SIZE_T NumberOfBytes)
{ {
PFN_NUMBER PageCount, Pfn; PFN_NUMBER Pfn;
PFN_COUNT PageCount;
PMMPTE PointerPte; PMMPTE PointerPte;
// //

View file

@ -318,7 +318,7 @@ MmMapLockedPagesSpecifyCache(IN PMDL Mdl,
{ {
PVOID Base; PVOID Base;
PPFN_NUMBER MdlPages, LastPage; PPFN_NUMBER MdlPages, LastPage;
PFN_NUMBER PageCount; PFN_COUNT PageCount;
BOOLEAN IsIoMapping; BOOLEAN IsIoMapping;
MI_PFN_CACHE_ATTRIBUTE CacheAttribute; MI_PFN_CACHE_ATTRIBUTE CacheAttribute;
PMMPTE PointerPte; PMMPTE PointerPte;
@ -491,7 +491,7 @@ MmUnmapLockedPages(IN PVOID BaseAddress,
IN PMDL Mdl) IN PMDL Mdl)
{ {
PVOID Base; PVOID Base;
PFN_NUMBER PageCount; PFN_COUNT PageCount, ExtraPageCount;
PPFN_NUMBER MdlPages; PPFN_NUMBER MdlPages;
PMMPTE PointerPte; PMMPTE PointerPte;
@ -538,14 +538,16 @@ MmUnmapLockedPages(IN PVOID BaseAddress,
// //
// Get the MDL page array // Get the MDL page array
// //
MdlPages = (PPFN_NUMBER)(Mdl + 1); MdlPages = MmGetMdlPfnArray(Mdl);
MdlPages += PageCount;
/* Number of extra pages stored after the PFN array */
ExtraPageCount = (PFN_COUNT)*(MdlPages + PageCount);
// //
// Do the math // Do the math
// //
PageCount += *MdlPages; PageCount += ExtraPageCount;
PointerPte -= *MdlPages; PointerPte -= ExtraPageCount;
ASSERT(PointerPte >= MmSystemPtesStart[SystemPteSpace]); ASSERT(PointerPte >= MmSystemPtesStart[SystemPteSpace]);
ASSERT(PointerPte <= MmSystemPtesEnd[SystemPteSpace]); ASSERT(PointerPte <= MmSystemPtesEnd[SystemPteSpace]);
@ -553,7 +555,7 @@ MmUnmapLockedPages(IN PVOID BaseAddress,
// Get the new base address // Get the new base address
// //
BaseAddress = (PVOID)((ULONG_PTR)BaseAddress - BaseAddress = (PVOID)((ULONG_PTR)BaseAddress -
(*MdlPages << PAGE_SHIFT)); (ExtraPageCount << PAGE_SHIFT));
} }
// //
@ -1251,7 +1253,7 @@ MmUnlockPages(IN PMDL Mdl)
// //
ASSERT(Process->NumberOfLockedPages > 0); ASSERT(Process->NumberOfLockedPages > 0);
InterlockedExchangeAddSizeT(&Process->NumberOfLockedPages, InterlockedExchangeAddSizeT(&Process->NumberOfLockedPages,
-PageCount); -(LONG_PTR)PageCount);
} }
// //
@ -1272,7 +1274,7 @@ MmUnlockPages(IN PMDL Mdl)
// //
ASSERT(Process->NumberOfLockedPages > 0); ASSERT(Process->NumberOfLockedPages > 0);
InterlockedExchangeAddSizeT(&Process->NumberOfLockedPages, InterlockedExchangeAddSizeT(&Process->NumberOfLockedPages,
-PageCount); -(LONG_PTR)PageCount);
} }
// //

View file

@ -230,7 +230,7 @@ extern const ULONG MmProtectToValue[32];
#define COLORED_LIST_HEAD ((1 << 25) - 1) // 0x1FFFFFF #define COLORED_LIST_HEAD ((1 << 25) - 1) // 0x1FFFFFF
#elif defined(_M_AMD64) #elif defined(_M_AMD64)
#define LIST_HEAD 0xFFFFFFFFFFFFFFFFLL #define LIST_HEAD 0xFFFFFFFFFFFFFFFFLL
#define COLORED_LIST_HEAD ((1 << 57) - 1) // 0x1FFFFFFFFFFFFFFLL #define COLORED_LIST_HEAD ((1ULL << 57) - 1) // 0x1FFFFFFFFFFFFFFLL
#else #else
#error Define these please! #error Define these please!
#endif #endif
@ -302,10 +302,10 @@ typedef struct _POOL_HEADER
struct struct
{ {
#ifdef _M_AMD64 #ifdef _M_AMD64
ULONG PreviousSize:8; USHORT PreviousSize:8;
ULONG PoolIndex:8; USHORT PoolIndex:8;
ULONG BlockSize:8; USHORT BlockSize:8;
ULONG PoolType:8; USHORT PoolType:8;
#else #else
USHORT PreviousSize:9; USHORT PreviousSize:9;
USHORT PoolIndex:7; USHORT PoolIndex:7;
@ -368,14 +368,14 @@ typedef enum _MI_PFN_CACHE_ATTRIBUTE
typedef struct _PHYSICAL_MEMORY_RUN typedef struct _PHYSICAL_MEMORY_RUN
{ {
ULONG BasePage; PFN_NUMBER BasePage;
ULONG PageCount; PFN_NUMBER PageCount;
} PHYSICAL_MEMORY_RUN, *PPHYSICAL_MEMORY_RUN; } PHYSICAL_MEMORY_RUN, *PPHYSICAL_MEMORY_RUN;
typedef struct _PHYSICAL_MEMORY_DESCRIPTOR typedef struct _PHYSICAL_MEMORY_DESCRIPTOR
{ {
ULONG NumberOfRuns; ULONG NumberOfRuns;
ULONG NumberOfPages; PFN_NUMBER NumberOfPages;
PHYSICAL_MEMORY_RUN Run[1]; PHYSICAL_MEMORY_RUN Run[1];
} PHYSICAL_MEMORY_DESCRIPTOR, *PPHYSICAL_MEMORY_DESCRIPTOR; } PHYSICAL_MEMORY_DESCRIPTOR, *PPHYSICAL_MEMORY_DESCRIPTOR;
@ -489,7 +489,7 @@ extern SIZE_T MmDefaultMaximumNonPagedPool;
extern ULONG MmMaxAdditionNonPagedPoolPerMb; extern ULONG MmMaxAdditionNonPagedPoolPerMb;
extern ULONG MmSecondaryColors; extern ULONG MmSecondaryColors;
extern ULONG MmSecondaryColorMask; extern ULONG MmSecondaryColorMask;
extern ULONG_PTR MmNumberOfSystemPtes; extern ULONG MmNumberOfSystemPtes;
extern ULONG MmMaximumNonPagedPoolPercent; extern ULONG MmMaximumNonPagedPoolPercent;
extern ULONG MmLargeStackSize; extern ULONG MmLargeStackSize;
extern PMMCOLOR_TABLES MmFreePagesByColor[FreePageList + 1]; extern PMMCOLOR_TABLES MmFreePagesByColor[FreePageList + 1];
@ -509,7 +509,7 @@ extern PFN_NUMBER MiLowNonPagedPoolThreshold;
extern PFN_NUMBER MiHighNonPagedPoolThreshold; extern PFN_NUMBER MiHighNonPagedPoolThreshold;
extern PFN_NUMBER MmMinimumFreePages; extern PFN_NUMBER MmMinimumFreePages;
extern PFN_NUMBER MmPlentyFreePages; extern PFN_NUMBER MmPlentyFreePages;
extern PFN_NUMBER MiExpansionPoolPagesInitialCharge; extern PFN_COUNT MiExpansionPoolPagesInitialCharge;
extern PFN_NUMBER MmResidentAvailablePages; extern PFN_NUMBER MmResidentAvailablePages;
extern PFN_NUMBER MmResidentAvailableAtInit; extern PFN_NUMBER MmResidentAvailableAtInit;
extern ULONG MmTotalFreeSystemPtes[MaximumPtePoolTypes]; extern ULONG MmTotalFreeSystemPtes[MaximumPtePoolTypes];
@ -565,7 +565,7 @@ FORCEINLINE
VOID VOID
MI_MAKE_HARDWARE_PTE_KERNEL(IN PMMPTE NewPte, MI_MAKE_HARDWARE_PTE_KERNEL(IN PMMPTE NewPte,
IN PMMPTE MappingPte, IN PMMPTE MappingPte,
IN ULONG ProtectionMask, IN ULONG_PTR ProtectionMask,
IN PFN_NUMBER PageFrameNumber) IN PFN_NUMBER PageFrameNumber)
{ {
/* Only valid for kernel, non-session PTEs */ /* Only valid for kernel, non-session PTEs */
@ -588,7 +588,7 @@ FORCEINLINE
VOID VOID
MI_MAKE_HARDWARE_PTE(IN PMMPTE NewPte, MI_MAKE_HARDWARE_PTE(IN PMMPTE NewPte,
IN PMMPTE MappingPte, IN PMMPTE MappingPte,
IN ULONG ProtectionMask, IN ULONG_PTR ProtectionMask,
IN PFN_NUMBER PageFrameNumber) IN PFN_NUMBER PageFrameNumber)
{ {
/* Set the protection and page */ /* Set the protection and page */
@ -604,7 +604,7 @@ FORCEINLINE
VOID VOID
MI_MAKE_HARDWARE_PTE_USER(IN PMMPTE NewPte, MI_MAKE_HARDWARE_PTE_USER(IN PMMPTE NewPte,
IN PMMPTE MappingPte, IN PMMPTE MappingPte,
IN ULONG ProtectionMask, IN ULONG_PTR ProtectionMask,
IN PFN_NUMBER PageFrameNumber) IN PFN_NUMBER PageFrameNumber)
{ {
/* Only valid for kernel, non-session PTEs */ /* Only valid for kernel, non-session PTEs */
@ -1160,7 +1160,7 @@ MiInsertPageInFreeList(
IN PFN_NUMBER PageFrameIndex IN PFN_NUMBER PageFrameIndex
); );
PFN_NUMBER PFN_COUNT
NTAPI NTAPI
MiDeleteSystemPageableVm( MiDeleteSystemPageableVm(
IN PMMPTE PointerPte, IN PMMPTE PointerPte,

View 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 // On systems with more than 32MB, this number is then doubled, and further
// aligned up to a PDE boundary (4MB). // aligned up to a PDE boundary (4MB).
// //
ULONG_PTR MmNumberOfSystemPtes; PFN_COUNT MmNumberOfSystemPtes;
// //
// This is how many pages the PFN database will take up // 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 // 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 // The total number of pages mapped by the boot loader, which include the kernel
@ -230,7 +231,10 @@ PVOID MmSystemRangeStart;
PMMPTE MiHighestUserPte; PMMPTE MiHighestUserPte;
PMMPDE MiHighestUserPde; PMMPDE MiHighestUserPde;
#if (_MI_PAGING_LEVELS >= 3) #if (_MI_PAGING_LEVELS >= 3)
/* We need the highest PPE and PXE addresses */ PMMPTE MiHighestUserPpe;
#if (_MI_PAGING_LEVELS >= 4)
PMMPTE MiHighestUserPxe;
#endif
#endif #endif
/* These variables define the system cache address space */ /* These variables define the system cache address space */
@ -555,7 +559,7 @@ NTAPI
INIT_FUNCTION INIT_FUNCTION
MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock) MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{ {
ULONG FreePage, FreePageCount, PagesLeft, BasePage, PageCount; PFN_NUMBER FreePage, FreePageCount, PagesLeft, BasePage, PageCount;
PLIST_ENTRY NextEntry; PLIST_ENTRY NextEntry;
PMEMORY_ALLOCATION_DESCRIPTOR MdBlock; PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
PMMPTE PointerPte, LastPte; PMMPTE PointerPte, LastPte;
@ -1557,12 +1561,14 @@ MiBuildPagedPool(VOID)
{ {
PMMPTE PointerPte; PMMPTE PointerPte;
PMMPDE PointerPde; PMMPDE PointerPde;
MMPTE TempPte = ValidKernelPte;
MMPDE TempPde = ValidKernelPde; MMPDE TempPde = ValidKernelPde;
PFN_NUMBER PageFrameIndex; PFN_NUMBER PageFrameIndex;
KIRQL OldIrql; KIRQL OldIrql;
ULONG Size, BitMapSize; SIZE_T Size;
ULONG BitMapSize;
#if (_MI_PAGING_LEVELS == 2) #if (_MI_PAGING_LEVELS == 2)
MMPTE TempPte = ValidKernelPte;
// //
// Get the page frame number for the system page directory // Get the page frame number for the system page directory
// //
@ -1704,7 +1710,7 @@ MiBuildPagedPool(VOID)
// //
Size = Size * 1024; Size = Size * 1024;
ASSERT(Size == MmSizeOfPagedPoolInPages); ASSERT(Size == MmSizeOfPagedPoolInPages);
BitMapSize = Size; BitMapSize = (ULONG)Size;
Size = sizeof(RTL_BITMAP) + (((Size + 31) / 32) * sizeof(ULONG)); Size = sizeof(RTL_BITMAP) + (((Size + 31) / 32) * sizeof(ULONG));
// //
@ -1770,7 +1776,7 @@ MiDbgDumpMemoryDescriptors(VOID)
{ {
PLIST_ENTRY NextEntry; PLIST_ENTRY NextEntry;
PMEMORY_ALLOCATION_DESCRIPTOR Md; PMEMORY_ALLOCATION_DESCRIPTOR Md;
ULONG TotalPages = 0; PFN_NUMBER TotalPages = 0;
PCHAR PCHAR
MemType[] = MemType[] =
{ {
@ -1812,7 +1818,7 @@ MiDbgDumpMemoryDescriptors(VOID)
TotalPages += Md->PageCount; 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 BOOLEAN
@ -1864,8 +1870,10 @@ MmArmInitSystem(IN ULONG Phase,
MiHighestUserPte = MiAddressToPte(MmHighestUserAddress); MiHighestUserPte = MiAddressToPte(MmHighestUserAddress);
MiHighestUserPde = MiAddressToPde(MmHighestUserAddress); MiHighestUserPde = MiAddressToPde(MmHighestUserAddress);
#if (_MI_PAGING_LEVELS >= 3) #if (_MI_PAGING_LEVELS >= 3)
/* We need the highest PPE and PXE addresses */ MiHighestUserPpe = MiAddressToPpe(MmHighestUserAddress);
ASSERT(FALSE); #if (_MI_PAGING_LEVELS >= 4)
MiHighestUserPxe = MiAddressToPxe(MmHighestUserAddress);
#endif
#endif #endif
// //
// Get the size of the boot loader's image allocations and then round // Get the size of the boot loader's image allocations and then round
@ -2063,7 +2071,7 @@ MmArmInitSystem(IN ULONG Phase,
// //
RtlInitializeBitMap(&MiPfnBitMap, RtlInitializeBitMap(&MiPfnBitMap,
Bitmap, Bitmap,
MmHighestPhysicalPage + 1); (ULONG)MmHighestPhysicalPage + 1);
RtlClearAllBits(&MiPfnBitMap); RtlClearAllBits(&MiPfnBitMap);
// //
@ -2087,7 +2095,7 @@ MmArmInitSystem(IN ULONG Phase,
// //
// Set the bits in the PFN bitmap // Set the bits in the PFN bitmap
// //
RtlSetBits(&MiPfnBitMap, Run->BasePage, Run->PageCount); RtlSetBits(&MiPfnBitMap, (ULONG)Run->BasePage, (ULONG)Run->PageCount);
} }
} }

View file

@ -136,7 +136,7 @@ NTAPI
MmIsThisAnNtAsSystem(VOID) MmIsThisAnNtAsSystem(VOID)
{ {
/* Return if this is a server system */ /* Return if this is a server system */
return MmProductType; return MmProductType & 0xFF;
} }
/* /*

View file

@ -24,7 +24,8 @@ PVOID
NTAPI NTAPI
MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes) MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes)
{ {
PFN_NUMBER PageCount, MdlPageCount, PageFrameIndex; PFN_COUNT PageCount, MdlPageCount;
PFN_NUMBER PageFrameIndex;
PHYSICAL_ADDRESS LowAddress, HighAddress, SkipBytes; PHYSICAL_ADDRESS LowAddress, HighAddress, SkipBytes;
MI_PFN_CACHE_ATTRIBUTE CacheAttribute; MI_PFN_CACHE_ATTRIBUTE CacheAttribute;
PMDL Mdl; PMDL Mdl;
@ -37,7 +38,7 @@ MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes)
// Get the page count // Get the page count
// //
ASSERT(NumberOfBytes != 0); 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 // Use the MDL allocator for simplicity, so setup the parameters
@ -173,7 +174,7 @@ MmFreeNonCachedMemory(IN PVOID BaseAddress,
{ {
PMDL Mdl; PMDL Mdl;
PMMPTE PointerPte; PMMPTE PointerPte;
PFN_NUMBER PageCount; PFN_COUNT PageCount;
// //
// Sanity checks // Sanity checks
@ -184,7 +185,7 @@ MmFreeNonCachedMemory(IN PVOID BaseAddress,
// //
// Get the page count // Get the page count
// //
PageCount = BYTES_TO_PAGES(NumberOfBytes); PageCount = (PFN_COUNT)BYTES_TO_PAGES(NumberOfBytes);
// //
// Get the first PTE // Get the first PTE

View file

@ -80,7 +80,7 @@ MiCheckVirtualAddress(IN PVOID VirtualAddress,
{ {
/* This must be a TEB/PEB VAD */ /* This must be a TEB/PEB VAD */
ASSERT(Vad->u.VadFlags.MemCommit == TRUE); ASSERT(Vad->u.VadFlags.MemCommit == TRUE);
*ProtectCode = Vad->u.VadFlags.Protection; *ProtectCode = (ULONG)Vad->u.VadFlags.Protection;
return NULL; return NULL;
} }
else else
@ -95,7 +95,7 @@ MiCheckVirtualAddress(IN PVOID VirtualAddress,
ASSERT(PointerPte != NULL); ASSERT(PointerPte != NULL);
/* Return the Prototype PTE and the protection for the page mapping */ /* Return the Prototype PTE and the protection for the page mapping */
*ProtectCode = Vad->u.VadFlags.Protection; *ProtectCode = (ULONG)Vad->u.VadFlags.Protection;
return PointerPte; return PointerPte;
} }
} }
@ -347,7 +347,7 @@ MiCompleteProtoPteFault(IN BOOLEAN StoreInstruction,
{ {
MMPTE TempPte; MMPTE TempPte;
PMMPTE OriginalPte; PMMPTE OriginalPte;
ULONG Protection; ULONG_PTR Protection;
PFN_NUMBER PageFrameIndex; PFN_NUMBER PageFrameIndex;
/* Must be called with an valid prototype PTE, with the PFN lock held */ /* 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 */ /* 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); ASSERT(TempPte.u.Soft.Prototype == 0);
/* Check for non-demand zero PTE */ /* Check for non-demand zero PTE */

View file

@ -226,7 +226,7 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex,
PMMPFNLIST ListHead; PMMPFNLIST ListHead;
MMLISTS ListName; MMLISTS ListName;
PFN_NUMBER OldFlink, OldBlink; PFN_NUMBER OldFlink, OldBlink;
ULONG OldColor, OldCache; USHORT OldColor, OldCache;
PMMCOLOR_TABLES ColorTable; PMMCOLOR_TABLES ColorTable;
/* Make sure PFN lock is held */ /* Make sure PFN lock is held */

View file

@ -18,7 +18,7 @@
/* GLOBALS ********************************************************************/ /* GLOBALS ********************************************************************/
LIST_ENTRY MmNonPagedPoolFreeListHead[MI_MAX_FREE_PAGE_LISTS]; LIST_ENTRY MmNonPagedPoolFreeListHead[MI_MAX_FREE_PAGE_LISTS];
PFN_NUMBER MmNumberOfFreeNonPagedPool, MiExpansionPoolPagesInitialCharge; PFN_COUNT MmNumberOfFreeNonPagedPool, MiExpansionPoolPagesInitialCharge;
PVOID MmNonPagedPoolEnd0; PVOID MmNonPagedPoolEnd0;
PFN_NUMBER MiStartOfInitialPoolFrame, MiEndOfInitialPoolFrame; PFN_NUMBER MiStartOfInitialPoolFrame, MiEndOfInitialPoolFrame;
KGUARDED_MUTEX MmPagedPoolMutex; KGUARDED_MUTEX MmPagedPoolMutex;
@ -272,7 +272,7 @@ INIT_FUNCTION
MiInitializeNonPagedPool(VOID) MiInitializeNonPagedPool(VOID)
{ {
ULONG i; ULONG i;
PFN_NUMBER PoolPages; PFN_COUNT PoolPages;
PMMFREE_POOL_ENTRY FreeEntry, FirstEntry; PMMFREE_POOL_ENTRY FreeEntry, FirstEntry;
PMMPTE PointerPte; PMMPTE PointerPte;
PAGED_CODE(); PAGED_CODE();
@ -291,7 +291,7 @@ MiInitializeNonPagedPool(VOID)
// //
// Calculate how many pages the initial nonpaged pool has // Calculate how many pages the initial nonpaged pool has
// //
PoolPages = BYTES_TO_PAGES(MmSizeOfNonPagedPoolInBytes); PoolPages = (PFN_COUNT)BYTES_TO_PAGES(MmSizeOfNonPagedPoolInBytes);
MmNumberOfFreeNonPagedPool = PoolPages; MmNumberOfFreeNonPagedPool = PoolPages;
// //
@ -351,7 +351,7 @@ MiInitializeNonPagedPool(VOID)
// //
// Calculate the size of the expansion region alone // Calculate the size of the expansion region alone
// //
MiExpansionPoolPagesInitialCharge = MiExpansionPoolPagesInitialCharge = (PFN_COUNT)
BYTES_TO_PAGES(MmMaximumNonPagedPoolInBytes - MmSizeOfNonPagedPoolInBytes); BYTES_TO_PAGES(MmMaximumNonPagedPoolInBytes - MmSizeOfNonPagedPoolInBytes);
// //
@ -374,7 +374,8 @@ NTAPI
MiAllocatePoolPages(IN POOL_TYPE PoolType, MiAllocatePoolPages(IN POOL_TYPE PoolType,
IN SIZE_T SizeInBytes) IN SIZE_T SizeInBytes)
{ {
PFN_NUMBER SizeInPages, PageFrameNumber, PageTableCount; PFN_NUMBER PageFrameNumber;
PFN_COUNT SizeInPages, PageTableCount;
ULONG i; ULONG i;
KIRQL OldIrql; KIRQL OldIrql;
PLIST_ENTRY NextEntry, NextHead, LastHead; PLIST_ENTRY NextEntry, NextHead, LastHead;
@ -391,7 +392,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
// //
// Figure out how big the allocation is in pages // Figure out how big the allocation is in pages
// //
SizeInPages = BYTES_TO_PAGES(SizeInBytes); SizeInPages = (PFN_COUNT)BYTES_TO_PAGES(SizeInBytes);
// //
// Handle paged pool // Handle paged pool
@ -440,9 +441,9 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
// //
// We can only support this much then // We can only support this much then
// //
PageTableCount = (PMMPDE)MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool) - PointerPde = MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool);
MmPagedPoolInfo.NextPdeForPagedPoolExpansion + PageTableCount = (PFN_COUNT)(PointerPde + 1 -
1; MmPagedPoolInfo.NextPdeForPagedPoolExpansion);
ASSERT(PageTableCount < i); ASSERT(PageTableCount < i);
i = PageTableCount; i = PageTableCount;
} }
@ -515,7 +516,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
// //
// These pages are now available, clear their availablity bits // These pages are now available, clear their availablity bits
// //
EndAllocation = (MmPagedPoolInfo.NextPdeForPagedPoolExpansion - EndAllocation = (ULONG)(MmPagedPoolInfo.NextPdeForPagedPoolExpansion -
(PMMPDE)MiAddressToPte(MmPagedPoolInfo.FirstPteForPagedPool)) * (PMMPDE)MiAddressToPte(MmPagedPoolInfo.FirstPteForPagedPool)) *
PTE_COUNT; PTE_COUNT;
RtlClearBits(MmPagedPoolInfo.PagedPoolAllocationMap, RtlClearBits(MmPagedPoolInfo.PagedPoolAllocationMap,
@ -823,10 +824,11 @@ MiFreePoolPages(IN PVOID StartingVa)
{ {
PMMPTE PointerPte, StartPte; PMMPTE PointerPte, StartPte;
PMMPFN Pfn1, StartPfn; PMMPFN Pfn1, StartPfn;
PFN_NUMBER FreePages, NumberOfPages; PFN_COUNT FreePages, NumberOfPages;
KIRQL OldIrql; KIRQL OldIrql;
PMMFREE_POOL_ENTRY FreeEntry, NextEntry, LastEntry; PMMFREE_POOL_ENTRY FreeEntry, NextEntry, LastEntry;
ULONG i, End; ULONG i, End;
ULONG_PTR Offset;
// //
// Handle paged pool // Handle paged pool
@ -837,7 +839,8 @@ MiFreePoolPages(IN PVOID StartingVa)
// Calculate the offset from the beginning of paged pool, and convert it // Calculate the offset from the beginning of paged pool, and convert it
// into pages // 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; End = i;
// //
@ -904,7 +907,7 @@ MiFreePoolPages(IN PVOID StartingVa)
// //
// Now we know how many pages we have // Now we know how many pages we have
// //
NumberOfPages = PointerPte - StartPte + 1; NumberOfPages = (PFN_COUNT)(PointerPte - StartPte + 1);
// //
// Acquire the nonpaged pool lock // Acquire the nonpaged pool lock

View file

@ -220,7 +220,8 @@ MmDeleteKernelStack(IN PVOID StackBase,
IN BOOLEAN GuiStack) IN BOOLEAN GuiStack)
{ {
PMMPTE PointerPte; PMMPTE PointerPte;
PFN_NUMBER StackPages, PageFrameNumber;//, PageTableFrameNumber; PFN_NUMBER PageFrameNumber;//, PageTableFrameNumber;
PFN_COUNT StackPages;
PMMPFN Pfn1;//, Pfn2; PMMPFN Pfn1;//, Pfn2;
ULONG i; ULONG i;
KIRQL OldIrql; KIRQL OldIrql;
@ -293,7 +294,7 @@ NTAPI
MmCreateKernelStack(IN BOOLEAN GuiStack, MmCreateKernelStack(IN BOOLEAN GuiStack,
IN UCHAR Node) IN UCHAR Node)
{ {
PFN_NUMBER StackPtes, StackPages; PFN_COUNT StackPtes, StackPages;
PMMPTE PointerPte, StackPte; PMMPTE PointerPte, StackPte;
PVOID BaseAddress; PVOID BaseAddress;
MMPTE TempPte, InvalidPte; MMPTE TempPte, InvalidPte;
@ -1113,7 +1114,7 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
PMMPFN Pfn1; PMMPFN Pfn1;
/* Choose a process color */ /* Choose a process color */
Process->NextPageColor = RtlRandom(&MmProcessColorSeed); Process->NextPageColor = (USHORT)RtlRandom(&MmProcessColorSeed);
/* Setup the hyperspace lock */ /* Setup the hyperspace lock */
KeInitializeSpinLock(&Process->HyperSpaceLock); KeInitializeSpinLock(&Process->HyperSpaceLock);

View file

@ -181,7 +181,7 @@ MiInitializeSystemSpaceMap(IN PVOID InputSession OPTIONAL)
ASSERT(Session->SystemSpaceBitMap); ASSERT(Session->SystemSpaceBitMap);
RtlInitializeBitMap(Session->SystemSpaceBitMap, RtlInitializeBitMap(Session->SystemSpaceBitMap,
(PULONG)(Session->SystemSpaceBitMap + 1), (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 */ /* Set system space fully empty to begin with */
RtlClearAllBits(Session->SystemSpaceBitMap); RtlClearAllBits(Session->SystemSpaceBitMap);
@ -401,7 +401,7 @@ MiLocateSubsection(IN PMMVAD Vad,
{ {
PSUBSECTION Subsection; PSUBSECTION Subsection;
PCONTROL_AREA ControlArea; PCONTROL_AREA ControlArea;
ULONG PteOffset; ULONG_PTR PteOffset;
/* Get the control area */ /* Get the control area */
ControlArea = Vad->ControlArea; ControlArea = Vad->ControlArea;
@ -418,7 +418,7 @@ MiLocateSubsection(IN PMMVAD Vad,
ASSERT(Vad->FirstPrototypePte < &Subsection->SubsectionBase[Subsection->PtesInSubsection]); ASSERT(Vad->FirstPrototypePte < &Subsection->SubsectionBase[Subsection->PtesInSubsection]);
/* Compute the PTE offset */ /* Compute the PTE offset */
PteOffset = (ULONG_PTR)Vpn - Vad->StartingVpn; PteOffset = Vpn - Vad->StartingVpn;
PteOffset += Vad->FirstPrototypePte - Subsection->SubsectionBase; PteOffset += Vad->FirstPrototypePte - Subsection->SubsectionBase;
/* Again, we only support single-subsection segments */ /* 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 */ /* 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++; if (*ViewSize & (MI_SYSTEM_VIEW_BUCKET_SIZE - 1)) Buckets++;
/* Check if the view is more than 4GB large */ /* Check if the view is more than 4GB large */
@ -660,7 +660,7 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
IN PSECTION Section, IN PSECTION Section,
IN SECTION_INHERIT InheritDisposition, IN SECTION_INHERIT InheritDisposition,
IN ULONG ProtectionMask, IN ULONG ProtectionMask,
IN ULONG CommitSize, IN SIZE_T CommitSize,
IN ULONG_PTR ZeroBits, IN ULONG_PTR ZeroBits,
IN ULONG AllocationType) 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 */ /* The caller did not, so pick a 64K aligned view size based on the offset */
SectionOffset->LowPart &= ~(_64K - 1); SectionOffset->LowPart &= ~(_64K - 1);
*ViewSize = Section->SizeOfSection.QuadPart - SectionOffset->QuadPart; *ViewSize = (SIZE_T)(Section->SizeOfSection.QuadPart - SectionOffset->QuadPart);
} }
else else
{ {
@ -719,7 +719,7 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
if (*ViewSize >= 0x80000000) return STATUS_INVALID_VIEW_SIZE; if (*ViewSize >= 0x80000000) return STATUS_INVALID_VIEW_SIZE;
/* Within this section, figure out which PTEs will describe the view */ /* 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 */ /* The offset must be in this segment's PTE chunk and it must be valid */
ASSERT(PteOffset < Segment->TotalNumberOfPtes); ASSERT(PteOffset < Segment->TotalNumberOfPtes);
@ -778,7 +778,7 @@ MiMapViewOfDataSection(IN PCONTROL_AREA ControlArea,
Vad->EndingVpn = EndingAddress >> PAGE_SHIFT; Vad->EndingVpn = EndingAddress >> PAGE_SHIFT;
Vad->ControlArea = ControlArea; Vad->ControlArea = ControlArea;
Vad->u.VadFlags.Protection = ProtectionMask; 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); Vad->u2.VadFlags2.Inherit = (InheritDisposition == ViewShare);
if ((AllocationType & SEC_NO_CHANGE) || (Section->u.Flags.NoChange)) if ((AllocationType & SEC_NO_CHANGE) || (Section->u.Flags.NoChange))
{ {
@ -825,7 +825,7 @@ MiCreatePagingFileMap(OUT PSEGMENT *Segment,
IN ULONG AllocationAttributes) IN ULONG AllocationAttributes)
{ {
SIZE_T SizeLimit; SIZE_T SizeLimit;
PFN_NUMBER PteCount; PFN_COUNT PteCount;
PMMPTE PointerPte; PMMPTE PointerPte;
MMPTE TempPte; MMPTE TempPte;
PCONTROL_AREA ControlArea; PCONTROL_AREA ControlArea;
@ -848,7 +848,7 @@ MiCreatePagingFileMap(OUT PSEGMENT *Segment,
if (*MaximumSize > SizeLimit) return STATUS_SECTION_TOO_BIG; if (*MaximumSize > SizeLimit) return STATUS_SECTION_TOO_BIG;
/* Calculate how many Prototype PTEs will be needed */ /* 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 */ /* For commited memory, we must have a valid protection mask */
if (AllocationAttributes & SEC_COMMIT) ASSERT(ProtectionMask != 0); if (AllocationAttributes & SEC_COMMIT) ASSERT(ProtectionMask != 0);
@ -914,7 +914,11 @@ MiCreatePagingFileMap(OUT PSEGMENT *Segment,
NewSegment->SegmentPteTemplate.u.Soft.Protection = ProtectionMask; NewSegment->SegmentPteTemplate.u.Soft.Protection = ProtectionMask;
/* Write out the prototype PTEs, for now they're simply demand zero */ /* 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); RtlFillMemoryUlong(PointerPte, PteCount * sizeof(MMPTE), TempPte.u.Long);
#endif
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -1246,14 +1250,16 @@ MmMapViewOfArm3Section(IN PVOID SectionObject,
#endif #endif
/* Check if the offset and size would cause an overflow */ /* 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"); DPRINT1("Section offset overflows\n");
return STATUS_INVALID_VIEW_SIZE; return STATUS_INVALID_VIEW_SIZE;
} }
/* Check if the offset and size are bigger than the section itself */ /* 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"); DPRINT1("Section offset is larger than section\n");
return STATUS_INVALID_VIEW_SIZE; return STATUS_INVALID_VIEW_SIZE;
@ -1263,7 +1269,7 @@ MmMapViewOfArm3Section(IN PVOID SectionObject,
if (!(*ViewSize)) if (!(*ViewSize))
{ {
/* Compute it for the caller */ /* 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 */ /* Check if it's larger than 4GB or overflows into kernel-mode */
if ((*ViewSize > 0xFFFFFFFF) || if ((*ViewSize > 0xFFFFFFFF) ||
@ -1282,7 +1288,7 @@ MmMapViewOfArm3Section(IN PVOID SectionObject,
} }
/* Check if the view size is larger than the section */ /* 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"); DPRINT1("The view is larger than the section\n");
return STATUS_INVALID_VIEW_SIZE; return STATUS_INVALID_VIEW_SIZE;

View file

@ -95,7 +95,7 @@ MiLoadImageSection(IN OUT PVOID *SectionPtr,
KAPC_STATE ApcState; KAPC_STATE ApcState;
LARGE_INTEGER SectionOffset = {{0, 0}}; LARGE_INTEGER SectionOffset = {{0, 0}};
BOOLEAN LoadSymbols = FALSE; BOOLEAN LoadSymbols = FALSE;
PFN_NUMBER PteCount; PFN_COUNT PteCount;
PMMPTE PointerPte, LastPte; PMMPTE PointerPte, LastPte;
PVOID DriverBase; PVOID DriverBase;
MMPTE TempPte; MMPTE TempPte;
@ -324,7 +324,7 @@ MmCallDllInitialize(IN PLDR_DATA_TABLE_ENTRY LdrEntry,
if (wcschr(ImportName.Buffer, L'.')) if (wcschr(ImportName.Buffer, L'.'))
{ {
/* Remove the extension */ /* Remove the extension */
ImportName.Length = (wcschr(ImportName.Buffer, L'.') - ImportName.Length = (USHORT)(wcschr(ImportName.Buffer, L'.') -
ImportName.Buffer) * sizeof(WCHAR); ImportName.Buffer) * sizeof(WCHAR);
} }
@ -690,7 +690,7 @@ MiSnapThunk(IN PVOID DllBase,
ULONG ForwardExportSize; ULONG ForwardExportSize;
PIMAGE_EXPORT_DIRECTORY ForwardExportDirectory; PIMAGE_EXPORT_DIRECTORY ForwardExportDirectory;
PIMAGE_IMPORT_BY_NAME ForwardName; PIMAGE_IMPORT_BY_NAME ForwardName;
ULONG ForwardLength; SIZE_T ForwardLength;
IMAGE_THUNK_DATA ForwardThunk; IMAGE_THUNK_DATA ForwardThunk;
PAGED_CODE(); PAGED_CODE();
@ -797,9 +797,9 @@ MiSnapThunk(IN PVOID DllBase,
/* Build the forwarder name */ /* Build the forwarder name */
DllName.Buffer = (PCHAR)Address->u1.Function; DllName.Buffer = (PCHAR)Address->u1.Function;
DllName.Length = strchr(DllName.Buffer, '.') - DllName.Length = (USHORT)(strchr(DllName.Buffer, '.') -
DllName.Buffer + DllName.Buffer) +
sizeof(ANSI_NULL); sizeof(WCHAR);
DllName.MaximumLength = DllName.Length; DllName.MaximumLength = DllName.Length;
/* Convert it */ /* Convert it */
@ -1377,7 +1377,7 @@ MiReloadBootLoadedDrivers(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
PVOID DllBase, NewImageAddress; PVOID DllBase, NewImageAddress;
NTSTATUS Status; NTSTATUS Status;
PMMPTE PointerPte, StartPte, LastPte; PMMPTE PointerPte, StartPte, LastPte;
PFN_NUMBER PteCount; PFN_COUNT PteCount;
PMMPFN Pfn1; PMMPFN Pfn1;
MMPTE TempPte, OldPte; MMPTE TempPte, OldPte;
@ -1666,7 +1666,7 @@ MiBuildImportsForBootDrivers(VOID)
/* Scan the thunks */ /* Scan the thunks */
for (i = 0, DllBase = 0, DllEnd = 0; i < ImportSize; i++, ImageThunk++) for (i = 0, DllBase = 0, DllEnd = 0; i < ImportSize; i++, ImageThunk++)
#else #else
i = DllBase = DllEnd = 0; DllBase = DllEnd = i = 0;
while ((ImportDescriptor->Name) && while ((ImportDescriptor->Name) &&
(ImportDescriptor->OriginalFirstThunk)) (ImportDescriptor->OriginalFirstThunk))
{ {
@ -2277,7 +2277,8 @@ MiSetPagingOfDriver(IN PMMPTE PointerPte,
{ {
PVOID ImageBase; PVOID ImageBase;
PETHREAD CurrentThread = PsGetCurrentThread(); PETHREAD CurrentThread = PsGetCurrentThread();
PFN_NUMBER PageCount = 0, PageFrameIndex; PFN_COUNT PageCount = 0;
PFN_NUMBER PageFrameIndex;
PMMPFN Pfn1; PMMPFN Pfn1;
PAGED_CODE(); PAGED_CODE();

View file

@ -73,7 +73,7 @@ MI_GET_CLUSTER_SIZE(IN PMMPTE Pte)
// Then read the size from the trailing PTE // Then read the size from the trailing PTE
// //
Pte++; Pte++;
return Pte->u.List.NextEntry; return (ULONG)Pte->u.List.NextEntry;
} }
PMMPTE PMMPTE
@ -270,7 +270,7 @@ MiReleaseSystemPtes(IN PMMPTE StartingPte,
IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType) IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
{ {
KIRQL OldIrql; KIRQL OldIrql;
ULONG_PTR ClusterSize; ULONG ClusterSize;
PMMPTE PreviousPte, NextPte, InsertPte; PMMPTE PreviousPte, NextPte, InsertPte;
// //

View file

@ -370,7 +370,7 @@ MiFindEmptyAddressRangeDownTree(IN SIZE_T Length,
OUT PMMADDRESS_NODE *Parent) OUT PMMADDRESS_NODE *Parent)
{ {
PMMADDRESS_NODE Node, LowestNode, Child; PMMADDRESS_NODE Node, LowestNode, Child;
ULONG LowVpn, HighVpn; ULONG_PTR LowVpn, HighVpn;
PFN_NUMBER PageCount; PFN_NUMBER PageCount;
/* Sanity checks */ /* Sanity checks */

View file

@ -107,14 +107,14 @@ MiMakeSystemAddressValidPfn(IN PVOID VirtualAddress,
return LockChange; return LockChange;
} }
PFN_NUMBER PFN_COUNT
NTAPI NTAPI
MiDeleteSystemPageableVm(IN PMMPTE PointerPte, MiDeleteSystemPageableVm(IN PMMPTE PointerPte,
IN PFN_NUMBER PageCount, IN PFN_NUMBER PageCount,
IN ULONG Flags, IN ULONG Flags,
OUT PPFN_NUMBER ValidPages) OUT PPFN_NUMBER ValidPages)
{ {
PFN_NUMBER ActualPages = 0; PFN_COUNT ActualPages = 0;
PETHREAD CurrentThread = PsGetCurrentThread(); PETHREAD CurrentThread = PsGetCurrentThread();
PMMPFN Pfn1; PMMPFN Pfn1;
//PMMPFN Pfn2; //PMMPFN Pfn2;
@ -2350,7 +2350,8 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle,
PMMVAD Vad = NULL; PMMVAD Vad = NULL;
PVOID Address, NextAddress; PVOID Address, NextAddress;
BOOLEAN Found = FALSE; BOOLEAN Found = FALSE;
ULONG NewProtect, NewState, BaseVpn; ULONG NewProtect, NewState;
ULONG_PTR BaseVpn;
MEMORY_BASIC_INFORMATION MemoryInfo; MEMORY_BASIC_INFORMATION MemoryInfo;
KAPC_STATE ApcState; KAPC_STATE ApcState;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
@ -2666,7 +2667,7 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle,
_SEH2_TRY _SEH2_TRY
{ {
RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer); RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer);
SectionName->SectionFileName.MaximumLength = MemoryInformationLength; SectionName->SectionFileName.MaximumLength = (USHORT)MemoryInformationLength;
RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName); RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName);
if (ReturnLength) *ReturnLength = ModuleFileName.Length; if (ReturnLength) *ReturnLength = ModuleFileName.Length;
@ -2681,7 +2682,7 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle,
else else
{ {
RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer); RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer);
SectionName->SectionFileName.MaximumLength = MemoryInformationLength; SectionName->SectionFileName.MaximumLength = (USHORT)MemoryInformationLength;
RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName); RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName);
if (ReturnLength) *ReturnLength = ModuleFileName.Length; if (ReturnLength) *ReturnLength = ModuleFileName.Length;

View file

@ -134,7 +134,7 @@ MiEvaluateMemoryDescriptors(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
} }
/* Add this to the total of pages */ /* Add this to the total of pages */
MmNumberOfPhysicalPages += Descriptor->PageCount; MmNumberOfPhysicalPages += (PFN_COUNT)Descriptor->PageCount;
/* Check if this is the new lowest page */ /* Check if this is the new lowest page */
if (Descriptor->BasePage < MmLowestPhysicalPage) if (Descriptor->BasePage < MmLowestPhysicalPage)
@ -535,7 +535,7 @@ MiBuildNonPagedPool(VOID)
ASSERT(IS_PAGE_ALIGNED(MmNonPagedPoolExpansionStart)); ASSERT(IS_PAGE_ALIGNED(MmNonPagedPoolExpansionStart));
/* Map the nonpaged pool */ /* Map the nonpaged pool */
PageCount = (MmSizeOfNonPagedPoolInBytes + PAGE_SIZE - 1) / PAGE_SIZE; PageCount = (PFN_COUNT)((MmSizeOfNonPagedPoolInBytes + PAGE_SIZE - 1) / PAGE_SIZE);
MxMapPageRange(MmNonPagedPoolStart, PageCount); MxMapPageRange(MmNonPagedPoolStart, PageCount);
/* Loop the non paged pool extension PTEs */ /* Loop the non paged pool extension PTEs */
@ -575,9 +575,9 @@ MiBuildSystemPteSpace()
MmNonPagedSystemStart = (PVOID)MI_NON_PAGED_SYSTEM_START_MIN; MmNonPagedSystemStart = (PVOID)MI_NON_PAGED_SYSTEM_START_MIN;
/* Reduce the amount of system PTEs to reach this point */ /* Reduce the amount of system PTEs to reach this point */
MmNumberOfSystemPtes = ((ULONG64)MmPfnDatabase - MmNumberOfSystemPtes = (ULONG)(((ULONG64)MmPfnDatabase -
(ULONG64)MmNonPagedSystemStart) >> (ULONG64)MmNonPagedSystemStart) >>
PAGE_SHIFT; PAGE_SHIFT);
MmNumberOfSystemPtes--; MmNumberOfSystemPtes--;
ASSERT(MmNumberOfSystemPtes > 1000); ASSERT(MmNumberOfSystemPtes > 1000);
} }
@ -615,7 +615,7 @@ MiBuildPhysicalMemoryBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
PFN_NUMBER NextPage = -1; PFN_NUMBER NextPage = -1;
PULONG Bitmap; PULONG Bitmap;
ULONG Runs = 0; ULONG Runs = 0;
ULONG Size; ULONG_PTR Size;
/* Calculate size for the PFN bitmap */ /* Calculate size for the PFN bitmap */
Size = ROUND_UP(MmHighestPhysicalPage + 1, sizeof(ULONG)); Size = ROUND_UP(MmHighestPhysicalPage + 1, sizeof(ULONG));
@ -640,7 +640,9 @@ MiBuildPhysicalMemoryBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
} }
/* Initialize the bitmap and clear all bits */ /* Initialize the bitmap and clear all bits */
RtlInitializeBitMap(&MiPfnBitMap, Bitmap, MmHighestPhysicalPage + 1); RtlInitializeBitMap(&MiPfnBitMap,
Bitmap,
(ULONG)MmHighestPhysicalPage + 1);
RtlClearAllBits(&MiPfnBitMap); RtlClearAllBits(&MiPfnBitMap);
/* Loop the memory descriptors */ /* Loop the memory descriptors */
@ -674,7 +676,9 @@ MiBuildPhysicalMemoryBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
} }
/* Set the bits in the PFN bitmap */ /* 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 */ /* Set the next page */
NextPage = Descriptor->BasePage + Descriptor->PageCount; NextPage = Descriptor->BasePage + Descriptor->PageCount;
@ -765,7 +769,7 @@ MiBuildPagedPool_x(VOID)
// into a 4-byte aligned bitmap. // into a 4-byte aligned bitmap.
/* The size of the bitmap in bits is the size in pages */ /* 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 */ /* Calculate buffer size in bytes, aligned to 32 bits */
Size = sizeof(RTL_BITMAP) + ROUND_UP(BitMapSize, 32) / 8; Size = sizeof(RTL_BITMAP) + ROUND_UP(BitMapSize, 32) / 8;

View file

@ -358,7 +358,7 @@ MmNotPresentFaultVirtualMemory(PMMSUPPORT AddressSpace,
static VOID static VOID
MmModifyAttributes(PMMSUPPORT AddressSpace, MmModifyAttributes(PMMSUPPORT AddressSpace,
PVOID BaseAddress, PVOID BaseAddress,
ULONG RegionSize, SIZE_T RegionSize,
ULONG OldType, ULONG OldType,
ULONG OldProtect, ULONG OldProtect,
ULONG NewType, ULONG NewType,
@ -510,7 +510,7 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
PVOID BaseAddress; PVOID BaseAddress;
ULONG RegionSize; ULONG RegionSize;
PVOID PBaseAddress; PVOID PBaseAddress;
ULONG PRegionSize; ULONG_PTR PRegionSize;
PHYSICAL_ADDRESS BoundaryAddressMultiple; PHYSICAL_ADDRESS BoundaryAddressMultiple;
PEPROCESS CurrentProcess = PsGetCurrentProcess(); PEPROCESS CurrentProcess = PsGetCurrentProcess();
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode(); KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
@ -979,7 +979,7 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
PEPROCESS Process; PEPROCESS Process;
PMMSUPPORT AddressSpace; PMMSUPPORT AddressSpace;
PVOID BaseAddress, PBaseAddress; PVOID BaseAddress, PBaseAddress;
ULONG RegionSize, PRegionSize; SIZE_T RegionSize, PRegionSize;
PEPROCESS CurrentProcess = PsGetCurrentProcess(); PEPROCESS CurrentProcess = PsGetCurrentProcess();
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode(); KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
KAPC_STATE ApcState; KAPC_STATE ApcState;
@ -1123,13 +1123,13 @@ NTAPI
MmProtectAnonMem(PMMSUPPORT AddressSpace, MmProtectAnonMem(PMMSUPPORT AddressSpace,
PMEMORY_AREA MemoryArea, PMEMORY_AREA MemoryArea,
PVOID BaseAddress, PVOID BaseAddress,
ULONG Length, SIZE_T Length,
ULONG Protect, ULONG Protect,
PULONG OldProtect) PULONG OldProtect)
{ {
PMM_REGION Region; PMM_REGION Region;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
ULONG LengthCount = 0; ULONG_PTR LengthCount = 0;
/* Search all Regions in MemoryArea up to Length */ /* Search all Regions in MemoryArea up to Length */
/* Every Region up to Length must be committed for success */ /* Every Region up to Length must be committed for success */
@ -1137,7 +1137,7 @@ MmProtectAnonMem(PMMSUPPORT AddressSpace,
{ {
Region = MmFindRegion(MemoryArea->StartingAddress, Region = MmFindRegion(MemoryArea->StartingAddress,
&MemoryArea->Data.VirtualMemoryData.RegionListHead, &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 a Region was found and it is committed */
if ((Region) && (Region->Type == MEM_COMMIT)) if ((Region) && (Region->Type == MEM_COMMIT))

View file

@ -196,7 +196,7 @@ MmRebalanceMemoryConsumers(VOID)
ULONG NrFreedPages; ULONG NrFreedPages;
NTSTATUS Status; NTSTATUS Status;
Target = (MiMinimumAvailablePages - MmAvailablePages) + MiPagesRequired; Target = (ULONG)(MiMinimumAvailablePages - MmAvailablePages) + MiPagesRequired;
Target = max(Target, (LONG) MiMinimumPagesPerRun); Target = max(Target, (LONG) MiMinimumPagesPerRun);
for (i = 0; i < MC_MAXIMUM && Target > 0; i++) for (i = 0; i < MC_MAXIMUM && Target > 0; i++)

View file

@ -60,7 +60,7 @@ MiInitializeUserPfnBitmap(VOID)
/* Initialize it and clear all the bits to begin with */ /* Initialize it and clear all the bits to begin with */
RtlInitializeBitMap(&MiUserPfnBitMap, RtlInitializeBitMap(&MiUserPfnBitMap,
Bitmap, Bitmap,
MmHighestPhysicalPage + 1); (ULONG)MmHighestPhysicalPage + 1);
RtlClearAllBits(&MiUserPfnBitMap); RtlClearAllBits(&MiUserPfnBitMap);
} }
@ -93,7 +93,7 @@ MmInsertLRULastUserPage(PFN_NUMBER Pfn)
ASSERT(Pfn != 0); ASSERT(Pfn != 0);
ASSERT_IS_ROS_PFN(MiGetPfnEntry(Pfn)); ASSERT_IS_ROS_PFN(MiGetPfnEntry(Pfn));
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
RtlSetBit(&MiUserPfnBitMap, Pfn); RtlSetBit(&MiUserPfnBitMap, (ULONG)Pfn);
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
} }
@ -106,7 +106,7 @@ MmGetLRUNextUserPage(PFN_NUMBER PreviousPfn)
/* Find the next user page */ /* Find the next user page */
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
Position = RtlFindSetBits(&MiUserPfnBitMap, 1, PreviousPfn + 1); Position = RtlFindSetBits(&MiUserPfnBitMap, 1, (ULONG)PreviousPfn + 1);
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
if (Position == 0xFFFFFFFF) return 0; if (Position == 0xFFFFFFFF) return 0;
@ -123,7 +123,7 @@ MmRemoveLRUUserPage(PFN_NUMBER Page)
/* Unset the page as a user page */ /* Unset the page as a user page */
ASSERT(Page != 0); ASSERT(Page != 0);
ASSERT_IS_ROS_PFN(MiGetPfnEntry(Page)); ASSERT_IS_ROS_PFN(MiGetPfnEntry(Page));
RtlClearBit(&MiUserPfnBitMap, Page); RtlClearBit(&MiUserPfnBitMap, (ULONG)Page);
} }
BOOLEAN BOOLEAN

View file

@ -881,7 +881,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
{ {
PVOID EndAddress; PVOID EndAddress;
ULONG Granularity; ULONG Granularity;
ULONG tmpLength; ULONG_PTR tmpLength;
PMEMORY_AREA MemoryArea; PMEMORY_AREA MemoryArea;
DPRINT("MmCreateMemoryArea(Type %d, BaseAddress %p, " DPRINT("MmCreateMemoryArea(Type %d, BaseAddress %p, "
@ -980,7 +980,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
VOID NTAPI VOID NTAPI
MmMapMemoryArea(PVOID BaseAddress, MmMapMemoryArea(PVOID BaseAddress,
ULONG Length, SIZE_T Length,
ULONG Consumer, ULONG Consumer,
ULONG Protection) ULONG Protection)
{ {

View file

@ -81,17 +81,17 @@ static ULONG MiPagingFileCount;
ULONG MmNumberOfPagingFiles; ULONG MmNumberOfPagingFiles;
/* Number of pages that are available for swapping */ /* Number of pages that are available for swapping */
PFN_NUMBER MiFreeSwapPages; PFN_COUNT MiFreeSwapPages;
/* Number of pages that have been allocated for swapping */ /* Number of pages that have been allocated for swapping */
PFN_NUMBER MiUsedSwapPages; PFN_COUNT MiUsedSwapPages;
BOOLEAN MmZeroPageFile; BOOLEAN MmZeroPageFile;
/* /*
* Number of pages that have been reserved for swapping but not yet allocated * 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 * Ratio between reserved and available swap pages, e.g. setting this to five
@ -219,7 +219,8 @@ NTSTATUS
NTAPI NTAPI
MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page) MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
{ {
ULONG i, offset; ULONG i;
ULONG_PTR offset;
LARGE_INTEGER file_offset; LARGE_INTEGER file_offset;
IO_STATUS_BLOCK Iosb; IO_STATUS_BLOCK Iosb;
NTSTATUS Status; NTSTATUS Status;
@ -281,7 +282,8 @@ NTSTATUS
NTAPI NTAPI
MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page) MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
{ {
ULONG i, offset; ULONG i;
ULONG_PTR offset;
LARGE_INTEGER file_offset; LARGE_INTEGER file_offset;
IO_STATUS_BLOCK Iosb; IO_STATUS_BLOCK Iosb;
NTSTATUS Status; NTSTATUS Status;
@ -421,7 +423,7 @@ NTAPI
MmFreeSwapPage(SWAPENTRY Entry) MmFreeSwapPage(SWAPENTRY Entry)
{ {
ULONG i; ULONG i;
ULONG off; ULONG_PTR off;
KIRQL oldIrql; KIRQL oldIrql;
i = FILE_FROM_ENTRY(Entry); i = FILE_FROM_ENTRY(Entry);

View file

@ -227,7 +227,7 @@ MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address,
} }
PageOp->ReferenceCount = 1; PageOp->ReferenceCount = 1;
PageOp->Next = MmPageOpHashTable[Hash]; PageOp->Next = MmPageOpHashTable[Hash];
PageOp->Hash = Hash; PageOp->Hash = (ULONG)Hash;
PageOp->Thread = PsGetCurrentThread(); PageOp->Thread = PsGetCurrentThread();
PageOp->Abandoned = FALSE; PageOp->Abandoned = FALSE;
PageOp->Status = STATUS_PENDING; PageOp->Status = STATUS_PENDING;

View file

@ -32,13 +32,13 @@ InsertAfterEntry(PLIST_ENTRY Previous,
static PMM_REGION static PMM_REGION
MmSplitRegion(PMM_REGION InitialRegion, PVOID InitialBaseAddress, MmSplitRegion(PMM_REGION InitialRegion, PVOID InitialBaseAddress,
PVOID StartAddress, ULONG Length, ULONG NewType, PVOID StartAddress, SIZE_T Length, ULONG NewType,
ULONG NewProtect, PMMSUPPORT AddressSpace, ULONG NewProtect, PMMSUPPORT AddressSpace,
PMM_ALTER_REGION_FUNC AlterFunc) PMM_ALTER_REGION_FUNC AlterFunc)
{ {
PMM_REGION NewRegion1; PMM_REGION NewRegion1;
PMM_REGION NewRegion2; PMM_REGION NewRegion2;
ULONG InternalLength; SIZE_T InternalLength;
/* Allocate this in front otherwise the failure case is too difficult. */ /* Allocate this in front otherwise the failure case is too difficult. */
NewRegion2 = ExAllocatePoolWithTag(NonPagedPool, sizeof(MM_REGION), NewRegion2 = ExAllocatePoolWithTag(NonPagedPool, sizeof(MM_REGION),
@ -106,7 +106,7 @@ MmSplitRegion(PMM_REGION InitialRegion, PVOID InitialBaseAddress,
NTSTATUS NTSTATUS
NTAPI NTAPI
MmAlterRegion(PMMSUPPORT AddressSpace, PVOID BaseAddress, 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) ULONG NewType, ULONG NewProtect, PMM_ALTER_REGION_FUNC AlterFunc)
{ {
PMM_REGION InitialRegion; PMM_REGION InitialRegion;
@ -115,7 +115,7 @@ MmAlterRegion(PMMSUPPORT AddressSpace, PVOID BaseAddress,
PLIST_ENTRY CurrentEntry; PLIST_ENTRY CurrentEntry;
PMM_REGION CurrentRegion = NULL; PMM_REGION CurrentRegion = NULL;
PVOID CurrentBaseAddress; PVOID CurrentBaseAddress;
ULONG RemainingLength; SIZE_T RemainingLength;
/* /*
* Find the first region containing part of the range of addresses to * Find the first region containing part of the range of addresses to

View file

@ -112,8 +112,8 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page)
Type = MemoryArea->Type; Type = MemoryArea->Type;
if (Type == MEMORY_AREA_SECTION_VIEW) if (Type == MEMORY_AREA_SECTION_VIEW)
{ {
Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress Offset = (ULONG)((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
+ MemoryArea->Data.SectionData.ViewOffset; + MemoryArea->Data.SectionData.ViewOffset);
/* /*
* Get or create a pageop * Get or create a pageop

View file

@ -178,7 +178,7 @@ ObFastReplaceObject(IN PEX_FAST_REF FastRef,
{ {
EX_FAST_REF OldValue; EX_FAST_REF OldValue;
PVOID OldObject; PVOID OldObject;
ULONG_PTR Count; ULONG Count;
/* Check if we were given an object and reference it 7 times */ /* Check if we were given an object and reference it 7 times */
if (Object) ObReferenceObjectEx(Object, MAX_FAST_REFS); if (Object) ObReferenceObjectEx(Object, MAX_FAST_REFS);

View file

@ -60,7 +60,7 @@ NTAPI
ObDeassignSecurity(IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor) ObDeassignSecurity(IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor)
{ {
EX_FAST_REF FastRef; EX_FAST_REF FastRef;
ULONG_PTR Count; ULONG Count;
PSECURITY_DESCRIPTOR OldSecurityDescriptor; PSECURITY_DESCRIPTOR OldSecurityDescriptor;
/* Get the fast reference and capture it */ /* Get the fast reference and capture it */
@ -126,7 +126,7 @@ ObSetSecurityDescriptorInfo(IN PVOID Object,
PSECURITY_DESCRIPTOR OldDescriptor, NewDescriptor, CachedDescriptor; PSECURITY_DESCRIPTOR OldDescriptor, NewDescriptor, CachedDescriptor;
PEX_FAST_REF FastRef; PEX_FAST_REF FastRef;
EX_FAST_REF OldValue; EX_FAST_REF OldValue;
ULONG_PTR Count; ULONG Count;
PAGED_CODE(); PAGED_CODE();
/* Get the object header */ /* Get the object header */

View file

@ -787,7 +787,7 @@ NtSetThreadExecutionState(IN EXECUTION_STATE esFlags,
PreviousState = Thread->PowerState | ES_CONTINUOUS; PreviousState = Thread->PowerState | ES_CONTINUOUS;
/* Check if we need to update the power state */ /* 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 */ /* Protect the write back to user mode */
_SEH2_TRY _SEH2_TRY

View file

@ -202,7 +202,7 @@ PspReapRoutine(IN PVOID Context)
/* Remove magic value, keep looping if it got changed */ /* Remove magic value, keep looping if it got changed */
} while (InterlockedCompareExchangePointer(&PspReaperListHead.Flink, } while (InterlockedCompareExchangePointer(&PspReaperListHead.Flink,
0, 0,
1) != (PVOID)1); (PVOID)1) != (PVOID)1);
} }
VOID VOID
@ -405,7 +405,7 @@ PspExitThread(IN NTSTATUS ExitStatus)
PEPROCESS CurrentProcess; PEPROCESS CurrentProcess;
PETHREAD Thread, OtherThread, PreviousThread = NULL; PETHREAD Thread, OtherThread, PreviousThread = NULL;
PVOID DeallocationStack; PVOID DeallocationStack;
ULONG Dummy; SIZE_T Dummy;
BOOLEAN Last = FALSE; BOOLEAN Last = FALSE;
PTERMINATION_PORT TerminationPort, NextPort; PTERMINATION_PORT TerminationPort, NextPort;
PLIST_ENTRY FirstEntry, CurrentEntry; PLIST_ENTRY FirstEntry, CurrentEntry;

View file

@ -348,7 +348,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
PDEBUG_OBJECT DebugObject; PDEBUG_OBJECT DebugObject;
PSECTION_OBJECT SectionObject; PSECTION_OBJECT SectionObject;
NTSTATUS Status, AccessStatus; NTSTATUS Status, AccessStatus;
ULONG DirectoryTableBase[2] = {0,0}; ULONG_PTR DirectoryTableBase[2] = {0,0};
KAFFINITY Affinity; KAFFINITY Affinity;
HANDLE_TABLE_ENTRY CidEntry; HANDLE_TABLE_ENTRY CidEntry;
PETHREAD CurrentThread = PsGetCurrentThread(); PETHREAD CurrentThread = PsGetCurrentThread();

Some files were not shown because too many files have changed in this diff Show more