[NTVDM]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 19 Apr 2015 00:01:03 +0000 (00:01 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 19 Apr 2015 00:01:03 +0000 (00:01 +0000)
- Rearrange header inclusions. Put almost all NDK stuff in ntvdm.h.
- sizeof(array)/sizeof(array[0]) --> ARRAYSIZE(array) : increase code readability.
- Use Rtl heap functions (other parts of the code already did use them).

svn path=/trunk/; revision=67283

67 files changed:
reactos/subsystems/mvdm/ntvdm/bios/bios.c
reactos/subsystems/mvdm/ntvdm/bios/bios.h
reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c
reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.h
reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32p.h
reactos/subsystems/mvdm/ntvdm/bios/bios32/ems.c
reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.c
reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.h
reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.c
reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.h
reactos/subsystems/mvdm/ntvdm/bios/bios32/vidbios32.c
reactos/subsystems/mvdm/ntvdm/bios/bios32/vidbios32.h
reactos/subsystems/mvdm/ntvdm/bios/kbdbios.c
reactos/subsystems/mvdm/ntvdm/bios/kbdbios.h
reactos/subsystems/mvdm/ntvdm/bios/rom.c
reactos/subsystems/mvdm/ntvdm/bios/rom.h
reactos/subsystems/mvdm/ntvdm/bios/vidbios.c
reactos/subsystems/mvdm/ntvdm/bios/vidbios.h
reactos/subsystems/mvdm/ntvdm/clock.c
reactos/subsystems/mvdm/ntvdm/clock.h
reactos/subsystems/mvdm/ntvdm/cpu/bop.c
reactos/subsystems/mvdm/ntvdm/cpu/callback.c
reactos/subsystems/mvdm/ntvdm/cpu/cpu.c
reactos/subsystems/mvdm/ntvdm/cpu/cpu.h
reactos/subsystems/mvdm/ntvdm/cpu/registers.c
reactos/subsystems/mvdm/ntvdm/dos/dem.c
reactos/subsystems/mvdm/ntvdm/dos/dem.h
reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c
reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/condrv.c
reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.c
reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.h
reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c
reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h
reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c
reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c
reactos/subsystems/mvdm/ntvdm/dos/mouse32.c
reactos/subsystems/mvdm/ntvdm/dos/mouse32.h
reactos/subsystems/mvdm/ntvdm/emulator.c
reactos/subsystems/mvdm/ntvdm/emulator.h
reactos/subsystems/mvdm/ntvdm/hardware/cmos.c
reactos/subsystems/mvdm/ntvdm/hardware/cmos.h
reactos/subsystems/mvdm/ntvdm/hardware/dma.c
reactos/subsystems/mvdm/ntvdm/hardware/dma.h
reactos/subsystems/mvdm/ntvdm/hardware/keyboard.c
reactos/subsystems/mvdm/ntvdm/hardware/keyboard.h
reactos/subsystems/mvdm/ntvdm/hardware/mouse.c
reactos/subsystems/mvdm/ntvdm/hardware/mouse.h
reactos/subsystems/mvdm/ntvdm/hardware/pic.c
reactos/subsystems/mvdm/ntvdm/hardware/pic.h
reactos/subsystems/mvdm/ntvdm/hardware/pit.c
reactos/subsystems/mvdm/ntvdm/hardware/pit.h
reactos/subsystems/mvdm/ntvdm/hardware/ps2.c
reactos/subsystems/mvdm/ntvdm/hardware/ps2.h
reactos/subsystems/mvdm/ntvdm/hardware/sound/speaker.c
reactos/subsystems/mvdm/ntvdm/hardware/sound/speaker.h
reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c
reactos/subsystems/mvdm/ntvdm/hardware/video/vga.h
reactos/subsystems/mvdm/ntvdm/int32.c
reactos/subsystems/mvdm/ntvdm/io.c
reactos/subsystems/mvdm/ntvdm/memory.c
reactos/subsystems/mvdm/ntvdm/ntvdm.c
reactos/subsystems/mvdm/ntvdm/ntvdm.h
reactos/subsystems/mvdm/ntvdm/utils.c
reactos/subsystems/mvdm/ntvdm/utils.h
reactos/subsystems/mvdm/ntvdm/vddsup.c
reactos/subsystems/mvdm/ntvdm/vddsup.h

index 78f78c1..25ca710 100644 (file)
@@ -10,6 +10,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "memory.h"
 #include "cpu/callback.h"
index a985639..d23fe19 100644 (file)
@@ -11,7 +11,6 @@
 
 /* INCLUDES *******************************************************************/
 
-#include "ntvdm.h"
 #include "kbdbios.h"
 #include "vidbios.h"
 
index bfc26b0..de07cfb 100644 (file)
@@ -13,6 +13,7 @@
 /* For BIOS Version number */
 #include <reactos/buildno.h>
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "cpu/cpu.h" // for EMULATOR_FLAG_CF
 #include "cpu/bop.h"
@@ -33,9 +34,6 @@
 #include "hardware/pic.h"
 #include "hardware/pit.h"
 
-/* Extra PSDK/NDK Headers */
-#include <ndk/kefuncs.h>
-
 /* PRIVATE VARIABLES **********************************************************/
 
 CALLBACK16 BiosContext;
index 1fb66ae..4f1523f 100644 (file)
@@ -11,7 +11,6 @@
 
 /* INCLUDES *******************************************************************/
 
-#include "ntvdm.h"
 // #include <bios/bios.h>
 
 /* DEFINES ********************************************************************/
index 9e70119..4236485 100644 (file)
@@ -11,7 +11,6 @@
 
 /* INCLUDES *******************************************************************/
 
-#include "ntvdm.h"
 #include <bios/bios.h>
 
 /**/ #include "int32.h" /**/
index 30d428f..3101fb4 100644 (file)
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "bios/bios32/bios32p.h"
-#include <ndk/rtltypes.h>
-#include <ndk/rtlfuncs.h>
 #include "ems.h"
 #include "memory.h"
 
index bfb319b..b8b79ba 100644 (file)
 
 #define NDEBUG
 
-#include "emulator.h"
-#include "cpu/cpu.h" // for EMULATOR_FLAG_ZF
-#include "int32.h"
+#include "ntvdm.h"
 
 #include "kbdbios32.h"
 #include <bios/kbdbios.h>
 #include "bios32p.h"
 
+#include "int32.h"
+#include "cpu/cpu.h" // for EMULATOR_FLAG_ZF
 #include "io.h"
 #include "hardware/ps2.h"
 
index 427945e..211033c 100644 (file)
@@ -9,10 +9,6 @@
 #ifndef _KBDBIOS32_H_
 #define _KBDBIOS32_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 // #define BIOS_KBD_INTERRUPT      0x16
index 0656c30..1aeb9aa 100644 (file)
@@ -9,10 +9,6 @@
 #ifndef _MOUBIOS32_H_
 #define _MOUBIOS32_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 #if 0 // This code is for the MOUSE.COM driver
index a647562..4b8ce6f 100644 (file)
@@ -12,7 +12,7 @@
 
 #define NDEBUG
 
-#include "emulator.h"
+#include "ntvdm.h"
 #include "int32.h"
 
 #include "vidbios32.h"
index 0cdea6e..5103e52 100644 (file)
 #ifndef _VIDBIOS32_H_
 #define _VIDBIOS32_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 // #define BIOS_VIDEO_INTERRUPT    0x10
index 007d256..27d2f0f 100644 (file)
@@ -10,6 +10,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "cpu/bop.h"
 
index 1d8798a..d1a4911 100644 (file)
@@ -9,10 +9,6 @@
 #ifndef _KBDBIOS_H_
 #define _KBDBIOS_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 #define BIOS_KBD_INTERRUPT      0x16
index 52864c1..78f282f 100644 (file)
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "cpu/callback.h"
-#include "utils.h"
-
 #include "rom.h"
 
+#include "utils.h"
+
 /* PRIVATE FUNCTIONS **********************************************************/
 
 static HANDLE
index 01f95e8..0bda3de 100644 (file)
@@ -9,10 +9,6 @@
 #ifndef _ROM_H_
 #define _ROM_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 #define ROM_AREA_START  0xE0000
index f135330..82b2d5f 100644 (file)
@@ -11,6 +11,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "cpu/cpu.h"
 #include "cpu/bop.h"
@@ -2235,13 +2236,13 @@ static VOID VgaChangePalette(BYTE ModeNumber)
     {
         /* VGA modes */
         Palette = VgaPalette;
-        Size    = sizeof(VgaPalette)/sizeof(VgaPalette[0]);
+        Size    = ARRAYSIZE(VgaPalette);
     }
     else if (ModeNumber == 0x10) // || (ModeNumber == 0x0D) || (ModeNumber == 0x0E)
     {
         /* EGA HiRes mode */
         Palette = EgaPalette__HiRes;
-        Size    = sizeof(EgaPalette__HiRes)/sizeof(EgaPalette__HiRes[0]);
+        Size    = ARRAYSIZE(EgaPalette__HiRes);
     }
 #if 0
     else if ((ModeNumber == 0x04) || (ModeNumber == 0x05))
@@ -2251,14 +2252,14 @@ static VOID VgaChangePalette(BYTE ModeNumber)
          * bright versions of CGA palettes 0 and 1
          */
         Palette = CgaPalette2;
-        Size    = sizeof(CgaPalette2)/sizeof(CgaPalette2[0]);
+        Size    = ARRAYSIZE(CgaPalette2);
     }
 #endif
     else // if ((ModeNumber == 0x0D) || (ModeNumber == 0x0E))
     {
         /* EGA modes */
         Palette = EgaPalette__16Colors;
-        Size    = sizeof(EgaPalette__16Colors)/sizeof(EgaPalette__16Colors[0]);
+        Size    = ARRAYSIZE(EgaPalette__16Colors);
     }
 
     VgaSetPalette(Palette, Size);
