diff --git a/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c b/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c index 14b4a2e062c..68d8569b189 100644 --- a/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c +++ b/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c @@ -145,10 +145,10 @@ MempIsPageMapped(PVOID VirtualAddress) return TRUE; } -ULONG -MempMapRangeOfPages(ULONG64 VirtualAddress, ULONG64 PhysicalAddress, ULONG cPages) +PFN_NUMBER +MempMapRangeOfPages(ULONG64 VirtualAddress, ULONG64 PhysicalAddress, PFN_NUMBER cPages) { - ULONG i; + PFN_NUMBER i; for (i = 0; i < cPages; i++) { @@ -165,8 +165,8 @@ MempMapRangeOfPages(ULONG64 VirtualAddress, ULONG64 PhysicalAddress, ULONG cPage } BOOLEAN -MempSetupPaging(IN ULONG StartPage, - IN ULONG NumberOfPages, +MempSetupPaging(IN PFN_NUMBER StartPage, + IN PFN_NUMBER NumberOfPages, IN BOOLEAN KernelMapping) { TRACE(">>> MempSetupPaging(0x%lx, %ld, %p)\n", @@ -196,7 +196,7 @@ MempSetupPaging(IN ULONG StartPage, } VOID -MempUnmapPage(ULONG Page) +MempUnmapPage(PFN_NUMBER Page) { // TRACE(">>> MempUnmapPage\n"); } diff --git a/reactos/boot/freeldr/freeldr/arch/arm/winldr.c b/reactos/boot/freeldr/freeldr/arch/arm/winldr.c index 37356a4107f..8301f10eae6 100644 --- a/reactos/boot/freeldr/freeldr/arch/arm/winldr.c +++ b/reactos/boot/freeldr/freeldr/arch/arm/winldr.c @@ -80,14 +80,14 @@ PKPDR_PAGE PdrPage; /* FUNCTIONS **************************************************************/ BOOLEAN -MempSetupPaging(IN ULONG StartPage, - IN ULONG NumberOfPages) +MempSetupPaging(IN PFN_NUMBER StartPage, + IN PFN_COUNT NumberOfPages) { return TRUE; } VOID -MempUnmapPage(IN ULONG Page) +MempUnmapPage(IN PFN_NUMBER Page) { return; } diff --git a/reactos/boot/freeldr/freeldr/arch/i386/pcvideo.c b/reactos/boot/freeldr/freeldr/arch/i386/pcvideo.c index c571097d541..b481dd4ec0d 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/pcvideo.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/pcvideo.c @@ -416,7 +416,7 @@ PcVideoSet480ScanLines(VOID) CRTC = (CRTC | 0xE2); /* (write) */ - WRITE_PORT_UCHAR((PUCHAR)0x03C2, CRTC); + WRITE_PORT_UCHAR((PUCHAR)0x03C2, (UCHAR)CRTC); } static VOID diff --git a/reactos/boot/freeldr/freeldr/arch/i386/winldr.c b/reactos/boot/freeldr/freeldr/arch/i386/winldr.c index cb94d0b4ead..2bb5979f0ed 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/winldr.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/winldr.c @@ -143,13 +143,13 @@ MempAllocatePTE(ULONG Entry, PHARDWARE_PTE *PhysicalPT, PHARDWARE_PTE *KernelPT) } BOOLEAN -MempSetupPaging(IN ULONG StartPage, - IN ULONG NumberOfPages, +MempSetupPaging(IN PFN_NUMBER StartPage, + IN PFN_COUNT NumberOfPages, IN BOOLEAN KernelMapping) { PHARDWARE_PTE PhysicalPT; PHARDWARE_PTE KernelPT; - ULONG Entry, Page; + PFN_COUNT Entry, Page; TRACE("MempSetupPaging: SP 0x%X, Number: 0x%X, Kernel: %s\n", StartPage, NumberOfPages, KernelMapping ? "yes" : "no"); @@ -199,10 +199,10 @@ MempSetupPaging(IN ULONG StartPage, } VOID -MempUnmapPage(ULONG Page) +MempUnmapPage(PFN_NUMBER Page) { PHARDWARE_PTE KernelPT; - ULONG Entry = (Page >> 10) + (KSEG0_BASE >> 22); + PFN_NUMBER Entry = (Page >> 10) + (KSEG0_BASE >> 22); /* Don't unmap hyperspace or HAL entries */ if (Entry == HYPER_SPACE_ENTRY || Entry == 1023) diff --git a/reactos/boot/freeldr/freeldr/cache/blocklist.c b/reactos/boot/freeldr/freeldr/cache/blocklist.c index 67c648df1cb..ffe82b4f352 100644 --- a/reactos/boot/freeldr/freeldr/cache/blocklist.c +++ b/reactos/boot/freeldr/freeldr/cache/blocklist.c @@ -175,7 +175,7 @@ BOOLEAN CacheInternalFreeBlock(PCACHE_DRIVE CacheDrive) VOID CacheInternalCheckCacheSizeLimits(PCACHE_DRIVE CacheDrive) { - ULONG NewCacheSize; + SIZE_T NewCacheSize; TRACE("CacheInternalCheckCacheSizeLimits()\n"); diff --git a/reactos/boot/freeldr/freeldr/cache/cache.c b/reactos/boot/freeldr/freeldr/cache/cache.c index dc2342577d2..ac547a772da 100644 --- a/reactos/boot/freeldr/freeldr/cache/cache.c +++ b/reactos/boot/freeldr/freeldr/cache/cache.c @@ -31,8 +31,8 @@ CACHE_DRIVE CacheManagerDrive; BOOLEAN CacheManagerInitialized = FALSE; BOOLEAN CacheManagerDataInvalid = FALSE; ULONG CacheBlockCount = 0; -ULONG CacheSizeLimit = 0; -ULONG CacheSizeCurrent = 0; +SIZE_T CacheSizeLimit = 0; +SIZE_T CacheSizeCurrent = 0; BOOLEAN CacheInitializeDrive(UCHAR DriveNumber) { diff --git a/reactos/boot/freeldr/freeldr/fs/fs.c b/reactos/boot/freeldr/freeldr/fs/fs.c index 34527e9458e..6692115acd8 100644 --- a/reactos/boot/freeldr/freeldr/fs/fs.c +++ b/reactos/boot/freeldr/freeldr/fs/fs.c @@ -248,14 +248,14 @@ LONG ArcGetFileInformation(ULONG FileId, FILEINFORMATION* Information) LONG ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) { - ULONG i, ret; + ULONG Count, i, ret; PLIST_ENTRY pEntry; DEVICE* pDevice; CHAR* DeviceName; CHAR* FileName; CHAR* p; CHAR* q; - ULONG dwCount, dwLength; + SIZE_T Length; OPENMODE DeviceOpenMode; ULONG DeviceId; @@ -271,16 +271,16 @@ LONG ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) FileName++; /* Count number of "()", which needs to be replaced by "(0)" */ - dwCount = 0; + Count = 0; for (p = Path; p != FileName; p++) if (*p == '(' && *(p + 1) == ')') - dwCount++; + Count++; /* Duplicate device name, and replace "()" by "(0)" (if required) */ - dwLength = FileName - Path + dwCount; - if (dwCount != 0) + Length = FileName - Path + Count; + if (Count != 0) { - DeviceName = MmHeapAlloc(FileName - Path + dwCount); + DeviceName = MmHeapAlloc(FileName - Path + Count); if (!DeviceName) return ENOMEM; for (p = Path, q = DeviceName; p != FileName; p++) @@ -302,7 +302,7 @@ LONG ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) while (pEntry != &DeviceListHead) { pDevice = CONTAINING_RECORD(pEntry, DEVICE, ListEntry); - if (strncmp(pDevice->Prefix, DeviceName, dwLength) == 0) + if (strncmp(pDevice->Prefix, DeviceName, Length) == 0) { /* OK, device found. It is already opened? */ if (pDevice->ReferenceCount == 0) @@ -412,18 +412,18 @@ LONG ArcSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode) VOID FsRegisterDevice(CHAR* Prefix, const DEVVTBL* FuncTable) { DEVICE* pNewEntry; - ULONG dwLength; + SIZE_T Length; TRACE("FsRegisterDevice() Prefix = %s\n", Prefix); - dwLength = strlen(Prefix) + 1; - pNewEntry = MmHeapAlloc(sizeof(DEVICE) + dwLength); + Length = strlen(Prefix) + 1; + pNewEntry = MmHeapAlloc(sizeof(DEVICE) + Length); if (!pNewEntry) return; pNewEntry->FuncTable = FuncTable; pNewEntry->ReferenceCount = 0; pNewEntry->Prefix = (CHAR*)(pNewEntry + 1); - memcpy(pNewEntry->Prefix, Prefix, dwLength); + memcpy(pNewEntry->Prefix, Prefix, Length); InsertHeadList(&DeviceListHead, &pNewEntry->ListEntry); } diff --git a/reactos/boot/freeldr/freeldr/include/cache.h b/reactos/boot/freeldr/freeldr/include/cache.h index ecc02acac5f..ae6c7707e9b 100644 --- a/reactos/boot/freeldr/freeldr/include/cache.h +++ b/reactos/boot/freeldr/freeldr/include/cache.h @@ -67,8 +67,8 @@ typedef struct extern CACHE_DRIVE CacheManagerDrive; extern BOOLEAN CacheManagerInitialized; extern ULONG CacheBlockCount; -extern ULONG CacheSizeLimit; -extern ULONG CacheSizeCurrent; +extern SIZE_T CacheSizeLimit; +extern SIZE_T CacheSizeCurrent; /////////////////////////////////////////////////////////////////////////////////////// // diff --git a/reactos/boot/freeldr/freeldr/include/mm.h b/reactos/boot/freeldr/freeldr/include/mm.h index c9068e1c6d7..a453a284770 100644 --- a/reactos/boot/freeldr/freeldr/include/mm.h +++ b/reactos/boot/freeldr/freeldr/include/mm.h @@ -60,7 +60,7 @@ typedef struct _FREELDR_MEMORY_DESCRIPTOR typedef struct { TYPE_OF_MEMORY PageAllocated; // Type of allocated memory (LoaderFree if this memory is free) - ULONG PageAllocationLength; // Number of pages allocated (or zero if this isn't the first page in the chain) + PFN_NUMBER PageAllocationLength; // Number of pages allocated (or zero if this isn't the first page in the chain) } PAGE_LOOKUP_TABLE_ITEM, *PPAGE_LOOKUP_TABLE_ITEM; #include @@ -72,38 +72,38 @@ typedef struct #define DUMP_MEM_MAP_ON_VERIFY 0 extern PVOID PageLookupTableAddress; -extern ULONG TotalPagesInLookupTable; -extern ULONG FreePagesInLookupTable; -extern ULONG LastFreePageHint; +extern PFN_NUMBER TotalPagesInLookupTable; +extern PFN_NUMBER FreePagesInLookupTable; +extern PFN_NUMBER LastFreePageHint; #if DBG PCSTR MmGetSystemMemoryMapTypeString(TYPE_OF_MEMORY Type); #endif -ULONG MmGetPageNumberFromAddress(PVOID Address); // Returns the page number that contains a linear address -ULONG MmGetAddressablePageCountIncludingHoles(VOID); // Returns the count of addressable pages from address zero including any memory holes and reserved memory regions -PVOID MmFindLocationForPageLookupTable(ULONG TotalPageCount); // Returns the address for a memory chunk big enough to hold the page lookup table (starts search from end of memory) -VOID MmInitPageLookupTable(PVOID PageLookupTable, ULONG TotalPageCount); // Inits the page lookup table according to the memory types in the memory map -VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount, TYPE_OF_MEMORY PageAllocated); // Marks the specified pages as allocated or free in the lookup table -VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount, TYPE_OF_MEMORY MemoryType); // Allocates the specified pages in the lookup table -ULONG MmCountFreePagesInLookupTable(PVOID PageLookupTable, ULONG TotalPageCount); // Returns the number of free pages in the lookup table -ULONG MmFindAvailablePages(PVOID PageLookupTable, ULONG TotalPageCount, ULONG PagesNeeded, BOOLEAN FromEnd); // Returns the page number of the first available page range from the beginning or end of memory -ULONG MmFindAvailablePagesBeforePage(PVOID PageLookupTable, ULONG TotalPageCount, ULONG PagesNeeded, ULONG LastPage); // Returns the page number of the first available page range before the specified page -VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, ULONG TotalPageCount); // Sets the LastFreePageHint to the last usable page of memory -BOOLEAN MmAreMemoryPagesAvailable(PVOID PageLookupTable, ULONG TotalPageCount, PVOID PageAddress, ULONG PageCount); // Returns TRUE if the specified pages of memory are available, otherwise FALSE -VOID MmSetMemoryType(PVOID MemoryAddress, ULONG MemorySize, TYPE_OF_MEMORY NewType); // Use with EXTREME caution! +PFN_NUMBER MmGetPageNumberFromAddress(PVOID Address); // Returns the page number that contains a linear address +PFN_NUMBER MmGetAddressablePageCountIncludingHoles(VOID); // Returns the count of addressable pages from address zero including any memory holes and reserved memory regions +PVOID MmFindLocationForPageLookupTable(PFN_NUMBER TotalPageCount); // Returns the address for a memory chunk big enough to hold the page lookup table (starts search from end of memory) +VOID MmInitPageLookupTable(PVOID PageLookupTable, PFN_NUMBER TotalPageCount); // Inits the page lookup table according to the memory types in the memory map +VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, PFN_NUMBER StartPage, PFN_NUMBER PageCount, TYPE_OF_MEMORY PageAllocated); // Marks the specified pages as allocated or free in the lookup table +VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, PFN_NUMBER StartPage, PFN_NUMBER PageCount, TYPE_OF_MEMORY MemoryType); // Allocates the specified pages in the lookup table +PFN_NUMBER MmCountFreePagesInLookupTable(PVOID PageLookupTable, PFN_NUMBER TotalPageCount); // Returns the number of free pages in the lookup table +PFN_NUMBER MmFindAvailablePages(PVOID PageLookupTable, PFN_NUMBER TotalPageCount, PFN_NUMBER PagesNeeded, BOOLEAN FromEnd); // Returns the page number of the first available page range from the beginning or end of memory +PFN_NUMBER MmFindAvailablePagesBeforePage(PVOID PageLookupTable, PFN_NUMBER TotalPageCount, PFN_NUMBER PagesNeeded, PFN_NUMBER LastPage); // Returns the page number of the first available page range before the specified page +VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, PFN_NUMBER TotalPageCount); // Sets the LastFreePageHint to the last usable page of memory +BOOLEAN MmAreMemoryPagesAvailable(PVOID PageLookupTable, PFN_NUMBER TotalPageCount, PVOID PageAddress, PFN_NUMBER PageCount); // Returns TRUE if the specified pages of memory are available, otherwise FALSE +VOID MmSetMemoryType(PVOID MemoryAddress, SIZE_T MemorySize, TYPE_OF_MEMORY NewType); // Use with EXTREME caution! -PPAGE_LOOKUP_TABLE_ITEM MmGetMemoryMap(ULONG *NoEntries); // Returns a pointer to the memory mapping table and a number of entries in it +PPAGE_LOOKUP_TABLE_ITEM MmGetMemoryMap(PFN_NUMBER *NoEntries); // Returns a pointer to the memory mapping table and a number of entries in it //BOOLEAN MmInitializeMemoryManager(ULONG LowMemoryStart, ULONG LowMemoryLength); BOOLEAN MmInitializeMemoryManager(VOID); VOID MmInitializeHeap(PVOID PageLookupTable); -PVOID MmAllocateMemory(ULONG MemorySize); -PVOID MmAllocateMemoryWithType(ULONG MemorySize, TYPE_OF_MEMORY MemoryType); +PVOID MmAllocateMemory(SIZE_T MemorySize); +PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType); VOID MmFreeMemory(PVOID MemoryPointer); -PVOID MmAllocateMemoryAtAddress(ULONG MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType); -PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType); +PVOID MmAllocateMemoryAtAddress(SIZE_T MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType); +PVOID MmAllocateHighestMemoryBelowAddress(SIZE_T MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType); PVOID MmHeapAlloc(SIZE_T MemorySize); VOID MmHeapFree(PVOID MemoryPointer); @@ -114,7 +114,7 @@ extern PVOID FrLdrTempHeap; PVOID HeapCreate( - ULONG MaximumSize, + SIZE_T MaximumSize, TYPE_OF_MEMORY MemoryType); VOID diff --git a/reactos/boot/freeldr/freeldr/include/winldr.h b/reactos/boot/freeldr/freeldr/include/winldr.h index 84bfa377353..58e0057f374 100644 --- a/reactos/boot/freeldr/freeldr/include/winldr.h +++ b/reactos/boot/freeldr/freeldr/include/winldr.h @@ -162,12 +162,12 @@ BOOLEAN MempAllocatePageTables(); BOOLEAN -MempSetupPaging(IN ULONG StartPage, - IN ULONG NumberOfPages, +MempSetupPaging(IN PFN_NUMBER StartPage, + IN PFN_NUMBER NumberOfPages, IN BOOLEAN KernelMapping); VOID -MempUnmapPage(ULONG Page); +MempUnmapPage(PFN_NUMBER Page); VOID MempDump(); diff --git a/reactos/boot/freeldr/freeldr/inifile/parse.c b/reactos/boot/freeldr/freeldr/inifile/parse.c index d1937eec12d..8af3080f57f 100644 --- a/reactos/boot/freeldr/freeldr/inifile/parse.c +++ b/reactos/boot/freeldr/freeldr/inifile/parse.c @@ -73,7 +73,7 @@ BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize) // Get the line of data CurrentOffset = IniGetNextLine(IniFileData, IniFileSize, IniFileLine, IniFileLineSize, CurrentOffset); - LineLength = strlen(IniFileLine); + LineLength = (ULONG)strlen(IniFileLine); // If it is a blank line or a comment then skip it if (IniIsLineEmpty(IniFileLine, LineLength) || IniIsCommentLine(IniFileLine, LineLength)) diff --git a/reactos/boot/freeldr/freeldr/mm/heap.c b/reactos/boot/freeldr/freeldr/mm/heap.c index e3a89f22754..07a083bad69 100644 --- a/reactos/boot/freeldr/freeldr/mm/heap.c +++ b/reactos/boot/freeldr/freeldr/mm/heap.c @@ -30,8 +30,8 @@ PVOID FrLdrTempHeap; typedef struct _BLOCK_DATA { - ULONG Flink; - ULONG Blink; + ULONG_PTR Flink; + ULONG_PTR Blink; } BLOCK_DATA, *PBLOCK_DATA; typedef struct _HEAP_BLOCK @@ -44,26 +44,26 @@ typedef struct _HEAP_BLOCK typedef struct _HEAP { - ULONG MaximumSize; - ULONG CurrentAllocBytes; - ULONG MaxAllocBytes; + SIZE_T MaximumSize; + SIZE_T CurrentAllocBytes; + SIZE_T MaxAllocBytes; ULONG NumAllocs; ULONG NumFrees; - ULONG LargestAllocation; + SIZE_T LargestAllocation; ULONGLONG AllocationTime; ULONGLONG FreeTime; - ULONG TerminatingBlock; + ULONG_PTR TerminatingBlock; HEAP_BLOCK Blocks; } HEAP, *PHEAP; PVOID HeapCreate( - ULONG MaximumSize, + SIZE_T MaximumSize, TYPE_OF_MEMORY MemoryType) { PHEAP Heap; PHEAP_BLOCK Block; - ULONG Remaining; + SIZE_T Remaining; USHORT PreviousSize; TRACE("HeapCreate(MemoryType=%ld)\n", MemoryType); @@ -136,7 +136,7 @@ HeapDestroy( /* Mark all pages as firmware temporary, so they are free for the kernel */ MmMarkPagesInLookupTable(PageLookupTableAddress, (ULONG_PTR)Heap / MM_PAGE_SIZE, - Heap->MaximumSize / MM_PAGE_SIZE, + (PFN_COUNT)(Heap->MaximumSize / MM_PAGE_SIZE), LoaderFirmwareTemporary); } @@ -147,7 +147,7 @@ HeapRelease( PHEAP Heap = HeapHandle; PHEAP_BLOCK Block; PUCHAR StartAddress, EndAddress; - ULONG FreePages, AllFreePages = 0; + PFN_COUNT FreePages, AllFreePages = 0; TRACE("HeapRelease(%p)\n", HeapHandle); /* Loop all heap chunks */ @@ -176,7 +176,7 @@ HeapRelease( EndAddress = ALIGN_DOWN_POINTER_BY(Block->Data, PAGE_SIZE); } - FreePages = (EndAddress - StartAddress) / MM_PAGE_SIZE; + FreePages = (PFN_COUNT)((EndAddress - StartAddress) / MM_PAGE_SIZE); AllFreePages += FreePages; /* Now mark the pages free */ @@ -449,7 +449,7 @@ MmInitializeHeap(PVOID PageLookupTable) } PVOID -MmHeapAlloc(ULONG MemorySize) +MmHeapAlloc(SIZE_T MemorySize) { return HeapAllocate(FrLdrDefaultHeap, MemorySize, 'pHmM'); } diff --git a/reactos/boot/freeldr/freeldr/mm/meminit.c b/reactos/boot/freeldr/freeldr/mm/meminit.c index d818218d970..7794f6f1639 100644 --- a/reactos/boot/freeldr/freeldr/mm/meminit.c +++ b/reactos/boot/freeldr/freeldr/mm/meminit.c @@ -53,11 +53,11 @@ ULONG MemoryTypeCount = sizeof(MemoryTypeArray) / sizeof(MemoryTypeArray[0]); #endif PVOID PageLookupTableAddress = NULL; -ULONG TotalPagesInLookupTable = 0; -ULONG FreePagesInLookupTable = 0; -ULONG LastFreePageHint = 0; -ULONG MmLowestPhysicalPage = 0xFFFFFFFF; -ULONG MmHighestPhysicalPage = 0; +PFN_NUMBER TotalPagesInLookupTable = 0; +PFN_NUMBER FreePagesInLookupTable = 0; +PFN_NUMBER LastFreePageHint = 0; +PFN_NUMBER MmLowestPhysicalPage = 0xFFFFFFFF; +PFN_NUMBER MmHighestPhysicalPage = 0; PFREELDR_MEMORY_DESCRIPTOR BiosMemoryMap; ULONG BiosMemoryMapEntryCount; @@ -232,15 +232,15 @@ PCSTR MmGetSystemMemoryMapTypeString(TYPE_OF_MEMORY Type) } #endif -ULONG MmGetPageNumberFromAddress(PVOID Address) +PFN_NUMBER MmGetPageNumberFromAddress(PVOID Address) { return ((ULONG_PTR)Address) / MM_PAGE_SIZE; } -ULONG MmGetAddressablePageCountIncludingHoles(VOID) +PFN_NUMBER MmGetAddressablePageCountIncludingHoles(VOID) { const FREELDR_MEMORY_DESCRIPTOR* MemoryDescriptor = NULL; - ULONG PageCount; + PFN_NUMBER PageCount; // // Go through the whole memory map to get max address @@ -277,12 +277,12 @@ ULONG MmGetAddressablePageCountIncludingHoles(VOID) return PageCount; } -PVOID MmFindLocationForPageLookupTable(ULONG TotalPageCount) +PVOID MmFindLocationForPageLookupTable(PFN_NUMBER TotalPageCount) { const FREELDR_MEMORY_DESCRIPTOR* MemoryDescriptor = NULL; - ULONG PageLookupTableSize; - ULONG PageLookupTablePages; - ULONG PageLookupTableStartPage = 0; + SIZE_T PageLookupTableSize; + PFN_NUMBER PageLookupTablePages; + PFN_NUMBER PageLookupTableStartPage = 0; PVOID PageLookupTableMemAddress = NULL; // Calculate how much pages we need to keep the page lookup table @@ -316,11 +316,11 @@ PVOID MmFindLocationForPageLookupTable(ULONG TotalPageCount) return PageLookupTableMemAddress; } -VOID MmInitPageLookupTable(PVOID PageLookupTable, ULONG TotalPageCount) +VOID MmInitPageLookupTable(PVOID PageLookupTable, PFN_NUMBER TotalPageCount) { const FREELDR_MEMORY_DESCRIPTOR* MemoryDescriptor = NULL; - ULONG PageLookupTableStartPage; - ULONG PageLookupTablePageCount; + PFN_NUMBER PageLookupTableStartPage; + PFN_NUMBER PageLookupTablePageCount; TRACE("MmInitPageLookupTable()\n"); @@ -359,10 +359,10 @@ VOID MmInitPageLookupTable(PVOID PageLookupTable, ULONG TotalPageCount) MmMarkPagesInLookupTable(PageLookupTable, PageLookupTableStartPage, PageLookupTablePageCount, LoaderFirmwareTemporary); } -VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount, TYPE_OF_MEMORY PageAllocated) +VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, PFN_NUMBER StartPage, PFN_NUMBER PageCount, TYPE_OF_MEMORY PageAllocated) { - PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable; - ULONG Index; + PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable; + PFN_NUMBER Index; TRACE("MmMarkPagesInLookupTable()\n"); /* Validate the range */ @@ -389,10 +389,10 @@ VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG Page TRACE("MmMarkPagesInLookupTable() Done\n"); } -VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount, TYPE_OF_MEMORY MemoryType) +VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, PFN_NUMBER StartPage, PFN_NUMBER PageCount, TYPE_OF_MEMORY MemoryType) { PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable; - ULONG Index; + PFN_NUMBER Index; StartPage -= MmLowestPhysicalPage; for (Index=StartPage; Index<(StartPage+PageCount); Index++) @@ -402,11 +402,11 @@ VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG } } -ULONG MmCountFreePagesInLookupTable(PVOID PageLookupTable, ULONG TotalPageCount) +PFN_NUMBER MmCountFreePagesInLookupTable(PVOID PageLookupTable, PFN_NUMBER TotalPageCount) { PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable; - ULONG Index; - ULONG FreePageCount; + PFN_NUMBER Index; + PFN_NUMBER FreePageCount; FreePageCount = 0; for (Index=0; Index TotalPageCount) { @@ -479,11 +479,11 @@ ULONG MmFindAvailablePages(PVOID PageLookupTable, ULONG TotalPageCount, ULONG Pa return 0; } -ULONG MmFindAvailablePagesBeforePage(PVOID PageLookupTable, ULONG TotalPageCount, ULONG PagesNeeded, ULONG LastPage) +PFN_NUMBER MmFindAvailablePagesBeforePage(PVOID PageLookupTable, PFN_NUMBER TotalPageCount, PFN_NUMBER PagesNeeded, PFN_NUMBER LastPage) { PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable; - ULONG AvailablePagesSoFar; - ULONG Index; + PFN_NUMBER AvailablePagesSoFar; + PFN_NUMBER Index; if (LastPage > TotalPageCount) { @@ -512,10 +512,10 @@ ULONG MmFindAvailablePagesBeforePage(PVOID PageLookupTable, ULONG TotalPageCount return 0; } -VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, ULONG TotalPageCount) +VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, PFN_NUMBER TotalPageCount) { PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable; - ULONG Index; + PFN_NUMBER Index; for (Index=TotalPageCount-1; Index>0; Index--) { @@ -527,11 +527,11 @@ VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, ULONG TotalPageCount) } } -BOOLEAN MmAreMemoryPagesAvailable(PVOID PageLookupTable, ULONG TotalPageCount, PVOID PageAddress, ULONG PageCount) +BOOLEAN MmAreMemoryPagesAvailable(PVOID PageLookupTable, PFN_NUMBER TotalPageCount, PVOID PageAddress, PFN_NUMBER PageCount) { PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable; - ULONG StartPage; - ULONG Index; + PFN_NUMBER StartPage; + PFN_NUMBER Index; StartPage = MmGetPageNumberFromAddress(PageAddress); diff --git a/reactos/boot/freeldr/freeldr/mm/mm.c b/reactos/boot/freeldr/freeldr/mm/mm.c index bf1b2063f25..cad4860d15f 100644 --- a/reactos/boot/freeldr/freeldr/mm/mm.c +++ b/reactos/boot/freeldr/freeldr/mm/mm.c @@ -27,12 +27,12 @@ VOID MemAllocTest(VOID); DBG_DEFAULT_CHANNEL(MEMORY); -ULONG LoaderPagesSpanned = 0; +PFN_NUMBER LoaderPagesSpanned = 0; -PVOID MmAllocateMemoryWithType(ULONG MemorySize, TYPE_OF_MEMORY MemoryType) +PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType) { - ULONG PagesNeeded; - ULONG FirstFreePageFromEnd; + PFN_NUMBER PagesNeeded; + PFN_NUMBER FirstFreePageFromEnd; PVOID MemPointer; if (MemorySize == 0) @@ -83,10 +83,10 @@ PVOID MmAllocateMemoryWithType(ULONG MemorySize, TYPE_OF_MEMORY MemoryType) return MemPointer; } -PVOID MmAllocateMemoryAtAddress(ULONG MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType) +PVOID MmAllocateMemoryAtAddress(SIZE_T MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType) { - ULONG PagesNeeded; - ULONG StartPageNumber; + PFN_NUMBER PagesNeeded; + PFN_NUMBER StartPageNumber; PVOID MemPointer; if (MemorySize == 0) @@ -142,10 +142,10 @@ PVOID MmAllocateMemoryAtAddress(ULONG MemorySize, PVOID DesiredAddress, TYPE_OF_ return MemPointer; } -VOID MmSetMemoryType(PVOID MemoryAddress, ULONG MemorySize, TYPE_OF_MEMORY NewType) +VOID MmSetMemoryType(PVOID MemoryAddress, SIZE_T MemorySize, TYPE_OF_MEMORY NewType) { - ULONG PagesNeeded; - ULONG StartPageNumber; + PFN_NUMBER PagesNeeded; + PFN_NUMBER StartPageNumber; // Find out how many blocks it will take to // satisfy this allocation @@ -158,11 +158,11 @@ VOID MmSetMemoryType(PVOID MemoryAddress, ULONG MemorySize, TYPE_OF_MEMORY NewTy MmAllocatePagesInLookupTable(PageLookupTableAddress, StartPageNumber, PagesNeeded, NewType); } -PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType) +PVOID MmAllocateHighestMemoryBelowAddress(SIZE_T MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType) { - ULONG PagesNeeded; - ULONG FirstFreePageFromEnd; - ULONG DesiredAddressPageNumber; + PFN_NUMBER PagesNeeded; + PFN_NUMBER FirstFreePageFromEnd; + PFN_NUMBER DesiredAddressPageNumber; PVOID MemPointer; if (MemorySize == 0) @@ -221,7 +221,7 @@ VOID MmFreeMemory(PVOID MemoryPointer) VOID DumpMemoryAllocMap(VOID) { - ULONG Idx; + PFN_NUMBER Idx; PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTableAddress; DbgPrint("----------- Memory Allocation Bitmap -----------\n"); @@ -295,7 +295,7 @@ VOID DumpMemoryAllocMap(VOID) } #endif // DBG -PPAGE_LOOKUP_TABLE_ITEM MmGetMemoryMap(ULONG *NoEntries) +PPAGE_LOOKUP_TABLE_ITEM MmGetMemoryMap(PFN_NUMBER *NoEntries) { PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTableAddress; diff --git a/reactos/boot/freeldr/freeldr/reactos/archwsup.c b/reactos/boot/freeldr/freeldr/reactos/archwsup.c index 5abf4d02f7c..31291d8ad60 100644 --- a/reactos/boot/freeldr/freeldr/reactos/archwsup.c +++ b/reactos/boot/freeldr/freeldr/reactos/archwsup.c @@ -15,7 +15,7 @@ /* GLOBALS ********************************************************************/ extern CHAR reactos_arc_hardware_data[]; -ULONG FldrpHwHeapLocation; +SIZE_T FldrpHwHeapLocation; PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot; BOOLEAN UseRealHeap = FALSE; @@ -30,7 +30,7 @@ FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData, PVOID NTAPI -FldrpHwHeapAlloc(IN ULONG Size) +FldrpHwHeapAlloc(IN SIZE_T Size) { PVOID Buffer; @@ -62,7 +62,7 @@ NTAPI FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData, IN PCHAR IdentifierString) { - ULONG IdentifierLength; + SIZE_T IdentifierLength; PCONFIGURATION_COMPONENT Component = &ComponentData->ComponentEntry; PCHAR Identifier; @@ -75,7 +75,7 @@ FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData, RtlCopyMemory(Identifier, IdentifierString, IdentifierLength); /* Set component information */ - Component->IdentifierLength = IdentifierLength; + Component->IdentifierLength = (ULONG)IdentifierLength; Component->Identifier = Identifier; } diff --git a/reactos/boot/freeldr/freeldr/reactos/registry.c b/reactos/boot/freeldr/freeldr/reactos/registry.c index f401807d175..8de13024d66 100644 --- a/reactos/boot/freeldr/freeldr/reactos/registry.c +++ b/reactos/boot/freeldr/freeldr/reactos/registry.c @@ -174,8 +174,8 @@ RegCreateKey(FRLDRHKEY ParentKey, FRLDRHKEY NewKey; PWCHAR p; PCWSTR name; - int subkeyLength; - int stringLength; + SIZE_T subkeyLength; + SIZE_T stringLength; ULONG NameSize; int CmpResult; @@ -220,7 +220,7 @@ RegCreateKey(FRLDRHKEY ParentKey, stringLength = subkeyLength; name = KeyName; } - NameSize = (subkeyLength + 1) * sizeof(WCHAR); + NameSize = (ULONG)((subkeyLength + 1) * sizeof(WCHAR)); Ptr = CurrentKey->SubKeyList.Flink; CmpResult = 1; @@ -345,8 +345,8 @@ RegOpenKey(FRLDRHKEY ParentKey, FRLDRHKEY CurrentKey; PWCHAR p; PCWSTR name; - int subkeyLength; - int stringLength; + SIZE_T subkeyLength; + SIZE_T stringLength; ULONG NameSize; TRACE("KeyName '%S'\n", KeyName); @@ -391,7 +391,7 @@ RegOpenKey(FRLDRHKEY ParentKey, stringLength = subkeyLength; name = KeyName; } - NameSize = (subkeyLength + 1) * sizeof(WCHAR); + NameSize = (ULONG)((subkeyLength + 1) * sizeof(WCHAR)); Ptr = CurrentKey->SubKeyList.Flink; while (Ptr != &CurrentKey->SubKeyList) @@ -495,7 +495,7 @@ RegSetValue(FRLDRHKEY Key, InsertTailList(&Key->ValueList, &Value->ValueList); Key->ValueCount++; - Value->NameSize = (wcslen(ValueName)+1) * sizeof(WCHAR); + Value->NameSize = (ULONG)(wcslen(ValueName)+1) * sizeof(WCHAR); Value->Name = MmHeapAlloc(Value->NameSize); if (Value->Name == NULL) return ERROR_OUTOFMEMORY; wcscpy(Value->Name, ValueName); diff --git a/reactos/boot/freeldr/freeldr/ui/tui.c b/reactos/boot/freeldr/freeldr/ui/tui.c index 91356d28122..1dfb615b92e 100644 --- a/reactos/boot/freeldr/freeldr/ui/tui.c +++ b/reactos/boot/freeldr/freeldr/ui/tui.c @@ -128,7 +128,7 @@ VOID TuiDrawBackdrop(VOID) // // Draw title text // - TuiDrawText( (UiScreenWidth / 2) - (strlen(UiTitleBoxTitleText) / 2), + TuiDrawText( (UiScreenWidth / 2) - ((ULONG)strlen(UiTitleBoxTitleText) / 2), 2, UiTitleBoxTitleText, ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor)); @@ -332,12 +332,12 @@ VOID TuiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr) VOID TuiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr) { - ULONG TextLength; + SIZE_T TextLength; ULONG BoxWidth; ULONG BoxHeight; ULONG LineBreakCount; - ULONG Index; - ULONG LastIndex; + SIZE_T Index; + SIZE_T LastIndex; ULONG RealLeft; ULONG RealTop; ULONG X; @@ -361,7 +361,7 @@ VOID TuiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR { if ((Index - LastIndex) > BoxWidth) { - BoxWidth = (Index - LastIndex); + BoxWidth = (ULONG)(Index - LastIndex); } } } @@ -381,7 +381,7 @@ VOID TuiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR } else { - X = RealLeft + LastIndex; + X = (ULONG)(RealLeft + LastIndex); Y = RealTop; LastIndex++; Temp[0] = TextString[Index]; @@ -393,14 +393,14 @@ VOID TuiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR VOID TuiDrawStatusText(PCSTR StatusText) { - ULONG i; + SIZE_T i; TuiDrawText(0, UiScreenHeight-1, " ", ATTR(UiStatusBarFgColor, UiStatusBarBgColor)); TuiDrawText(1, UiScreenHeight-1, StatusText, ATTR(UiStatusBarFgColor, UiStatusBarBgColor)); for (i=strlen(StatusText)+1; iHour > 12) @@ -498,7 +498,7 @@ VOID TuiUpdateDateTime(VOID) } // Draw the time - TuiDrawText(UiScreenWidth-strlen(TimeString)-2, 2, TimeString, ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor)); + TuiDrawText(UiScreenWidth-(ULONG)strlen(TimeString)-2, 2, TimeString, ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor)); } VOID TuiSaveScreen(PUCHAR Buffer) diff --git a/reactos/boot/freeldr/freeldr/ui/tuimenu.c b/reactos/boot/freeldr/freeldr/ui/tuimenu.c index 055e1b44b85..00402df96dc 100644 --- a/reactos/boot/freeldr/freeldr/ui/tuimenu.c +++ b/reactos/boot/freeldr/freeldr/ui/tuimenu.c @@ -151,7 +151,7 @@ TuiCalcMenuBoxSize(PUI_MENU_INFO MenuInfo) // // Get the string length and make it become the new width if necessary // - Length = strlen(MenuInfo->MenuItemList[i]); + Length = (ULONG)strlen(MenuInfo->MenuItemList[i]); if (Length > Width) Width = Length; } @@ -248,7 +248,7 @@ TuiDrawMenuBox(PUI_MENU_INFO MenuInfo) // Copy the integral time text string, and remove the last 2 chars // strcpy(TempString, UiTimeText); - i = strlen(TempString); + i = (ULONG)strlen(TempString); TempString[i - 2] = 0; // @@ -271,7 +271,7 @@ TuiDrawMenuBox(PUI_MENU_INFO MenuInfo) // // Display it in the center of the menu // - UiDrawText(MenuInfo->Right - strlen(MenuLineText) - 1, + UiDrawText(MenuInfo->Right - (ULONG)strlen(MenuLineText) - 1, MenuInfo->Bottom, MenuLineText, ATTR(UiMenuFgColor, UiMenuBgColor)); @@ -303,7 +303,7 @@ TuiDrawMenuBox(PUI_MENU_INFO MenuInfo) // if (UiCenterMenu) { - UiDrawText(MenuInfo->Right - strlen(MenuLineText) - 1, + UiDrawText(MenuInfo->Right - (ULONG)strlen(MenuLineText) - 1, MenuInfo->Bottom, MenuLineText, ATTR(UiMenuFgColor, UiMenuBgColor)); @@ -364,7 +364,7 @@ TuiDrawMenuItem(PUI_MENU_INFO MenuInfo, // how many spaces will be to the left and right // SpaceTotal = (MenuInfo->Right - MenuInfo->Left - 2) - - strlen(MenuInfo->MenuItemList[MenuItemNumber]); + (ULONG)strlen(MenuInfo->MenuItemList[MenuItemNumber]); SpaceLeft = (SpaceTotal / 2) + 1; SpaceRight = (SpaceTotal - SpaceLeft) + 1; diff --git a/reactos/boot/freeldr/freeldr/ui/ui.c b/reactos/boot/freeldr/freeldr/ui/ui.c index dbbd9361722..b0f0f12dcc9 100644 --- a/reactos/boot/freeldr/freeldr/ui/ui.c +++ b/reactos/boot/freeldr/freeldr/ui/ui.c @@ -228,7 +228,8 @@ BOOLEAN UiInitialize(BOOLEAN ShowGui) BOOLEAN SetupUiInitialize(VOID) { CHAR DisplayModeText[260]; - ULONG Depth, Length; + ULONG Depth; + SIZE_T Length; DisplayModeText[0] = '\0'; @@ -313,12 +314,12 @@ VOID UiUpdateDateTime(VOID) VOID UiInfoBox(PCSTR MessageText) { - ULONG TextLength; + SIZE_T TextLength; ULONG BoxWidth; ULONG BoxHeight; ULONG LineBreakCount; - ULONG Index; - ULONG LastIndex; + SIZE_T Index; + SIZE_T LastIndex; ULONG Left; ULONG Top; ULONG Right; @@ -341,7 +342,7 @@ VOID UiInfoBox(PCSTR MessageText) { if ((Index - LastIndex) > BoxWidth) { - BoxWidth = (Index - LastIndex); + BoxWidth = (ULONG)(Index - LastIndex); } } } diff --git a/reactos/boot/freeldr/freeldr/windows/peloader.c b/reactos/boot/freeldr/freeldr/windows/peloader.c index 62a2dd26cba..07c1a079f6c 100644 --- a/reactos/boot/freeldr/freeldr/windows/peloader.c +++ b/reactos/boot/freeldr/freeldr/windows/peloader.c @@ -453,7 +453,7 @@ WinLdrpCompareDllName(IN PCH DllName, { PWSTR Buffer; UNICODE_STRING UnicodeNamePA; - ULONG i, Length; + SIZE_T i, Length; /* First obvious check: for length of two names */ Length = strlen(DllName); diff --git a/reactos/boot/freeldr/freeldr/windows/wlmemory.c b/reactos/boot/freeldr/freeldr/windows/wlmemory.c index 505c52e9454..1f04319e731 100644 --- a/reactos/boot/freeldr/freeldr/windows/wlmemory.c +++ b/reactos/boot/freeldr/freeldr/windows/wlmemory.c @@ -49,8 +49,8 @@ WinLdrInsertDescriptor(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, extern PFREELDR_MEMORY_DESCRIPTOR BiosMemoryMap; extern ULONG BiosMemoryMapEntryCount; -extern ULONG MmLowestPhysicalPage; -extern ULONG MmHighestPhysicalPage; +extern PFN_NUMBER MmLowestPhysicalPage; +extern PFN_NUMBER MmHighestPhysicalPage; /* GLOBALS ***************************************************************/ @@ -63,8 +63,8 @@ ULONG MadCount = 0; VOID MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - ULONG BasePage, - ULONG PageCount, + PFN_NUMBER BasePage, + PFN_NUMBER PageCount, ULONG Type) { BOOLEAN Status = TRUE; @@ -195,10 +195,10 @@ MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, BOOLEAN WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock) { - ULONG i, PagesCount, MemoryMapSizeInPages; - ULONG LastPageIndex, LastPageType, MemoryMapStartPage; + PFN_NUMBER i, PagesCount, MemoryMapSizeInPages, NoEntries; + PFN_NUMBER LastPageIndex, MemoryMapStartPage; PPAGE_LOOKUP_TABLE_ITEM MemoryMap; - ULONG NoEntries; + ULONG LastPageType; //PKTSS Tss; //BOOLEAN Status; diff --git a/reactos/boot/freeldr/freeldr/windows/wlregistry.c b/reactos/boot/freeldr/freeldr/windows/wlregistry.c index 55def6632f8..a7a33c75aa4 100644 --- a/reactos/boot/freeldr/freeldr/windows/wlregistry.c +++ b/reactos/boot/freeldr/freeldr/windows/wlregistry.c @@ -720,7 +720,7 @@ WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead, if (ImagePath && (wcslen(ImagePath) > 0)) { // Just copy ImagePath to the corresponding field in the structure - PathLength = wcslen(ImagePath) * sizeof(WCHAR) + sizeof(UNICODE_NULL); + PathLength = (USHORT)wcslen(ImagePath) * sizeof(WCHAR) + sizeof(UNICODE_NULL); BootDriverEntry->FilePath.Length = 0; BootDriverEntry->FilePath.MaximumLength = PathLength; @@ -743,7 +743,7 @@ WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead, else { // we have to construct ImagePath ourselves - PathLength = wcslen(ServiceName)*sizeof(WCHAR) + sizeof(L"system32\\drivers\\.sys"); + PathLength = (USHORT)wcslen(ServiceName)*sizeof(WCHAR) + sizeof(L"system32\\drivers\\.sys"); BootDriverEntry->FilePath.Length = 0; BootDriverEntry->FilePath.MaximumLength = PathLength; BootDriverEntry->FilePath.Buffer = MmHeapAlloc(PathLength); @@ -780,7 +780,7 @@ WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead, } // Add registry path - PathLength = (wcslen(RegistryPath) + wcslen(ServiceName))*sizeof(WCHAR) + sizeof(UNICODE_NULL); + PathLength = (USHORT)(wcslen(RegistryPath) + wcslen(ServiceName))*sizeof(WCHAR) + sizeof(UNICODE_NULL); BootDriverEntry->RegistryPath.Length = 0; BootDriverEntry->RegistryPath.MaximumLength = PathLength; BootDriverEntry->RegistryPath.Buffer = MmHeapAlloc(PathLength);