https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3be40816079f3b3f2ff3bafde7c237336f0c461e

commit 3be40816079f3b3f2ff3bafde7c237336f0c461e
Author:     Timo Kreuzer <timo.kreu...@reactos.org>
AuthorDate: Sun Mar 18 16:10:41 2018 +0100
Commit:     GitHub <nore...@github.com>
CommitDate: Sun Mar 18 16:10:41 2018 +0100

    [BOOTLIB] Fix 64 bit issues (#433)
---
 boot/environ/app/bootmgr/bootmgr.c       | 24 +++++++++++-----------
 boot/environ/app/rosload/roslogo.c       |  2 +-
 boot/environ/include/bl.h                | 10 +++++++++-
 boot/environ/lib/arch/stub/arch.c        | 13 ++++++++++++
 boot/environ/lib/firmware/efi/firmware.c | 34 ++++++++++++++++----------------
 boot/environ/lib/io/device.c             |  2 +-
 boot/environ/lib/io/display/display.c    |  8 ++++----
 boot/environ/lib/io/etfs.c               |  3 ++-
 boot/environ/lib/io/file.c               |  4 ++--
 boot/environ/lib/misc/bcd.c              |  2 +-
 boot/environ/lib/misc/bootreg.c          |  2 +-
 boot/environ/lib/misc/font.c             |  2 +-
 boot/environ/lib/misc/image.c            | 16 +++++++--------
 boot/environ/lib/misc/rtlcompat.c        |  4 ++++
 boot/environ/lib/misc/util.c             |  3 ++-
 boot/environ/lib/mm/blkalloc.c           |  4 ++--
 boot/environ/lib/mm/heapalloc.c          |  6 +++---
 boot/environ/lib/mm/pagealloc.c          |  4 ++--
 18 files changed, 85 insertions(+), 58 deletions(-)

diff --git a/boot/environ/app/bootmgr/bootmgr.c 
b/boot/environ/app/bootmgr/bootmgr.c
index 85d501b310..458e1437f8 100644
--- a/boot/environ/app/bootmgr/bootmgr.c
+++ b/boot/environ/app/bootmgr/bootmgr.c
@@ -231,7 +231,7 @@ BmpFwGetApplicationDirectoryPath (
     )
 {
     NTSTATUS Status;
-    ULONG i, AppPathLength;
+    SIZE_T i, AppPathLength;
     PWCHAR ApplicationPath, PathCopy;
 
     /* Clear the incoming string */
@@ -257,11 +257,11 @@ BmpFwGetApplicationDirectoryPath (
         }
 
         /* Check if we have space for one more character */
-        Status = RtlULongAdd(i, 1, &AppPathLength);
+        Status = RtlSIZETAdd(i, 1, &AppPathLength);
         if (NT_SUCCESS(Status))
         {
             /* Check if it's safe to multiply by two */
-            Status = RtlULongMult(AppPathLength, sizeof(WCHAR), 
&AppPathLength);
+            Status = RtlSIZETMult(AppPathLength, sizeof(WCHAR), 
&AppPathLength);
             if (NT_SUCCESS(Status))
             {
                 /* Allocate a copy for the string */
@@ -647,11 +647,11 @@ BmpFwGetFullPath (
     )
 {
     NTSTATUS Status;
-    ULONG BootDirLength, PathLength;
+    SIZE_T BootDirLength, PathLength;
 
     /* Compute the length of the directory, and add a NUL */
     BootDirLength = wcslen(BootDirectory);
-    Status = RtlULongAdd(BootDirLength, 1, &BootDirLength);
+    Status = RtlSIZETAdd(BootDirLength, 1, &BootDirLength);
     if (!NT_SUCCESS(Status))
     {
         goto Quickie;
@@ -659,14 +659,14 @@ BmpFwGetFullPath (
 
     /* Add the length of the file, make sure it fits */
     PathLength = wcslen(FileName);
-    Status = RtlULongAdd(PathLength, BootDirLength, &PathLength);
+    Status = RtlSIZETAdd(PathLength, BootDirLength, &PathLength);
     if (!NT_SUCCESS(Status))
     {
         goto Quickie;
     }
 
     /* Convert to bytes */
-    Status = RtlULongLongToULong(PathLength * sizeof(WCHAR), &PathLength);
+    Status = RtlSIZETMult(PathLength, sizeof(WCHAR), &PathLength);
     if (!NT_SUCCESS(Status))
     {
         goto Quickie;
@@ -716,7 +716,7 @@ BmOpenDataStore (
     PBL_DEVICE_DESCRIPTOR BcdDevice;
     PWCHAR BcdPath, FullPath, PathBuffer;
     BOOLEAN HavePath;
-    ULONG PathLength, FullSize;
+    SIZE_T PathLength, FullSize;
     PVOID FinalBuffer;
     UNICODE_STRING BcdString;
 
@@ -795,21 +795,21 @@ BmOpenDataStore (
 
     /* Add a NUL to the path, make sure it'll fit */
     PathLength = wcslen(PathBuffer);
-    Status = RtlULongAdd(PathLength, 1, &PathLength);
+    Status = RtlSIZETAdd(PathLength, 1, &PathLength);
     if (!NT_SUCCESS(Status))
     {
         goto Quickie;
     }
 
     /* Convert to bytes */
-    Status = RtlULongLongToULong(PathLength * sizeof(WCHAR), &PathLength);
+    Status = RtlSIZETMult(PathLength, sizeof(WCHAR), &PathLength);
     if (!NT_SUCCESS(Status))
     {
         goto Quickie;
     }
 
     /* Now add the size of the path to the device path, check if it fits */
-    Status = RtlULongAdd(PathLength, BcdDevice->Size, &FullSize);
+    Status = RtlSIZETAdd(PathLength, BcdDevice->Size, &FullSize);
     if (!NT_SUCCESS(Status))
     {
         goto Quickie;
@@ -2158,7 +2158,7 @@ BmDisplayDumpError (
     if (BmpInternalBootError)
     {
         /* Return it -- but it's a pointer? */
-        return (ULONG)BmpInternalBootError; // ???
+        return (ULONG_PTR)BmpInternalBootError; // ???
     }
 
     /* Otherwise, show the menu to see what to do */
diff --git a/boot/environ/app/rosload/roslogo.c 
b/boot/environ/app/rosload/roslogo.c
index 3cf4a87a91..eb432eb2f0 100644
--- a/boot/environ/app/rosload/roslogo.c
+++ b/boot/environ/app/rosload/roslogo.c
@@ -9785,7 +9785,7 @@ OslDrawLogo (
     CoordinateX = (DspGraphicalConsole->DisplayMode.HRes / 2) - (BmpWidth / 2);
     CoordinateY = (DspGraphicalConsole->DisplayMode.VRes / 2) - (BmpHeight / 
2);
     BlMmTranslateVirtualAddress(GopBlt, &GopBltPhys);
-    GopBlt = (PVOID)GopBltPhys.LowPart;
+    GopBlt = PhysicalAddressToPtr(GopBltPhys);
 
     /* Make the screen black */
     RtlFillMemory(DspGraphicalConsole->FrameBuffer,
diff --git a/boot/environ/include/bl.h b/boot/environ/include/bl.h
index 82edfbcb00..bea6856f05 100644
--- a/boot/environ/include/bl.h
+++ b/boot/environ/include/bl.h
@@ -1385,6 +1385,14 @@ MmMdInitializeListHead (
     List->Type = 0;
 }
 
+FORCEINLINE
+PVOID
+PhysicalAddressToPtr (
+    _In_ PHYSICAL_ADDRESS PhysicalAddress)
+{
+    return (PVOID)(ULONG_PTR)PhysicalAddress.QuadPart;
+}
+
 /* INITIALIZATION ROUTINES ***************************************************/
 
 NTSTATUS
@@ -2369,7 +2377,7 @@ BlpMmCreateBlockAllocator (
 
 PVOID
 BlMmAllocateHeap (
-    _In_ ULONG Size
+    _In_ SIZE_T Size
     );
 
 NTSTATUS
diff --git a/boot/environ/lib/arch/stub/arch.c 
b/boot/environ/lib/arch/stub/arch.c
index be6685edab..31c96e7994 100644
--- a/boot/environ/lib/arch/stub/arch.c
+++ b/boot/environ/lib/arch/stub/arch.c
@@ -13,6 +13,9 @@
 /* DATA VARIABLES ************************************************************/
 
 PBL_ARCH_CONTEXT CurrentExecutionContext;
+PBL_MM_RELOCATE_SELF_MAP BlMmRelocateSelfMap;
+PBL_MM_MOVE_VIRTUAL_ADDRESS_RANGE BlMmMoveVirtualAddressRange;
+PBL_MM_ZERO_VIRTUAL_ADDRESS_RANGE BlMmZeroVirtualAddressRange;
 
 /* FUNCTIONS *****************************************************************/
 
@@ -50,3 +53,13 @@ Archx86TransferTo32BitApplicationAsm (VOID)
     EfiPrintf(L" Archx86TransferTo32BitApplicationAsm NOT IMPLEMENTED for this 
platform\r\n");
 }
 
+NTSTATUS
+OslArchTransferToKernel(
+    _In_ struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
+    _In_ PVOID KernelEntrypoint
+    )
+{
+    EfiPrintf(L" OslArchTransferToKernel NOT IMPLEMENTED for this 
platform\r\n");
+    return STATUS_NOT_IMPLEMENTED;
+}
+
diff --git a/boot/environ/lib/firmware/efi/firmware.c 
b/boot/environ/lib/firmware/efi/firmware.c
index 915de6d43e..6c9edb24ca 100644
--- a/boot/environ/lib/firmware/efi/firmware.c
+++ b/boot/environ/lib/firmware/efi/firmware.c
@@ -280,7 +280,7 @@ EfiVmOpenProtocol (
     }
 
     /* Check what address the interface lives at, and translate it */
-    InterfaceVa = (PVOID)InterfaceAddress.LowPart;
+    InterfaceVa = PhysicalAddressToPtr(InterfaceAddress);
     if (BlMmTranslateVirtualAddress(InterfaceVa, &TranslatedAddress))
     {
         /* We expect firmware to be 1:1 mapped, fail if not */
@@ -868,9 +868,9 @@ EfiConInExSetState (
     {
         /* Translate pointers from virtual to physical */
         BlMmTranslateVirtualAddress(ConInEx, &ConInExPhys);
-        ConInEx = (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL*)ConInExPhys.LowPart;
+        ConInEx = 
(EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL*)PhysicalAddressToPtr(ConInExPhys);
         BlMmTranslateVirtualAddress(KeyToggleState, &KeyTogglePhys);
-        KeyToggleState = (EFI_KEY_TOGGLE_STATE*)KeyTogglePhys.LowPart;
+        KeyToggleState = 
(EFI_KEY_TOGGLE_STATE*)PhysicalAddressToPtr(KeyTogglePhys);
 
         /* Switch to real mode */
         BlpArchSwitchContext(BlRealMode);
@@ -938,15 +938,15 @@ EfiGetMemoryMap (
     {
         /* Convert all of the addresses to physical */
         BlMmTranslateVirtualAddress(MemoryMapSize, &MemoryMapSizePhysical);
-        MemoryMapSize = (UINTN*)MemoryMapSizePhysical.LowPart;
+        MemoryMapSize = (UINTN*)PhysicalAddressToPtr(MemoryMapSizePhysical);
         BlMmTranslateVirtualAddress(MemoryMap, &MemoryMapPhysical);
-        MemoryMap = (EFI_MEMORY_DESCRIPTOR*)MemoryMapPhysical.LowPart;
+        MemoryMap = 
(EFI_MEMORY_DESCRIPTOR*)PhysicalAddressToPtr(MemoryMapPhysical);
         BlMmTranslateVirtualAddress(MapKey, &MapKeyPhysical);
-        MapKey = (UINTN*)MapKeyPhysical.LowPart;
+        MapKey = (UINTN*)PhysicalAddressToPtr(MapKeyPhysical);
         BlMmTranslateVirtualAddress(DescriptorSize, &DescriptorSizePhysical);
-        DescriptorSize = (UINTN*)DescriptorSizePhysical.LowPart;
+        DescriptorSize = (UINTN*)PhysicalAddressToPtr(DescriptorSizePhysical);
         BlMmTranslateVirtualAddress(DescriptorVersion, 
&DescriptorVersionPhysical);
-        DescriptorVersion = (UINTN*)DescriptorVersionPhysical.LowPart;
+        DescriptorVersion = 
(UINTN*)PhysicalAddressToPtr(DescriptorVersionPhysical);
 
         /* Switch to real mode */
         BlpArchSwitchContext(BlRealMode);
@@ -1267,15 +1267,15 @@ EfiGopGetFrameBuffer (
     {
         /* Translate pointer to physical */
         BlMmTranslateVirtualAddress(GopInterface, &GopInterfacePhys);
-        GopInterface = (PVOID)GopInterfacePhys.LowPart;
+        GopInterface = PhysicalAddressToPtr(GopInterfacePhys);
 
         /* Translate pointer to physical */
         BlMmTranslateVirtualAddress(FrameBuffer, &FrameBufferPhys);
-        FrameBuffer = (PVOID)FrameBufferPhys.LowPart;
+        FrameBuffer = PhysicalAddressToPtr(FrameBufferPhys);
 
         /* Translate pointer to physical */
         BlMmTranslateVirtualAddress(FrameBufferSize, &FrameBufferSizePhys);
-        FrameBufferSize = (PVOID)FrameBufferSizePhys.LowPart;
+        FrameBufferSize = PhysicalAddressToPtr(FrameBufferSizePhys);
 
         /* Switch to real mode */
         BlpArchSwitchContext(BlRealMode);
@@ -1311,21 +1311,21 @@ EfiGopGetCurrentMode (
         {
             return STATUS_UNSUCCESSFUL;
         }
-        GopInterface = (PVOID)GopInterfacePhys.LowPart;
+        GopInterface = PhysicalAddressToPtr(GopInterfacePhys);
 
         /* Translate pointer to physical */
         if (!BlMmTranslateVirtualAddress(Mode, &ModePhys))
         {
             return STATUS_UNSUCCESSFUL;
         }
-        Mode = (PVOID)ModePhys.LowPart;
+        Mode = PhysicalAddressToPtr(ModePhys);
 
         /* Translate pointer to physical */
         if (!BlMmTranslateVirtualAddress(Information, &InformationPhys))
         {
             return STATUS_UNSUCCESSFUL;
         }
-        Information = (PVOID)InformationPhys.LowPart;
+        Information = PhysicalAddressToPtr(InformationPhys);
 
         /* Switch to real mode */
         BlpArchSwitchContext(BlRealMode);
@@ -1435,7 +1435,7 @@ EfiLocateHandleBuffer (
     {
         /* Translate the input buffer from virtual to physical */
         TranslateResult = BlMmTranslateVirtualAddress(InputBuffer, 
&BufferPhys);
-        InputBuffer = TranslateResult ? (PVOID)BufferPhys.LowPart : NULL;
+        InputBuffer = TranslateResult ? PhysicalAddressToPtr(BufferPhys) : 
NULL;
 
         /* Switch to real mode */
         BlpArchSwitchContext(BlRealMode);
@@ -1478,7 +1478,7 @@ EfiLocateHandleBuffer (
             /* Translate the input buffer from virtual to physical */
             TranslateResult = BlMmTranslateVirtualAddress(InputBuffer,
                                                           &BufferPhys);
-            InputBuffer = TranslateResult ? (PVOID)BufferPhys.LowPart : NULL;
+            InputBuffer = TranslateResult ? PhysicalAddressToPtr(BufferPhys) : 
NULL;
 
             /* Switch to real mode */
             BlpArchSwitchContext(BlRealMode);
@@ -1581,7 +1581,7 @@ EfiAllocatePages (
     {
         /* Translate output address */
         BlMmTranslateVirtualAddress(Memory, &MemoryPhysical);
-        Memory = (EFI_PHYSICAL_ADDRESS*)MemoryPhysical.LowPart;
+        Memory = (EFI_PHYSICAL_ADDRESS*)PhysicalAddressToPtr(MemoryPhysical);
 
         /* Switch to real mode */
         BlpArchSwitchContext(BlRealMode);
diff --git a/boot/environ/lib/io/device.c b/boot/environ/lib/io/device.c
index b4fd38e178..48606b5258 100644
--- a/boot/environ/lib/io/device.c
+++ b/boot/environ/lib/io/device.c
@@ -1835,7 +1835,7 @@ BlockIoEfiHashFunction (
     )
 {
     /* Get rid of the alignment bits to have a more unique number */
-    return ((ULONG)Entry->Value >> 3) % TableSize;
+    return ((ULONG_PTR)Entry->Value >> 3) % TableSize;
 }
 
 NTSTATUS
diff --git a/boot/environ/lib/io/display/display.c 
b/boot/environ/lib/io/display/display.c
index 8d7631f37b..6c186df37a 100644
--- a/boot/environ/lib/io/display/display.c
+++ b/boot/environ/lib/io/display/display.c
@@ -61,7 +61,7 @@ DsppLoadFontFile (
 {
     PBL_DEVICE_DESCRIPTOR FontDevice;
     NTSTATUS Status;
-    ULONG NameLength, DirectoryLength, TotalLength;
+    SIZE_T NameLength, DirectoryLength, TotalLength;
     PWCHAR FontPath, FontDirectory;
     BL_LIBRARY_PARAMETERS LibraryParameters;
     BOOLEAN CustomDirectory, CustomDevice;
@@ -114,21 +114,21 @@ DsppLoadFontFile (
     DirectoryLength = wcslen(FontDirectory);
 
     /* Safely add them up*/
-    Status = RtlULongAdd(NameLength, DirectoryLength, &TotalLength);
+    Status = RtlSIZETAdd(NameLength, DirectoryLength, &TotalLength);
     if (!NT_SUCCESS(Status))
     {
         goto Quickie;
     }
 
     /* Convert to bytes */
-    Status = RtlULongLongToULong(TotalLength * sizeof(WCHAR), &TotalLength);
+    Status = RtlSIZETMult(TotalLength, sizeof(WCHAR), &TotalLength);
     if (!NT_SUCCESS(Status))
     {
         goto Quickie;
     }
 
     /* Add a terminating NUL */
-    Status = RtlULongAdd(TotalLength, sizeof(UNICODE_NULL), &TotalLength);
+    Status = RtlSIZETAdd(TotalLength, sizeof(UNICODE_NULL), &TotalLength);
     if (!NT_SUCCESS(Status))
     {
         goto Quickie;
diff --git a/boot/environ/lib/io/etfs.c b/boot/environ/lib/io/etfs.c
index ffb4553f9a..8d8797b01b 100644
--- a/boot/environ/lib/io/etfs.c
+++ b/boot/environ/lib/io/etfs.c
@@ -547,7 +547,8 @@ EtfsOpen (
     PBL_FILE_ENTRY NewFile;
     PWCHAR FilePath, FormatString;
     PBL_ETFS_FILE EtfsFile;
-    ULONG DeviceId, FileSize, DirOffset, FileOffset, Size;
+    ULONG DeviceId, FileSize, DirOffset, FileOffset;
+    SIZE_T Size;
     PRAW_DIR_REC DirEntry;
     BOOLEAN IsDirectory;
 
diff --git a/boot/environ/lib/io/file.c b/boot/environ/lib/io/file.c
index a3f4b6e581..6d8c657da2 100644
--- a/boot/environ/lib/io/file.c
+++ b/boot/environ/lib/io/file.c
@@ -41,7 +41,7 @@ FileIoCopyParentDirectoryPath (
     _In_ PWCHAR FilePath
     )
 {
-    ULONG PathSize, PathSizeWithNull;
+    SIZE_T PathSize, PathSizeWithNull;
     PWCHAR Backslash, ParentCopy;
 
     PathSize = wcslen(FilePath) * sizeof(WCHAR);
@@ -81,7 +81,7 @@ FileIoCopyFileName (
     )
 {
     PWCHAR Separator, FileCopy;
-    ULONG PathSize;
+    SIZE_T PathSize;
 
     Separator = wcsrchr(FilePath, '\\');
     if (!Separator)
diff --git a/boot/environ/lib/misc/bcd.c b/boot/environ/lib/misc/bcd.c
index 26cdd4f324..b3ae2b5375 100644
--- a/boot/environ/lib/misc/bcd.c
+++ b/boot/environ/lib/misc/bcd.c
@@ -59,7 +59,7 @@ BiConvertRegistryDataToElement (
     )
 {
     NTSTATUS Status;
-    ULONG Length, Size, ReturnedLength;
+    SIZE_T Length, Size, ReturnedLength;
     PBL_DEVICE_DESCRIPTOR Device;
     BOOLEAN NullTerminate;
     PBCD_DEVICE_OPTION BcdDevice, ElementDevice;
diff --git a/boot/environ/lib/misc/bootreg.c b/boot/environ/lib/misc/bootreg.c
index 88b970dbac..bf66657230 100644
--- a/boot/environ/lib/misc/bootreg.c
+++ b/boot/environ/lib/misc/bootreg.c
@@ -192,7 +192,7 @@ BiOpenKey(
     PBI_KEY_OBJECT ParentKey, NewKey;
     PBI_KEY_HIVE ParentHive;
     NTSTATUS Status;
-    ULONG NameLength, SubNameLength, NameBytes;
+    SIZE_T NameLength, SubNameLength, NameBytes;
     PWCHAR NameStart, NameBuffer;
     UNICODE_STRING KeyString;
     HCELL_INDEX KeyCell;
diff --git a/boot/environ/lib/misc/font.c b/boot/environ/lib/misc/font.c
index e271d286f1..ede267d3c0 100644
--- a/boot/environ/lib/misc/font.c
+++ b/boot/environ/lib/misc/font.c
@@ -54,7 +54,7 @@ BfLoadFontFile (
     )
 {
     PBL_DEFERRED_FONT_FILE DeferredFont;
-    ULONG FontPathSize;
+    SIZE_T FontPathSize;
 
     /* Allocate the deferred font structure */
     DeferredFont = 
(PBL_DEFERRED_FONT_FILE)BlMmAllocateHeap(sizeof(*DeferredFont));
diff --git a/boot/environ/lib/misc/image.c b/boot/environ/lib/misc/image.c
index 29fdb9def9..9e682f4288 100644
--- a/boot/environ/lib/misc/image.c
+++ b/boot/environ/lib/misc/image.c
@@ -304,7 +304,7 @@ BlImgAllocateImageBuffer (
         }
 
         /* Now map the physical buffer at the address requested */
-        MappedBase = (PVOID)PhysicalAddress.LowPart;
+        MappedBase = PhysicalAddressToPtr(PhysicalAddress);
         Status = BlMmMapPhysicalAddressEx(&MappedBase,
                                           BlMemoryFixed,
                                           Size,
@@ -976,9 +976,9 @@ ImgpLoadPEImage (
         }
 
         /* Make sure that the section doesn't overflow in memory */
-        Status = RtlULongAdd(Section->VirtualAddress,
-                             SectionSize,
-                             &SectionEnd);
+        Status = RtlULongPtrAdd(Section->VirtualAddress,
+                                SectionSize,
+                                &SectionEnd);
         if (!NT_SUCCESS(Status))
         {
             EfiPrintf(L"fail 21\r\n");
@@ -994,9 +994,9 @@ ImgpLoadPEImage (
         }
 
         /* Make sure it doesn't overflow on disk */
-        Status = RtlULongAdd(Section->VirtualAddress,
-                             AlignSize,
-                             &SectionEnd);
+        Status = RtlULongPtrAdd(Section->VirtualAddress,
+                                AlignSize,
+                                &SectionEnd);
         if (!NT_SUCCESS(Status))
         {
             EfiPrintf(L"fail 31\r\n");
@@ -1848,7 +1848,7 @@ ImgArchEfiStartBootApplication (
     __sidt(&Idt.Limit);
 
     /* Allocate space for the IDT, GDT, and 24 pages of stack */
-    BootSizeNeeded = (ULONG)PAGE_ALIGN(Idt.Limit + Gdt.Limit + 1 + 25 * 
PAGE_SIZE);
+    BootSizeNeeded = (ULONG_PTR)PAGE_ALIGN(Idt.Limit + Gdt.Limit + 1 + 25 * 
PAGE_SIZE);
     Status = MmPapAllocatePagesInRange(&BootData,
                                        BlLoaderArchData,
                                        BootSizeNeeded >> PAGE_SHIFT,
diff --git a/boot/environ/lib/misc/rtlcompat.c 
b/boot/environ/lib/misc/rtlcompat.c
index 0a0e1d55bc..06ebf7e35d 100644
--- a/boot/environ/lib/misc/rtlcompat.c
+++ b/boot/environ/lib/misc/rtlcompat.c
@@ -23,7 +23,11 @@ CHECK_PAGED_CODE_RTL (
 }
 #endif
 
+#ifdef _WIN64
+PVOID MmHighestUserAddress = (PVOID)0xFFFFFFFFULL; // CHECKME
+#else
 PVOID MmHighestUserAddress = (PVOID)0xFFFFFFFF;
+#endif
 
 PVOID
 NTAPI
diff --git a/boot/environ/lib/misc/util.c b/boot/environ/lib/misc/util.c
index 18f21cc2e9..20a01881dc 100644
--- a/boot/environ/lib/misc/util.c
+++ b/boot/environ/lib/misc/util.c
@@ -960,6 +960,7 @@ BlArchGetCpuVendor (
     {
         return CPU_VIA;
     }
+#ifdef _M_IX86
     if (!strncmp((PCHAR)&CpuInfo.Ebx, "CyrixInstead", 12))
     {
         return CPU_CYRIX;
@@ -972,7 +973,7 @@ BlArchGetCpuVendor (
     {
         return CPU_RISE;
     }
-
+#endif // _M_IX86
     /* Other */
     return CPU_UNKNOWN;
 }
diff --git a/boot/environ/lib/mm/blkalloc.c b/boot/environ/lib/mm/blkalloc.c
index 3133f1a8a3..53dae681dd 100644
--- a/boot/environ/lib/mm/blkalloc.c
+++ b/boot/environ/lib/mm/blkalloc.c
@@ -48,7 +48,7 @@ MmBapCompareBlockAllocatorTableEntry (
     )
 {
     PBL_BLOCK_DESCRIPTOR BlockInfo = (PBL_BLOCK_DESCRIPTOR)Entry;
-    ULONG BlockId = (ULONG)Argument1;
+    ULONG BlockId = PtrToUlong(Argument1);
 
     /* Check if the block ID matches */
     return BlockInfo->BlockId == BlockId;
@@ -67,7 +67,7 @@ MmBapFindBlockInformation (
                           MmBlockAllocatorTableEntries,
                           &EntryId,
                           MmBapCompareBlockAllocatorTableEntry,
-                          (PVOID)EntryId,
+                          UlongToPtr(EntryId),
                           NULL,
                           NULL,
                           NULL);
diff --git a/boot/environ/lib/mm/heapalloc.c b/boot/environ/lib/mm/heapalloc.c
index 5b65399638..973417fc53 100644
--- a/boot/environ/lib/mm/heapalloc.c
+++ b/boot/environ/lib/mm/heapalloc.c
@@ -567,7 +567,7 @@ MmHaInitialize (
 
 PVOID
 BlMmAllocateHeap (
-    _In_ ULONG Size
+    _In_ SIZE_T Size
     )
 {
     ULONG BufferSize;
@@ -581,8 +581,8 @@ BlMmAllocateHeap (
     }
 
     /* Align the buffer size to the minimum size required */
-    BufferSize = ALIGN_UP(Size + FIELD_OFFSET(BL_BUSY_HEAP_ENTRY, Buffer),
-                          FIELD_OFFSET(BL_BUSY_HEAP_ENTRY, Buffer));
+    BufferSize = ALIGN_UP_BY(Size + FIELD_OFFSET(BL_BUSY_HEAP_ENTRY, Buffer),
+                             FIELD_OFFSET(BL_BUSY_HEAP_ENTRY, Buffer));
 
     /* Watch out for overflow */
     if (BufferSize <= Size)
diff --git a/boot/environ/lib/mm/pagealloc.c b/boot/environ/lib/mm/pagealloc.c
index fc42077ce5..4642552f88 100644
--- a/boot/environ/lib/mm/pagealloc.c
+++ b/boot/environ/lib/mm/pagealloc.c
@@ -865,7 +865,7 @@ MmPapAllocatePagesInRange (
                                                    Type);
 
         /* Return the allocated address */
-        *PhysicalAddress = (PVOID)BaseAddress.LowPart;
+        *PhysicalAddress = PhysicalAddressToPtr(BaseAddress);
     }
 
 Exit:
@@ -1639,7 +1639,7 @@ MmSelectMappingAddress (
     if (MmTranslationType == BlNone)
     {
         /* Just return the physical address as the mapping address */
-        PreferredAddress = (PVOID)PhysicalAddress.LowPart;
+        PreferredAddress = PhysicalAddressToPtr(PhysicalAddress);
         goto Success;
     }
 

Reply via email to