@@ -2388,7 +2389,7 @@ static BOOLEAN VidBiosSetVideoMode(BYTE ModeNumber)
 
     /* Retrieve the real mode number and check its validity */
     ModeNumber &= 0x7F;
-    // if (ModeNumber >= sizeof(VideoModes)/sizeof(VideoModes[0]))
+    // if (ModeNumber >= ARRAYSIZE(VideoModes))
     if (ModeNumber > BIOS_MAX_VIDEO_MODE)
     {
         DPRINT1("VidBiosSetVideoMode -- Mode %02Xh invalid\n", ModeNumber);
@@ -3045,7 +3046,7 @@ VOID WINAPI VidBiosVideoService(LPWORD Stack)
                     // FIXME: Use BL and DL for the number of screen rows
 
                     /* Write the default font to the VGA font plane */
-                    VgaWriteFont(0, Font8x8, sizeof(Font8x8)/sizeof(Font8x8[0]) / VGA_FONT_CHARACTERS);
+                    VgaWriteFont(0, Font8x8, ARRAYSIZE(Font8x8) / VGA_FONT_CHARACTERS);
 
                     /* Update the BIOS INT 43h vector */
                     // Far pointer to the 8x8 characters 00h-...
@@ -3060,7 +3061,7 @@ VOID WINAPI VidBiosVideoService(LPWORD Stack)
                     // FIXME: Use BL and DL for the number of screen rows
 
                     /* Write the default font to the VGA font plane */
-                    VgaWriteFont(0, Font8x16, sizeof(Font8x16)/sizeof(Font8x16[0]) / VGA_FONT_CHARACTERS);
+                    VgaWriteFont(0, Font8x16, ARRAYSIZE(Font8x16) / VGA_FONT_CHARACTERS);
 
                     /* Update the BIOS INT 43h vector */
                     // Far pointer to the 8x16 characters 00h-...
@@ -3293,7 +3294,7 @@ BOOLEAN VidBiosInitialize(VOID)
                   Font8x14, sizeof(Font8x14));
 
     /* Write the default font to the VGA font plane */
