- 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
}
/* Re-enable the interrupt and return */
- InterruptValid = HalEnableSystemInterrupt((UCHAR)DeviceExtension->InterruptVector,
+ InterruptValid = HalEnableSystemInterrupt(DeviceExtension->InterruptVector,
0,
DeviceExtension->InterruptLevel);
}
/* Disable the interrupt and return */
- HalDisableSystemInterrupt((UCHAR)DeviceExtension->InterruptVector,
- 0);
+ HalDisableSystemInterrupt(DeviceExtension->InterruptVector, 0);
return NO_ERROR;
#else
/* FIXME: Function still present? If so what to use instead of HalDisableSystemInterrupt? */
ARM_STATUS_REGISTER Flags;
PKIPCR Pcr = (PKIPCR)KeGetPcr();
ULONG InterruptMask;
-
+
/* Disableinterrupts */
Flags = KeArmStatusRegisterGet();
- _disable();
+ _disable();
#ifdef IRQL_DEBUG
/* Validate correct lower */
*/
BOOLEAN
NTAPI
-HalEnableSystemInterrupt(IN UCHAR Vector,
+HalEnableSystemInterrupt(IN ULONG Vector,
IN KIRQL Irql,
IN KINTERRUPT_MODE InterruptMode)
{
*/
VOID
NTAPI
-HalDisableSystemInterrupt(IN UCHAR Vector,
+HalDisableSystemInterrupt(IN ULONG Vector,
IN KIRQL Irql)
{
UNIMPLEMENTED;
BOOLEAN
NTAPI
HalBeginSystemInterrupt(IN KIRQL Irql,
- IN UCHAR Vector,
+ IN ULONG Vector,
OUT PKIRQL OldIrql)
{
UNIMPLEMENTED;
BOOLEAN
NTAPI
HalEnableSystemInterrupt(
- IN UCHAR Vector,
+ IN ULONG Vector,
IN KIRQL Irql,
IN KINTERRUPT_MODE InterruptMode)
{
VOID
NTAPI
HalDisableSystemInterrupt(
- IN UCHAR Vector,
+ IN ULONG Vector,
IN KIRQL Irql)
{
IOAPIC_REDIRECTION_REGISTER ReDirReg;
UCHAR Index;
ASSERT(Irql <= HIGH_LEVEL);
+ ASSERT(Vector < RTL_NUMBER_OF(HalpVectorToIndex));
Index = HalpVectorToIndex[Vector];
NTAPI
HalBeginSystemInterrupt(
IN KIRQL Irql,
- IN UCHAR Vector,
+ IN ULONG Vector,
OUT PKIRQL OldIrql)
{
KIRQL CurrentIrql;
}
}
-VOID
+VOID
HalpLowerIrql(KIRQL NewIrql, BOOLEAN FromHalEndSystemInterrupt)
{
ULONG Flags;
{
return;
}
- if (KeGetCurrentThread () != NULL &&
+ if (KeGetCurrentThread () != NULL &&
KeGetCurrentThread ()->ApcState.KernelApcPending)
{
_enable();
{
KIRQL OldIrql;
ULONG Flags;
-
+
Flags = __readeflags();
_disable();
BOOLEAN NTAPI
HalBeginSystemInterrupt (KIRQL Irql,
- UCHAR Vector,
+ ULONG Vector,
PKIRQL OldIrql)
{
ULONG Flags;
DPRINT("Vector (0x%X) Irql (0x%X)\n", Vector, Irql);
-
+
if (KeGetCurrentIrql () >= Irql)
{
DPRINT1("current irql %d, new irql %d\n", KeGetCurrentIrql(), Irql);
APICSendEOI();
HalpLowerIrql (Irql, TRUE);
}
-
+
VOID
NTAPI
-HalDisableSystemInterrupt(UCHAR Vector,
+HalDisableSystemInterrupt(ULONG Vector,
KIRQL Irql)
{
ULONG irq;
DPRINT ("Vector (0x%X)\n", Vector);
if (Vector < FIRST_DEVICE_VECTOR ||
- Vector >= FIRST_DEVICE_VECTOR + NUMBER_DEVICE_VECTORS)
+ Vector >= FIRST_DEVICE_VECTOR + NUMBER_DEVICE_VECTORS)
{
DPRINT1("Not a device interrupt, vector=%x\n", Vector);
ASSERT(FALSE);
irq = VECTOR2IRQ (Vector);
IOAPICMaskIrq (irq);
- return;
+ return;
}
BOOLEAN NTAPI
-HalEnableSystemInterrupt (UCHAR Vector,
+HalEnableSystemInterrupt (ULONG Vector,
KIRQL Irql,
KINTERRUPT_MODE InterruptMode)
{
ULONG irq;
if (Vector < FIRST_DEVICE_VECTOR ||
- Vector >= FIRST_DEVICE_VECTOR + NUMBER_DEVICE_VECTORS)
+ Vector >= FIRST_DEVICE_VECTOR + NUMBER_DEVICE_VECTORS)
{
DPRINT("Not a device interrupt\n");
return FALSE;
case DISPATCH_LEVEL:
__writefsbyte(FIELD_OFFSET(KIPCR, HalReserved[HAL_DPC_REQUEST]), 1);
break;
-
+
default:
ASSERT(FALSE);
}
* IRQ2 since the line was asserted by the slave when it received the spurious
* IRQ15!
*
- * - When the 80287/80387 math co-processor generates an FPU/NPX trap, this is
+ * - When the 80287/80387 math co-processor generates an FPU/NPX trap, this is
* connected to IRQ13, so we have to clear the busy latch on the NPX port.
*/
PHAL_DISMISS_INTERRUPT HalpSpecialDismissTable[16] =
*/
BOOLEAN
NTAPI
-HalEnableSystemInterrupt(IN UCHAR Vector,
+HalEnableSystemInterrupt(IN ULONG Vector,
IN KIRQL Irql,
IN KINTERRUPT_MODE InterruptMode)
{
*/
VOID
NTAPI
-HalDisableSystemInterrupt(IN UCHAR Vector,
+HalDisableSystemInterrupt(IN ULONG Vector,
IN KIRQL Irql)
{
ULONG IrqMask;
BOOLEAN
NTAPI
HalBeginSystemInterrupt(IN KIRQL Irql,
- IN UCHAR Vector,
+ IN ULONG Vector,
OUT PKIRQL OldIrql)
{
ULONG Irq;
Mask.Both = Pcr->IDR;
__outbyte(PIC1_DATA_PORT, Mask.Master);
__outbyte(PIC2_DATA_PORT, Mask.Slave);
-
+
/* Now check if this specific interrupt is already in-service */
PendingIrqMask = (1 << PendingIrql);
if (Pcr->IrrActive & PendingIrqMask) return;
-
+
/* Set active bit otherwise, and clear it from IRR */
Pcr->IrrActive |= PendingIrqMask;
Pcr->IRR ^= PendingIrqMask;
-
+
/* Handle delayed hardware interrupt */
SWInterruptHandlerTable[PendingIrql]();
-
+
/* Handling complete */
Pcr->IrrActive ^= PendingIrqMask;
-
+
/* Check if there's still interrupts pending */
PendingIrqlMask = Pcr->IRR & FindHigherIrqlMask[Pcr->Irql];
if (!PendingIrqlMask) break;
HalpEndSoftwareInterrupt(CurrentIrql, TrapFrame);
/* Exit the interrupt */
- KiEoiHelper(TrapFrame);
+ KiEoiHelper(TrapFrame);
}
VOID
/* Clear IRR bit */
Pcr->IRR ^= (1 << PendingIrql);
}
-
+
/* Now handle pending interrupt */
SWInterruptHandlerTable[PendingIrql]();
}
TF_SAVE_ALL = (TF_VOLATILES OR TF_NONVOLATILES OR TF_XMM OR TF_SEGMENTS)\r
TF_HAS_ERROR_CODE = HEX(40)\r
TF_SEND_EOI = HEX(80)\r
+//TF_SYSTEMSERVICE = (TRAPFLAG_VOLATILES or TRAPFLAG_DEBUG)\r
+\r
+/*\r
+ * Stack Layout:\r
+ * |-------------------|\r
+ * | KTRAP_FRAME |\r
+ * |-------------------| <- rbp\r
+ * | EXCEPTION_RECORD |\r
+ * |-------------------|\r
+ * | KEXCEPTION_FRAME |\r
+ * |-------------------| <- rsp\r
+ *\r
+ */\r
\r
/*\r
* EnterTrap - Allocate KTRAP_FRAME_LENGTH and save registers to it\r
typedef struct _HANDLE_TABLE
{
#if (NTDDI_VERSION >= NTDDI_WINXP)
- ULONG TableCode;
+ ULONG_PTR TableCode;
#else
PHANDLE_TABLE_ENTRY **Table;
#endif
NTAPI
HalBeginSystemInterrupt(
KIRQL Irql,
- UCHAR Vector,
+ ULONG Vector,
PKIRQL OldIrql
);
VOID
NTAPI
HalDisableSystemInterrupt(
- UCHAR Vector,
+ ULONG Vector,
KIRQL Irql
);
BOOLEAN
NTAPI
HalEnableSystemInterrupt(
- UCHAR Vector,
+ ULONG Vector,
KIRQL Irql,
KINTERRUPT_MODE InterruptMode
);
HalAdjustResourceList(
IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList
);
-
+
//
// Environment Functions
//
{
LIST_ENTRY DpcListHead;
ULONG_PTR DpcLock;
+#ifdef _M_AMD64
+ volatile LONG DpcQueueDepth;
+#else
volatile ULONG DpcQueueDepth;
+#endif
ULONG DpcCount;
} KDPC_DATA, *PKDPC_DATA;
DISPATCHER_HEADER Header;
LIST_ENTRY ProfileListHead;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
- ULONG DirectoryTableBase;
+ ULONG_PTR DirectoryTableBase;
ULONG Unused0;
#else
- ULONG DirectoryTableBase[2];
+ ULONG_PTR DirectoryTableBase[2];
#endif
#if defined(_M_IX86)
KGDTENTRY LdtDescriptor;
NTAPI
LdrVerifyMappedImageMatchesChecksum(
IN PVOID BaseAddress,
- IN ULONG NumberOfBytes,
+ IN SIZE_T NumberOfBytes,
IN ULONG FileLength
);
{
PVOID TransferAddress;
ULONG ZeroBits;
- ULONG MaximumStackSize;
- ULONG CommittedStackSize;
+ SIZE_T MaximumStackSize;
+ SIZE_T CommittedStackSize;
ULONG SubSystemType;
- USHORT SubSystemMinorVersion;
- USHORT SubSystemMajorVersion;
+ union
+ {
+ struct
+ {
+ USHORT SubSystemMinorVersion;
+ USHORT SubSystemMajorVersion;
+ };
+ ULONG SubSystemVersion;
+ };
ULONG GpValue;
USHORT ImageCharacteristics;
USHORT DllCharacteristics;
//
typedef struct _MMADDRESS_LIST
{
- ULONG StartVpn;
- ULONG EndVpn;
+ ULONG_PTR StartVpn;
+ ULONG_PTR EndVpn;
} MMADDRESS_LIST, *PMMADDRESS_LIST;
//
//
typedef struct _MMVAD_FLAGS
{
- ULONG CommitCharge:19;
- ULONG NoChange:1;
- ULONG VadType:3;
- ULONG MemCommit:1;
- ULONG Protection:5;
- ULONG Spare:2;
- ULONG PrivateMemory:1;
+#ifdef _WIN64
+ ULONG_PTR CommitCharge:51;
+#else
+ ULONG_PTR CommitCharge:19;
+#endif
+ ULONG_PTR NoChange:1;
+ ULONG_PTR VadType:3;
+ ULONG_PTR MemCommit:1;
+ ULONG_PTR Protection:5;
+ ULONG_PTR Spare:2;
+ ULONG_PTR PrivateMemory:1;
} MMVAD_FLAGS, *PMMVAD_FLAGS;
//
} u1;
struct _MMVAD *LeftChild;
struct _MMVAD *RightChild;
- ULONG StartingVpn;
- ULONG EndingVpn;
+ ULONG_PTR StartingVpn;
+ ULONG_PTR EndingVpn;
union
{
- ULONG LongFlags;
+ ULONG_PTR LongFlags;
MMVAD_FLAGS VadFlags;
} u;
PCONTROL_AREA ControlArea;
} u1;
PMMVAD LeftChild;
PMMVAD RightChild;
- ULONG StartingVpn;
- ULONG EndingVpn;
+ ULONG_PTR StartingVpn;
+ ULONG_PTR EndingVpn;
union
{
- ULONG LongFlags;
+ ULONG_PTR LongFlags;
MMVAD_FLAGS VadFlags;
} u;
PCONTROL_AREA ControlArea;
} u1;
PMMVAD LeftChild;
PMMVAD RightChild;
- ULONG StartingVpn;
- ULONG EndingVpn;
+ ULONG_PTR StartingVpn;
+ ULONG_PTR EndingVpn;
union
{
- ULONG LongFlags;
+ ULONG_PTR LongFlags;
MMVAD_FLAGS VadFlags;
} u;
} MMVAD_SHORT, *PMMVAD_SHORT;
typedef struct _MEMORY_DESCRIPTOR
{
MEMORY_TYPE MemoryType;
- ULONG BasePage;
- ULONG PageCount;
+ PFN_NUMBER BasePage;
+ PFN_NUMBER PageCount;
} MEMORY_DESCRIPTOR, *PMEMORY_DESCRIPTOR;
typedef struct _MEMORY_ALLOCATION_DESCRIPTOR
{
LIST_ENTRY ListEntry;
TYPE_OF_MEMORY MemoryType;
- ULONG BasePage;
- ULONG PageCount;
+ PFN_NUMBER BasePage;
+ PFN_NUMBER PageCount;
} MEMORY_ALLOCATION_DESCRIPTOR, *PMEMORY_ALLOCATION_DESCRIPTOR;
typedef struct _BOOT_DRIVER_LIST_ENTRY
// This guid identifies a RAM disk volume
//
DEFINE_GUID(RAMDISK_BOOTDISK_GUID, 0xd9b257fc, 0x684e, 0x4dcb, 0x79, 0xab, 0xf6, 0xa2, 0xcf, 0x03, 0x50, 0xb7);
-
+
//
// Device Name - this string is the name of the device. It is the name
// that should be passed to NtOpenFile when accessing the device.
#define RAMDISK_MEMORY_MAPPED_DISK 2 // Loaded from the registry
#define RAMDISK_BOOT_DISK 3 // Used as a boot device
#define RAMDISK_WIM_DISK 4 // Used as an installation device
-
+
//
// Options when creating a ramdisk
//
struct
{
ULONG ViewCount;
- ULONG ViewLength;
+ SIZE_T ViewLength;
WCHAR FileName[ANYSIZE_ARRAY];
};
struct
{
- ULONG BasePage;
+ ULONG_PTR BasePage;
WCHAR DriveLetter;
};
PVOID BaseAddress;
ObDereferenceObject(KeyBody);
return Loaded;
}
-
+
BOOLEAN
NTAPI
CmpDoFlushAll(IN BOOLEAN ForceFlush)
ResultLength,
&Status);
if (Result == SearchNeedExclusiveLock)
- {
+ {
/* Release the value cell */
if (CellToRelease != HCELL_NIL)
{
Kcb->ValueCache.Count = Parent->ValueList.Count;
}
- /* Make sure the index is valid */
+ /* Make sure the index is valid */
if (Index >= Kcb->ValueCache.Count)
{
/* Release the cell and fail */
if (Parent)
{
/* Update the maximum name length */
- Kcb->ParentKcb->KcbMaxNameLen = Parent->MaxNameLen;
+ Kcb->ParentKcb->KcbMaxNameLen = (USHORT)Parent->MaxNameLen;
/* Make sure we're dirty */
ASSERT(HvIsCellDirty(Hive, ParentCell));
PCM_KEY_HASH Entry;
PCM_KEY_CONTROL_BLOCK CachedKcb;
PCM_KEY_CONTROL_BLOCK ParentKcb;
- USHORT ParentKeyCount;
- USHORT j;
- ULONG i;
+ ULONG ParentKeyCount;
+ ULONG i, j;
ULONG SubKeys = 0;
DPRINT("CmCountOpenSubKeys() called\n");
PBOOT_DRIVER_NODE DriverNode;
PBOOT_DRIVER_LIST_ENTRY DriverEntry;
PCM_KEY_NODE Node;
- ULONG NameLength, Length;
- HCELL_INDEX ValueCell, TagCell;
- PCM_KEY_VALUE Value;
+ ULONG Length;
+ USHORT NameLength;
+ HCELL_INDEX ValueCell, TagCell; PCM_KEY_VALUE Value;
PUNICODE_STRING FileName, RegistryString;
UNICODE_STRING UnicodeString;
PULONG ErrorControl;
ASSERT(Node);
/* Get the name from the cell */
- DriverNode->Name.Length = Node->Flags & KEY_COMP_NAME ?
+ DriverNode->Name.Length = Node->Flags & KEY_COMP_NAME ?
CmpCompressedNameSize(Node->Name, Node->NameLength) :
Node->NameLength;
DriverNode->Name.MaximumLength = DriverNode->Name.Length;
/* Allocate the path name */
FileName = &DriverEntry->FilePath;
FileName->Length = 0;
- FileName->MaximumLength = Length;
+ FileName->MaximumLength = (USHORT)Length;
FileName->Buffer = CmpAllocate(Length, FALSE,TAG_CM);
if (!FileName->Buffer) return FALSE;
/* Write the path name */
RtlAppendUnicodeToString(FileName, L"System32\\Drivers\\");
RtlAppendUnicodeStringToString(FileName, &DriverNode->Name);
- RtlAppendUnicodeToString(FileName, L".sys");
+ RtlAppendUnicodeToString(FileName, L".sys");
}
else
{
/* Allocate and setup the path name */
FileName = &DriverEntry->FilePath;
Buffer = (PWCHAR)CmpValueToData(Hive, Value, &Length);
- FileName->MaximumLength = FileName->Length = Length;
+ FileName->MaximumLength = FileName->Length = (USHORT)Length;
FileName->Buffer = CmpAllocate(Length, FALSE, TAG_CM);
- /* Transfer the data */
- if (!(FileName->Buffer) || !(Buffer)) return FALSE;
+ /* Transfer the data */
+ if (!(FileName->Buffer) || !(Buffer)) return FALSE;
RtlCopyMemory(FileName->Buffer, Buffer, Length);
}
/* The entry is done, add it */
InsertHeadList(BootDriverListHead, &DriverEntry->Link);
- /* Now find error control settings */
+ /* Now find error control settings */
RtlInitUnicodeString(&UnicodeString, L"ErrorControl");
ValueCell = CmpFindValueByName(Hive, Node, &UnicodeString);
if (ValueCell == HCELL_NIL)
/* Copy it into the node */
DriverNode->Group.Buffer = (PWCHAR)CmpValueToData(Hive, Value, &Length);
if (!DriverNode->Group.Buffer) return FALSE;
- DriverNode->Group.Length = Length - sizeof(UNICODE_NULL);
+ DriverNode->Group.Length = (USHORT)Length - sizeof(UNICODE_NULL);
DriverNode->Group.MaximumLength = DriverNode->Group.Length;
}
/* This is our cleaned up string for this specific group */
ASSERT(End != NULL);
- GroupName.Length = (End - Current) * sizeof(WCHAR);
+ GroupName.Length = (USHORT)(End - Current) * sizeof(WCHAR);
GroupName.MaximumLength = GroupName.Length;
GroupName.Buffer = Current;
RemoveEntryList(&CurrentNode->ListEntry.Link);
InsertHeadList(DriverListHead, &CurrentNode->ListEntry.Link);
}
- }
+ }
/* Move on */
Current--;
/* Copy it into a buffer */
DependList.Buffer = (PWCHAR)CmpValueToData(Hive, ListNode, &Length);
if (!DependList.Buffer) return FALSE;
- DependList.Length = DependList.MaximumLength = Length - sizeof(UNICODE_NULL);
+ DependList.Length = DependList.MaximumLength = (USHORT)Length - sizeof(UNICODE_NULL);
/* And start the recurive sort algorithm */
return CmpDoSort(DriverListHead, &DependList);
/* Compose the search 'key' */
Name.Buffer = (PWCHAR)CmpValueToData(Hive, KeyValue, &Length);
if (!Name.Buffer) return FALSE;
- Name.Length = Length - sizeof(UNICODE_NULL);
+ Name.Length = (USHORT)Length - sizeof(UNICODE_NULL);
Name.MaximumLength = Name.Length;
/* Search for corresponding key in the Safe Boot key */
CellIndex = CmpFindSubKeyByName(Hive, SafeBootNode, &Name);
if (!Name.Buffer) return FALSE;
++Name.Buffer;
/* Length of the base name must be >=1 */
- Name.Length = Length - ((PUCHAR)Name.Buffer - (PUCHAR)OriginalName)
+ Name.Length = (USHORT)Length - (USHORT)((PUCHAR)Name.Buffer - (PUCHAR)OriginalName)
- sizeof(UNICODE_NULL);
if(Name.Length < 1) return FALSE;
Name.MaximumLength = Name.Length;
if (Extension)
{
/* Update the name length */
- Length += wcslen(Extension) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
+ Length += (USHORT)wcslen(Extension) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
/* Allocate the buffer for the full name */
NameBuffer = ExAllocatePoolWithTag(PagedPool, Length, TAG_CM);
}
/* Get the disposition */
- *PrimaryDisposition = IoStatusBlock.Information;
+ *PrimaryDisposition = (ULONG)IoStatusBlock.Information;
if (IoStatusBlock.Information != FILE_CREATED)
{
/* Check how large the file is */
}
/* Return the disposition */
- *LogDisposition = IoStatusBlock.Information;
+ *LogDisposition = (ULONG)IoStatusBlock.Information;
}
/* We're done, close handles and free buffers */
ULONG i;
BOOLEAN IsCompressed = TRUE, Found = FALSE;
PCM_NAME_HASH HashEntry;
- ULONG Length, NcbSize;
+ ULONG NcbSize;
+ USHORT Length;
/* Loop the name */
p = NodeName->Buffer;
CmpCleanUpSubKeyInfo(IN PCM_KEY_CONTROL_BLOCK Kcb)
{
PCM_KEY_NODE KeyNode;
-
+
/* Sanity check */
ASSERT((CmpIsKcbLockedExclusive(Kcb) == TRUE) ||
(CmpTestRegistryLockExclusive() == TRUE));
/* Kill it */
CmpFree(Kcb->IndexHint, 0);
}
-
+
/* Remove subkey flags */
Kcb->ExtFlags &= ~(CM_KCB_NO_SUBKEY | CM_KCB_SUBKEY_ONE | CM_KCB_SUBKEY_HINT);
}
/* Get the ref count and update it */
OldRefCount = *(PLONG)&Kcb->RefCount;
NewRefCount = OldRefCount - 1;
-
+
/* Check if we still have references */
if ((NewRefCount & 0xFFFF) > 0)
{
return;
}
}
-
+
/* Save the key */
ConvKey = Kcb->ConvKey;
CmpConstructName(IN PCM_KEY_CONTROL_BLOCK Kcb)
{
PUNICODE_STRING KeyName;
- ULONG NameLength, i;
+ ULONG i;
+ USHORT NameLength;
PCM_KEY_CONTROL_BLOCK MyKcb;
PCM_KEY_NODE KeyNode;
BOOLEAN DeletedKey = FALSE;
/* We need the exclusive lock */
return SearchNeedExclusiveLock;
}
-
+
/* Select the value list as our cell, and get the actual list array */
CellToRelease = ChildList->ValueList;
*CellData = (PCELL_DATA)HvGetCell(Hive, CellToRelease);
PVOID Buffer;
HCELL_INDEX ValueCellToRelease = HCELL_NIL, CellToRelease = HCELL_NIL;
BOOLEAN IsSmall;
- ULONG CompareResult;
+ ULONG_PTR CompareResult;
PAGED_CODE();
/* Check if this is a symlink */
_FileOffset.QuadPart = *FileOffset;
Status = ZwReadFile(HiveHandle, 0, 0, 0, &IoStatusBlock,
- Buffer, BufferLength, &_FileOffset, 0);
+ Buffer, (ULONG)BufferLength, &_FileOffset, 0);
return NT_SUCCESS(Status) ? TRUE : FALSE;
}
_FileOffset.QuadPart = *FileOffset;
Status = ZwWriteFile(HiveHandle, 0, 0, 0, &IoStatusBlock,
- Buffer, BufferLength, &_FileOffset, 0);
+ Buffer, (ULONG)BufferLength, &_FileOffset, 0);
return NT_SUCCESS(Status) ? TRUE : FALSE;
}
}
/* Save the ID string length now that we've created it */
- ConfigData.ComponentEntry.IdentifierLength = strlen(Buffer) + 1;
+ ConfigData.ComponentEntry.IdentifierLength = (ULONG)strlen(Buffer) + 1;
/* Initialize the registry configuration node for it */
Status = CmpInitializeRegistryNode(&ConfigData,
if (Prcb->CpuType == 3) strcpy(Buffer, "80387");
/* Save the ID string length now that we've created it */
- ConfigData.ComponentEntry.IdentifierLength = strlen(Buffer) + 1;
+ ConfigData.ComponentEntry.IdentifierLength = (ULONG)strlen(Buffer) + 1;
/* Initialize the registry configuration node for it */
Status = CmpInitializeRegistryNode(&ConfigData,
/* Now prepare for Video BIOS Mapping of 32KB */
BaseAddress = 0;
ViewSize = 8 * PAGE_SIZE;
- ViewBase.LowPart = VideoRomBase;
- ViewBase.HighPart = 0;
+ ViewBase.QuadPart = VideoRomBase;
/* Map it */
Status = ZwMapViewOfSection(SectionHandle,
{
EX_FAST_REF OldValue;
PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
- ULONG_PTR Count;
+ ULONG Count;
/* Check that we have a new block */
if (NewBlock)
return FALSE;
}
}
-
+
/* Do the swap */
OldValue = ExCompareSwapFastReference(&CallBack->RoutineBlock,
NewBlock,
ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable,
IN EXHANDLE LookupHandle)
{
- ULONG i, j, k, TableLevel, NextHandle;
- ULONG_PTR TableBase;
+ ULONG TableLevel, NextHandle;
+ ULONG_PTR i, j, k, TableBase;
PHANDLE_TABLE_ENTRY Entry = NULL;
EXHANDLE Handle = LookupHandle;
PUCHAR Level1, Level2, Level3;
/* Free this entry */
NewEntry->Object = NULL;
NewEntry->NextFreeTableEntry = NewTable->FirstFree;
- NewTable->FirstFree = Handle.Value;
+ NewTable->FirstFree = (ULONG)Handle.Value;
}
/* Increase the handle value and move to the next entry */
PLIST_ENTRY ListHead, NextEntry;
PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
ULONG NlsTablesEncountered = 0;
- ULONG NlsTableSizes[3]; /* 3 NLS tables */
+ SIZE_T NlsTableSizes[3]; /* 3 NLS tables */
/* Check if this is boot-time phase 0 initialization */
if (!ExpInitializationPhase)
}
/* Setup the basic header, and give the process the low 1MB to itself */
- ProcessParams->Length = Size;
- ProcessParams->MaximumLength = Size;
+ ProcessParams->Length = (ULONG)Size;
+ ProcessParams->MaximumLength = (ULONG)Size;
ProcessParams->Flags = RTL_USER_PROCESS_PARAMETERS_NORMALIZED |
RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB;
NTAPI
INIT_FUNCTION
ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
- IN ULONG PagesToDestroy,
+ IN ULONG_PTR PagesToDestroy,
IN TYPE_OF_MEMORY MemoryType)
{
PLIST_ENTRY ListEntry;
NlsData = LoaderBlock->NlsData;
ExpNlsTableBase = NlsData->AnsiCodePageData;
ExpAnsiCodePageDataOffset = 0;
- ExpOemCodePageDataOffset = ((ULONG_PTR)NlsData->OemCodePageData -
- (ULONG_PTR)NlsData->AnsiCodePageData);
- ExpUnicodeCaseTableDataOffset = ((ULONG_PTR)NlsData->UnicodeCodePageData -
- (ULONG_PTR)NlsData->AnsiCodePageData);
+ ExpOemCodePageDataOffset = (ULONG)((ULONG_PTR)NlsData->OemCodePageData -
+ (ULONG_PTR)NlsData->AnsiCodePageData);
+ ExpUnicodeCaseTableDataOffset = (ULONG)((ULONG_PTR)NlsData->UnicodeCodePageData -
+ (ULONG_PTR)NlsData->AnsiCodePageData);
/* Initialize the NLS Tables */
RtlInitNlsTables((PVOID)((ULONG_PTR)ExpNlsTableBase +
}
/* Set system ranges */
+#ifdef _M_AMD64
+ SharedUserData->Reserved1 = MM_HIGHEST_USER_ADDRESS_WOW64;
+ SharedUserData->Reserved3 = MM_SYSTEM_RANGE_START_WOW64;
+#else
SharedUserData->Reserved1 = (ULONG_PTR)MmHighestUserAddress;
SharedUserData->Reserved3 = (ULONG_PTR)MmSystemRangeStart;
+#endif
/* Make a copy of the NLS Tables */
ExpInitNls(LoaderBlock);
Lookaside->L.FreeMisses = 0;
Lookaside->L.Type = NonPagedPool | Flags;
Lookaside->L.Tag = Tag;
- Lookaside->L.Size = Size;
+ Lookaside->L.Size = (ULONG)Size;
Lookaside->L.Depth = 4;
Lookaside->L.MaximumDepth = 256;
Lookaside->L.LastTotalAllocates = 0;
Lookaside->L.FreeMisses = 0;
Lookaside->L.Type = PagedPool | Flags;
Lookaside->L.Tag = Tag;
- Lookaside->L.Size = Size;
+ Lookaside->L.Size = (ULONG)Size;
Lookaside->L.Depth = 4;
Lookaside->L.MaximumDepth = 256;
Lookaside->L.LastTotalAllocates = 0;
}
/* Query the Interval */
- ReturnInterval = KeQueryIntervalProfile(ProfileSource);
+ ReturnInterval = (ULONG)KeQueryIntervalProfile(ProfileSource);
/* Enter SEH block for return */
_SEH2_TRY
{
/* Get the last wait block */
LastWaitBlock = WaitBlock->Last;
-
+
/* Check if we found it */
if (LastWaitBlock)
{
WaitBlock->Last = WaitBlock;
/* Set the share count */
- WaitBlock->ShareCount = OldValue.Shared;
+ WaitBlock->ShareCount = (LONG)OldValue.Shared;
/* Check if someone is sharing this pushlock */
if (OldValue.Shared > 1)
}
}
- /*
+ /*
* If nobody was waiting on the block, then we possibly reduced the number
* of times the pushlock was shared, and we unlocked it.
* If someone was waiting, and more then one person is waiting, then we
if (InterlockedDecrement(&WaitBlock->ShareCount) > 0) return;
}
- /*
+ /*
* If nobody was waiting on the block, then we possibly reduced the number
* of times the pushlock was shared, and we unlocked it.
* If someone was waiting, and more then one person is waiting, then we
}
/* Set the offset */
- ModuleInfo->OffsetToFileName = p - ModuleName.Buffer;
+ ModuleInfo->OffsetToFileName = (USHORT)(p - ModuleName.Buffer);
}
else
{
Sbi->TimerResolution = KeMaximumIncrement;
Sbi->PageSize = PAGE_SIZE;
Sbi->NumberOfPhysicalPages = MmNumberOfPhysicalPages;
- Sbi->LowestPhysicalPageNumber = MmLowestPhysicalPage;
- Sbi->HighestPhysicalPageNumber = MmHighestPhysicalPage;
+ Sbi->LowestPhysicalPageNumber = (ULONG)MmLowestPhysicalPage;
+ Sbi->HighestPhysicalPageNumber = (ULONG)MmHighestPhysicalPage;
Sbi->AllocationGranularity = MM_VIRTMEM_GRANULARITY; /* hard coded on Intel? */
Sbi->MinimumUserModeAddress = 0x10000; /* Top of 64k */
Sbi->MaximumUserModeAddress = (ULONG_PTR)MmHighestUserAddress;
Spi->IoWriteOperationCount = IoWriteOperationCount;
Spi->IoOtherOperationCount = IoOtherOperationCount;
- Spi->AvailablePages = MmAvailablePages;
+ Spi->AvailablePages = (ULONG)MmAvailablePages;
/*
* Add up all the used "Committed" memory + pagefile.
* Not sure this is right. 8^\
}
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 */
if (Size != sizeof(ULONG_PTR)) return STATUS_INFO_LENGTH_MISMATCH;
*(PULONG_PTR)Buffer = (ULONG_PTR)MmSystemRangeStart;
-
+
if (ReqSize) *ReqSize = sizeof(ULONG_PTR);
-
+
return STATUS_SUCCESS;
}
if (IoStatus->Status != STATUS_END_OF_FILE)
{
ASSERT((ULONGLONG)FcbHeader->FileSize.QuadPart >=
- (FileOffset->QuadPart + IoStatus->Information));
+ ((ULONGLONG)FileOffset->QuadPart + IoStatus->Information));
}
}
else
if (Result == TRUE)
{
ASSERT((IoStatus->Status == STATUS_END_OF_FILE) ||
- ((FileOffset->QuadPart + IoStatus->Information) <=
+ (((ULONGLONG)FileOffset->QuadPart + IoStatus->Information) <=
(ULONGLONG)FcbHeader->FileSize.QuadPart));
}
}
if (PartitionLength > MaxOffset)
{
/* Resize partition to its maximum real length */
- PartitionDescriptor->PartitionLengthLsb0 = MaxOffset - PartitionDescriptor->StartingSectorLsb0;
+#pragma message("--> FIXME: FstubFixupEfiPartition is most likeley broken!")
+ PartitionDescriptor->PartitionLengthLsb0 =
+ (UCHAR)(MaxOffset - PartitionDescriptor->StartingSectorLsb0);
}
}
xHalVectorToIDTEntry(IN ULONG Vector)
{
/* Return the vector */
- return Vector;
+ return (UCHAR)Vector;
}
VOID
return !!(TrapFrame->SegCs & MODE_MASK);
}
-#define Ki386PerfEnd(x)
+#define Ki386PerfEnd()
struct _KPCR;
// HACK
extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount;
+// win64 uses DMA macros, this one is not defined
+NTHALAPI
+NTSTATUS
+NTAPI
+HalAllocateAdapterChannel(
+ IN PADAPTER_OBJECT AdapterObject,
+ IN PWAIT_CONTEXT_BLOCK Wcb,
+ IN ULONG NumberOfMapRegisters,
+ IN PDRIVER_CONTROL ExecutionRoutine);
+
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_AMD64_KE_H */
/* EOF */
#define MM_HIGHEST_VAD_ADDRESS \
(PVOID)((ULONG_PTR)MM_HIGHEST_USER_ADDRESS - (16 * PAGE_SIZE))
+#define MM_HIGHEST_USER_ADDRESS_WOW64 0x7FFEFFFF
+#define MM_SYSTEM_RANGE_START_WOW64 0x80000000
+
PULONG64
FORCEINLINE
MmGetPageDirectory(VOID)
#define MiPdeToPte(PDE) ((PMMPTE)MiPteToAddress(PDE))
#define MiPteToPde(PTE) ((PMMPDE)MiAddressToPte(PTE))
-#define ADDR_TO_PAGE_TABLE(v) (((ULONG_PTR)(v)) / (512 * PAGE_SIZE))
-#define ADDR_TO_PDE_OFFSET(v) ((((ULONG_PTR)(v)) / (512 * PAGE_SIZE)))
-#define ADDR_TO_PTE_OFFSET(v) ((((ULONG_PTR)(v)) % (512 * PAGE_SIZE)) / PAGE_SIZE)
+#define ADDR_TO_PAGE_TABLE(v) ((ULONG)(((ULONG_PTR)(v)) / (512 * PAGE_SIZE)))
+#define ADDR_TO_PDE_OFFSET(v) ((ULONG)((((ULONG_PTR)(v)) / (512 * PAGE_SIZE))))
+#define ADDR_TO_PTE_OFFSET(v) ((ULONG)((((ULONG_PTR)(v)) % (512 * PAGE_SIZE)) / PAGE_SIZE))
#define MiGetPdeOffset ADDR_TO_PDE_OFFSET
ULONG Tag;
ULONG ErrorControl;
} BOOT_DRIVER_NODE, *PBOOT_DRIVER_NODE;
-
+
//
// List of Bus Type GUIDs
//
NTAPI
PipCallDriverAddDevice(
IN PDEVICE_NODE DeviceNode,
- IN BOOLEAN LoadDriver,
+ IN BOOLEAN LoadDriver,
IN PDRIVER_OBJECT DriverObject
);
IopInitiatePnpIrp(
IN PDEVICE_OBJECT DeviceObject,
IN PIO_STATUS_BLOCK IoStatusBlock,
- IN ULONG MinorFunction,
+ IN UCHAR MinorFunction,
IN PIO_STACK_LOCATION Stack
);
IN ULONG RegSzLength,
OUT PUSHORT StringLength OPTIONAL
);
-
+
//
// Initialization Routines
//
extern BOOLEAN KdpOweBreakpoint;
extern BOOLEAN BreakpointsSuspended;
extern ULONG KdpNumInternalBreakpoints;
-extern ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
+extern ULONG_PTR KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
extern ULONG TraceDataBuffer[40];
extern ULONG TraceDataBufferPosition;
extern LARGE_INTEGER KeBootTime;
extern ULONGLONG KeBootTimeBias;
extern BOOLEAN ExCmosClockIsSane;
-extern ULONG KeProcessorArchitecture;
-extern ULONG KeProcessorLevel;
-extern ULONG KeProcessorRevision;
+extern USHORT KeProcessorArchitecture;
+extern USHORT KeProcessorLevel;
+extern USHORT KeProcessorRevision;
extern ULONG KeFeatureBits;
extern KNODE KiNode0;
extern PKNODE KeNodeBlock[1];
extern KEVENT KiSwapEvent;
extern PKPRCB KiProcessorBlock[];
extern ULONG KiMask32Array[MAXIMUM_PRIORITY];
-extern ULONG KiIdleSummary;
+extern ULONG_PTR KiIdleSummary;
extern PVOID KeUserApcDispatcher;
extern PVOID KeUserCallbackDispatcher;
extern PVOID KeUserExceptionDispatcher;
struct _KPROFILE* Profile,
struct _KPROCESS* Process,
PVOID ImageBase,
- ULONG ImageSize,
+ SIZE_T ImageSize,
ULONG BucketSize,
KPROFILE_SOURCE ProfileSource,
KAFFINITY Affinity
FASTCALL
KiUnlinkThread(
IN PKTHREAD Thread,
- IN NTSTATUS WaitStatus
+ IN LONG_PTR WaitStatus
);
VOID
struct _KPROCESS *Process,
KPRIORITY Priority,
KAFFINITY Affinity,
- PULONG DirectoryTableBase,
+ PULONG_PTR DirectoryTableBase,
IN BOOLEAN Enable
);
struct _EPROCESS;
extern PMMSUPPORT MmKernelAddressSpace;
-extern PFN_NUMBER MiFreeSwapPages;
-extern PFN_NUMBER MiUsedSwapPages;
+extern PFN_COUNT MiFreeSwapPages;
+extern PFN_COUNT MiUsedSwapPages;
extern SIZE_T MmTotalPagedPoolQuota;
extern SIZE_T MmTotalNonPagedPoolQuota;
extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
-extern PFN_NUMBER MmNumberOfPhysicalPages;
+extern PFN_COUNT MmNumberOfPhysicalPages;
extern UCHAR MmDisablePagingExecutive;
extern PFN_NUMBER MmLowestPhysicalPage;
extern PFN_NUMBER MmHighestPhysicalPage;
struct _EPROCESS;
struct _MM_RMAP_ENTRY;
struct _MM_PAGEOP;
-typedef ULONG SWAPENTRY;
+typedef ULONG_PTR SWAPENTRY;
//
// MmDbgCopyMemory Flags
LONG FileOffset; /* start offset into the file for image sections */
ULONG_PTR VirtualAddress; /* dtart offset into the address range for image sections */
ULONG RawLength; /* length of the segment which is part of the mapped file */
- ULONG Length; /* absolute length of the segment */
+ SIZE_T Length; /* absolute length of the segment */
ULONG Protection;
FAST_MUTEX Lock; /* lock which protects the page directory */
ULONG ReferenceCount;
{
ULONG Type;
ULONG Protect;
- ULONG Length;
+ SIZE_T Length;
LIST_ENTRY RegionListEntry;
} MM_REGION, *PMM_REGION;
typedef struct _MMFREE_POOL_ENTRY
{
LIST_ENTRY List;
- PFN_NUMBER Size;
+ PFN_COUNT Size;
ULONG Signature;
struct _MMFREE_POOL_ENTRY *Owner;
} MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY;
(*PMM_ALTER_REGION_FUNC)(
PMMSUPPORT AddressSpace,
PVOID BaseAddress,
- ULONG Length,
+ SIZE_T Length,
ULONG OldType,
ULONG OldProtect,
ULONG NewType,
PMMSUPPORT AddressSpace,
ULONG Type,
PVOID *BaseAddress,
- ULONG_PTR Length,
+ SIZE_T Length,
ULONG Protection,
PMEMORY_AREA *Result,
BOOLEAN FixedAddress,
MmLocateMemoryAreaByRegion(
PMMSUPPORT AddressSpace,
PVOID Address,
- ULONG_PTR Length
+ SIZE_T Length
);
PVOID
NTAPI
MmFindGap(
PMMSUPPORT AddressSpace,
- ULONG_PTR Length,
+ SIZE_T Length,
ULONG_PTR Granularity,
BOOLEAN TopDown
);
VOID
NTAPI
MmMapMemoryArea(PVOID BaseAddress,
- ULONG Length,
+ SIZE_T Length,
ULONG Consumer,
ULONG Protection);
PMMSUPPORT AddressSpace,
PMEMORY_AREA MemoryArea,
PVOID BaseAddress,
- ULONG Length,
+ SIZE_T Length,
ULONG Protect,
PULONG OldProtect
);
PVOID BaseAddress,
PLIST_ENTRY RegionListHead,
PVOID StartAddress,
- ULONG Length,
+ SIZE_T Length,
ULONG NewType,
ULONG NewProtect,
PMM_ALTER_REGION_FUNC AlterFunc
PVOID
NTAPI
MmAllocateSection(
- IN ULONG Length,
+ IN SIZE_T Length,
PVOID BaseAddress
);
PMMSUPPORT AddressSpace,
PMEMORY_AREA MemoryArea,
PVOID BaseAddress,
- ULONG Length,
+ SIZE_T Length,
ULONG Protect,
PULONG OldProtect
);
// Identifies a Kernel Handle
//
#define KERNEL_HANDLE_FLAG \
- (1 << ((sizeof(HANDLE) * 8) - 1))
+ ((ULONG_PTR)1 << ((sizeof(HANDLE) * 8) - 1))
#define ObIsKernelHandle(Handle, ProcessorMode) \
(((ULONG_PTR)(Handle) & KERNEL_HANDLE_FLAG) && \
((ProcessorMode) == KernelMode))
#pragma once
#ifdef _WIN64
+VOID
+NTAPI
+RtlInitializeSListHead(IN PSLIST_HEADER ListHead);
#define InitializeSListHead RtlInitializeSListHead
#endif
CHAR Buffer[128];
ANSI_STRING ArcSystemString, ArcString;
BOOLEAN SingleDisk;
- ULONG Length;
+ SIZE_T Length;
NTSTATUS Status;
BOOLEAN FoundBoot = FALSE;
0,
REG_SZ,
(PVOID)Buffer,
- (wcslen(Buffer) + 1) * sizeof(WCHAR));
+ (ULONG)(wcslen(Buffer) + 1) * sizeof(WCHAR));
ZwClose(BootLogKey);
ZwClose(ControlSetKey);
NULL,
NULL,
&IoStatusBlock,
- (PVOID)LogText,
- wcslen(LogText) * sizeof(WCHAR),
+ LogText,
+ (ULONG)wcslen(LogText) * sizeof(WCHAR),
NULL,
NULL);
if (!NT_SUCCESS(Status))
}
KeyName.Length = 0;
- KeyName.MaximumLength = LocalMachine.Length + (wcslen(REGSTR_PATH_DEVICE_CLASSES) + 1) * sizeof(WCHAR) + GuidString.Length;
+ KeyName.MaximumLength = LocalMachine.Length + ((USHORT)wcslen(REGSTR_PATH_DEVICE_CLASSES) + 1) * sizeof(WCHAR) + GuidString.Length;
KeyName.Buffer = ExAllocatePool(PagedPool, KeyName.MaximumLength);
if (!KeyName.Buffer)
{
if (ReturnBuffer.Length + KeyName.Length + sizeof(WCHAR) > ReturnBuffer.MaximumLength)
{
PWSTR NewBuffer;
- ReturnBuffer.MaximumLength = max(ReturnBuffer.MaximumLength * 2, ReturnBuffer.Length + KeyName.Length + 2 * sizeof(WCHAR));
+ ReturnBuffer.MaximumLength = (USHORT)max(ReturnBuffer.MaximumLength * 2,
+ ReturnBuffer.Length + KeyName.Length + 2 * sizeof(WCHAR));
NewBuffer = ExAllocatePool(PagedPool, ReturnBuffer.MaximumLength);
if (!NewBuffer)
{
DPRINT("RtlAppendUnicodeStringToString() failed with status 0x%08lx\n", Status);
goto cleanup;
}
- /* RtlAppendUnicodeStringToString added a NULL at the end of the
- * destination string, but didn't increase the Length field.
- * Do it for it.
- */
- ReturnBuffer.Length += sizeof(WCHAR);
+ /* RtlAppendUnicodeStringToString added a NULL at the end of the
+ * destination string, but didn't increase the Length field.
+ * Do it for it.
+ */
+ ReturnBuffer.Length += sizeof(WCHAR);
NextReferenceString:
ExFreePool(ReferenceBi);
/* Create base key name for this interface: HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses\{GUID} */
ASSERT(((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode);
InstancePath = &((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode->InstancePath;
- BaseKeyName.Length = wcslen(BaseKeyString) * sizeof(WCHAR);
+ BaseKeyName.Length = (USHORT)wcslen(BaseKeyString) * sizeof(WCHAR);
BaseKeyName.MaximumLength = BaseKeyName.Length
+ GuidString.Length;
BaseKeyName.Buffer = ExAllocatePool(
DPRINT1("IoGetDeviceObjectPointer() failed with status 0x%08lx\n", Status);
return Status;
}
-
+
Status = RtlGUIDFromString(&GuidString, &DeviceGuid);
if (!NT_SUCCESS(Status))
{
DPRINT("Filter Driver: %S (%wZ)\n", Filters, &DeviceNode->InstancePath);
ServiceName.Buffer = Filters;
ServiceName.MaximumLength =
- ServiceName.Length = wcslen(Filters) * sizeof(WCHAR);
+ ServiceName.Length = (USHORT)wcslen(Filters) * sizeof(WCHAR);
/* Load and initialize the filter driver */
Status = IopLoadServiceModule(&ServiceName, &ModuleObject);
FileExtension = wcsrchr(ServiceName.Buffer, '.');
if (FileExtension != NULL)
{
- ServiceName.Length -= wcslen(FileExtension) * sizeof(WCHAR);
+ ServiceName.Length -= (USHORT)wcslen(FileExtension) * sizeof(WCHAR);
FileExtension[0] = 0;
}
* Construct the driver object name
*/
- ObjectName.Length = (wcslen(Start) + 8) * sizeof(WCHAR);
+ ObjectName.Length = ((USHORT)wcslen(Start) + 8) * sizeof(WCHAR);
ObjectName.MaximumLength = ObjectName.Length + sizeof(WCHAR);
ObjectName.Buffer = ExAllocatePool(PagedPool, ObjectName.MaximumLength);
if (!ObjectName.Buffer) return STATUS_INSUFFICIENT_RESOURCES;
(VOID)KeSetEvent(&LoadParams->Event, 0, FALSE);
return;
}
-
+
/* Initialize and start device */
IopInitializeDevice(DeviceNode, DriverObject);
Status = IopStartDevice(DeviceNode);
StringBuffer = ALIGN_UP_POINTER(StringBuffer, WCHAR);
/* Set the offset for the driver's name to the current buffer */
- ErrorMessage->DriverNameOffset = (ULONG_PTR)(StringBuffer -
- (ULONG_PTR)ErrorMessage);
+ ErrorMessage->DriverNameOffset = (ULONG)(StringBuffer -
+ (PCHAR)ErrorMessage);
/* Check how much space we have left for the device string */
RemainingLength = (ULONG)((ULONG_PTR)Message +
{
/* Use default name */
DriverNameString.Buffer = L"Application Popup";
- DriverNameLength = wcslen(DriverNameString.Buffer) * sizeof(WCHAR);
+ DriverNameLength = (ULONG)wcslen(DriverNameString.Buffer) * sizeof(WCHAR);
}
/* Check if we have a driver name by here */
_SEH2_TRY
{
/* Return length */
- *BufferLength = IoStatusBlock.Information;
+ *BufferLength = (ULONG)IoStatusBlock.Information;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Now calculate the new lengths left */
FileLength = LocalReturnLength -
FIELD_OFFSET(FILE_NAME_INFORMATION, FileName);
- LocalReturnLength = (ULONG_PTR)p -
- (ULONG_PTR)ObjectNameInfo +
- LocalFileInfo->FileNameLength;
+ LocalReturnLength = (ULONG)((ULONG_PTR)p -
+ (ULONG_PTR)ObjectNameInfo +
+ LocalFileInfo->FileNameLength);
/* Write the Name and null-terminate it */
RtlCopyMemory(p, LocalFileInfo->FileName, FileLength);
*ReturnLength = LocalReturnLength;
/* Setup the length and maximum length */
- FileLength = (ULONG_PTR)p - (ULONG_PTR)ObjectNameInfo;
+ FileLength = (ULONG)((ULONG_PTR)p - (ULONG_PTR)ObjectNameInfo);
ObjectNameInfo->Name.Length = (USHORT)FileLength -
sizeof(OBJECT_NAME_INFORMATION);
ObjectNameInfo->Name.MaximumLength = (USHORT)ObjectNameInfo->Name.Length +
}
/* Return the Length and Status. ReturnedLength is NOT optional */
- *ReturnedLength = IoStatusBlock.Information;
+ *ReturnedLength = (ULONG)IoStatusBlock.Information;
return Status;
}
TargetMdl->MappedSystemVa = (PCHAR)SourceMdl->MappedSystemVa + Offset;
/* Now do the copy */
- Offset = ((ULONG_PTR)TargetMdl->StartVa - (ULONG_PTR)SourceMdl->StartVa) >>
- PAGE_SHIFT;
+ Offset = (ULONG)(((ULONG_PTR)TargetMdl->StartVa -
+ (ULONG_PTR)SourceMdl->StartVa) >> PAGE_SHIFT);
SourcePages += Offset;
RtlCopyMemory(TargetPages, SourcePages, Length * sizeof(PFN_NUMBER));
}
IoIs32bitProcess(
IN PIRP Irp OPTIONAL)
{
-#pragma message "IoIs32bitProcess is hardcoded to FALSE"
+ UNIMPLEMENTED;
return FALSE;
}
#endif
EaBufferEnd->EaNameLength + EaBufferEnd->EaValueLength +
FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]) + 1;
- if (IntEaLength >= NextEaBufferOffset)
+ if ((ULONG)IntEaLength >= NextEaBufferOffset)
{
/* is the EaBufferName terminated with zero? */
if (EaBufferEnd->EaName[EaBufferEnd->EaNameLength]==0)
} IOPNP_DEVICE_EXTENSION, *PIOPNP_DEVICE_EXTENSION;
PUNICODE_STRING PiInitGroupOrderTable;
-ULONG PiInitGroupOrderTableCount;
+USHORT PiInitGroupOrderTableCount;
INTERFACE_TYPE PnpDefaultInterfaceType;
/* FUNCTIONS ******************************************************************/
/* Cache it for later */
PiInitGroupOrderTable = GroupTable;
- PiInitGroupOrderTableCount = Count;
+ PiInitGroupOrderTableCount = (USHORT)Count;
}
else
{
{
NTSTATUS Status;
PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
- ULONG i;
+ USHORT i;
PVOID Buffer;
UNICODE_STRING Group;
PAGED_CODE();
/* Convert to unicode string */
Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset);
PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &Group.Length);
- Group.MaximumLength = KeyValueInformation->DataLength;
+ Group.MaximumLength = (USHORT)KeyValueInformation->DataLength;
Group.Buffer = Buffer;
/* Loop the groups */
PVOID Buffer;
UNICODE_STRING Group;
PULONG GroupOrder;
- ULONG i = -1, Count, Tag = 0;
+ ULONG Count, Tag = 0;
+ USHORT i = -1;
UNICODE_STRING GroupString =
RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet"
L"\\Control\\ServiceGroupOrder");
/* Convert to unicode string */
Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset);
PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &Group.Length);
- Group.MaximumLength = KeyValueInformation->DataLength;
+ Group.MaximumLength = (USHORT)KeyValueInformation->DataLength;
Group.Buffer = Buffer;
}
NTSTATUS
NTAPI
PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
- IN BOOLEAN LoadDriver,
+ IN BOOLEAN LoadDriver,
IN PDRIVER_OBJECT DriverObject)
-{
+{
NTSTATUS Status;
HANDLE EnumRootKey, SubKey, ControlKey, ClassKey, PropertiesKey;
UNICODE_STRING ClassGuid, Properties;
/* Convert to unicode string */
Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset);
PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &ClassGuid.Length);
- ClassGuid.MaximumLength = KeyValueInformation->DataLength;
+ ClassGuid.MaximumLength = (USHORT)KeyValueInformation->DataLength;
ClassGuid.Buffer = Buffer;
/* Open the key */
/* Report the device to the user-mode pnp manager */
IopQueueTargetDeviceEvent(&GUID_DEVICE_ARRIVAL,
- &IopRootDeviceNode->InstancePath);
+ &IopRootDeviceNode->InstancePath);
/* Initialize the Bus Type GUID List */
PnpBusTypeGuidList = ExAllocatePool(PagedPool, sizeof(IO_BUS_TYPE_GUID_LIST));
DriverObject, DeviceNode->PhysicalDeviceObject);
if (!NT_SUCCESS(Status))
{
- DPRINT1("%wZ->AddDevice(%wZ) failed with status 0x%x\n",
+ DPRINT1("%wZ->AddDevice(%wZ) failed with status 0x%x\n",
&DriverObject->DriverName,
&DeviceNode->InstancePath,
Status);
Stack.MajorFunction = IRP_MJ_PNP;
Stack.MinorFunction = IRP_MN_EJECT;
- return IopSynchronousCall(DeviceObject, &Stack, &Dummy);
+ return IopSynchronousCall(DeviceObject, &Stack, &Dummy);
}
static
NTAPI
IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject,
IN OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN ULONG MinorFunction,
+ IN UCHAR MinorFunction,
IN PIO_STACK_LOCATION Stack OPTIONAL)
{
IO_STACK_LOCATION IoStackLocation;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
LPCWSTR Current, Last;
- ULONG dwLength;
+ USHORT Length;
NTSTATUS Status;
/* Assume failure */
}
/* Prepare relative key name */
- dwLength = (ULONG_PTR)Current - (ULONG_PTR)KeyName.Buffer;
- KeyName.MaximumLength = KeyName.Length = dwLength;
+ Length = (USHORT)((ULONG_PTR)Current - (ULONG_PTR)KeyName.Buffer);
+ KeyName.MaximumLength = KeyName.Length = Length;
DPRINT("Create '%wZ'\n", &KeyName);
/* Open key */
0,
REG_SZ,
(PVOID)KeyValue.Buffer,
- (wcslen(KeyValue.Buffer) + 1) * sizeof(WCHAR));
+ ((ULONG)wcslen(KeyValue.Buffer) + 1) * sizeof(WCHAR));
cleanup:
if (NT_SUCCESS(Status))
while (*Ptr)
{
DPRINT(" %S\n", Ptr);
- Length = wcslen(Ptr) + 1;
+ Length = (ULONG)wcslen(Ptr) + 1;
Ptr += Length;
TotalLength += Length;
while (*Ptr)
{
DPRINT(" %S\n", Ptr);
- Length = wcslen(Ptr) + 1;
+ Length = (ULONG)wcslen(Ptr) + 1;
Ptr += Length;
TotalLength += Length;
0,
REG_SZ,
(PVOID)IoStatusBlock.Information,
- (wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
+ ((ULONG)wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
}
else
{
0,
REG_SZ,
(PVOID)IoStatusBlock.Information,
- (wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
+ ((ULONG)wcslen((PWSTR)IoStatusBlock.Information) + 1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
DPRINT1("ZwSetValueKey() failed (Status %lx)\n", Status);
OUT PULONG Disposition OPTIONAL)
{
OBJECT_ATTRIBUTES ObjectAttributes;
- ULONG KeyDisposition, RootHandleIndex = 0, i = 1, NestedCloseLevel = 0, Length;
+ ULONG KeyDisposition, RootHandleIndex = 0, i = 1, NestedCloseLevel = 0;
+ USHORT Length;
HANDLE HandleArray[2];
BOOLEAN Recursing = TRUE;
PWCHAR pp, p, p1;
/* Process the parent key name */
for (p = p1; ((p < pp) && (*p != OBJ_NAME_PATH_SEPARATOR)); p++);
- Length = (p - p1) * sizeof(WCHAR);
+ Length = (USHORT)(p - p1) * sizeof(WCHAR);
/* Is there a parent name? */
if (Length)
{
case DevicePropertyBusTypeGuid:
- /* Get the GUID from the internal cache */
+ /* Get the GUID from the internal cache */
Status = PnpBusTypeGuidGet(DeviceNode->ChildBusTypeIndex, &BusTypeGuid);
if (!NT_SUCCESS(Status)) return Status;
NullTerminate = TRUE;
/* This is the format of the returned data */
- PIP_RETURN_DATA((EnumeratorNameEnd - DeviceInstanceName) * sizeof(WCHAR),
+ PIP_RETURN_DATA((ULONG)(EnumeratorNameEnd - DeviceInstanceName) * sizeof(WCHAR),
DeviceInstanceName);
case DevicePropertyAddress:
case DevicePropertyRemovalPolicy:
PIP_UNIMPLEMENTED();
case DevicePropertyInstallState:
- PIP_UNIMPLEMENTED();
+ PIP_UNIMPLEMENTED();
case DevicePropertyResourceRequirements:
- PIP_UNIMPLEMENTED();
+ PIP_UNIMPLEMENTED();
case DevicePropertyAllocatedResources:
- PIP_UNIMPLEMENTED();
+ PIP_UNIMPLEMENTED();
default:
return STATUS_INVALID_PARAMETER_2;
}
/* Having a registry value name implies registry data */
if (ValueName)
- {
+ {
/* We know up-front how much data to expect */
*ResultLength = BufferLength;
IN PIO_RESOURCE_DESCRIPTOR IoDesc,
OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
{
- ULONGLONG Start;
+ LONGLONG Start;
CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
ASSERT(IoDesc->Type == CmDesc->Type);
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
{
IN PIO_RESOURCE_DESCRIPTOR IoDesc,
OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
{
- ULONGLONG Start;
+ LONGLONG Start;
CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc;
ASSERT(IoDesc->Type == CmDesc->Type);
ZwClose(ControlKey);
if (!NT_SUCCESS(Status))
- return Status;
+ return Status;
return STATUS_SUCCESS;
}
}
NameU.Length = 0;
- NameU.MaximumLength = OldLength + TranslatedSuffix.Length;
+ NameU.MaximumLength = (USHORT)OldLength + TranslatedSuffix.Length;
Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
DevicePropertyPhysicalDeviceObjectName,
ASSERT(FALSE);
}
- NameU.Length = OldLength;
+ NameU.Length = (USHORT)OldLength;
RtlAppendUnicodeStringToString(&NameU, &RawSuffix);
}
/* "Remove" the suffix by setting the length back to what it used to be */
- NameU.Length = OldLength;
+ NameU.Length = (USHORT)OldLength;
RtlAppendUnicodeStringToString(&NameU, &TranslatedSuffix);
}
}
-
ByeBye:
return Result;
goto cleanup;
}
- Status = ZwEnumerateKey(ResourceMapKey,
+ Status = ZwEnumerateKey(ResourceMapKey,
ChildKeyIndex1,
KeyBasicInformation,
KeyInformation,
goto cleanup;
KeyName.Buffer = KeyInformation->Name;
- KeyName.MaximumLength = KeyName.Length = KeyInformation->NameLength;
+ KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
while (TRUE)
{
- Status = ZwEnumerateKey(ChildKey2,
+ Status = ZwEnumerateKey(ChildKey2,
ChildKeyIndex2,
KeyBasicInformation,
NULL,
goto cleanup;
KeyName.Buffer = KeyInformation->Name;
- KeyName.MaximumLength = KeyName.Length = KeyInformation->NameLength;
+ KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
return STATUS_SUCCESS;
}
- Source.MaximumLength = Source.Length = ValueLength;
+ Source.MaximumLength = Source.Length = (USHORT)ValueLength;
Source.Buffer = ValueData;
return RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, &Source, Destination);
{
/* Get the entry */
Device = CONTAINING_RECORD(NextEntry, PNPROOT_DEVICE, ListEntry);
-
+
if (!Device->Pdo)
{
/* Create a physical device object for the
DPRINT("PnpRootDriverEntry(%p %wZ)\n", DriverObject, RegistryPath);
IopRootDriverObject = DriverObject;
-
+
DriverObject->DriverExtension->AddDevice = PnpRootAddDevice;
DriverObject->MajorFunction[IRP_MJ_PNP] = PnpRootPnpControl;
OUT PULONG UnicodeStringCount)
{
PWCHAR p, pp, ps;
- ULONG i = 0, n;
+ ULONG i = 0;
+ SIZE_T n;
ULONG Count = 0;
/* Validate the key information */
RtlCopyMemory((*UnicodeStringList)[i].Buffer, ps, n);
/* Set the lengths */
- (*UnicodeStringList)[i].MaximumLength = n;
- (*UnicodeStringList)[i].Length = n - sizeof(UNICODE_NULL);
+ (*UnicodeStringList)[i].MaximumLength = (USHORT)n;
+ (*UnicodeStringList)[i].Length = (USHORT)(n - sizeof(UNICODE_NULL));
/* One more entry done */
i++;
(*UnicodeStringList)[i].Buffer[n / sizeof(WCHAR)] = UNICODE_NULL;
/* Set the lenghts */
- (*UnicodeStringList)[i].Length = n;
- (*UnicodeStringList)[i].MaximumLength = n + sizeof(UNICODE_NULL);
+ (*UnicodeStringList)[i].Length = (USHORT)n;
+ (*UnicodeStringList)[i].MaximumLength = (USHORT)(n + sizeof(UNICODE_NULL));
}
/* And we're done */
for (p = RegSzData; p < pp; p++) if (!*p) break;
/* Return it */
- if (StringLength) *StringLength = (p - RegSzData) * sizeof(WCHAR);
+ if (StringLength) *StringLength = (USHORT)(p - RegSzData) * sizeof(WCHAR);
return TRUE;
}
TraceDataBuffer[0] = TraceDataBufferPosition;
/* Setup the trace data */
- TraceData->Length = TraceDataBufferPosition * sizeof(ULONG);
+ TraceData->Length = (USHORT)(TraceDataBufferPosition * sizeof(ULONG));
TraceData->Buffer = (PCHAR)TraceDataBuffer;
/* Reset the buffer location */
0,
MMDBG_COPY_UNSAFE,
&InstructionCount);
- WaitStateChange->ControlReport.InstructionCount = InstructionCount;
+ WaitStateChange->ControlReport.InstructionCount = (USHORT)InstructionCount;
/* Clear all the breakpoints in this region */
HadBreakpoints =
&Length);
/* Return the actual length read */
- Data->Length = ReadMemory->ActualBytesRead = Length;
+ ReadMemory->ActualBytesRead = Length;
+ Data->Length = (USHORT)Length;
/* Send the packet */
KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
&Length);
/* Return the actual length read */
- Data->Length = ReadMemory->ActualBytesRead = Length;
+ ReadMemory->ActualBytesRead = Length;
+ Data->Length = (USHORT)Length;
/* Send the packet */
KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
&Length);
/* Return the actual length read */
- Data->Length = ReadMemory->ActualBytesRead = Length;
+ ReadMemory->ActualBytesRead = Length;
+ Data->Length = (USHORT)Length;
/* Send the reply */
KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
&Length);
/* Return the actual length read */
- Data->Length = GetBusData->Length = Length;
+ GetBusData->Length = Length;
+ Data->Length = (USHORT)Length;
/* Send the reply */
KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
/*
* Clear the value so 1 or 2 byte reads
- * don't leave the higher bits unmodified
+ * don't leave the higher bits unmodified
*/
ReadIo->DataValue = 0;
/*
* Clear the value so 1 or 2 byte reads
- * don't leave the higher bits unmodified
+ * don't leave the higher bits unmodified
*/
ReadIoExtended->DataValue = 0;
Data.MaximumLength = sizeof(KdpMessageBuffer);
Data.Buffer = KdpMessageBuffer;
- /*
+ /*
* Reset the context state to ensure the debugger has received
* the current context before it sets it
*/
/* Set up the data */
Data.Buffer = KdpPathBuffer;
- Data.Length = PathNameLength;
+ Data.Length = (USHORT)PathNameLength;
ExtraData = &Data;
}
else
/* Now set up the header and the data */
Header.Length = sizeof(DBGKD_ANY_WAIT_STATE_CHANGE);
Header.Buffer = (PCHAR)&WaitStateChange;
- Data.Length = TotalLength;
+ Data.Length = (USHORT)TotalLength;
Data.Buffer = KdpMessageBuffer;
/* Send State Change packet and wait for a reply */
//
// Symbol Data
//
-ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
+ULONG_PTR KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
//
// Tracepoint Data
STRING ImageName;
PLDR_DATA_TABLE_ENTRY LdrEntry;
PLIST_ENTRY NextEntry;
- ULONG i, j, Length, DebugOptionLength;
+ ULONG i, j, Length;
+ SIZE_T DebugOptionLength;
CHAR NameBuffer[256];
PWCHAR Name;
}
/* Calculate the length of the current option */
- DebugOptionLength = ((ULONG_PTR)DebugOptionEnd -
- (ULONG_PTR)DebugOptionStart);
+ DebugOptionLength = (DebugOptionEnd - DebugOptionStart);
/*
* Break out if we reached the last option
{
/*
* Disable the debugger, but
- * allow it to be reenabled
+ * allow it to be reenabled
*/
DisableKdAfterInit = TRUE;
BlockEnable = FALSE;
}
/*
- * If there are more options then
+ * If there are more options then
* the next character should be a comma
*/
if (*DebugOptionEnd != ',')
}
else if (SecondChanceException == FALSE)
{
- /*
+ /*
* This isn't a debug exception and the stop-on-exception flag isn't
* set, so don't bother
*/
IN KPROCESSOR_MODE PreviousMode,
IN BOOLEAN SecondChanceException)
{
- ULONG ExceptionCommand = ExceptionRecord->ExceptionInformation[0];
+ ULONG_PTR ExceptionCommand = ExceptionRecord->ExceptionInformation[0];
/* Check if this was a breakpoint due to DbgPrint or Load/UnloadSymbols */
if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
/* CPU Features and Flags */
ULONG KeI386CpuType;
ULONG KeI386CpuStep;
-ULONG KeProcessorArchitecture;
-ULONG KeProcessorLevel;
-ULONG KeProcessorRevision;
-ULONG KeFeatureBits;
ULONG KeI386MachineType;
ULONG KeI386NpxPresent = 1;
ULONG KeLargestCacheLine = 0x40;
ULONG KiDmaIoCoherency = 0;
-KAFFINITY KeActiveProcessors = 1;
BOOLEAN KiSMTProcessorsPresent;
/* Freeze data */
/* Check for RDMSR/WRMSR */
if ((Instructions[0] == 0xF) && // 2-byte opcode
- (((Instructions[1] >> 8) == 0x30) || // RDMSR
- ((Instructions[2] >> 8) == 0x32))) // WRMSR
+ ((Instructions[1] == 0x30) || // RDMSR
+ (Instructions[1] == 0x32))) // WRMSR
{
/* Unknown CPU MSR, so raise an access violation */
return STATUS_ACCESS_VIOLATION;
IN PKPRCB Prcb,
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
- ULONG PageDirectory[2];
+ ULONG_PTR PageDirectory[2];
PVOID DpcStack;
ULONG i;
ULONG KiDmaIoCoherency;
ULONG KeIcacheFlushCount = 0;
ULONG KeDcacheFlushCount;
-ULONG KeActiveProcessors;
-ULONG KeProcessorArchitecture;
-ULONG KeProcessorLevel;
-ULONG KeProcessorRevision;
-ULONG KeFeatureBits;
ULONG KeLargestCacheLine = 64; // FIXME: It depends
/* FUNCTIONS ******************************************************************/
KeRosDumpStackFrameArray(IN PULONG_PTR Frames,
IN ULONG FrameCount)
{
- ULONG i, Addr;
+ ULONG i;
+ ULONG_PTR Addr;
BOOLEAN InSystem;
PVOID p;
ULONG_PTR MessageEntry;
PCHAR BugCode;
BOOLEAN Result = FALSE;
+ USHORT Length;
/* Make sure we're not bugchecking too early */
if (!KiBugCodeMessages) return Result;
/* Get the final Code */
BugCode = (PCHAR)((PMESSAGE_RESOURCE_ENTRY)MessageEntry)->Text;
- i = strlen(BugCode);
+ Length = (USHORT)strlen(BugCode);
- /* Handle newlines */
- while ((i > 0) && ((BugCode[i] == '\n') ||
- (BugCode[i] == '\r') ||
- (BugCode[i] == ANSI_NULL)))
+ /* Handle trailing newlines */
+ while ((Length > 0) && ((BugCode[Length] == '\n') ||
+ (BugCode[Length] == '\r') ||
+ (BugCode[Length] == ANSI_NULL)))
{
/* Check if we have a string to return */
- if (!OutputString) BugCode[i] = ANSI_NULL;
- i--;
+ if (!OutputString) BugCode[Length] = ANSI_NULL;
+ Length--;
}
/* Check if caller wants an output string */
{
/* Return it in the OutputString */
OutputString->Buffer = BugCode;
- OutputString->Length = (USHORT)i + 1;
- OutputString->MaximumLength = (USHORT)i + 1;
+ OutputString->Length = Length + 1;
+ OutputString->MaximumLength = Length + 1;
}
else
{
if (MessageId == BUGCODE_PSS_MESSAGE)
{
/* It is, so get the bug code string as well */
- KeGetBugMessageText(KiBugCheckData[0], NULL);
+ KeGetBugMessageText((ULONG)KiBugCheckData[0], NULL);
InbvDisplayString("\r\n\r\n");
}
NTSTATUS
NTAPI
KeDeregisterNmiCallback(PVOID Handle)
-{
+{
UNIMPLEMENTED;
return STATUS_UNSUCCESSFUL;
}
KLOCK_QUEUE_HANDLE ApcLock;
PKTHREAD Thread = KeGetCurrentThread();
PKWAIT_BLOCK GateWaitBlock;
- NTSTATUS Status;
+ LONG_PTR Status;
PKQUEUE Queue;
ASSERT_GATE(Gate);
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
/* CPU Features and Flags */
ULONG KeI386CpuType;
ULONG KeI386CpuStep;
-ULONG KeProcessorArchitecture;
-ULONG KeProcessorLevel;
-ULONG KeProcessorRevision;
-ULONG KeFeatureBits;
ULONG KiFastSystemCallDisable = 1;
ULONG KeI386NpxPresent = 0;
ULONG KiMXCsrMask = 0;
ULONG KeIcacheFlushCount = 0;
ULONG KiDmaIoCoherency = 0;
ULONG KePrefetchNTAGranularity = 32;
-KAFFINITY KeActiveProcessors = 1;
BOOLEAN KiI386PentiumLockErrataPresent;
BOOLEAN KiSMTProcessorsPresent;
/* NSC/Cyrix CPU indexed register access macros */
static __inline
-ULONG
+UCHAR
getCx86(UCHAR reg)
{
WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22, reg);
return READ_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23);
}
-#define setCx86(reg, data) do { \
- WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22,(reg)); \
- WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23,(data)); \
-} while (0)
+static __inline
+void
+setCx86(UCHAR reg, UCHAR data)
+{
+ WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22, reg);
+ WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23, data);
+}
+
/* FUNCTIONS *****************************************************************/
PKPRCB Prcb = KeGetCurrentPrcb();
ULONG Vendor;
ULONG FeatureBits = KF_WORKING_PTE;
- ULONG Reg[4], Dummy, Ccr1;
+ ULONG Reg[4], Dummy;
+ UCHAR Ccr1;
BOOLEAN ExtendedCPUID = TRUE;
ULONG CpuFeatures = 0;
ULONG Data[4], Dummy;
ULONG CacheRequests = 0, i;
ULONG CurrentRegister;
- UCHAR RegisterByte;
- ULONG Size, Associativity = 0, CacheLine = 64, CurrentSize = 0;
+ UCHAR RegisterByte, Associativity = 0;
+ ULONG Size, CacheLine = 64, CurrentSize = 0;
BOOLEAN FirstPass = TRUE;
/* Set default L2 size */
CacheLine = Data[2] & 0xFF;
/* Hardcode associativity */
- RegisterByte = Data[2] >> 12;
+ RegisterByte = (Data[2] >> 12) & 0xFF;
switch (RegisterByte)
{
case 2:
/* GLOBALS *******************************************************************/
+/* Portable CPU Features and Flags */
+USHORT KeProcessorArchitecture;
+USHORT KeProcessorLevel;
+USHORT KeProcessorRevision;
+ULONG KeFeatureBits;
+KAFFINITY KeActiveProcessors = 1;
+
/* System call count */
ULONG KiServiceLimit = NUMBER_OF_SYSCALLS;
/* GLOBALS *******************************************************************/
/* CPU Features and Flags */
-ULONG KeProcessorArchitecture;
-ULONG KeProcessorLevel;
-ULONG KeProcessorRevision;
-ULONG KeFeatureBits;
ULONG KeLargestCacheLine = 0x40;
ULONG KeDcacheFlushCount = 0;
ULONG KeIcacheFlushCount = 0;
ULONG KiDmaIoCoherency = 0;
-KAFFINITY KeActiveProcessors = 1;
BOOLEAN KiSMTProcessorsPresent;
/* CPU Signatures */
KeInitializeProcess(IN OUT PKPROCESS Process,
IN KPRIORITY Priority,
IN KAFFINITY Affinity,
- IN PULONG DirectoryTableBase,
+ IN PULONG_PTR DirectoryTableBase,
IN BOOLEAN Enable)
{
#ifdef CONFIG_SMP
KeInitializeProfile(PKPROFILE Profile,
PKPROCESS Process,
PVOID ImageBase,
- ULONG ImageSize,
+ SIZE_T ImageSize,
ULONG BucketSize,
KPROFILE_SOURCE ProfileSource,
KAFFINITY Affinity)
if (ProfileSource == ProfileTime)
{
/* Set the interval through HAL */
- KiProfileTimeInterval = HalSetProfileInterval(Interval);
+ KiProfileTimeInterval = (ULONG)HalSetProfileInterval(Interval);
}
else if (ProfileSource == ProfileAlignmentFixup)
{
#define NDEBUG
#include <debug.h>
+#ifdef _WIN64
+# define InterlockedOrSetMember(Destination, SetMember) \
+ InterlockedOr64((PLONG64)Destination, SetMember);
+#else
+# define InterlockedOrSetMember(Destination, SetMember) \
+ InterlockedOr((PLONG)Destination, SetMember);
+#endif
+
/* GLOBALS *******************************************************************/
-ULONG KiIdleSummary;
-ULONG KiIdleSMTSummary;
+ULONG_PTR KiIdleSummary;
+ULONG_PTR KiIdleSMTSummary;
/* FUNCTIONS *****************************************************************/
Thread = Prcb->IdleThread;
/* Enable idle scheduling */
- InterlockedOr((PLONG) &KiIdleSummary, Prcb->SetMember);
+ InterlockedOrSetMember(&KiIdleSummary, Prcb->SetMember);
Prcb->IdleSchedule = TRUE;
/* FIXME: SMT support */
else
{
/* Set the idle summary */
- InterlockedOr((PLONG)&KiIdleSummary, Prcb->SetMember);
+ InterlockedOrSetMember(&KiIdleSummary, Prcb->SetMember);
/* Schedule the idle thread */
NextThread = Prcb->IdleThread;
VOID
FASTCALL
KiUnlinkThread(IN PKTHREAD Thread,
- IN NTSTATUS WaitStatus)
+ IN LONG_PTR WaitStatus)
{
PKWAIT_BLOCK WaitBlock;
PKTIMER Timer;
ASSERT(Thread->WaitIrql <= DISPATCH_LEVEL);
KiSetThreadSwapBusy(Thread);
KxInsertTimer(Timer, Hand);
- WaitStatus = KiSwapThread(Thread, KeGetCurrentPrcb());
+ WaitStatus = (NTSTATUS)KiSwapThread(Thread, KeGetCurrentPrcb());
/* Check if were swapped ok */
if (WaitStatus != STATUS_KERNEL_APC)
{
/* It has a normal signal state. Unwait and return */
KiSatisfyMutantWait(CurrentObject, Thread);
- WaitStatus = Thread->WaitStatus;
+ WaitStatus = (NTSTATUS)Thread->WaitStatus;
goto DontWait;
}
else
}
/* Do the actual swap */
- WaitStatus = KiSwapThread(Thread, KeGetCurrentPrcb());
+ WaitStatus = (NTSTATUS)KiSwapThread(Thread, KeGetCurrentPrcb());
/* Check if we were executing an APC */
if (WaitStatus != STATUS_KERNEL_APC) return WaitStatus;
{
/* Normal signal state, unwait it and return */
KiSatisfyMutantWait(CurrentObject, Thread);
- WaitStatus = Thread->WaitStatus | Index;
+ WaitStatus = (NTSTATUS)Thread->WaitStatus | Index;
goto DontWait;
}
else
} while(WaitBlock != WaitBlockArray);
/* Set the wait status and get out */
- WaitStatus = Thread->WaitStatus;
+ WaitStatus = (NTSTATUS)Thread->WaitStatus;
goto DontWait;
}
}
}
/* Swap the thread */
- WaitStatus = KiSwapThread(Thread, KeGetCurrentPrcb());
+ WaitStatus = (NTSTATUS)KiSwapThread(Thread, KeGetCurrentPrcb());
/* Check if we were executing an APC */
if (WaitStatus != STATUS_KERNEL_APC) return WaitStatus;
PETHREAD Thread = PsGetCurrentThread();
BOOLEAN Callback = FALSE;
PKSEMAPHORE Semaphore;
- ULONG MessageType;
+ USHORT MessageType;
PAGED_CODE();
Port = (PLPCP_PORT_OBJECT)PortObject;
IN MEMORY_CACHING_TYPE CacheType)
{
- PFN_NUMBER Pfn, PageCount;
+ PFN_NUMBER Pfn;
+ PFN_COUNT PageCount;
PMMPTE PointerPte;
PVOID BaseAddress;
MMPTE TempPte;
MmUnmapIoSpace(IN PVOID BaseAddress,
IN SIZE_T NumberOfBytes)
{
- PFN_NUMBER PageCount, Pfn;
+ PFN_NUMBER Pfn;
+ PFN_COUNT PageCount;
PMMPTE PointerPte;
//
{
PVOID Base;
PPFN_NUMBER MdlPages, LastPage;
- PFN_NUMBER PageCount;
+ PFN_COUNT PageCount;
BOOLEAN IsIoMapping;
MI_PFN_CACHE_ATTRIBUTE CacheAttribute;
PMMPTE PointerPte;
IN PMDL Mdl)
{
PVOID Base;
- PFN_NUMBER PageCount;
+ PFN_COUNT PageCount, ExtraPageCount;
PPFN_NUMBER MdlPages;
PMMPTE PointerPte;
//
// Get the MDL page array
//
- MdlPages = (PPFN_NUMBER)(Mdl + 1);
- MdlPages += PageCount;
+ MdlPages = MmGetMdlPfnArray(Mdl);
+
+ /* Number of extra pages stored after the PFN array */
+ ExtraPageCount = (PFN_COUNT)*(MdlPages + PageCount);
//
// Do the math
//
- PageCount += *MdlPages;
- PointerPte -= *MdlPages;
+ PageCount += ExtraPageCount;
+ PointerPte -= ExtraPageCount;
ASSERT(PointerPte >= MmSystemPtesStart[SystemPteSpace]);
ASSERT(PointerPte <= MmSystemPtesEnd[SystemPteSpace]);
// Get the new base address
//
BaseAddress = (PVOID)((ULONG_PTR)BaseAddress -
- (*MdlPages << PAGE_SHIFT));
+ (ExtraPageCount << PAGE_SHIFT));
}
//
//
ASSERT(Process->NumberOfLockedPages > 0);
InterlockedExchangeAddSizeT(&Process->NumberOfLockedPages,
- -PageCount);
+ -(LONG_PTR)PageCount);
}
//
//
ASSERT(Process->NumberOfLockedPages > 0);
InterlockedExchangeAddSizeT(&Process->NumberOfLockedPages,
- -PageCount);
+ -(LONG_PTR)PageCount);
}
//
#define COLORED_LIST_HEAD ((1 << 25) - 1) // 0x1FFFFFF
#elif defined(_M_AMD64)
#define LIST_HEAD 0xFFFFFFFFFFFFFFFFLL
-#define COLORED_LIST_HEAD ((1 << 57) - 1) // 0x1FFFFFFFFFFFFFFLL
+#define COLORED_LIST_HEAD ((1ULL << 57) - 1) // 0x1FFFFFFFFFFFFFFLL
#else
#error Define these please!
#endif
struct
{
#ifdef _M_AMD64
- ULONG PreviousSize:8;
- ULONG PoolIndex:8;
- ULONG BlockSize:8;
- ULONG PoolType:8;
+ USHORT PreviousSize:8;
+ USHORT PoolIndex:8;
+ USHORT BlockSize:8;
+ USHORT PoolType:8;
#else
USHORT PreviousSize:9;
USHORT PoolIndex:7;
typedef struct _PHYSICAL_MEMORY_RUN
{
- ULONG BasePage;
- ULONG PageCount;
+ PFN_NUMBER BasePage;
+ PFN_NUMBER PageCount;
} PHYSICAL_MEMORY_RUN, *PPHYSICAL_MEMORY_RUN;
typedef struct _PHYSICAL_MEMORY_DESCRIPTOR
{
ULONG NumberOfRuns;
- ULONG NumberOfPages;
+ PFN_NUMBER NumberOfPages;
PHYSICAL_MEMORY_RUN Run[1];
} PHYSICAL_MEMORY_DESCRIPTOR, *PPHYSICAL_MEMORY_DESCRIPTOR;
extern ULONG MmMaxAdditionNonPagedPoolPerMb;
extern ULONG MmSecondaryColors;
extern ULONG MmSecondaryColorMask;
-extern ULONG_PTR MmNumberOfSystemPtes;
+extern ULONG MmNumberOfSystemPtes;
extern ULONG MmMaximumNonPagedPoolPercent;
extern ULONG MmLargeStackSize;
extern PMMCOLOR_TABLES MmFreePagesByColor[FreePageList + 1];
extern PFN_NUMBER MiHighNonPagedPoolThreshold;
extern PFN_NUMBER MmMinimumFreePages;
extern PFN_NUMBER MmPlentyFreePages;
-extern PFN_NUMBER MiExpansionPoolPagesInitialCharge;
+extern PFN_COUNT MiExpansionPoolPagesInitialCharge;
extern PFN_NUMBER MmResidentAvailablePages;
extern PFN_NUMBER MmResidentAvailableAtInit;
extern ULONG MmTotalFreeSystemPtes[MaximumPtePoolTypes];
VOID
MI_MAKE_HARDWARE_PTE_KERNEL(IN PMMPTE NewPte,
IN PMMPTE MappingPte,
- IN ULONG ProtectionMask,
+ IN ULONG_PTR ProtectionMask,
IN PFN_NUMBER PageFrameNumber)
{
/* Only valid for kernel, non-session PTEs */
VOID
MI_MAKE_HARDWARE_PTE(IN PMMPTE NewPte,
IN PMMPTE MappingPte,
- IN ULONG ProtectionMask,
+ IN ULONG_PTR ProtectionMask,
IN PFN_NUMBER PageFrameNumber)
{
/* Set the protection and page */
VOID
MI_MAKE_HARDWARE_PTE_USER(IN PMMPTE NewPte,
IN PMMPTE MappingPte,
- IN ULONG ProtectionMask,
+ IN ULONG_PTR ProtectionMask,
IN PFN_NUMBER PageFrameNumber)
{
/* Only valid for kernel, non-session PTEs */
IN PFN_NUMBER PageFrameIndex
);
-PFN_NUMBER
+PFN_COUNT
NTAPI
MiDeleteSystemPageableVm(
IN PMMPTE PointerPte,
// On systems with more than 32MB, this number is then doubled, and further
// aligned up to a PDE boundary (4MB).
//
-ULONG_PTR MmNumberOfSystemPtes;
+PFN_COUNT MmNumberOfSystemPtes;
//
// This is how many pages the PFN database will take up
//
// 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
PMMPTE MiHighestUserPte;
PMMPDE MiHighestUserPde;
#if (_MI_PAGING_LEVELS >= 3)
-/* We need the highest PPE and PXE addresses */
+PMMPTE MiHighestUserPpe;
+#if (_MI_PAGING_LEVELS >= 4)
+PMMPTE MiHighestUserPxe;
+#endif
#endif
/* These variables define the system cache address space */
INIT_FUNCTION
MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
- ULONG FreePage, FreePageCount, PagesLeft, BasePage, PageCount;
+ PFN_NUMBER FreePage, FreePageCount, PagesLeft, BasePage, PageCount;
PLIST_ENTRY NextEntry;
PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
PMMPTE PointerPte, LastPte;
{
PMMPTE PointerPte;
PMMPDE PointerPde;
- MMPTE TempPte = ValidKernelPte;
MMPDE TempPde = ValidKernelPde;
PFN_NUMBER PageFrameIndex;
KIRQL OldIrql;
- ULONG Size, BitMapSize;
+ SIZE_T Size;
+ ULONG BitMapSize;
#if (_MI_PAGING_LEVELS == 2)
+ MMPTE TempPte = ValidKernelPte;
+
//
// Get the page frame number for the system page directory
//
//
Size = Size * 1024;
ASSERT(Size == MmSizeOfPagedPoolInPages);
- BitMapSize = Size;
+ BitMapSize = (ULONG)Size;
Size = sizeof(RTL_BITMAP) + (((Size + 31) / 32) * sizeof(ULONG));
//
{
PLIST_ENTRY NextEntry;
PMEMORY_ALLOCATION_DESCRIPTOR Md;
- ULONG TotalPages = 0;
+ PFN_NUMBER TotalPages = 0;
PCHAR
MemType[] =
{
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
MiHighestUserPte = MiAddressToPte(MmHighestUserAddress);
MiHighestUserPde = MiAddressToPde(MmHighestUserAddress);
#if (_MI_PAGING_LEVELS >= 3)
- /* We need the highest PPE and PXE addresses */
- ASSERT(FALSE);
+ MiHighestUserPpe = MiAddressToPpe(MmHighestUserAddress);
+#if (_MI_PAGING_LEVELS >= 4)
+ MiHighestUserPxe = MiAddressToPxe(MmHighestUserAddress);
+#endif
#endif
//
// Get the size of the boot loader's image allocations and then round
//
RtlInitializeBitMap(&MiPfnBitMap,
Bitmap,
- MmHighestPhysicalPage + 1);
+ (ULONG)MmHighestPhysicalPage + 1);
RtlClearAllBits(&MiPfnBitMap);
//
//
// Set the bits in the PFN bitmap
//
- RtlSetBits(&MiPfnBitMap, Run->BasePage, Run->PageCount);
+ RtlSetBits(&MiPfnBitMap, (ULONG)Run->BasePage, (ULONG)Run->PageCount);
}
}
MmIsThisAnNtAsSystem(VOID)
{
/* Return if this is a server system */
- return MmProductType;
+ return MmProductType & 0xFF;
}
/*
NTAPI
MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes)
{
- PFN_NUMBER PageCount, MdlPageCount, PageFrameIndex;
+ PFN_COUNT PageCount, MdlPageCount;
+ PFN_NUMBER PageFrameIndex;
PHYSICAL_ADDRESS LowAddress, HighAddress, SkipBytes;
MI_PFN_CACHE_ATTRIBUTE CacheAttribute;
PMDL Mdl;
// Get the page count
//
ASSERT(NumberOfBytes != 0);
- PageCount = BYTES_TO_PAGES(NumberOfBytes);
+ PageCount = (PFN_COUNT)BYTES_TO_PAGES(NumberOfBytes);
//
// Use the MDL allocator for simplicity, so setup the parameters
{
PMDL Mdl;
PMMPTE PointerPte;
- PFN_NUMBER PageCount;
+ PFN_COUNT PageCount;
//
// Sanity checks
//
// Get the page count
//
- PageCount = BYTES_TO_PAGES(NumberOfBytes);
+ PageCount = (PFN_COUNT)BYTES_TO_PAGES(NumberOfBytes);
//
// Get the first PTE
{
/* This must be a TEB/PEB VAD */
ASSERT(Vad->u.VadFlags.MemCommit == TRUE);
- *ProtectCode = Vad->u.VadFlags.Protection;
+ *ProtectCode = (ULONG)Vad->u.VadFlags.Protection;
return NULL;
}
else
ASSERT(PointerPte != NULL);
/* Return the Prototype PTE and the protection for the page mapping */
- *ProtectCode = Vad->u.VadFlags.Protection;
+ *ProtectCode = (ULONG)Vad->u.VadFlags.Protection;
return PointerPte;
}
}
{
MMPTE TempPte;
PMMPTE OriginalPte;
- ULONG Protection;
+ ULONG_PTR Protection;
PFN_NUMBER PageFrameIndex;
/* Must be called with an valid prototype PTE, with the PFN lock held */
}
/* Get protection and check if it's a prototype PTE */
- ProtectionCode = TempPte.u.Soft.Protection;
+ ProtectionCode = (ULONG)TempPte.u.Soft.Protection;
ASSERT(TempPte.u.Soft.Prototype == 0);
/* Check for non-demand zero PTE */
PMMPFNLIST ListHead;
MMLISTS ListName;
PFN_NUMBER OldFlink, OldBlink;
- ULONG OldColor, OldCache;
+ USHORT OldColor, OldCache;
PMMCOLOR_TABLES ColorTable;
/* Make sure PFN lock is held */
/* GLOBALS ********************************************************************/
LIST_ENTRY MmNonPagedPoolFreeListHead[MI_MAX_FREE_PAGE_LISTS];
-PFN_NUMBER MmNumberOfFreeNonPagedPool, MiExpansionPoolPagesInitialCharge;
+PFN_COUNT MmNumberOfFreeNonPagedPool, MiExpansionPoolPagesInitialCharge;
PVOID MmNonPagedPoolEnd0;
PFN_NUMBER MiStartOfInitialPoolFrame, MiEndOfInitialPoolFrame;
KGUARDED_MUTEX MmPagedPoolMutex;
MiInitializeNonPagedPool(VOID)
{
ULONG i;
- PFN_NUMBER PoolPages;
+ PFN_COUNT PoolPages;
PMMFREE_POOL_ENTRY FreeEntry, FirstEntry;
PMMPTE PointerPte;
PAGED_CODE();
//
// Calculate how many pages the initial nonpaged pool has
//
- PoolPages = BYTES_TO_PAGES(MmSizeOfNonPagedPoolInBytes);
+ PoolPages = (PFN_COUNT)BYTES_TO_PAGES(MmSizeOfNonPagedPoolInBytes);
MmNumberOfFreeNonPagedPool = PoolPages;
//
//
// Calculate the size of the expansion region alone
//
- MiExpansionPoolPagesInitialCharge =
+ MiExpansionPoolPagesInitialCharge = (PFN_COUNT)
BYTES_TO_PAGES(MmMaximumNonPagedPoolInBytes - MmSizeOfNonPagedPoolInBytes);
//
MiAllocatePoolPages(IN POOL_TYPE PoolType,
IN SIZE_T SizeInBytes)
{
- PFN_NUMBER SizeInPages, PageFrameNumber, PageTableCount;
+ PFN_NUMBER PageFrameNumber;
+ PFN_COUNT SizeInPages, PageTableCount;
ULONG i;
KIRQL OldIrql;
PLIST_ENTRY NextEntry, NextHead, LastHead;
//
// Figure out how big the allocation is in pages
//
- SizeInPages = BYTES_TO_PAGES(SizeInBytes);
+ SizeInPages = (PFN_COUNT)BYTES_TO_PAGES(SizeInBytes);
//
// Handle paged pool
//
// We can only support this much then
//
- PageTableCount = (PMMPDE)MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool) -
- MmPagedPoolInfo.NextPdeForPagedPoolExpansion +
- 1;
+ PointerPde = MiAddressToPte(MmPagedPoolInfo.LastPteForPagedPool);
+ PageTableCount = (PFN_COUNT)(PointerPde + 1 -
+ MmPagedPoolInfo.NextPdeForPagedPoolExpansion);
ASSERT(PageTableCount < i);
i = PageTableCount;
}
//
// These pages are now available, clear their availablity bits
//
- EndAllocation = (MmPagedPoolInfo.NextPdeForPagedPoolExpansion -
+ EndAllocation = (ULONG)(MmPagedPoolInfo.NextPdeForPagedPoolExpansion -
(PMMPDE)MiAddressToPte(MmPagedPoolInfo.FirstPteForPagedPool)) *
PTE_COUNT;
RtlClearBits(MmPagedPoolInfo.PagedPoolAllocationMap,
{
PMMPTE PointerPte, StartPte;
PMMPFN Pfn1, StartPfn;
- PFN_NUMBER FreePages, NumberOfPages;
+ PFN_COUNT FreePages, NumberOfPages;
KIRQL OldIrql;
PMMFREE_POOL_ENTRY FreeEntry, NextEntry, LastEntry;
ULONG i, End;
+ ULONG_PTR Offset;
//
// Handle paged pool
// Calculate the offset from the beginning of paged pool, and convert it
// into pages
//
- i = ((ULONG_PTR)StartingVa - (ULONG_PTR)MmPagedPoolStart) >> PAGE_SHIFT;
+ Offset = (ULONG_PTR)StartingVa - (ULONG_PTR)MmPagedPoolStart;
+ i = (ULONG)(Offset >> PAGE_SHIFT);
End = i;
//
//
// Now we know how many pages we have
//
- NumberOfPages = PointerPte - StartPte + 1;
+ NumberOfPages = (PFN_COUNT)(PointerPte - StartPte + 1);
//
// Acquire the nonpaged pool lock
IN BOOLEAN GuiStack)
{
PMMPTE PointerPte;
- PFN_NUMBER StackPages, PageFrameNumber;//, PageTableFrameNumber;
+ PFN_NUMBER PageFrameNumber;//, PageTableFrameNumber;
+ PFN_COUNT StackPages;
PMMPFN Pfn1;//, Pfn2;
ULONG i;
KIRQL OldIrql;
MmCreateKernelStack(IN BOOLEAN GuiStack,
IN UCHAR Node)
{
- PFN_NUMBER StackPtes, StackPages;
+ PFN_COUNT StackPtes, StackPages;
PMMPTE PointerPte, StackPte;
PVOID BaseAddress;
MMPTE TempPte, InvalidPte;
// Attach to Process
//
KeAttachProcess(&Process->Pcb);
-
+
//
// Map NLS Tables
//
PMMPFN Pfn1;
/* Choose a process color */
- Process->NextPageColor = RtlRandom(&MmProcessColorSeed);
+ Process->NextPageColor = (USHORT)RtlRandom(&MmProcessColorSeed);
/* Setup the hyperspace lock */
KeInitializeSpinLock(&Process->HyperSpaceLock);
ASSERT(Session->SystemSpaceBitMap);
RtlInitializeBitMap(Session->SystemSpaceBitMap,
(PULONG)(Session->SystemSpaceBitMap + 1),
- MmSystemViewSize / MI_SYSTEM_VIEW_BUCKET_SIZE);
+ (ULONG)(MmSystemViewSize / MI_SYSTEM_VIEW_BUCKET_SIZE));
/* Set system space fully empty to begin with */
RtlClearAllBits(Session->SystemSpaceBitMap);
{
PSUBSECTION Subsection;
PCONTROL_AREA ControlArea;
- ULONG PteOffset;
+ ULONG_PTR PteOffset;
/* Get the control area */
ControlArea = Vad->ControlArea;
ASSERT(Vad->FirstPrototypePte < &Subsection->SubsectionBase[Subsection->PtesInSubsection]);
/* Compute the PTE offset */
- PteOffset = (ULONG_PTR)Vpn - Vad->StartingVpn;
+ PteOffset = Vpn - Vad->StartingVpn;
PteOffset += Vad->FirstPrototypePte - Subsection->SubsectionBase;
/* Again, we only support single-subsection segments */
}
/* Get the number of 64K buckets required for this mapping */
- Buckets = *ViewSize / MI_SYSTEM_VIEW_BUCKET_SIZE;
+ Buckets = (ULONG)(*ViewSize / MI_SYSTEM_VIEW_BUCKET_SIZE);
if (*ViewSize & (MI_SYSTEM_VIEW_BUCKET_SIZE - 1)) Buckets++;
/* Check if the view is more than 4GB large */
IN PSECTION Section,
IN SECTION_INHERIT InheritDisposition,
IN ULONG ProtectionMask,
- IN ULONG CommitSize,
+ IN SIZE_T CommitSize,
IN ULONG_PTR ZeroBits,
IN ULONG AllocationType)
{
{
/* The caller did not, so pick a 64K aligned view size based on the offset */
SectionOffset->LowPart &= ~(_64K - 1);
- *ViewSize = Section->SizeOfSection.QuadPart - SectionOffset->QuadPart;
+ *ViewSize = (SIZE_T)(Section->SizeOfSection.QuadPart - SectionOffset->QuadPart);
}
else
{
if (*ViewSize >= 0x80000000) return STATUS_INVALID_VIEW_SIZE;
/* Within this section, figure out which PTEs will describe the view */
- PteOffset = SectionOffset->QuadPart >> PAGE_SHIFT;
+ PteOffset = (PFN_NUMBER)(SectionOffset->QuadPart >> PAGE_SHIFT);
/* The offset must be in this segment's PTE chunk and it must be valid */
ASSERT(PteOffset < Segment->TotalNumberOfPtes);
Vad->EndingVpn = EndingAddress >> PAGE_SHIFT;
Vad->ControlArea = ControlArea;
Vad->u.VadFlags.Protection = ProtectionMask;
- Vad->u2.VadFlags2.FileOffset = SectionOffset->QuadPart >> 16;
+ Vad->u2.VadFlags2.FileOffset = (ULONG)(SectionOffset->QuadPart >> 16);
Vad->u2.VadFlags2.Inherit = (InheritDisposition == ViewShare);
if ((AllocationType & SEC_NO_CHANGE) || (Section->u.Flags.NoChange))
{
IN ULONG AllocationAttributes)
{
SIZE_T SizeLimit;
- PFN_NUMBER PteCount;
+ PFN_COUNT PteCount;
PMMPTE PointerPte;
MMPTE TempPte;
PCONTROL_AREA ControlArea;
if (*MaximumSize > SizeLimit) return STATUS_SECTION_TOO_BIG;
/* Calculate how many Prototype PTEs will be needed */
- PteCount = (*MaximumSize + PAGE_SIZE - 1) >> PAGE_SHIFT;
+ PteCount = (PFN_COUNT)((*MaximumSize + PAGE_SIZE - 1) >> PAGE_SHIFT);
/* For commited memory, we must have a valid protection mask */
if (AllocationAttributes & SEC_COMMIT) ASSERT(ProtectionMask != 0);
NewSegment->SegmentPteTemplate.u.Soft.Protection = ProtectionMask;
/* Write out the prototype PTEs, for now they're simply demand zero */
+#ifdef _WIN64
+ RtlFillMemoryUlonglong(PointerPte, PteCount * sizeof(MMPTE), TempPte.u.Long);
+#else
RtlFillMemoryUlong(PointerPte, PteCount * sizeof(MMPTE), TempPte.u.Long);
+#endif
return STATUS_SUCCESS;
}
#endif
/* Check if the offset and size would cause an overflow */
- if ((SectionOffset->QuadPart + *ViewSize) < SectionOffset->QuadPart)
+ if (((ULONG64)SectionOffset->QuadPart + *ViewSize) <
+ (ULONG64)SectionOffset->QuadPart)
{
DPRINT1("Section offset overflows\n");
return STATUS_INVALID_VIEW_SIZE;
}
/* Check if the offset and size are bigger than the section itself */
- if ((SectionOffset->QuadPart + *ViewSize) > Section->SizeOfSection.QuadPart)
+ if (((ULONG64)SectionOffset->QuadPart + *ViewSize) >
+ (ULONG64)Section->SizeOfSection.QuadPart)
{
DPRINT1("Section offset is larger than section\n");
return STATUS_INVALID_VIEW_SIZE;
if (!(*ViewSize))
{
/* Compute it for the caller */
- *ViewSize = Section->SizeOfSection.QuadPart - SectionOffset->QuadPart;
+ *ViewSize = (SIZE_T)(Section->SizeOfSection.QuadPart - SectionOffset->QuadPart);
/* Check if it's larger than 4GB or overflows into kernel-mode */
if ((*ViewSize > 0xFFFFFFFF) ||
}
/* Check if the view size is larger than the section */
- if (*ViewSize > Section->SizeOfSection.QuadPart)
+ if (*ViewSize > (ULONG64)Section->SizeOfSection.QuadPart)
{
DPRINT1("The view is larger than the section\n");
return STATUS_INVALID_VIEW_SIZE;
KAPC_STATE ApcState;
LARGE_INTEGER SectionOffset = {{0, 0}};
BOOLEAN LoadSymbols = FALSE;
- PFN_NUMBER PteCount;
+ PFN_COUNT PteCount;
PMMPTE PointerPte, LastPte;
PVOID DriverBase;
MMPTE TempPte;
if (wcschr(ImportName.Buffer, L'.'))
{
/* Remove the extension */
- ImportName.Length = (wcschr(ImportName.Buffer, L'.') -
+ ImportName.Length = (USHORT)(wcschr(ImportName.Buffer, L'.') -
ImportName.Buffer) * sizeof(WCHAR);
}
ULONG ForwardExportSize;
PIMAGE_EXPORT_DIRECTORY ForwardExportDirectory;
PIMAGE_IMPORT_BY_NAME ForwardName;
- ULONG ForwardLength;
+ SIZE_T ForwardLength;
IMAGE_THUNK_DATA ForwardThunk;
PAGED_CODE();
/* Build the forwarder name */
DllName.Buffer = (PCHAR)Address->u1.Function;
- DllName.Length = strchr(DllName.Buffer, '.') -
- DllName.Buffer +
- sizeof(ANSI_NULL);
+ DllName.Length = (USHORT)(strchr(DllName.Buffer, '.') -
+ DllName.Buffer) +
+ sizeof(WCHAR);
DllName.MaximumLength = DllName.Length;
/* Convert it */
PVOID DllBase, NewImageAddress;
NTSTATUS Status;
PMMPTE PointerPte, StartPte, LastPte;
- PFN_NUMBER PteCount;
+ PFN_COUNT PteCount;
PMMPFN Pfn1;
MMPTE TempPte, OldPte;
/* Scan the thunks */
for (i = 0, DllBase = 0, DllEnd = 0; i < ImportSize; i++, ImageThunk++)
#else
- i = DllBase = DllEnd = 0;
+ DllBase = DllEnd = i = 0;
while ((ImportDescriptor->Name) &&
(ImportDescriptor->OriginalFirstThunk))
{
{
PVOID ImageBase;
PETHREAD CurrentThread = PsGetCurrentThread();
- PFN_NUMBER PageCount = 0, PageFrameIndex;
+ PFN_COUNT PageCount = 0;
+ PFN_NUMBER PageFrameIndex;
PMMPFN Pfn1;
PAGED_CODE();
// Then read the size from the trailing PTE
//
Pte++;
- return Pte->u.List.NextEntry;
+ return (ULONG)Pte->u.List.NextEntry;
}
PMMPTE
IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
{
KIRQL OldIrql;
- ULONG_PTR ClusterSize;
+ ULONG ClusterSize;
PMMPTE PreviousPte, NextPte, InsertPte;
//
OUT PMMADDRESS_NODE *Parent)
{
PMMADDRESS_NODE Node, LowestNode, Child;
- ULONG LowVpn, HighVpn;
+ ULONG_PTR LowVpn, HighVpn;
PFN_NUMBER PageCount;
/* Sanity checks */
return LockChange;
}
-PFN_NUMBER
+PFN_COUNT
NTAPI
MiDeleteSystemPageableVm(IN PMMPTE PointerPte,
IN PFN_NUMBER PageCount,
IN ULONG Flags,
OUT PPFN_NUMBER ValidPages)
{
- PFN_NUMBER ActualPages = 0;
+ PFN_COUNT ActualPages = 0;
PETHREAD CurrentThread = PsGetCurrentThread();
PMMPFN Pfn1;
//PMMPFN Pfn2;
PMMVAD Vad = NULL;
PVOID Address, NextAddress;
BOOLEAN Found = FALSE;
- ULONG NewProtect, NewState, BaseVpn;
+ ULONG NewProtect, NewState;
+ ULONG_PTR BaseVpn;
MEMORY_BASIC_INFORMATION MemoryInfo;
KAPC_STATE ApcState;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
_SEH2_TRY
{
RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer);
- SectionName->SectionFileName.MaximumLength = MemoryInformationLength;
+ SectionName->SectionFileName.MaximumLength = (USHORT)MemoryInformationLength;
RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName);
if (ReturnLength) *ReturnLength = ModuleFileName.Length;
else
{
RtlInitUnicodeString(&SectionName->SectionFileName, SectionName->NameBuffer);
- SectionName->SectionFileName.MaximumLength = MemoryInformationLength;
+ SectionName->SectionFileName.MaximumLength = (USHORT)MemoryInformationLength;
RtlCopyUnicodeString(&SectionName->SectionFileName, &ModuleFileName);
if (ReturnLength) *ReturnLength = ModuleFileName.Length;
}
/* Add this to the total of pages */
- MmNumberOfPhysicalPages += Descriptor->PageCount;
+ MmNumberOfPhysicalPages += (PFN_COUNT)Descriptor->PageCount;
/* Check if this is the new lowest page */
if (Descriptor->BasePage < MmLowestPhysicalPage)
ASSERT(IS_PAGE_ALIGNED(MmNonPagedPoolExpansionStart));
/* Map the nonpaged pool */
- PageCount = (MmSizeOfNonPagedPoolInBytes + PAGE_SIZE - 1) / PAGE_SIZE;
+ PageCount = (PFN_COUNT)((MmSizeOfNonPagedPoolInBytes + PAGE_SIZE - 1) / PAGE_SIZE);
MxMapPageRange(MmNonPagedPoolStart, PageCount);
/* Loop the non paged pool extension PTEs */
MmNonPagedSystemStart = (PVOID)MI_NON_PAGED_SYSTEM_START_MIN;
/* Reduce the amount of system PTEs to reach this point */
- MmNumberOfSystemPtes = ((ULONG64)MmPfnDatabase -
+ MmNumberOfSystemPtes = (ULONG)(((ULONG64)MmPfnDatabase -
(ULONG64)MmNonPagedSystemStart) >>
- PAGE_SHIFT;
+ PAGE_SHIFT);
MmNumberOfSystemPtes--;
ASSERT(MmNumberOfSystemPtes > 1000);
}
PFN_NUMBER NextPage = -1;
PULONG Bitmap;
ULONG Runs = 0;
- ULONG Size;
+ ULONG_PTR Size;
/* Calculate size for the PFN bitmap */
Size = ROUND_UP(MmHighestPhysicalPage + 1, sizeof(ULONG));
}
/* Initialize the bitmap and clear all bits */
- RtlInitializeBitMap(&MiPfnBitMap, Bitmap, MmHighestPhysicalPage + 1);
+ RtlInitializeBitMap(&MiPfnBitMap,
+ Bitmap,
+ (ULONG)MmHighestPhysicalPage + 1);
RtlClearAllBits(&MiPfnBitMap);
/* Loop the memory descriptors */
}
/* Set the bits in the PFN bitmap */
- RtlSetBits(&MiPfnBitMap, Descriptor->BasePage, Descriptor->PageCount);
+ RtlSetBits(&MiPfnBitMap,
+ (ULONG)Descriptor->BasePage,
+ (ULONG)Descriptor->PageCount);
/* Set the next page */
NextPage = Descriptor->BasePage + Descriptor->PageCount;
// into a 4-byte aligned bitmap.
/* The size of the bitmap in bits is the size in pages */
- BitMapSize = MmSizeOfPagedPoolInPages;
+ BitMapSize = (ULONG)MmSizeOfPagedPoolInPages;
/* Calculate buffer size in bytes, aligned to 32 bits */
Size = sizeof(RTL_BITMAP) + ROUND_UP(BitMapSize, 32) / 8;
static VOID
MmModifyAttributes(PMMSUPPORT AddressSpace,
PVOID BaseAddress,
- ULONG RegionSize,
+ SIZE_T RegionSize,
ULONG OldType,
ULONG OldProtect,
ULONG NewType,
PVOID BaseAddress;
ULONG RegionSize;
PVOID PBaseAddress;
- ULONG PRegionSize;
+ ULONG_PTR PRegionSize;
PHYSICAL_ADDRESS BoundaryAddressMultiple;
PEPROCESS CurrentProcess = PsGetCurrentProcess();
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
PEPROCESS Process;
PMMSUPPORT AddressSpace;
PVOID BaseAddress, PBaseAddress;
- ULONG RegionSize, PRegionSize;
+ SIZE_T RegionSize, PRegionSize;
PEPROCESS CurrentProcess = PsGetCurrentProcess();
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
KAPC_STATE ApcState;
MmProtectAnonMem(PMMSUPPORT AddressSpace,
PMEMORY_AREA MemoryArea,
PVOID BaseAddress,
- ULONG Length,
+ SIZE_T Length,
ULONG Protect,
PULONG OldProtect)
{
PMM_REGION Region;
NTSTATUS Status = STATUS_SUCCESS;
- ULONG LengthCount = 0;
+ ULONG_PTR LengthCount = 0;
/* Search all Regions in MemoryArea up to Length */
/* Every Region up to Length must be committed for success */
{
Region = MmFindRegion(MemoryArea->StartingAddress,
&MemoryArea->Data.VirtualMemoryData.RegionListHead,
- (PVOID)((ULONG_PTR)BaseAddress + (ULONG_PTR)LengthCount), NULL);
+ (PVOID)((ULONG_PTR)BaseAddress + LengthCount), NULL);
/* If a Region was found and it is committed */
if ((Region) && (Region->Type == MEM_COMMIT))
MiMinimumAvailablePages = 64;
if ((NrAvailablePages + NrSystemPages) >= 8192)
{
- MiMemoryConsumers[MC_CACHE].PagesTarget = NrAvailablePages / 4 * 3;
+ MiMemoryConsumers[MC_CACHE].PagesTarget = NrAvailablePages / 4 * 3;
}
else if ((NrAvailablePages + NrSystemPages) >= 4096)
{
}
else
{
- MiMemoryConsumers[MC_CACHE].PagesTarget = NrAvailablePages / 8;
+ MiMemoryConsumers[MC_CACHE].PagesTarget = NrAvailablePages / 8;
}
MiMemoryConsumers[MC_USER].PagesTarget = NrAvailablePages - MiMinimumAvailablePages;
}
ULONG NrFreedPages;
NTSTATUS Status;
- Target = (MiMinimumAvailablePages - MmAvailablePages) + MiPagesRequired;
+ Target = (ULONG)(MiMinimumAvailablePages - MmAvailablePages) + MiPagesRequired;
Target = max(Target, (LONG) MiMinimumPagesPerRun);
for (i = 0; i < MC_MAXIMUM && Target > 0; i++)
SIZE_T MmDriverCommit;
SIZE_T MmProcessCommit;
SIZE_T MmPagedPoolCommit;
-SIZE_T MmPeakCommitment;
+SIZE_T MmPeakCommitment;
SIZE_T MmtotalCommitLimitMaximum;
static RTL_BITMAP MiUserPfnBitMap;
/* Initialize it and clear all the bits to begin with */
RtlInitializeBitMap(&MiUserPfnBitMap,
Bitmap,
- MmHighestPhysicalPage + 1);
+ (ULONG)MmHighestPhysicalPage + 1);
RtlClearAllBits(&MiUserPfnBitMap);
}
ASSERT(Pfn != 0);
ASSERT_IS_ROS_PFN(MiGetPfnEntry(Pfn));
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
- RtlSetBit(&MiUserPfnBitMap, Pfn);
+ RtlSetBit(&MiUserPfnBitMap, (ULONG)Pfn);
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
}
/* Find the next user page */
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
- Position = RtlFindSetBits(&MiUserPfnBitMap, 1, PreviousPfn + 1);
+ Position = RtlFindSetBits(&MiUserPfnBitMap, 1, (ULONG)PreviousPfn + 1);
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
if (Position == 0xFFFFFFFF) return 0;
/* Unset the page as a user page */
ASSERT(Page != 0);
ASSERT_IS_ROS_PFN(MiGetPfnEntry(Page));
- RtlClearBit(&MiUserPfnBitMap, Page);
+ RtlClearBit(&MiUserPfnBitMap, (ULONG)Page);
}
BOOLEAN
//
// Convert, and normalize, the high address into a PFN
//
- HighPage = (PFN_NUMBER)(HighAddress.QuadPart >> PAGE_SHIFT);
+ HighPage = (PFN_NUMBER)(HighAddress.QuadPart >> PAGE_SHIFT);
if (HighPage > MmHighestPhysicalPage) HighPage = MmHighestPhysicalPage;
//
// We're done, mark the pages as locked
//
Mdl->Process = NULL;
- Mdl->MdlFlags |= MDL_PAGES_LOCKED;
+ Mdl->MdlFlags |= MDL_PAGES_LOCKED;
return Mdl;
}
{
PVOID EndAddress;
ULONG Granularity;
- ULONG tmpLength;
+ ULONG_PTR tmpLength;
PMEMORY_AREA MemoryArea;
DPRINT("MmCreateMemoryArea(Type %d, BaseAddress %p, "
VOID NTAPI
MmMapMemoryArea(PVOID BaseAddress,
- ULONG Length,
+ SIZE_T Length,
ULONG Consumer,
ULONG Protection)
{
ULONG MmNumberOfPagingFiles;
/* Number of pages that are available for swapping */
-PFN_NUMBER MiFreeSwapPages;
+PFN_COUNT MiFreeSwapPages;
/* Number of pages that have been allocated for swapping */
-PFN_NUMBER MiUsedSwapPages;
+PFN_COUNT MiUsedSwapPages;
BOOLEAN MmZeroPageFile;
/*
* Number of pages that have been reserved for swapping but not yet allocated
*/
-static PFN_NUMBER MiReservedSwapPages;
+static PFN_COUNT MiReservedSwapPages;
/*
* Ratio between reserved and available swap pages, e.g. setting this to five
MmBuildMdlFromPages(PMDL Mdl, PPFN_NUMBER Pages)
{
memcpy(Mdl + 1, Pages, sizeof(PFN_NUMBER) * (PAGE_ROUND_UP(Mdl->ByteOffset+Mdl->ByteCount)/PAGE_SIZE));
-
+
/* FIXME: this flag should be set by the caller perhaps? */
Mdl->MdlFlags |= MDL_IO_PAGE_READ;
}
NTAPI
MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
{
- ULONG i, offset;
+ ULONG i;
+ ULONG_PTR offset;
LARGE_INTEGER file_offset;
IO_STATUS_BLOCK Iosb;
NTSTATUS Status;
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = Iosb.Status;
}
-
+
if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
{
MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
NTAPI
MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
{
- ULONG i, offset;
+ ULONG i;
+ ULONG_PTR offset;
LARGE_INTEGER file_offset;
IO_STATUS_BLOCK Iosb;
NTSTATUS Status;
MmFreeSwapPage(SWAPENTRY Entry)
{
ULONG i;
- ULONG off;
+ ULONG_PTR off;
KIRQL oldIrql;
i = FILE_FROM_ENTRY(Entry);
}
PageOp->ReferenceCount = 1;
PageOp->Next = MmPageOpHashTable[Hash];
- PageOp->Hash = Hash;
+ PageOp->Hash = (ULONG)Hash;
PageOp->Thread = PsGetCurrentThread();
PageOp->Abandoned = FALSE;
PageOp->Status = STATUS_PENDING;
static PMM_REGION
MmSplitRegion(PMM_REGION InitialRegion, PVOID InitialBaseAddress,
- PVOID StartAddress, ULONG Length, ULONG NewType,
+ PVOID StartAddress, SIZE_T Length, ULONG NewType,
ULONG NewProtect, PMMSUPPORT AddressSpace,
PMM_ALTER_REGION_FUNC AlterFunc)
{
PMM_REGION NewRegion1;
PMM_REGION NewRegion2;
- ULONG InternalLength;
+ SIZE_T InternalLength;
/* Allocate this in front otherwise the failure case is too difficult. */
NewRegion2 = ExAllocatePoolWithTag(NonPagedPool, sizeof(MM_REGION),
NTSTATUS
NTAPI
MmAlterRegion(PMMSUPPORT AddressSpace, PVOID BaseAddress,
- PLIST_ENTRY RegionListHead, PVOID StartAddress, ULONG Length,
+ PLIST_ENTRY RegionListHead, PVOID StartAddress, SIZE_T Length,
ULONG NewType, ULONG NewProtect, PMM_ALTER_REGION_FUNC AlterFunc)
{
PMM_REGION InitialRegion;
PLIST_ENTRY CurrentEntry;
PMM_REGION CurrentRegion = NULL;
PVOID CurrentBaseAddress;
- ULONG RemainingLength;
+ SIZE_T RemainingLength;
/*
* Find the first region containing part of the range of addresses to
else
{
NewRegion = InitialRegion;
- if(((ULONG_PTR)InitialBaseAddress + NewRegion->Length) <
+ if(((ULONG_PTR)InitialBaseAddress + NewRegion->Length) <
((ULONG_PTR)StartAddress + Length))
RemainingLength = ((ULONG_PTR)StartAddress + Length) - ((ULONG_PTR)InitialBaseAddress + NewRegion->Length);
else
Type = MemoryArea->Type;
if (Type == MEMORY_AREA_SECTION_VIEW)
{
- Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
- + MemoryArea->Data.SectionData.ViewOffset;
+ Offset = (ULONG)((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
+ + MemoryArea->Data.SectionData.ViewOffset);
/*
* Get or create a pageop
{
if (
#ifdef NEWCC
- !RMAP_IS_SEGMENT(current_entry->Address) &&
+ !RMAP_IS_SEGMENT(current_entry->Address) &&
#endif
MmIsDirtyPage(current_entry->Process, current_entry->Address))
{
if (
#ifdef NEWCC
- !RMAP_IS_SEGMENT(Address) &&
+ !RMAP_IS_SEGMENT(Address) &&
#endif
MmGetPfnForProcess(Process, Address) != Page)
{
MmSetRmapListHeadPage(Page, new_entry);
ExReleaseFastMutex(&RmapListLock);
#ifdef NEWCC
- if (!RMAP_IS_SEGMENT(Address))
+ if (!RMAP_IS_SEGMENT(Address))
#endif
{
if (Process == NULL)
previous_entry = current_entry;
current_entry = current_entry->Next;
#ifdef NEWCC
- if (!RMAP_IS_SEGMENT(previous_entry->Address))
+ if (!RMAP_IS_SEGMENT(previous_entry->Address))
#endif
{
if (DeleteMapping)
{
(void)InterlockedExchangeAddUL(&Process->Vm.WorkingSetSize, -PAGE_SIZE);
}
- }
+ }
#ifdef NEWCC
- else
+ else
{
ExFreeToNPagedLookasideList(&RmapLookasideList, previous_entry);
}
{
EX_FAST_REF OldValue;
PVOID OldObject;
- ULONG_PTR Count;
+ ULONG Count;
/* Check if we were given an object and reference it 7 times */
if (Object) ObReferenceObjectEx(Object, MAX_FAST_REFS);
ObDeassignSecurity(IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor)
{
EX_FAST_REF FastRef;
- ULONG_PTR Count;
+ ULONG Count;
PSECURITY_DESCRIPTOR OldSecurityDescriptor;
/* Get the fast reference and capture it */
PSECURITY_DESCRIPTOR OldDescriptor, NewDescriptor, CachedDescriptor;
PEX_FAST_REF FastRef;
EX_FAST_REF OldValue;
- ULONG_PTR Count;
+ ULONG Count;
PAGED_CODE();
/* Get the object header */
POWER_STATE_TRAVERSE_CONTEXT PowerContext;
Status = IopGetSystemPowerDeviceObject(&DeviceObject);
- if (!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status))
{
DPRINT1("No system power driver available\n");
Fdo = NULL;
PreviousState = Thread->PowerState | ES_CONTINUOUS;
/* Check if we need to update the power state */
- if (esFlags & ES_CONTINUOUS) Thread->PowerState = esFlags;
+ if (esFlags & ES_CONTINUOUS) Thread->PowerState = (UCHAR)esFlags;
/* Protect the write back to user mode */
_SEH2_TRY
(MinSystemState <= PowerSystemUnspecified) ||
(SystemAction > PowerActionWarmEject) ||
(SystemAction < PowerActionReserved) ||
- (Flags & ~(POWER_ACTION_QUERY_ALLOWED |
- POWER_ACTION_UI_ALLOWED |
- POWER_ACTION_OVERRIDE_APPS |
- POWER_ACTION_LIGHTEST_FIRST |
- POWER_ACTION_LOCK_CONSOLE |
- POWER_ACTION_DISABLE_WAKES |
+ (Flags & ~(POWER_ACTION_QUERY_ALLOWED |
+ POWER_ACTION_UI_ALLOWED |
+ POWER_ACTION_OVERRIDE_APPS |
+ POWER_ACTION_LIGHTEST_FIRST |
+ POWER_ACTION_LOCK_CONSOLE |
+ POWER_ACTION_DISABLE_WAKES |
POWER_ACTION_CRITICAL)))
{
DPRINT1("NtSetSystemPowerState: Bad parameters!\n");
/* Remove magic value, keep looping if it got changed */
} while (InterlockedCompareExchangePointer(&PspReaperListHead.Flink,
0,
- 1) != (PVOID)1);
+ (PVOID)1) != (PVOID)1);
}
VOID
PEPROCESS CurrentProcess;
PETHREAD Thread, OtherThread, PreviousThread = NULL;
PVOID DeallocationStack;
- ULONG Dummy;
+ SIZE_T Dummy;
BOOLEAN Last = FALSE;
PTERMINATION_PORT TerminationPort, NextPort;
PLIST_ENTRY FirstEntry, CurrentEntry;
PDEBUG_OBJECT DebugObject;
PSECTION_OBJECT SectionObject;
NTSTATUS Status, AccessStatus;
- ULONG DirectoryTableBase[2] = {0,0};
+ ULONG_PTR DirectoryTableBase[2] = {0,0};
KAFFINITY Affinity;
HANDLE_TABLE_ENTRY CidEntry;
PETHREAD CurrentThread = PsGetCurrentThread();
KAFFINITY Affinity = 0, CombinedAffinity;
PVOID Address = NULL;
PEPROCESS Process;
- ULONG DisableBoost = 0;
- ULONG IdealProcessor = 0;
+ ULONG_PTR DisableBoost = 0;
+ ULONG_PTR IdealProcessor = 0;
PTEB Teb;
- ULONG TlsIndex = 0;
+ ULONG_PTR TlsIndex = 0;
PVOID *ExpansionSlots;
PETHREAD ProcThread;
PAGED_CODE();
/* Generate a new cookie */
KeQuerySystemTime(&SystemTime);
Prcb = KeGetCurrentPrcb();
- NewCookie = Prcb->MmPageFaultCount ^ Prcb->InterruptTime ^
+ NewCookie = (Prcb->MmPageFaultCount ^ Prcb->InterruptTime ^
SystemTime.u.LowPart ^ SystemTime.u.HighPart ^
- (ULONG_PTR)&SystemTime;
+ (ULONG)(ULONG_PTR)&SystemTime);
/* Set the new cookie*/
InterlockedCompareExchange((LONG*)&SharedUserData->Cookie,