[MVDM] Fix 64 bit issues
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 11 Feb 2018 23:38:10 +0000 (00:38 +0100)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sat, 4 Aug 2018 17:19:34 +0000 (19:19 +0200)
13 files changed:
subsystems/mvdm/ntvdm/bios/bios.c
subsystems/mvdm/ntvdm/bios/bios32/bios32.c
subsystems/mvdm/ntvdm/bios/bios32/dskbios32.c
subsystems/mvdm/ntvdm/bios/vidbios.c
subsystems/mvdm/ntvdm/cpu/cpu.c
subsystems/mvdm/ntvdm/dos/dem.c
subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c
subsystems/mvdm/ntvdm/dos/dos32krnl/process.c
subsystems/mvdm/ntvdm/dos/mouse32.c
subsystems/mvdm/ntvdm/emulator.c
subsystems/mvdm/ntvdm/hardware/video/svga.c
subsystems/mvdm/ntvdm/ntvdm.c
subsystems/mvdm/ntvdm/ntvdm.h

index 9ee04e2..14c44ae 100644 (file)
@@ -64,7 +64,7 @@ BiosInitialize(IN LPCSTR BiosFileName,
     BOOLEAN Success2 = FALSE;
     LPCSTR RomFile;
     LPSTR ptr;
     BOOLEAN Success2 = FALSE;
     LPCSTR RomFile;
     LPSTR ptr;
-    ULONG RomAddress;
+    ULONG_PTR RomAddress;
     CHAR RomFileName[MAX_PATH + 10 + 1];
 
     /* Disable interrupts */
     CHAR RomFileName[MAX_PATH + 10 + 1];
 
     /* Disable interrupts */
index 1a65f0e..a6dfa39 100644 (file)
@@ -1017,16 +1017,16 @@ static VOID InitializeBiosInt32(VOID)
     // They don't have any default handler at the moment.
 
     /* Some vectors are in fact addresses to tables */
     // They don't have any default handler at the moment.
 
     /* Some vectors are in fact addresses to tables */
-    ((PULONG)BaseAddress)[0x1D] = (ULONG)NULL; // Video Parameter Tables
-    ((PULONG)BaseAddress)[0x1E] = (ULONG)NULL; // Diskette Parameters
-    ((PULONG)BaseAddress)[0x1F] = (ULONG)NULL; // 8x8 Graphics Font
-    ((PULONG)BaseAddress)[0x41] = (ULONG)NULL; // Hard Disk 0 Parameter Table Address
-    ((PULONG)BaseAddress)[0x43] = (ULONG)NULL; // Character Table (EGA, MCGA, VGA)
-    ((PULONG)BaseAddress)[0x46] = (ULONG)NULL; // Hard Disk 1 Drive Parameter Table Address
+    ((PULONG)BaseAddress)[0x1D] = NULL32; // Video Parameter Tables
+    ((PULONG)BaseAddress)[0x1E] = NULL32; // Diskette Parameters
+    ((PULONG)BaseAddress)[0x1F] = NULL32; // 8x8 Graphics Font
+    ((PULONG)BaseAddress)[0x41] = NULL32; // Hard Disk 0 Parameter Table Address
+    ((PULONG)BaseAddress)[0x43] = NULL32; // Character Table (EGA, MCGA, VGA)
+    ((PULONG)BaseAddress)[0x46] = NULL32; // Hard Disk 1 Drive Parameter Table Address
     /* Tables that are always uninitialized */
     /* Tables that are always uninitialized */
-    ((PULONG)BaseAddress)[0x44] = (ULONG)NULL; // ROM BIOS Character Font, Characters 00h-7Fh (PCjr)
-    ((PULONG)BaseAddress)[0x48] = (ULONG)NULL; // Cordless Keyboard Translation (PCjr)
-    ((PULONG)BaseAddress)[0x49] = (ULONG)NULL; // Non-Keyboard Scan-code Translation Table (PCJr)
+    ((PULONG)BaseAddress)[0x44] = NULL32; // ROM BIOS Character Font, Characters 00h-7Fh (PCjr)
+    ((PULONG)BaseAddress)[0x48] = NULL32; // Cordless Keyboard Translation (PCjr)
+    ((PULONG)BaseAddress)[0x49] = NULL32; // Non-Keyboard Scan-code Translation Table (PCJr)
 }
 
 static VOID InitializeBiosData(VOID)
 }
 
 static VOID InitializeBiosData(VOID)