-    VgaWriteFont(0, Font8x16, sizeof(Font8x16)/sizeof(Font8x16[0]) / VGA_FONT_CHARACTERS);
+    VgaWriteFont(0, Font8x16, ARRAYSIZE(Font8x16) / VGA_FONT_CHARACTERS);
 
     //
     // FIXME: At the moment we always set a VGA mode. In the future,
index 99849d5..6c80227 100644 (file)
 #ifndef _VIDBIOS_H_
 #define _VIDBIOS_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 #define BIOS_VIDEO_INTERRUPT    0x10
index b0a4190..69a8696 100644 (file)
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
-#include "cpu/cpu.h"
-
 #include "clock.h"
 
+#include "cpu/cpu.h"
 #include "hardware/cmos.h"
 #include "hardware/ps2.h"
 #include "hardware/pit.h"
 #include "hardware/video/vga.h"
 #include "hardware/mouse.h"
 
-/* Extra PSDK/NDK Headers */
-#include <ndk/kefuncs.h>
-
 /* DEFINES ********************************************************************/
 
 /*
@@ -128,7 +125,7 @@ PHARDWARE_TIMER CreateHardwareTimer(ULONG Flags, ULONGLONG Delay, PHARDWARE_TIME
 {
     PHARDWARE_TIMER Timer;
     
-    Timer = (PHARDWARE_TIMER)RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(HARDWARE_TIMER));
+    Timer = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(*Timer));
     if (Timer == NULL) return NULL;
 
     Timer->Flags = Flags & ~HARDWARE_TIMER_ENABLED;
index fb48cd4..65fa322 100644 (file)
@@ -10,8 +10,6 @@
 #ifndef _CLOCK_H_
 #define _CLOCK_H_
 
-#include <ndk/rtlfuncs.h>
-
 /* DEFINITIONS ****************************************************************/
 
 #define HARDWARE_TIMER_ENABLED (1 << 0)
index d4f2430..3cc411e 100644 (file)
@@ -11,6 +11,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "bop.h"
 
index 0a71e88..8482ba7 100644 (file)
 
 #define NDEBUG
 
-#include "cpu.h"
-#include "callback.h"
+#include "ntvdm.h"
 #include "emulator.h"
+#include "callback.h"
 
+#include "cpu.h"
 #include "bop.h"
 #include <isvbop.h>
 
index 7246186..b2074dd 100644 (file)
 
 #define NDEBUG
 
+#include "ntvdm.h"
+#include "emulator.h"
 #include "cpu.h"
 
