NTAPI
RtlpFreeDebugInfo(PRTL_CRITICAL_SECTION_DEBUG DebugInfo)
{
- ULONG EntryId;
+ SIZE_T EntryId;
/* Is it part of our cached entries? */
if ((DebugInfo >= RtlpStaticDebugInfo) &&
/* Mark as free */
EntryId = (DebugInfo - RtlpStaticDebugInfo);
- DPRINT("Freeing from Buffer: %p. Entry: %lu inside Process: %p\n",
+ DPRINT("Freeing from Buffer: %p. Entry: %Iu inside Process: %p\n",
DebugInfo,
EntryId,
NtCurrentTeb()->ClientId.UniqueProcess);
ASSERT(HeaderSize <= PAGE_SIZE);
/* Initialise the Heap Entry header containing the Heap header */
- Heap->Entry.Size = HeaderSize >> HEAP_ENTRY_SHIFT;
+ Heap->Entry.Size = (USHORT)(HeaderSize >> HEAP_ENTRY_SHIFT);
Heap->Entry.Flags = HEAP_ENTRY_BUSY;
Heap->Entry.SmallTagIndex = LOBYTE(Heap->Entry.Size) ^ HIBYTE(Heap->Entry.Size) ^ Heap->Entry.Flags;
Heap->Entry.PreviousSize = 0;
/* Initialise the Heap validation info */
Heap->HeaderValidateCopy = NULL;
- Heap->HeaderValidateLength = HeaderSize;
+ Heap->HeaderValidateLength = (USHORT)HeaderSize;
/* Initialise the Heap Lock */
if (!(Flags & HEAP_NO_SERIALIZE) && !(Flags & HEAP_LOCK_USER_ALLOCATED))
}
/* Update tracking numbers */
- Segment->NumberOfUnCommittedPages -= *Size / PAGE_SIZE;
+ Segment->NumberOfUnCommittedPages -= (ULONG)(*Size / PAGE_SIZE);
/* Calculate first and last entries */
FirstEntry = (PHEAP_ENTRY)Address;
PHEAP_ENTRY PrecedingInUseEntry = NULL, NextInUseEntry = NULL;
PHEAP_FREE_ENTRY NextFreeEntry;
PHEAP_UCR_DESCRIPTOR UcrDescriptor;
- ULONG PrecedingSize, NextSize, DecommitSize;
+ SIZE_T PrecedingSize, NextSize, DecommitSize;
ULONG_PTR DecommitBase;
NTSTATUS Status;
/* Insert uncommitted pages */
RtlpInsertUnCommittedPages(Segment, DecommitBase, DecommitSize);
- Segment->NumberOfUnCommittedPages += (DecommitSize / PAGE_SIZE);
+ Segment->NumberOfUnCommittedPages += (ULONG)(DecommitSize / PAGE_SIZE);
if (PrecedingSize)
{
}
}
-BOOLEAN NTAPI
+NTSTATUS
+NTAPI
RtlpInitializeHeapSegment(IN OUT PHEAP Heap,
OUT PHEAP_SEGMENT Segment,
IN UCHAR SegmentIndex,
/* Initialise the Heap Segment location information */
Segment->BaseAddress = Segment;
- Segment->NumberOfPages = SegmentReserve >> PAGE_SHIFT;
+ Segment->NumberOfPages = (ULONG)(SegmentReserve >> PAGE_SHIFT);
/* Initialise the Heap Entries contained within the Heap Segment */
Segment->FirstEntry = &Segment->Entry + Segment->Entry.Size;
}
/* Initialise the Heap Segment UnCommitted Range information */
- Segment->NumberOfUnCommittedPages = (SegmentReserve - SegmentCommit) >> PAGE_SHIFT;
+ Segment->NumberOfUnCommittedPages = (ULONG)((SegmentReserve - SegmentCommit) >> PAGE_SHIFT);
Segment->NumberOfUnCommittedRanges = 0;
InitializeListHead(&Segment->UCRSegmentList);
DPRINT("RtlpExtendHeap(%p %x)\n", Heap, Size);
/* Calculate amount in pages */
- Pages = (Size + PAGE_SIZE - 1) / PAGE_SIZE;
+ Pages = (ULONG)((Size + PAGE_SIZE - 1) / PAGE_SIZE);
FreeSize = Pages * PAGE_SIZE;
DPRINT("Pages %x, FreeSize %x. Going through segments...\n", Pages, FreeSize);
PULONG FreeListsInUse;
ULONG FreeListsInUseUlong;
SIZE_T AllocationSize;
- SIZE_T Index;
+ SIZE_T Index, InUseIndex, i;
PLIST_ENTRY FreeListHead;
PHEAP_ENTRY InUseEntry;
PHEAP_FREE_ENTRY FreeBlock;
- ULONG InUseIndex, i;
UCHAR FreeFlags;
EXCEPTION_RECORD ExceptionRecord;
BOOLEAN HeapLocked = FALSE;
}
else
{
- UnCommittedPages += (UcrDescriptor->Size / PAGE_SIZE);
+ UnCommittedPages += (ULONG)(UcrDescriptor->Size / PAGE_SIZE);
UnCommittedRanges++;
CurrentEntry = (PHEAP_ENTRY)((PCHAR)UcrDescriptor->Address + UcrDescriptor->Size);
{
ULONG Allocs;
ULONG Frees;
- ULONG Size;
+ SIZE_T Size;
} HEAP_PSEUDO_TAG_ENTRY, *PHEAP_PSEUDO_TAG_ENTRY;
typedef struct _HEAP_COUNTERS
{
- ULONG TotalMemoryReserved;
- ULONG TotalMemoryCommitted;
- ULONG TotalMemoryLargeUCR;
- ULONG TotalSizeInVirtualBlocks;
+ SIZE_T TotalMemoryReserved;
+ SIZE_T TotalMemoryCommitted;
+ SIZE_T TotalMemoryLargeUCR;
+ SIZE_T TotalSizeInVirtualBlocks;
ULONG TotalSegments;
ULONG TotalUCRs;
ULONG CommittOps;
ULONG CompactHeapCalls;
ULONG CompactedUCRs;
ULONG InBlockDeccommits;
- ULONG InBlockDeccomitSize;
+ SIZE_T InBlockDeccomitSize;
} HEAP_COUNTERS, *PHEAP_COUNTERS;
typedef struct _HEAP_TUNING_PARAMETERS
{
ULONG CommittThresholdShift;
- ULONG MaxPreCommittThreshold;
+ SIZE_T MaxPreCommittThreshold;
} HEAP_TUNING_PARAMETERS, *PHEAP_TUNING_PARAMETERS;
typedef struct _HEAP_LIST_LOOKUP
ULONG CompatibilityFlags;
ULONG EncodeFlagMask;
HEAP_ENTRY Encoding;
- ULONG PointerKey;
+ ULONG_PTR PointerKey;
ULONG Interceptor;
ULONG VirtualMemoryThreshold;
ULONG Signature;
- ULONG SegmentReserve;
- ULONG SegmentCommit;
- ULONG DeCommitFreeBlockThreshold;
- ULONG DeCommitTotalFreeThreshold;
- ULONG TotalFreeSize;
- ULONG MaximumAllocationSize;
+ SIZE_T SegmentReserve;
+ SIZE_T SegmentCommit;
+ SIZE_T DeCommitFreeBlockThreshold;
+ SIZE_T DeCommitTotalFreeThreshold;
+ SIZE_T TotalFreeSize;
+ SIZE_T MaximumAllocationSize;
USHORT ProcessHeapsListIndex;
USHORT HeaderValidateLength;
PVOID HeaderValidateCopy;
PHEAP_TAG_ENTRY TagEntries;
LIST_ENTRY UCRList;
LIST_ENTRY UCRSegments; // FIXME: non-Vista
- ULONG AlignRound;
- ULONG AlignMask;
+ ULONG_PTR AlignRound;
+ ULONG_PTR AlignMask;
LIST_ENTRY VirtualAllocdBlocks;
LIST_ENTRY SegmentList;
struct _HEAP_SEGMENT *Segments[HEAP_SEGMENTS]; //FIXME: non-Vista
LIST_ENTRY ListEntry;
LIST_ENTRY SegmentEntry;
PVOID Address;
- ULONG Size;
+ SIZE_T Size;
} HEAP_UCR_DESCRIPTOR, *PHEAP_UCR_DESCRIPTOR;
typedef struct _HEAP_UCR_SEGMENT
{
LIST_ENTRY Entry;
HEAP_ENTRY_EXTRA ExtraStuff;
- ULONG CommitSize;
- ULONG ReserveSize;
+ SIZE_T CommitSize;
+ SIZE_T ReserveSize;
HEAP_ENTRY BusyBlock;
} HEAP_VIRTUAL_ALLOC_ENTRY, *PHEAP_VIRTUAL_ALLOC_ENTRY;
{
ULONG StartStamp;
PVOID Heap;
- ULONG RequestedSize;
- ULONG ActualSize;
+ SIZE_T RequestedSize;
+ SIZE_T ActualSize;
union
{
LIST_ENTRY FreeQueue;
};
PUCHAR pUserAllocation;
PUCHAR pVirtualBlock;
- ULONG nVirtualBlockSize;
- ULONG nVirtualAccessSize;
- ULONG nUserRequestedSize;
- ULONG nUserActualSize;
+ SIZE_T nVirtualBlockSize;
+ SIZE_T nVirtualAccessSize;
+ SIZE_T nUserRequestedSize;
+ SIZE_T nUserActualSize;
PVOID UserValue;
ULONG UserFlags;
PRTL_TRACE_BLOCK StackTrace;
PDPH_HEAP_BLOCK pVirtualStorageListHead;
PDPH_HEAP_BLOCK pVirtualStorageListTail;
ULONG nVirtualStorageRanges;
- ULONG nVirtualStorageBytes;
+ SIZE_T nVirtualStorageBytes;
RTL_AVL_TABLE BusyNodesTable;
PDPH_HEAP_BLOCK NodeToAllocate;
ULONG nBusyAllocations;
- ULONG nBusyAllocationBytesCommitted;
+ SIZE_T nBusyAllocationBytesCommitted;
PDPH_HEAP_BLOCK pFreeAllocationListHead;
PDPH_HEAP_BLOCK pFreeAllocationListTail;
ULONG nFreeAllocations;
- ULONG nFreeAllocationBytesCommitted;
+ SIZE_T nFreeAllocationBytesCommitted;
LIST_ENTRY AvailableAllocationHead;
ULONG nAvailableAllocations;
- ULONG nAvailableAllocationBytesCommitted;
+ SIZE_T nAvailableAllocationBytesCommitted;
PDPH_HEAP_BLOCK pUnusedNodeListHead;
PDPH_HEAP_BLOCK pUnusedNodeListTail;
ULONG nUnusedNodes;
- ULONG nBusyAllocationBytesAccessible;
+ SIZE_T nBusyAllocationBytesAccessible;
PDPH_HEAP_BLOCK pNodePoolListHead;
PDPH_HEAP_BLOCK pNodePoolListTail;
ULONG nNodePools;
- ULONG nNodePoolBytes;
+ SIZE_T nNodePoolBytes;
LIST_ENTRY NextHeap;
ULONG ExtraFlags;
RTL_CRITICAL_SECTION RtlpDphDelayedFreeQueueLock;
LIST_ENTRY RtlpDphDelayedFreeQueue;
SLIST_HEADER RtlpDphDelayedTemporaryPushList;
-ULONG RtlpDphMemoryUsedByDelayedFreeBlocks;
+SIZE_T RtlpDphMemoryUsedByDelayedFreeBlocks;
ULONG RtlpDphNumberOfDelayedFreeBlocks;
/* Counters */
RtlFillMemory(FillPtr, ROUND_UP(FillPtr, PAGE_SIZE) - (ULONG_PTR)FillPtr, DPH_FILL_SUFFIX);
/* FIXME: Check if logging stack traces is turned on */
- //if (DphRoot->ExtraFlags &
+ //if (DphRoot->ExtraFlags &
return TRUE;
}
ULONG NodeCount, i;
//NodeCount = (Size >> 6) - 1;
- NodeCount = (Size / sizeof(DPH_HEAP_BLOCK));
+ NodeCount = (ULONG)(Size / sizeof(DPH_HEAP_BLOCK));
DphStartNode = Virtual;
/* Set pNextAlloc for all blocks */
PDPH_HEAP_ROOT DphRoot;
PDPH_HEAP_BLOCK Node = NULL, AllocatedNode;
BOOLEAN Biased = FALSE, UseNormalHeap = FALSE, OldBlockPageHeap = TRUE;
- ULONG DataSize, ValidationInfo;
+ ULONG ValidationInfo;
+ SIZE_T DataSize;
PVOID NewAlloc = NULL;
/* Check requested size */
IN PVOID Context,
IN PVOID Environment)
{
- ULONG InfoLength, Length, c;
- LONG RequiredLength, SpareLength;
+ ULONG InfoLength;
+ SIZE_T Length, SpareLength, c;
+ LONG RequiredLength;
PCHAR SpareData, DataEnd;
ULONG Type;
PWCHAR Name, p, ValueEnd;
if (SpareLength < RequiredLength)
{
/* Fail and return the missing length */
- *InfoSize = SpareData - (PCHAR)KeyValueInfo + RequiredLength;
+ *InfoSize = (ULONG)(SpareData - (PCHAR)KeyValueInfo) + RequiredLength;
return STATUS_BUFFER_TOO_SMALL;
}
/* Do the query */
Status = RtlpQueryRegistryDirect(REG_SZ,
Data,
- Length,
+ (ULONG)Length,
QueryTable->EntryContext);
QueryTable->EntryContext = (PVOID)((ULONG_PTR)QueryTable->
EntryContext +
Status = QueryTable->QueryRoutine(Name,
REG_SZ,
Data,
- Length,
+ (ULONG)Length,
Context,
QueryTable->EntryContext);
}
if (FoundExpander)
{
/* Setup the source string */
- RtlInitEmptyUnicodeString(&Source, Data, Length);
+ RtlInitEmptyUnicodeString(&Source, Data, (USHORT)Length);
Source.Length = Source.MaximumLength - sizeof(UNICODE_NULL);
/* Setup the desination string */
else if (SpareLength <= MAXUSHORT)
{
/* This is the good case, where we fit into a string */
- Destination.MaximumLength = SpareLength;
+ Destination.MaximumLength = (USHORT)SpareLength;
Destination.Buffer[SpareLength / 2 - 1] = UNICODE_NULL;
}
else
if (Status == STATUS_BUFFER_TOO_SMALL)
{
/* Set the required missing length */
- *InfoSize = SpareData -
- (PCHAR)KeyValueInfo +
- RequiredLength;
+ *InfoSize = (ULONG)(SpareData - (PCHAR)KeyValueInfo) +
+ RequiredLength;
/* Notify debugger */
DPRINT1("RTL: Expand variables for %wZ failed - "
/* Return the data */
Status = RtlpQueryRegistryDirect(Type,
Data,
- Length,
+ (ULONG)Length,
QueryTable->EntryContext);
}
else
Status = QueryTable->QueryRoutine(Name,
Type,
Data,
- Length,
+ (ULONG)Length,
Context,
QueryTable->EntryContext);
}
/* Initialize a string */
RtlInitEmptyUnicodeString(KeyPath,
RtlpAllocateStringMemory(Length, TAG_USTR),
- Length);
+ (USHORT)Length);
if (!KeyPath->Buffer)
{
/* Free the string and fail */
if (KeyInfo->NameLength <= SubKeyName->MaximumLength)
{
/* Set the length */
- SubKeyName->Length = KeyInfo->NameLength;
+ SubKeyName->Length = (USHORT)KeyInfo->NameLength;
/* Copy it */
RtlMoveMemory(SubKeyName->Buffer,
&KeyValueName,
KeyValueFullInformation,
KeyValueInfo,
- InfoSize,
+ (ULONG)InfoSize,
&ResultLength);
if (Status == STATUS_BUFFER_OVERFLOW)
{
/* Setup a default */
KeyValueInfo->Type = REG_NONE;
KeyValueInfo->DataLength = 0;
- ResultLength = InfoSize;
+ ResultLength = (ULONG)InfoSize;
/* Call the query routine */
Status = RtlpCallQueryRegistryRoutine(QueryTable,
}
/* Call the query routine */
- ResultLength = InfoSize;
+ ResultLength = (ULONG)InfoSize;
Status = RtlpCallQueryRegistryRoutine(QueryTable,
KeyValueInfo,
&ResultLength,
Value,
KeyValueFullInformation,
KeyValueInfo,
- InfoSize,
+ (ULONG)InfoSize,
&ResultLength);
if (Status == STATUS_BUFFER_OVERFLOW)
{
if (NT_SUCCESS(Status))
{
/* Call the query routine */
- ResultLength = InfoSize;
+ ResultLength = (ULONG)InfoSize;
Status = RtlpCallQueryRegistryRoutine(QueryTable,
KeyValueInfo,
&ResultLength,
PVOID
NTAPI
RtlpAllocateMemory(
- ULONG Bytes,
+ SIZE_T Bytes,
ULONG Tag);
VOID
/* There are no wait blocks so far, we need to add ourselves as the first
wait block. We need to keep the shared count! */
StackWaitBlock.Exclusive = TRUE;
- StackWaitBlock.SharedCount = CurrentValue >> RTL_SRWLOCK_BITS;
+ StackWaitBlock.SharedCount = (LONG)(CurrentValue >> RTL_SRWLOCK_BITS);
StackWaitBlock.Next = NULL;
StackWaitBlock.Last = &StackWaitBlock;
StackWaitBlock.Wake = 0;
if (t->expire != EXPIRE_NEVER)
{
ULONGLONG time = queue_current_time();
- timeout = t->expire < time ? 0 : t->expire - time;
+ timeout = t->expire < time ? 0 : (ULONG)(t->expire - time);
}
}
RtlLeaveCriticalSection(&q->cs);
NTSTATUS NTAPI
RtlSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
{
- ULONG Length;
+ SIZE_T Length;
NTSTATUS Status;
DPRINT("RtlSetTimeZoneInformation()\n");
L"Standard Name",
REG_SZ,
TimeZoneInformation->StandardName,
- Length);
+ (ULONG)Length);
if (!NT_SUCCESS(Status))
{
return Status;
L"Daylight Name",
REG_SZ,
TimeZoneInformation->DaylightName,
- Length);
+ (ULONG)Length);
if (!NT_SUCCESS(Status))
{
return Status;