index a473178..2a3691e 100644 (file)
@@ -654,12 +654,12 @@ VOID DiskBios32Post(VOID)
     // Diskette Parameters
     ((PULONG)BaseAddress)[0x1E] = MAKELONG(0xEFC7, BIOS_SEGMENT);
     // Hard Disk 0 Parameter Table Address
     // Diskette Parameters
     ((PULONG)BaseAddress)[0x1E] = MAKELONG(0xEFC7, BIOS_SEGMENT);
     // Hard Disk 0 Parameter Table Address
-    ((PULONG)BaseAddress)[0x41] = (ULONG)NULL;
+    ((PULONG)BaseAddress)[0x41] = NULL32;
     // Hard Disk 1 Drive Parameter Table Address
     // Hard Disk 1 Drive Parameter Table Address
-    ((PULONG)BaseAddress)[0x46] = (ULONG)NULL;
+    ((PULONG)BaseAddress)[0x46] = NULL32;
 
     /* Relocated services by the BIOS (when needed) */
 
     /* Relocated services by the BIOS (when needed) */
-    ((PULONG)BaseAddress)[0x40] = (ULONG)NULL; // ROM BIOS Diskette Handler relocated by Hard Disk BIOS
+    ((PULONG)BaseAddress)[0x40] = NULL32; // ROM BIOS Diskette Handler relocated by Hard Disk BIOS
     // RegisterBiosInt32(0x40, NULL); // ROM BIOS Diskette Handler relocated by Hard Disk BIOS
 
     /* Register the BIOS 32-bit Interrupts */
     // RegisterBiosInt32(0x40, NULL); // ROM BIOS Diskette Handler relocated by Hard Disk BIOS
 
     /* Register the BIOS 32-bit Interrupts */