-#include "emulator.h"
 #include "memory.h"
 #include "callback.h"
 #include "bop.h"
 #include <isvbop.h>
-#include <pseh/pseh2.h>
 
 #include "clock.h"
 #include "bios/rom.h"
index b0e7fe2..7c721e3 100644 (file)
@@ -11,7 +11,6 @@
 
 /* INCLUDES *******************************************************************/
 
-#include "ntvdm.h"
 #include <fast486.h>
 
 /* DEFINES ********************************************************************/
index 7056787..c59e7d0 100644 (file)
@@ -10,6 +10,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "cpu.h"
 #include "x86context.h"
index 9deee83..f6de163 100644 (file)
@@ -14,6 +14,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "utils.h"
 
@@ -23,9 +24,6 @@
 #include "bios/bios.h"
 #include "mouse32.h"
 
-/* Extra PSDK/NDK Headers */
-#include <ndk/obtypes.h>
-
 /* PRIVATE VARIABLES **********************************************************/
 
 /**/extern BYTE CurrentDrive;/**/
@@ -201,7 +199,7 @@ CommandThreadProc(LPVOID Parameter)
     CHAR Desktop[MAX_PATH];
     CHAR Title[MAX_PATH];
     ULONG EnvSize = 256;
-    PVOID Env = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, EnvSize);
+    PVOID Env = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, EnvSize);
 
     UNREFERENCED_PARAMETER(Parameter);
     ASSERT(Env != NULL);
@@ -236,7 +234,7 @@ Command:
             {
                 /* Expand the environment size */
                 EnvSize = CommandInfo.EnvLen;
-                CommandInfo.Env = Env = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Env, EnvSize);
+                CommandInfo.Env = Env = RtlReAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, Env, EnvSize);
 
                 /* Repeat the request */
                 goto Command;
@@ -259,7 +257,7 @@ Command:
     }
     while (AcceptCommands);
 
-    HeapFree(GetProcessHeap(), 0, Env);
+    RtlFreeHeap(RtlGetProcessHeap(), 0, Env);
     return 0;
 }
 #endif
index 297ac26..d32ab46 100644 (file)
@@ -15,7 +15,6 @@
 
 /* INCLUDES *******************************************************************/
 
-#include "ntvdm.h"
 #include "dos32krnl/dos.h"
 
 /* FUNCTIONS ******************************************************************/
index aa03db5..41b144f 100644 (file)
@@ -10,6 +10,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "int32.h"
 
@@ -221,7 +222,7 @@ BOOLEAN DosBIOSInitialize(VOID)
     Stream = _wfopen(DOS_CONFIG_PATH, L"r");
     if (Stream != NULL)
     {
-        while (fgetws(Buffer, sizeof(Buffer)/sizeof(Buffer[0]), Stream))
+        while (fgetws(Buffer, ARRAYSIZE(Buffer), Stream))
         {
             // TODO: Parse the line
         }
index 5eb9415..d16e486 100644 (file)
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
+#include "device.h"
+
 #include "dos.h"
 #include "dos/dem.h"
 #include "memory.h"
-#include "device.h"
 
 /* PRIVATE VARIABLES **********************************************************/
 
@@ -212,9 +214,7 @@ PDOS_DEVICE_NODE DosCreateDevice(WORD Attributes, PCHAR DeviceName)
         return FALSE;
     }
 
-    Node = (PDOS_DEVICE_NODE)RtlAllocateHeap(RtlGetProcessHeap(),
-                                             HEAP_ZERO_MEMORY,
-                                             sizeof(DOS_DEVICE_NODE));
+    Node = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*Node));
     if (Node == NULL) return NULL;
 
     Node->DeviceAttributes = Attributes;
index 01d9efd..1635c6d 100644 (file)
@@ -9,8 +9,6 @@
 #ifndef _DEVICE_H_
 #define _DEVICE_H_
 
-#include <ndk/rtlfuncs.h>
-
 /* DEFINITIONS ****************************************************************/
 
 #define MAX_DEVICE_NAME 8
index eea13a7..5b11898 100644 (file)
@@ -11,6 +11,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "cpu/cpu.h"
 #include "int32.h"
index 9023882..d262bbf 100644 (file)
@@ -11,7 +11,6 @@
 
 /* INCLUDES *******************************************************************/
 
-#include "ntvdm.h"
 #include "device.h"
 
 /**/ #include "int32.h" /**/
index 6579394..1dde4b3 100644 (file)
@@ -10,6 +10,8 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
+
 #include "dos.h"
 #include "dos/dem.h"
 #include "device.h"
index b6fb32d..1d20673 100644 (file)
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
+#include "memory.h"
 
 #include "dos.h"
 #include "dos/dem.h"
-#include "memory.h"
 
 /* PUBLIC VARIABLES ***********************************************************/
 
index 4a3c10a..a57e532 100644 (file)
@@ -10,7 +10,9 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
+
 #include "cpu/cpu.h"
 #include "int32.h"
 #include "hardware/mouse.h"
