From 9d3bb1fef2cfcdb6d609ae6c70e02e1e73b720d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 19 Apr 2015 00:01:03 +0000 Subject: [PATCH] [NTVDM] - 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 --- reactos/subsystems/mvdm/ntvdm/bios/bios.c | 1 + reactos/subsystems/mvdm/ntvdm/bios/bios.h | 1 - .../mvdm/ntvdm/bios/bios32/bios32.c | 4 +- .../mvdm/ntvdm/bios/bios32/bios32.h | 1 - .../mvdm/ntvdm/bios/bios32/bios32p.h | 1 - .../subsystems/mvdm/ntvdm/bios/bios32/ems.c | 3 +- .../mvdm/ntvdm/bios/bios32/kbdbios32.c | 6 +-- .../mvdm/ntvdm/bios/bios32/kbdbios32.h | 4 -- .../mvdm/ntvdm/bios/bios32/moubios32.c | 1 + .../mvdm/ntvdm/bios/bios32/moubios32.h | 4 -- .../mvdm/ntvdm/bios/bios32/vidbios32.c | 2 +- .../mvdm/ntvdm/bios/bios32/vidbios32.h | 4 -- reactos/subsystems/mvdm/ntvdm/bios/kbdbios.c | 1 + reactos/subsystems/mvdm/ntvdm/bios/kbdbios.h | 4 -- reactos/subsystems/mvdm/ntvdm/bios/rom.c | 5 +- reactos/subsystems/mvdm/ntvdm/bios/rom.h | 4 -- reactos/subsystems/mvdm/ntvdm/bios/vidbios.c | 17 ++++--- reactos/subsystems/mvdm/ntvdm/bios/vidbios.h | 4 -- reactos/subsystems/mvdm/ntvdm/clock.c | 9 ++-- reactos/subsystems/mvdm/ntvdm/clock.h | 2 - reactos/subsystems/mvdm/ntvdm/cpu/bop.c | 1 + reactos/subsystems/mvdm/ntvdm/cpu/callback.c | 5 +- reactos/subsystems/mvdm/ntvdm/cpu/cpu.c | 4 +- reactos/subsystems/mvdm/ntvdm/cpu/cpu.h | 1 - reactos/subsystems/mvdm/ntvdm/cpu/registers.c | 1 + reactos/subsystems/mvdm/ntvdm/dos/dem.c | 10 ++-- reactos/subsystems/mvdm/ntvdm/dos/dem.h | 1 - .../mvdm/ntvdm/dos/dos32krnl/bios.c | 3 +- .../mvdm/ntvdm/dos/dos32krnl/condrv.c | 1 + .../mvdm/ntvdm/dos/dos32krnl/device.c | 8 +-- .../mvdm/ntvdm/dos/dos32krnl/device.h | 2 - .../subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c | 1 + .../subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h | 1 - .../mvdm/ntvdm/dos/dos32krnl/dosfiles.c | 1 + .../mvdm/ntvdm/dos/dos32krnl/emsdrv.c | 2 + .../mvdm/ntvdm/dos/dos32krnl/memory.c | 3 +- reactos/subsystems/mvdm/ntvdm/dos/mouse32.c | 14 ++--- reactos/subsystems/mvdm/ntvdm/dos/mouse32.h | 4 -- reactos/subsystems/mvdm/ntvdm/emulator.c | 5 +- reactos/subsystems/mvdm/ntvdm/emulator.h | 1 - reactos/subsystems/mvdm/ntvdm/hardware/cmos.c | 1 + reactos/subsystems/mvdm/ntvdm/hardware/cmos.h | 4 -- reactos/subsystems/mvdm/ntvdm/hardware/dma.c | 4 +- reactos/subsystems/mvdm/ntvdm/hardware/dma.h | 4 -- .../subsystems/mvdm/ntvdm/hardware/keyboard.c | 1 + .../subsystems/mvdm/ntvdm/hardware/keyboard.h | 4 -- .../subsystems/mvdm/ntvdm/hardware/mouse.c | 2 + .../subsystems/mvdm/ntvdm/hardware/mouse.h | 4 -- reactos/subsystems/mvdm/ntvdm/hardware/pic.c | 4 +- reactos/subsystems/mvdm/ntvdm/hardware/pic.h | 4 -- reactos/subsystems/mvdm/ntvdm/hardware/pit.c | 4 +- reactos/subsystems/mvdm/ntvdm/hardware/pit.h | 4 -- reactos/subsystems/mvdm/ntvdm/hardware/ps2.c | 4 +- reactos/subsystems/mvdm/ntvdm/hardware/ps2.h | 4 -- .../mvdm/ntvdm/hardware/sound/speaker.c | 7 +-- .../mvdm/ntvdm/hardware/sound/speaker.h | 6 --- .../mvdm/ntvdm/hardware/video/vga.c | 51 ++++++++++--------- .../mvdm/ntvdm/hardware/video/vga.h | 4 -- reactos/subsystems/mvdm/ntvdm/int32.c | 1 + reactos/subsystems/mvdm/ntvdm/io.c | 1 + reactos/subsystems/mvdm/ntvdm/memory.c | 6 ++- reactos/subsystems/mvdm/ntvdm/ntvdm.c | 14 ++--- reactos/subsystems/mvdm/ntvdm/ntvdm.h | 11 +++- reactos/subsystems/mvdm/ntvdm/utils.c | 2 +- reactos/subsystems/mvdm/ntvdm/utils.h | 4 -- reactos/subsystems/mvdm/ntvdm/vddsup.c | 7 +-- reactos/subsystems/mvdm/ntvdm/vddsup.h | 2 - 67 files changed, 128 insertions(+), 183 deletions(-) diff --git a/reactos/subsystems/mvdm/ntvdm/bios/bios.c b/reactos/subsystems/mvdm/ntvdm/bios/bios.c index 78f78c14d91..25ca71054b4 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/bios.c +++ b/reactos/subsystems/mvdm/ntvdm/bios/bios.c @@ -10,6 +10,7 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "memory.h" #include "cpu/callback.h" diff --git a/reactos/subsystems/mvdm/ntvdm/bios/bios.h b/reactos/subsystems/mvdm/ntvdm/bios/bios.h index a985639d283..d23fe1992db 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/bios.h +++ b/reactos/subsystems/mvdm/ntvdm/bios/bios.h @@ -11,7 +11,6 @@ /* INCLUDES *******************************************************************/ -#include "ntvdm.h" #include "kbdbios.h" #include "vidbios.h" diff --git a/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c b/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c index bfc26b0291c..de07cfbf74e 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c +++ b/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c @@ -13,6 +13,7 @@ /* For BIOS Version number */ #include +#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 - /* PRIVATE VARIABLES **********************************************************/ CALLBACK16 BiosContext; diff --git a/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.h b/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.h index 1fb66aef87a..4f1523fa1d7 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.h +++ b/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.h @@ -11,7 +11,6 @@ /* INCLUDES *******************************************************************/ -#include "ntvdm.h" // #include /* DEFINES ********************************************************************/ diff --git a/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32p.h b/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32p.h index 9e70119bb1b..423648551ad 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32p.h +++ b/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32p.h @@ -11,7 +11,6 @@ /* INCLUDES *******************************************************************/ -#include "ntvdm.h" #include /**/ #include "int32.h" /**/ diff --git a/reactos/subsystems/mvdm/ntvdm/bios/bios32/ems.c b/reactos/subsystems/mvdm/ntvdm/bios/bios32/ems.c index 30d428f6dd8..3101fb4e094 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/bios32/ems.c +++ b/reactos/subsystems/mvdm/ntvdm/bios/bios32/ems.c @@ -10,10 +10,9 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "bios/bios32/bios32p.h" -#include -#include #include "ems.h" #include "memory.h" diff --git a/reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.c b/reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.c index bfb319b7ef2..b8b79ba0e94 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.c +++ b/reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.c @@ -10,14 +10,14 @@ #define NDEBUG -#include "emulator.h" -#include "cpu/cpu.h" // for EMULATOR_FLAG_ZF -#include "int32.h" +#include "ntvdm.h" #include "kbdbios32.h" #include #include "bios32p.h" +#include "int32.h" +#include "cpu/cpu.h" // for EMULATOR_FLAG_ZF #include "io.h" #include "hardware/ps2.h" diff --git a/reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.h b/reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.h index 427945e368a..211033c0aae 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.h +++ b/reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.h @@ -9,10 +9,6 @@ #ifndef _KBDBIOS32_H_ #define _KBDBIOS32_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ // #define BIOS_KBD_INTERRUPT 0x16 diff --git a/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.c b/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.c index a77fa4d8334..bdb22aa4118 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.c +++ b/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.c @@ -10,6 +10,7 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "moubios32.h" diff --git a/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.h b/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.h index 0656c30798a..1aeb9aa29d3 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.h +++ b/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.h @@ -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 diff --git a/reactos/subsystems/mvdm/ntvdm/bios/bios32/vidbios32.c b/reactos/subsystems/mvdm/ntvdm/bios/bios32/vidbios32.c index a647562846e..4b8ce6fb35b 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/bios32/vidbios32.c +++ b/reactos/subsystems/mvdm/ntvdm/bios/bios32/vidbios32.c @@ -12,7 +12,7 @@ #define NDEBUG -#include "emulator.h" +#include "ntvdm.h" #include "int32.h" #include "vidbios32.h" diff --git a/reactos/subsystems/mvdm/ntvdm/bios/bios32/vidbios32.h b/reactos/subsystems/mvdm/ntvdm/bios/bios32/vidbios32.h index 0cdea6e7f1c..5103e5202c5 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/bios32/vidbios32.h +++ b/reactos/subsystems/mvdm/ntvdm/bios/bios32/vidbios32.h @@ -11,10 +11,6 @@ #ifndef _VIDBIOS32_H_ #define _VIDBIOS32_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ // #define BIOS_VIDEO_INTERRUPT 0x10 diff --git a/reactos/subsystems/mvdm/ntvdm/bios/kbdbios.c b/reactos/subsystems/mvdm/ntvdm/bios/kbdbios.c index 007d2566100..27d2f0f521c 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/kbdbios.c +++ b/reactos/subsystems/mvdm/ntvdm/bios/kbdbios.c @@ -10,6 +10,7 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "cpu/bop.h" diff --git a/reactos/subsystems/mvdm/ntvdm/bios/kbdbios.h b/reactos/subsystems/mvdm/ntvdm/bios/kbdbios.h index 1d8798ac763..d1a4911b919 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/kbdbios.h +++ b/reactos/subsystems/mvdm/ntvdm/bios/kbdbios.h @@ -9,10 +9,6 @@ #ifndef _KBDBIOS_H_ #define _KBDBIOS_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ #define BIOS_KBD_INTERRUPT 0x16 diff --git a/reactos/subsystems/mvdm/ntvdm/bios/rom.c b/reactos/subsystems/mvdm/ntvdm/bios/rom.c index 52864c1efbd..78f282ffe1c 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/rom.c +++ b/reactos/subsystems/mvdm/ntvdm/bios/rom.c @@ -10,12 +10,13 @@ #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 diff --git a/reactos/subsystems/mvdm/ntvdm/bios/rom.h b/reactos/subsystems/mvdm/ntvdm/bios/rom.h index 01f95e85dc8..0bda3de911c 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/rom.h +++ b/reactos/subsystems/mvdm/ntvdm/bios/rom.h @@ -9,10 +9,6 @@ #ifndef _ROM_H_ #define _ROM_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ #define ROM_AREA_START 0xE0000 diff --git a/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c b/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c index f135330acb0..82b2d5f0aea 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c +++ b/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c @@ -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, diff --git a/reactos/subsystems/mvdm/ntvdm/bios/vidbios.h b/reactos/subsystems/mvdm/ntvdm/bios/vidbios.h index 99849d5dd4e..6c802278213 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/vidbios.h +++ b/reactos/subsystems/mvdm/ntvdm/bios/vidbios.h @@ -10,10 +10,6 @@ #ifndef _VIDBIOS_H_ #define _VIDBIOS_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ #define BIOS_VIDEO_INTERRUPT 0x10 diff --git a/reactos/subsystems/mvdm/ntvdm/clock.c b/reactos/subsystems/mvdm/ntvdm/clock.c index b0a4190d7e5..69a86965c6e 100644 --- a/reactos/subsystems/mvdm/ntvdm/clock.c +++ b/reactos/subsystems/mvdm/ntvdm/clock.c @@ -11,20 +11,17 @@ #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 - /* 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; diff --git a/reactos/subsystems/mvdm/ntvdm/clock.h b/reactos/subsystems/mvdm/ntvdm/clock.h index fb48cd4411e..65fa32258f9 100644 --- a/reactos/subsystems/mvdm/ntvdm/clock.h +++ b/reactos/subsystems/mvdm/ntvdm/clock.h @@ -10,8 +10,6 @@ #ifndef _CLOCK_H_ #define _CLOCK_H_ -#include - /* DEFINITIONS ****************************************************************/ #define HARDWARE_TIMER_ENABLED (1 << 0) diff --git a/reactos/subsystems/mvdm/ntvdm/cpu/bop.c b/reactos/subsystems/mvdm/ntvdm/cpu/bop.c index d4f2430c61b..3cc411e1dab 100644 --- a/reactos/subsystems/mvdm/ntvdm/cpu/bop.c +++ b/reactos/subsystems/mvdm/ntvdm/cpu/bop.c @@ -11,6 +11,7 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "bop.h" diff --git a/reactos/subsystems/mvdm/ntvdm/cpu/callback.c b/reactos/subsystems/mvdm/ntvdm/cpu/callback.c index 0a71e88bf4f..8482ba79f56 100644 --- a/reactos/subsystems/mvdm/ntvdm/cpu/callback.c +++ b/reactos/subsystems/mvdm/ntvdm/cpu/callback.c @@ -19,10 +19,11 @@ #define NDEBUG -#include "cpu.h" -#include "callback.h" +#include "ntvdm.h" #include "emulator.h" +#include "callback.h" +#include "cpu.h" #include "bop.h" #include diff --git a/reactos/subsystems/mvdm/ntvdm/cpu/cpu.c b/reactos/subsystems/mvdm/ntvdm/cpu/cpu.c index 7246186fd65..b2074ddbb94 100644 --- a/reactos/subsystems/mvdm/ntvdm/cpu/cpu.c +++ b/reactos/subsystems/mvdm/ntvdm/cpu/cpu.c @@ -10,14 +10,14 @@ #define NDEBUG +#include "ntvdm.h" +#include "emulator.h" #include "cpu.h" -#include "emulator.h" #include "memory.h" #include "callback.h" #include "bop.h" #include -#include #include "clock.h" #include "bios/rom.h" diff --git a/reactos/subsystems/mvdm/ntvdm/cpu/cpu.h b/reactos/subsystems/mvdm/ntvdm/cpu/cpu.h index b0e7fe258b8..7c721e3873a 100644 --- a/reactos/subsystems/mvdm/ntvdm/cpu/cpu.h +++ b/reactos/subsystems/mvdm/ntvdm/cpu/cpu.h @@ -11,7 +11,6 @@ /* INCLUDES *******************************************************************/ -#include "ntvdm.h" #include /* DEFINES ********************************************************************/ diff --git a/reactos/subsystems/mvdm/ntvdm/cpu/registers.c b/reactos/subsystems/mvdm/ntvdm/cpu/registers.c index 7056787e0e5..c59e7d07ad1 100644 --- a/reactos/subsystems/mvdm/ntvdm/cpu/registers.c +++ b/reactos/subsystems/mvdm/ntvdm/cpu/registers.c @@ -10,6 +10,7 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "cpu.h" #include "x86context.h" diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dem.c b/reactos/subsystems/mvdm/ntvdm/dos/dem.c index 9deee83dd77..f6de1637e38 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dem.c +++ b/reactos/subsystems/mvdm/ntvdm/dos/dem.c @@ -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 - /* 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 diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dem.h b/reactos/subsystems/mvdm/ntvdm/dos/dem.h index 297ac26f002..d32ab46afd0 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dem.h +++ b/reactos/subsystems/mvdm/ntvdm/dos/dem.h @@ -15,7 +15,6 @@ /* INCLUDES *******************************************************************/ -#include "ntvdm.h" #include "dos32krnl/dos.h" /* FUNCTIONS ******************************************************************/ diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c index aa03db51588..41b144fc1de 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c +++ b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c @@ -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 } diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/condrv.c b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/condrv.c index 1395ff776d2..ec4440e6c57 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/condrv.c +++ b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/condrv.c @@ -11,6 +11,7 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "dos.h" diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.c b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.c index 5eb94155190..d16e48685bc 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.c +++ b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.c @@ -10,11 +10,13 @@ #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; diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.h b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.h index 01d9efd19bf..1635c6d591f 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.h +++ b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/device.h @@ -9,8 +9,6 @@ #ifndef _DEVICE_H_ #define _DEVICE_H_ -#include - /* DEFINITIONS ****************************************************************/ #define MAX_DEVICE_NAME 8 diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c index eea13a7b184..5b1189896e0 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c +++ b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c @@ -11,6 +11,7 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "cpu/cpu.h" #include "int32.h" diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h index 90238820a26..d262bbf467f 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h +++ b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h @@ -11,7 +11,6 @@ /* INCLUDES *******************************************************************/ -#include "ntvdm.h" #include "device.h" /**/ #include "int32.h" /**/ diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c index 76cb1eea4a5..fd11e855833 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c +++ b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c @@ -11,6 +11,7 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "../../memory.h" diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c index 6579394b26d..1dde4b3ab1b 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c +++ b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c @@ -10,6 +10,8 @@ #define NDEBUG +#include "ntvdm.h" + #include "dos.h" #include "dos/dem.h" #include "device.h" diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c index b6fb32d3106..1d20673390e 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c +++ b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c @@ -10,11 +10,12 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" +#include "memory.h" #include "dos.h" #include "dos/dem.h" -#include "memory.h" /* PUBLIC VARIABLES ***********************************************************/ diff --git a/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c b/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c index 4a3c10afc73..a57e532a4b2 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c +++ b/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c @@ -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) { diff --git a/reactos/subsystems/mvdm/ntvdm/dos/mouse32.h b/reactos/subsystems/mvdm/ntvdm/dos/mouse32.h index aadfbee7226..8b630bb5628 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/mouse32.h +++ b/reactos/subsystems/mvdm/ntvdm/dos/mouse32.h @@ -9,10 +9,6 @@ #ifndef _MOUSE32_H_ #define _MOUSE32_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ #define DOS_MOUSE_INTERRUPT 0x33 diff --git a/reactos/subsystems/mvdm/ntvdm/emulator.c b/reactos/subsystems/mvdm/ntvdm/emulator.c index 2de9db12c1e..d9389a4a13a 100644 --- a/reactos/subsystems/mvdm/ntvdm/emulator.c +++ b/reactos/subsystems/mvdm/ntvdm/emulator.c @@ -10,6 +10,7 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "memory.h" @@ -35,10 +36,6 @@ #include "vddsup.h" #include "io.h" -/* Extra PSDK/NDK Headers */ -#include -#include - /* PRIVATE VARIABLES **********************************************************/ LPVOID BaseAddress = NULL; diff --git a/reactos/subsystems/mvdm/ntvdm/emulator.h b/reactos/subsystems/mvdm/ntvdm/emulator.h index f0cdf849552..169447de6d1 100644 --- a/reactos/subsystems/mvdm/ntvdm/emulator.h +++ b/reactos/subsystems/mvdm/ntvdm/emulator.h @@ -11,7 +11,6 @@ /* INCLUDES *******************************************************************/ -#include "ntvdm.h" #include /* DEFINES ********************************************************************/ diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/cmos.c b/reactos/subsystems/mvdm/ntvdm/hardware/cmos.c index 1006ee27ec6..b894b7c0370 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/cmos.c +++ b/reactos/subsystems/mvdm/ntvdm/hardware/cmos.c @@ -10,6 +10,7 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "cmos.h" diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/cmos.h b/reactos/subsystems/mvdm/ntvdm/hardware/cmos.h index b7369c6038e..ac243ad9b5a 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/cmos.h +++ b/reactos/subsystems/mvdm/ntvdm/hardware/cmos.h @@ -9,10 +9,6 @@ #ifndef _CMOS_H_ #define _CMOS_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ #define RTC_IRQ_NUMBER 8 diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/dma.c b/reactos/subsystems/mvdm/ntvdm/hardware/dma.c index e4422427046..27bb56fa067 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/dma.c +++ b/reactos/subsystems/mvdm/ntvdm/hardware/dma.c @@ -11,10 +11,12 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" -#include "io.h" #include "dma.h" +#include "io.h" + /* PRIVATE VARIABLES **********************************************************/ /* diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/dma.h b/reactos/subsystems/mvdm/ntvdm/hardware/dma.h index 1e41f28980e..3fe93f8a4cb 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/dma.h +++ b/reactos/subsystems/mvdm/ntvdm/hardware/dma.h @@ -10,10 +10,6 @@ #ifndef _DMA_H_ #define _DMA_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ #define DMA_CONTROLLERS 2 diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/keyboard.c b/reactos/subsystems/mvdm/ntvdm/hardware/keyboard.c index 520d5036e08..0516fa7985d 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/keyboard.c +++ b/reactos/subsystems/mvdm/ntvdm/hardware/keyboard.c @@ -10,6 +10,7 @@ #define NDEBUG +#include "ntvdm.h" #include "keyboard.h" #include "ps2.h" diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/keyboard.h b/reactos/subsystems/mvdm/ntvdm/hardware/keyboard.h index 39c91bc34bd..0b7cd4a55b8 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/keyboard.h +++ b/reactos/subsystems/mvdm/ntvdm/hardware/keyboard.h @@ -9,10 +9,6 @@ #ifndef _KEYBOARD_H_ #define _KEYBOARD_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ /* Command responses */ diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c b/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c index 5ffda0271e7..20815ec1ef8 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c +++ b/reactos/subsystems/mvdm/ntvdm/hardware/mouse.c @@ -10,8 +10,10 @@ #define NDEBUG +#include "ntvdm.h" #include "mouse.h" #include "ps2.h" + #include "clock.h" #include "video/vga.h" diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/mouse.h b/reactos/subsystems/mvdm/ntvdm/hardware/mouse.h index b91146e80b0..23f15a0082d 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/mouse.h +++ b/reactos/subsystems/mvdm/ntvdm/hardware/mouse.h @@ -9,10 +9,6 @@ #ifndef _MOUSE_H_ #define _MOUSE_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ /* Mouse packet constants */ diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/pic.c b/reactos/subsystems/mvdm/ntvdm/hardware/pic.c index 2d6296aaf85..e7c38ebc064 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/pic.c +++ b/reactos/subsystems/mvdm/ntvdm/hardware/pic.c @@ -11,10 +11,12 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" -#include "io.h" #include "pic.h" +#include "io.h" + /* PRIVATE VARIABLES **********************************************************/ static PIC MasterPic, SlavePic; diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/pic.h b/reactos/subsystems/mvdm/ntvdm/hardware/pic.h index 03d7dd1738e..d8dfafd8a1a 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/pic.h +++ b/reactos/subsystems/mvdm/ntvdm/hardware/pic.h @@ -10,10 +10,6 @@ #ifndef _PIC_H_ #define _PIC_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ #define PIC_MASTER_CMD 0x20 diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/pit.c b/reactos/subsystems/mvdm/ntvdm/hardware/pit.c index f64d267da48..118b5943271 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/pit.c +++ b/reactos/subsystems/mvdm/ntvdm/hardware/pit.c @@ -12,9 +12,11 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" -#include "io.h" #include "pit.h" + +#include "io.h" #include "pic.h" #include "clock.h" diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/pit.h b/reactos/subsystems/mvdm/ntvdm/hardware/pit.h index b06fe24aebf..9a101429c7a 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/pit.h +++ b/reactos/subsystems/mvdm/ntvdm/hardware/pit.h @@ -11,10 +11,6 @@ #ifndef _PIT_H_ #define _PIT_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ #define PIT_CHANNELS 3 diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c b/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c index 5309fd7b2ea..bcb2fb2f528 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c +++ b/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c @@ -11,9 +11,11 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" -#include "io.h" #include "ps2.h" + +#include "io.h" #include "pic.h" #include "clock.h" diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/ps2.h b/reactos/subsystems/mvdm/ntvdm/hardware/ps2.h index d62387cff59..d8cf276b1fa 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/ps2.h +++ b/reactos/subsystems/mvdm/ntvdm/hardware/ps2.h @@ -10,10 +10,6 @@ #ifndef _PS2_H_ #define _PS2_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ #define PS2_DATA_PORT 0x60 diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/sound/speaker.c b/reactos/subsystems/mvdm/ntvdm/hardware/sound/speaker.c index ef2c98dd8f1..d3e313780ec 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/sound/speaker.c +++ b/reactos/subsystems/mvdm/ntvdm/hardware/sound/speaker.c @@ -10,17 +10,12 @@ #define NDEBUG -#include "emulator.h" +#include "ntvdm.h" #include "speaker.h" #include "hardware/pit.h" /* Extra PSDK/NDK Headers */ #include -#include -#include - -/* Extra PSDK/NDK Headers */ -#include /* DDK Driver Headers */ #include diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/sound/speaker.h b/reactos/subsystems/mvdm/ntvdm/hardware/sound/speaker.h index 95c21d2fe01..ad1a38a3144 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/sound/speaker.h +++ b/reactos/subsystems/mvdm/ntvdm/hardware/sound/speaker.h @@ -9,12 +9,6 @@ #ifndef _SPEAKER_H_ #define _SPEAKER_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - -/* DEFINES ********************************************************************/ - /* FUNCTIONS ******************************************************************/ VOID SpeakerChange(UCHAR Port61hValue); diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c b/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c index 8e8411794fc..3562d793d7a 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c +++ b/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c @@ -10,6 +10,7 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "vga.h" #include @@ -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) { diff --git a/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.h b/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.h index b1716b39f25..445f700cb5e 100644 --- a/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.h +++ b/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.h @@ -9,10 +9,6 @@ #ifndef _VGA_H_ #define _VGA_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* DEFINES ********************************************************************/ #define VGA_NUM_BANKS 4 diff --git a/reactos/subsystems/mvdm/ntvdm/int32.c b/reactos/subsystems/mvdm/ntvdm/int32.c index e87db2ec5e1..a1112704c98 100644 --- a/reactos/subsystems/mvdm/ntvdm/int32.c +++ b/reactos/subsystems/mvdm/ntvdm/int32.c @@ -11,6 +11,7 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "int32.h" diff --git a/reactos/subsystems/mvdm/ntvdm/io.c b/reactos/subsystems/mvdm/ntvdm/io.c index 5ecce93c49f..ca8e207760c 100644 --- a/reactos/subsystems/mvdm/ntvdm/io.c +++ b/reactos/subsystems/mvdm/ntvdm/io.c @@ -11,6 +11,7 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" #include "io.h" diff --git a/reactos/subsystems/mvdm/ntvdm/memory.c b/reactos/subsystems/mvdm/ntvdm/memory.c index f5cb23aba40..e6c8723c96b 100644 --- a/reactos/subsystems/mvdm/ntvdm/memory.c +++ b/reactos/subsystems/mvdm/ntvdm/memory.c @@ -10,11 +10,13 @@ #define NDEBUG +#include "ntvdm.h" #include "emulator.h" -#include -#include #include "memory.h" +/* Extra PSDK/NDK Headers */ +#include + /* PRIVATE VARIABLES **********************************************************/ typedef struct _MEM_HOOK diff --git a/reactos/subsystems/mvdm/ntvdm/ntvdm.c b/reactos/subsystems/mvdm/ntvdm/ntvdm.c index 58f18bffb76..7f0885c1fce 100644 --- a/reactos/subsystems/mvdm/ntvdm/ntvdm.c +++ b/reactos/subsystems/mvdm/ntvdm/ntvdm.c @@ -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); diff --git a/reactos/subsystems/mvdm/ntvdm/ntvdm.h b/reactos/subsystems/mvdm/ntvdm/ntvdm.h index 7bcc748f66d..1b7c988a5af 100644 --- a/reactos/subsystems/mvdm/ntvdm/ntvdm.h +++ b/reactos/subsystems/mvdm/ntvdm/ntvdm.h @@ -13,9 +13,9 @@ #include #include -#include #include +/* PSDK/NDK Headers */ #define WIN32_NO_STATUS #include #include @@ -30,6 +30,15 @@ DWORD WINAPI SetLastConsoleEventActive(VOID); +#define NTOS_MODE_USER +#include +#include +#include +#include + +/* PSEH for SEH Support */ +#include + #include /* diff --git a/reactos/subsystems/mvdm/ntvdm/utils.c b/reactos/subsystems/mvdm/ntvdm/utils.c index 0619376ee98..be9b9c1a343 100644 --- a/reactos/subsystems/mvdm/ntvdm/utils.c +++ b/reactos/subsystems/mvdm/ntvdm/utils.c @@ -10,7 +10,7 @@ #define NDEBUG -#include "emulator.h" +#include "ntvdm.h" /* PRIVATE FUNCTIONS **********************************************************/ diff --git a/reactos/subsystems/mvdm/ntvdm/utils.h b/reactos/subsystems/mvdm/ntvdm/utils.h index 98ce0936a96..7a6ffac45e4 100644 --- a/reactos/subsystems/mvdm/ntvdm/utils.h +++ b/reactos/subsystems/mvdm/ntvdm/utils.h @@ -9,10 +9,6 @@ #ifndef _UTILS_H_ #define _UTILS_H_ -/* INCLUDES *******************************************************************/ - -#include "ntvdm.h" - /* FUNCTIONS ******************************************************************/ VOID diff --git a/reactos/subsystems/mvdm/ntvdm/vddsup.c b/reactos/subsystems/mvdm/ntvdm/vddsup.c index 7d3f4e2411b..0180e9c901f 100644 --- a/reactos/subsystems/mvdm/ntvdm/vddsup.c +++ b/reactos/subsystems/mvdm/ntvdm/vddsup.c @@ -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; } diff --git a/reactos/subsystems/mvdm/ntvdm/vddsup.h b/reactos/subsystems/mvdm/ntvdm/vddsup.h index 4de9178a3ea..3b55e0bb337 100644 --- a/reactos/subsystems/mvdm/ntvdm/vddsup.h +++ b/reactos/subsystems/mvdm/ntvdm/vddsup.h @@ -9,8 +9,6 @@ #ifndef _VDDSUP_H_ #define _VDDSUP_H_ -/* DEFINES ********************************************************************/ - /* FUNCTIONS ******************************************************************/ VOID VDDSupInitialize(VOID);