index a2e19ac..54ce259 100644 (file)
@@ -3628,7 +3628,7 @@ VOID WINAPI VidBiosVideoService(LPWORD Stack)
                 /* Get Current Character Font Information */
                 case 0x30:
                 {
                 /* Get Current Character Font Information */
                 case 0x30:
                 {
-                    ULONG Address = (ULONG)NULL;
+                    ULONG Address = NULL32;
 
                     switch (getBH())
                     {
 
                     switch (getBH())
                     {
@@ -3936,16 +3936,16 @@ VOID VidBiosPost(VOID)
      */
 
     /* Some vectors are in fact addresses to tables */
      */
 
     /* Some vectors are in fact addresses to tables */
-    ((PULONG)BaseAddress)[0x1D] = (ULONG)NULL; // Video Parameter Tables
+    ((PULONG)BaseAddress)[0x1D] = NULL32; // Video Parameter Tables
     // Far pointer to the 8x8 graphics font for the 8x8 characters 80h-FFh
     ((PULONG)BaseAddress)[0x1F] = MAKELONG(FONT_8x8_HIGH_OFFSET, VIDEO_BIOS_DATA_SEG);
     // Far pointer to the character table (EGA, MCGA, VGA) for the 8x16 characters 00h-...
     ((PULONG)BaseAddress)[0x43] = MAKELONG(FONT_8x16_OFFSET, VIDEO_BIOS_DATA_SEG);
     // Far pointer to the 8x8 graphics font for the 8x8 characters 80h-FFh
     ((PULONG)BaseAddress)[0x1F] = MAKELONG(FONT_8x8_HIGH_OFFSET, VIDEO_BIOS_DATA_SEG);
     // Far pointer to the character table (EGA, MCGA, VGA) for the 8x16 characters 00h-...
     ((PULONG)BaseAddress)[0x43] = MAKELONG(FONT_8x16_OFFSET, VIDEO_BIOS_DATA_SEG);
-    ((PULONG)BaseAddress)[0x44] = (ULONG)NULL; // ROM BIOS Character Font, Characters 00h-7Fh (PCjr)
+    ((PULONG)BaseAddress)[0x44] = NULL32; // ROM BIOS Character Font, Characters 00h-7Fh (PCjr)
 
     /* Relocated services by the BIOS (when needed) */
 
     /* Relocated services by the BIOS (when needed) */
-    ((PULONG)BaseAddress)[0x42] = (ULONG)NULL; // Relocated Default INT 10h Video Services
-    ((PULONG)BaseAddress)[0x6D] = (ULONG)NULL; // Video BIOS Entry Point
+    ((PULONG)BaseAddress)[0x42] = NULL32; // Relocated Default INT 10h Video Services
+    ((PULONG)BaseAddress)[0x6D] = NULL32; // Video BIOS Entry Point
 
     //
     // FIXME: At the moment we always set a VGA mode. In the future,
 
     //
     // FIXME: At the moment we always set a VGA mode. In the future,
index 212f522..2fcbc00 100644 (file)
@@ -147,7 +147,7 @@ LONG CpuExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
             Fast486Rewind(&EmulatorContext);
 
             /* Call the memory handler */
             Fast486Rewind(&EmulatorContext);
 
             /* Call the memory handler */
-            MemExceptionHandler((ULONG)PHYS_TO_REAL(Address), Writing);
+            MemExceptionHandler((ULONG_PTR)PHYS_TO_REAL(Address), Writing);
 
             /* The execution of the CPU opcode handler MUST NOT continue */
             return EXCEPTION_EXECUTE_HANDLER;
 
             /* The execution of the CPU opcode handler MUST NOT continue */
             return EXCEPTION_EXECUTE_HANDLER;
index 1c81eac..d1edc10 100644 (file)
@@ -418,7 +418,7 @@ static VOID CmdStartExternalCommand(VOID)
     LPSTR Command = (LPSTR)SEG_OFF_TO_PTR(getDS(), getSI());
     CHAR CmdLine[sizeof("cmd.exe /c ") + DOS_CMDLINE_LENGTH + 1] = "";
     LPSTR CmdLinePtr;
     LPSTR Command = (LPSTR)SEG_OFF_TO_PTR(getDS(), getSI());
     CHAR CmdLine[sizeof("cmd.exe /c ") + DOS_CMDLINE_LENGTH + 1] = "";
     LPSTR CmdLinePtr;
-    ULONG CmdLineLen;
+    SIZE_T CmdLineLen;
 
     /* Spawn a user-defined 32-bit command preprocessor */
 
 
     /* Spawn a user-defined 32-bit command preprocessor */
 
index 8ba7489..7f40260 100644 (file)
@@ -830,7 +830,7 @@ BOOLEAN EmsDrvInitialize(USHORT Segment, ULONG TotalPages)
         return FALSE;
     }
 
         return FALSE;
     }
 
-    MemInstallFastMemoryHook((PVOID)TO_LINEAR(EmsSegment, 0),
+    MemInstallFastMemoryHook(UlongToPtr(TO_LINEAR(EmsSegment, 0)),
                              EMS_PHYSICAL_PAGES * EMS_PAGE_SIZE,
                              EmsReadMemory,
                              EmsWriteMemory);
                              EMS_PHYSICAL_PAGES * EMS_PAGE_SIZE,
                              EmsReadMemory,
                              EmsWriteMemory);
@@ -852,7 +852,7 @@ VOID EmsDrvCleanup(VOID)
     /* Delete the device */
     DosDeleteDevice(Node);
 
     /* Delete the device */
     DosDeleteDevice(Node);
 
-    MemRemoveFastMemoryHook((PVOID)TO_LINEAR(EmsSegment, 0),
+    MemRemoveFastMemoryHook(UlongToPtr(TO_LINEAR(EmsSegment, 0)),
                             EMS_PHYSICAL_PAGES * EMS_PAGE_SIZE);
 
     if (EmsMemory)
                             EMS_PHYSICAL_PAGES * EMS_PAGE_SIZE);
 
     if (EmsMemory)
index 01291b4..7f356b0 100644 (file)
@@ -174,7 +174,7 @@ static WORD DosCopyEnvironmentBlock(IN LPCSTR Environment OPTIONAL,
                                     IN LPCSTR ProgramName)
 {
     PCHAR Ptr, DestBuffer = NULL;
                                     IN LPCSTR ProgramName)
 {
     PCHAR Ptr, DestBuffer = NULL;
-    ULONG TotalSize = 0;
+    SIZE_T TotalSize = 0;
     WORD DestSegment;
 
     /* If we have an environment strings list, compute its size */
     WORD DestSegment;
 
     /* If we have an environment strings list, compute its size */
index 7b0671b..1353bb5 100644 (file)
@@ -397,7 +397,7 @@ static VOID CallMouseUserHandlers(USHORT CallMask)
 
     /* Call handler 0 */
     if ((DriverState.Handler0.CallMask & CallMask) != 0 &&
 
     /* Call handler 0 */
     if ((DriverState.Handler0.CallMask & CallMask) != 0 &&
-         DriverState.Handler0.Callback != (ULONG)NULL)
+         DriverState.Handler0.Callback != NULL32)
     {
         /*
          * Set the parameters for the callback.
     {
         /*
          * Set the parameters for the callback.
@@ -445,7 +445,7 @@ static VOID CallMouseUserHandlers(USHORT CallMask)
     {
         /* Call the suitable handlers */
         if ((DriverState.Handlers[i].CallMask & CallMask) != 0 &&
     {
         /* Call the suitable handlers */
         if ((DriverState.Handlers[i].CallMask & CallMask) != 0 &&
-             DriverState.Handlers[i].Callback != (ULONG)NULL)
+             DriverState.Handlers[i].Callback != NULL32)
         {
             /*
              * Set the parameters for the callback.
         {
             /*
              * Set the parameters for the callback.
@@ -920,13 +920,13 @@ static VOID WINAPI DosMouseService(LPWORD Stack)
                     {
                         /* Found it, undefine the handler */
                         DriverState.Handlers[i].CallMask = 0x0000;
                     {
                         /* Found it, undefine the handler */
                         DriverState.Handlers[i].CallMask = 0x0000;
-                        DriverState.Handlers[i].Callback = (ULONG)NULL;
+                        DriverState.Handlers[i].Callback = NULL32;
                         Success = TRUE;
                         break;
                     }
                 }
             }
                         Success = TRUE;
                         break;
                     }
                 }
             }
-            else if (Callback == (ULONG)NULL)
+            else if (Callback == NULL32)
             {
                 /*
                  * Find the handler entry corresponding to the given
             {
                 /*
                  * Find the handler entry corresponding to the given
@@ -938,7 +938,7 @@ static VOID WINAPI DosMouseService(LPWORD Stack)
                     {
                         /* Found it, undefine the handler */
                         DriverState.Handlers[i].CallMask = 0x0000;
                     {
                         /* Found it, undefine the handler */
                         DriverState.Handlers[i].CallMask = 0x0000;
-                        DriverState.Handlers[i].Callback = (ULONG)NULL;
+                        DriverState.Handlers[i].Callback = NULL32;
                         Success = TRUE;
                         break;
                     }
                         Success = TRUE;
                         break;
                     }
@@ -959,7 +959,7 @@ static VOID WINAPI DosMouseService(LPWORD Stack)
                     /* Find the first empty handler */
                     if (EmptyHandler == 0xFFFF &&
                         DriverState.Handlers[i].CallMask == 0x0000 &&
                     /* Find the first empty handler */
                     if (EmptyHandler == 0xFFFF &&
                         DriverState.Handlers[i].CallMask == 0x0000 &&
-                        DriverState.Handlers[i].Callback == (ULONG)NULL)
+                        DriverState.Handlers[i].Callback == NULL32)
                     {
                         EmptyHandler = i;
                     }
                     {
                         EmptyHandler = i;
                     }
index b90d8e8..2a6b186 100644 (file)
@@ -304,7 +304,7 @@ static VOID
 DumpMemoryRaw(HANDLE hFile)
 {
     PVOID  Buffer;
 DumpMemoryRaw(HANDLE hFile)
 {
     PVOID  Buffer;
-    SIZE_T Size;
+    DWORD Size;
 
     /* Dump the VM memory */
     SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
 
     /* Dump the VM memory */
     SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
@@ -321,7 +321,7 @@ DumpMemoryTxt(HANDLE hFile)
     PBYTE  Ptr1, Ptr2;
     CHAR   LineBuffer[LINE_SIZE];
     PCHAR  Line;
     PBYTE  Ptr1, Ptr2;
     CHAR   LineBuffer[LINE_SIZE];
     PCHAR  Line;
-    SIZE_T LineSize;
+    DWORD LineSize;
 
     /* Dump the VM memory */
     SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
 
     /* Dump the VM memory */
     SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
@@ -332,7 +332,7 @@ DumpMemoryTxt(HANDLE hFile)
         Line = LineBuffer;
 
         /* Print the address */
         Line = LineBuffer;
 
         /* Print the address */
-        Line += snprintf(Line, LINE_SIZE + LineBuffer - Line, "%08x ", PHYS_TO_REAL(Ptr1));
+        Line += snprintf(Line, LINE_SIZE + LineBuffer - Line, "%08Ix ", (ULONG_PTR)PHYS_TO_REAL(Ptr1));
 
         /* Print up to 16 bytes... */
 
 
         /* Print up to 16 bytes... */
 
index b253d6d..209f8ea 100644 (file)
@@ -1296,7 +1296,7 @@ static inline VOID VgaWriteGc(BYTE Data)
                 UCHAR MemoryMap = (VgaGcRegisters[VGA_GC_MISC_REG] >> 2) & 0x03;
 
                 /* Register a memory hook */
                 UCHAR MemoryMap = (VgaGcRegisters[VGA_GC_MISC_REG] >> 2) & 0x03;
 
                 /* Register a memory hook */
-                MemInstallFastMemoryHook((PVOID)MemoryBase[MemoryMap],
+                MemInstallFastMemoryHook(UlongToPtr(MemoryBase[MemoryMap]),
                                          MemorySize[MemoryMap],
                                          VgaReadMemory,
                                          VgaWriteMemory);
                                          MemorySize[MemoryMap],
                                          VgaReadMemory,
                                          VgaWriteMemory);
@@ -1466,7 +1466,7 @@ static VOID WINAPI VgaWritePort(USHORT Port, BYTE Data)
                 UCHAR MemoryMap = (VgaGcRegisters[VGA_GC_MISC_REG] >> 2) & 0x03;
 
                 /* Register a memory hook */
                 UCHAR MemoryMap = (VgaGcRegisters[VGA_GC_MISC_REG] >> 2) & 0x03;
 
                 /* Register a memory hook */
-                MemInstallFastMemoryHook((PVOID)MemoryBase[MemoryMap],
+                MemInstallFastMemoryHook(UlongToPtr(MemoryBase[MemoryMap]),
                                          MemorySize[MemoryMap],
                                          VgaReadMemory,
                                          VgaWriteMemory);
                                          MemorySize[MemoryMap],
                                          VgaReadMemory,
                                          VgaWriteMemory);
index 4804536..4e5cd99 100644 (file)
@@ -95,7 +95,7 @@ NtVdmConfigureFloppy(IN PWSTR ValueName,
 {
     BOOLEAN Success;
     PNTVDM_SETTINGS Settings = (PNTVDM_SETTINGS)Context;
 {
     BOOLEAN Success;
     PNTVDM_SETTINGS Settings = (PNTVDM_SETTINGS)Context;
-    ULONG DiskNumber = (ULONG)EntryContext;
+    ULONG DiskNumber = PtrToUlong(EntryContext);
 
     ASSERT(DiskNumber < ARRAYSIZE(Settings->FloppyDisks));
 
 
     ASSERT(DiskNumber < ARRAYSIZE(Settings->FloppyDisks));
 
@@ -131,7 +131,7 @@ NtVdmConfigureHDD(IN PWSTR ValueName,
 {
     BOOLEAN Success;
     PNTVDM_SETTINGS Settings = (PNTVDM_SETTINGS)Context;
 {
     BOOLEAN Success;
     PNTVDM_SETTINGS Settings = (PNTVDM_SETTINGS)Context;
-    ULONG DiskNumber = (ULONG)EntryContext;
+    ULONG DiskNumber = PtrToUlong(EntryContext);
 
     ASSERT(DiskNumber < ARRAYSIZE(Settings->HardDisks));
 
 
     ASSERT(DiskNumber < ARRAYSIZE(Settings->HardDisks));
 
index 60a763f..17dbd8d 100644 (file)
@@ -67,6 +67,7 @@ DWORD WINAPI SetLastConsoleEventActive(VOID);
 #define ADVANCED_DEBUGGING_LEVEL    1
 #endif
 
 #define ADVANCED_DEBUGGING_LEVEL    1
 #endif
 
+#define NULL32 0
 
 /* VARIABLES ******************************************************************/
 
 
 /* VARIABLES ******************************************************************/