@@ -187,7 +189,7 @@ static VOID CallMouseUserHandlers(USHORT CallMask)
         setDI(DI);
     }
 
-    for (i = 0; i < sizeof(DriverState.Handlers)/sizeof(DriverState.Handlers[0]); ++i)
+    for (i = 0; i < ARRAYSIZE(DriverState.Handlers); ++i)
     {
         /* Call the suitable handlers */
         if ((DriverState.Handlers[i].CallMask & CallMask) != 0 &&
@@ -654,7 +656,7 @@ static VOID WINAPI DosMouseService(LPWORD Stack)
                  * Find the handler entry corresponding to the given
                  * callback and undefine it.
                  */
-                for (i = 0; i < sizeof(DriverState.Handlers)/sizeof(DriverState.Handlers[0]); ++i)
+                for (i = 0; i < ARRAYSIZE(DriverState.Handlers); ++i)
                 {
                     if (DriverState.Handlers[i].Callback == Callback)
                     {
@@ -672,7 +674,7 @@ static VOID WINAPI DosMouseService(LPWORD Stack)
                  * Find the handler entry corresponding to the given
                  * callmask and undefine it.
                  */
-                for (i = 0; i < sizeof(DriverState.Handlers)/sizeof(DriverState.Handlers[0]); ++i)
+                for (i = 0; i < ARRAYSIZE(DriverState.Handlers); ++i)
                 {
                     if (DriverState.Handlers[i].CallMask == CallMask)
                     {
@@ -694,7 +696,7 @@ static VOID WINAPI DosMouseService(LPWORD Stack)
 
                 USHORT EmptyHandler = 0xFFFF; // Invalid handler
 
-                for (i = 0; i < sizeof(DriverState.Handlers)/sizeof(DriverState.Handlers[0]); ++i)
+                for (i = 0; i < ARRAYSIZE(DriverState.Handlers); ++i)
                 {
                     /* Find the first empty handler */
                     if (EmptyHandler == 0xFFFF &&
@@ -719,7 +721,7 @@ static VOID WINAPI DosMouseService(LPWORD Stack)
                  * an empty handler, set it.
                  */
                 if (!Success && EmptyHandler != 0xFFFF
-                    /* && EmptyHandler < sizeof(DriverState.Handlers)/sizeof(DriverState.Handlers[0]) */)
+                    /* && EmptyHandler < ARRAYSIZE(DriverState.Handlers) */)
                 {
                     DriverState.Handlers[EmptyHandler].CallMask = CallMask;
                     DriverState.Handlers[EmptyHandler].Callback = Callback;
@@ -744,7 +746,7 @@ static VOID WINAPI DosMouseService(LPWORD Stack)
             /*
              * Find the handler entry corresponding to the given callmask.
              */
-            for (i = 0; i < sizeof(DriverState.Handlers)/sizeof(DriverState.Handlers[0]); ++i)
+            for (i = 0; i < ARRAYSIZE(DriverState.Handlers); ++i)
             {
                 if (DriverState.Handlers[i].CallMask == CallMask)
                 {
index aadfbee..8b630bb 100644 (file)
@@ -9,10 +9,6 @@
 #ifndef _MOUSE32_H_
 #define _MOUSE32_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 #define DOS_MOUSE_INTERRUPT 0x33
index 2de9db1..d9389a4 100644 (file)
@@ -10,6 +10,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "memory.h"
 
 #include "vddsup.h"
 #include "io.h"
 
-/* Extra PSDK/NDK Headers */
-#include <ndk/psfuncs.h>
-#include <ndk/mmfuncs.h>
-
 /* PRIVATE VARIABLES **********************************************************/
 
 LPVOID  BaseAddress = NULL;
index f0cdf84..169447d 100644 (file)
@@ -11,7 +11,6 @@
 
 /* INCLUDES *******************************************************************/
 
-#include "ntvdm.h"
 #include <fast486.h>
 
 /* DEFINES ********************************************************************/
index 1006ee2..b894b7c 100644 (file)
@@ -10,6 +10,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "cmos.h"
 
index b7369c6..ac243ad 100644 (file)
@@ -9,10 +9,6 @@
 #ifndef _CMOS_H_
 #define _CMOS_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 #define RTC_IRQ_NUMBER      8
index e442242..27bb56f 100644 (file)
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
-#include "io.h"
 #include "dma.h"
 
+#include "io.h"
+
 /* PRIVATE VARIABLES **********************************************************/
 
 /*
index 1e41f28..3fe93f8 100644 (file)
 #ifndef _DMA_H_
 #define _DMA_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 #define DMA_CONTROLLERS         2
index 520d503..0516fa7 100644 (file)
@@ -10,6 +10,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "keyboard.h"
 #include "ps2.h"
 
index 39c91bc..0b7cd4a 100644 (file)
@@ -9,10 +9,6 @@
 #ifndef _KEYBOARD_H_
 #define _KEYBOARD_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 /* Command responses */
index 5ffda02..20815ec 100644 (file)
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "mouse.h"
 #include "ps2.h"
+
 #include "clock.h"
 #include "video/vga.h"
 
index b91146e..23f15a0 100644 (file)
@@ -9,10 +9,6 @@
 #ifndef _MOUSE_H_
 #define _MOUSE_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 /* Mouse packet constants */
index 2d6296a..e7c38eb 100644 (file)
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
-#include "io.h"
 #include "pic.h"
 
+#include "io.h"
+
 /* PRIVATE VARIABLES **********************************************************/
 
 static PIC MasterPic, SlavePic;
index 03d7dd1..d8dfafd 100644 (file)
 #ifndef _PIC_H_
 #define _PIC_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 #define PIC_MASTER_CMD  0x20
index f64d267..118b594 100644 (file)
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
-#include "io.h"
 #include "pit.h"
+
+#include "io.h"
 #include "pic.h"
 #include "clock.h"
 
index b06fe24..9a10142 100644 (file)
 #ifndef _PIT_H_
 #define _PIT_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 #define PIT_CHANNELS 3
index 5309fd7..bcb2fb2 100644 (file)
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
-#include "io.h"
 #include "ps2.h"
+
+#include "io.h"
 #include "pic.h"
 #include "clock.h"
 
index d62387c..d8cf276 100644 (file)
 #ifndef _PS2_H_
 #define _PS2_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 #define PS2_DATA_PORT       0x60
index ef2c98d..d3e3137 100644 (file)
 
 #define NDEBUG
 
-#include "emulator.h"
+#include "ntvdm.h"
 #include "speaker.h"
 #include "hardware/pit.h"
 
 /* Extra PSDK/NDK Headers */
 #include <ndk/iofuncs.h>
-#include <ndk/obfuncs.h>
-#include <ndk/rtlfuncs.h>
-
-/* Extra PSDK/NDK Headers */
-#include <ndk/kefuncs.h>
 
 /* DDK Driver Headers */
 #include <ntddbeep.h>
index 95c21d2..ad1a38a 100644 (file)
@@ -9,12 +9,6 @@
 #ifndef _SPEAKER_H_
 #define _SPEAKER_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
-/* DEFINES ********************************************************************/
-
 /* FUNCTIONS ******************************************************************/
 
 VOID SpeakerChange(UCHAR Port61hValue);
index 8e84117..3562d79 100644 (file)
@@ -10,6 +10,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "vga.h"
 #include <bios/vidbios.h>
@@ -356,26 +357,26 @@ __RegisterConsoleVDM(IN DWORD dwRegisterFlags,
         VDMBufferSize = dwVDMBufferSize;
 
         /* HACK: Cache -- to be removed in the real implementation */
-        CharBuff = HeapAlloc(GetProcessHeap(),
-                             HEAP_ZERO_MEMORY,
-                             VDMBufferSize.X * VDMBufferSize.Y
-                                             * sizeof(CHAR_INFO));
+        CharBuff = RtlAllocateHeap(RtlGetProcessHeap(),
+                                   HEAP_ZERO_MEMORY,
+                                   VDMBufferSize.X * VDMBufferSize.Y
+                                                   * sizeof(*CharBuff));
         ASSERT(CharBuff);
 
-        VDMBuffer = HeapAlloc(GetProcessHeap(),
-                              HEAP_ZERO_MEMORY,
-                              VDMBufferSize.X * VDMBufferSize.Y
-                                              * sizeof(CHAR_CELL));
+        VDMBuffer = RtlAllocateHeap(RtlGetProcessHeap(),
+                                    HEAP_ZERO_MEMORY,
+                                    VDMBufferSize.X * VDMBufferSize.Y
+                                                    * sizeof(*VDMBuffer));
         *lpVDMBuffer = VDMBuffer;
         return (VDMBuffer != NULL);
     }
     else
     {
         /* HACK: Cache -- to be removed in the real implementation */
-        if (CharBuff) HeapFree(GetProcessHeap(), 0, CharBuff);
+        if (CharBuff) RtlFreeHeap(RtlGetProcessHeap(), 0, CharBuff);
         CharBuff = NULL;
 
-        if (VDMBuffer) HeapFree(GetProcessHeap(), 0, VDMBuffer);
+        if (VDMBuffer) RtlFreeHeap(RtlGetProcessHeap(), 0, VDMBuffer);
         VDMBuffer = NULL;
 
         VDMBufferSize.X = VDMBufferSize.Y = 0;
@@ -500,10 +501,10 @@ static BOOL VgaAttachToConsoleInternal(PCOORD Resolution)
     }
 
 #ifdef USE_REAL_REGISTERCONSOLEVDM
-    CharBuff = HeapAlloc(GetProcessHeap(),
-                         HEAP_ZERO_MEMORY,
-                         TextResolution.X * TextResolution.Y
-                                          * sizeof(CHAR_INFO));
+    CharBuff = RtlAllocateHeap(RtlGetProcessHeap(),
+                               HEAP_ZERO_MEMORY,
+                               TextResolution.X * TextResolution.Y
+                                                * sizeof(*CharBuff));
     ASSERT(CharBuff);
 #endif
 
@@ -568,7 +569,7 @@ static BOOL VgaAttachToConsoleInternal(PCOORD Resolution)
     }
 
 #ifdef USE_REAL_REGISTERCONSOLEVDM
-    if (CharBuff) HeapFree(GetProcessHeap(), 0, CharBuff);
+    if (CharBuff) RtlFreeHeap(RtlGetProcessHeap(), 0, CharBuff);
 #endif
 
     VgaUpdateCursorPosition();
@@ -773,14 +774,14 @@ static BOOLEAN VgaInitializePalette(VOID)
     LPLOGPALETTE Palette, TextPalette;
 
     /* Allocate storage space for the palettes */
-    Palette = (LPLOGPALETTE)HeapAlloc(GetProcessHeap(),
-                                      HEAP_ZERO_MEMORY,
-                                      sizeof(LOGPALETTE) +
-                                      VGA_MAX_COLORS * sizeof(PALETTEENTRY));
-    TextPalette = (LPLOGPALETTE)HeapAlloc(GetProcessHeap(),
-                                          HEAP_ZERO_MEMORY,
-                                          sizeof(LOGPALETTE) + 
-                                          (VGA_AC_PAL_F_REG + 1) * sizeof(PALETTEENTRY));
+    Palette = RtlAllocateHeap(RtlGetProcessHeap(),
+                              HEAP_ZERO_MEMORY,
+                              sizeof(LOGPALETTE) +
+                                  VGA_MAX_COLORS * sizeof(PALETTEENTRY));
+    TextPalette = RtlAllocateHeap(RtlGetProcessHeap(),
+                                  HEAP_ZERO_MEMORY,
+                                  sizeof(LOGPALETTE) + 
+                                      (VGA_AC_PAL_F_REG + 1) * sizeof(PALETTEENTRY));
     if ((Palette == NULL) || (TextPalette == NULL)) goto Cleanup;
 
     /* Initialize the palettes */
@@ -813,8 +814,8 @@ static BOOLEAN VgaInitializePalette(VOID)
 
 Cleanup:
     /* Free the palettes */
-    if (Palette) HeapFree(GetProcessHeap(), 0, Palette);
-    if (TextPalette) HeapFree(GetProcessHeap(), 0, TextPalette);
+    if (Palette) RtlFreeHeap(RtlGetProcessHeap(), 0, Palette);
+    if (TextPalette) RtlFreeHeap(RtlGetProcessHeap(), 0, TextPalette);
 
     if (!Result)
     {
index b1716b3..445f700 100644 (file)
@@ -9,10 +9,6 @@
 #ifndef _VGA_H_
 #define _VGA_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* DEFINES ********************************************************************/
 
 #define VGA_NUM_BANKS 4
index e87db2e..a111270 100644 (file)
@@ -11,6 +11,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "int32.h"
 
index 5ecce93..ca8e207 100644 (file)
@@ -11,6 +11,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "io.h"
 
index f5cb23a..e6c8723 100644 (file)
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
-#include <ndk/mmfuncs.h>
-#include <ndk/rtlfuncs.h>
 #include "memory.h"
 
+/* Extra PSDK/NDK Headers */
+#include <ndk/mmfuncs.h>
+
 /* PRIVATE VARIABLES **********************************************************/
 
 typedef struct _MEM_HOOK
index 58f18bf..7f0885c 100644 (file)
@@ -12,9 +12,9 @@
 
 #include "ntvdm.h"
 #include "emulator.h"
-#include "cpu/cpu.h"
 
 #include "bios/bios.h"
+#include "cpu/cpu.h"
 
 #include "resource.h"
 
@@ -85,7 +85,7 @@ AppendMenuItems(HMENU hMenu,
             if (LoadStringW(GetModuleHandle(NULL),
                             Items[i].uID,
                             szMenuString,
-                            sizeof(szMenuString) / sizeof(szMenuString[0])) > 0)
+                            ARRAYSIZE(szMenuString)) > 0)
             {
                 if (Items[i].SubMenu != NULL)
                 {
@@ -169,7 +169,7 @@ static VOID ShowHideMousePointer(HANDLE ConOutHandle, BOOLEAN ShowPtr)
     if (LoadStringW(GetModuleHandle(NULL),
                     (!ShowPtr ? IDS_SHOW_MOUSE : IDS_HIDE_MOUSE),
                     szMenuString,
-                    sizeof(szMenuString) / sizeof(szMenuString[0])) > 0)
+                    ARRAYSIZE(szMenuString)) > 0)
     {
         ModifyMenu(hConsoleMenu, ID_SHOWHIDE_MOUSE,
                    MF_BYCOMMAND, ID_SHOWHIDE_MOUSE, szMenuString);
@@ -226,9 +226,9 @@ DisplayMessage(LPCWSTR Format, ...)
      * an auxiliary buffer; otherwise use the static buffer.
      */
     MsgLen = _vscwprintf(Format, Parameters) + 1; // NULL-terminated
-    if (MsgLen > sizeof(StaticBuffer)/sizeof(StaticBuffer[0]))
+    if (MsgLen > ARRAYSIZE(StaticBuffer))
     {
-        Buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MsgLen * sizeof(WCHAR));
+        Buffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, MsgLen * sizeof(WCHAR));
         if (Buffer == NULL)
         {
             /* Allocation failed, use the static buffer and display a suitable error message */
@@ -238,7 +238,7 @@ DisplayMessage(LPCWSTR Format, ...)
         }
     }
 #else
-    MsgLen = sizeof(Buffer)/sizeof(Buffer[0]);
+    MsgLen = ARRAYSIZE(Buffer);
 #endif
 
     /* Display the message */
@@ -248,7 +248,7 @@ DisplayMessage(LPCWSTR Format, ...)
 
 #ifndef WIN2K_COMPLIANT
     /* Free the buffer if needed */
-    if (Buffer != StaticBuffer) HeapFree(GetProcessHeap(), 0, Buffer);
+    if (Buffer != StaticBuffer) RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
 #endif
 
     va_end(Parameters);
index 7bcc748..1b7c988 100644 (file)
@@ -13,9 +13,9 @@
 
 #include <stdio.h>
 #include <stdarg.h>
-#include <conio.h>
 #include <wchar.h>
 
+/* PSDK/NDK Headers */
 #define WIN32_NO_STATUS
 #include <windef.h>
 #include <winbase.h>
 
 DWORD WINAPI SetLastConsoleEventActive(VOID);
 
+#define NTOS_MODE_USER
+#include <ndk/kefuncs.h>
+#include <ndk/obfuncs.h>
+#include <ndk/rtlfuncs.h>
+#include <ndk/rtltypes.h>
+
+/* PSEH for SEH Support */
+#include <pseh/pseh2.h>
+
 #include <debug.h>
 
 /*
index 0619376..be9b9c1 100644 (file)
@@ -10,7 +10,7 @@
 
 #define NDEBUG
 
-#include "emulator.h"
+#include "ntvdm.h"
 
 /* PRIVATE FUNCTIONS **********************************************************/
 
index 98ce093..7a6ffac 100644 (file)
@@ -9,10 +9,6 @@
 #ifndef _UTILS_H_
 #define _UTILS_H_
 
-/* INCLUDES *******************************************************************/
-
-#include "ntvdm.h"
-
 /* FUNCTIONS ******************************************************************/
 
 VOID
index 7d3f4e2..0180e9c 100644 (file)
@@ -10,6 +10,7 @@
 
 #define NDEBUG
 
+#include "ntvdm.h"
 #include "emulator.h"
 #include "vddsup.h"
 
@@ -41,7 +42,7 @@ static VDD_MODULE VDDList[MAX_VDD_MODULES] = {{NULL}};
 static USHORT GetNextFreeVDDEntry(VOID)
 {
     USHORT Entry = MAX_VDD_MODULES;
-    for (Entry = 0; Entry < sizeof(VDDList)/sizeof(VDDList[0]); ++Entry)
+    for (Entry = 0; Entry < ARRAYSIZE(VDDList); ++Entry)
     {
         if (VDDList[Entry].hDll == NULL) break;
     }
@@ -296,7 +297,7 @@ static BOOL LoadInstallableVDD(VOID)
 
     /* Allocate the buffer */
     BufSize = (BufSize < 2*sizeof(WCHAR) ? 2*sizeof(WCHAR) : BufSize);
-    VDDList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, BufSize);
+    VDDList = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, BufSize);
     if (VDDList == NULL)
     {
         DisplayMessage(ERROR_MEMORYVDD);
@@ -338,7 +339,7 @@ static BOOL LoadInstallableVDD(VOID)
     VDDList = VDDValueName;
 
 Quit:
-    if (VDDList) HeapFree(GetProcessHeap(), 0, VDDList);
+    if (VDDList) RtlFreeHeap(RtlGetProcessHeap(), 0, VDDList);
     RegCloseKey(hVDDKey);
     return Success;
 }
index 4de9178..3b55e0b 100644 (file)
@@ -9,8 +9,6 @@
 #ifndef _VDDSUP_H_
 #define _VDDSUP_H_
 
-/* DEFINES ********************************************************************/
-
 /* FUNCTIONS ******************************************************************/
 
 VOID VDDSupInitialize(VOID);