[NTVDM]: Zero-fill memory with RtlZeroMemory (that exists also in NT mode), and use sizeof(object) instead of sizeof(type_of_object).

svn path=/trunk/; revision=64747
This commit is contained in:
Hermès Bélusca-Maïto 2014-10-14 22:46:40 +00:00
parent 9718330254
commit 1fd3e7e17e
8 changed files with 21 additions and 20 deletions

View file

@ -134,8 +134,8 @@ static VOID WINAPI DosCmdInterpreterBop(LPWORD Stack)
strcpy(CommandLine, "cmd.exe /c "); strcpy(CommandLine, "cmd.exe /c ");
strcat(CommandLine, Command); strcat(CommandLine, Command);
ZeroMemory(&StartupInfo, sizeof(StartupInfo)); RtlZeroMemory(&StartupInfo, sizeof(StartupInfo));
ZeroMemory(&ProcessInformation, sizeof(ProcessInformation)); RtlZeroMemory(&ProcessInformation, sizeof(ProcessInformation));
StartupInfo.cb = sizeof(StartupInfo); StartupInfo.cb = sizeof(StartupInfo);
@ -209,7 +209,7 @@ CommandThreadProc(LPVOID Parameter)
do do
{ {
/* Clear the structure */ /* Clear the structure */
ZeroMemory(&CommandInfo, sizeof(CommandInfo)); RtlZeroMemory(&CommandInfo, sizeof(CommandInfo));
/* Initialize the structure members */ /* Initialize the structure members */
CommandInfo.TaskId = SessionId; CommandInfo.TaskId = SessionId;

View file

@ -168,7 +168,7 @@ BOOLEAN DosBIOSInitialize(VOID)
#if 0 #if 0
/* Clear the current directory buffer */ /* Clear the current directory buffer */
ZeroMemory(CurrentDirectories, sizeof(CurrentDirectories)); RtlZeroMemory(CurrentDirectories, sizeof(CurrentDirectories));
/* Get the current directory */ /* Get the current directory */
if (!GetCurrentDirectoryA(MAX_PATH, CurrentDirectory)) if (!GetCurrentDirectoryA(MAX_PATH, CurrentDirectory))

View file

@ -860,7 +860,7 @@ VOID DosInitializePsp(WORD PspSegment, LPCSTR CommandLine, WORD ProgramSize, WOR
PDOS_PSP PspBlock = SEGMENT_TO_PSP(PspSegment); PDOS_PSP PspBlock = SEGMENT_TO_PSP(PspSegment);
LPDWORD IntVecTable = (LPDWORD)((ULONG_PTR)BaseAddress); LPDWORD IntVecTable = (LPDWORD)((ULONG_PTR)BaseAddress);
ZeroMemory(PspBlock, sizeof(DOS_PSP)); RtlZeroMemory(PspBlock, sizeof(*PspBlock));
/* Set the exit interrupt */ /* Set the exit interrupt */
PspBlock->Exit[0] = 0xCD; // int 0x20 PspBlock->Exit[0] = 0xCD; // int 0x20
@ -1204,8 +1204,8 @@ WORD DosCreateProcess(DOS_EXEC_TYPE LoadType,
} }
/* Set up the startup info structure */ /* Set up the startup info structure */
ZeroMemory(&StartupInfo, sizeof(STARTUPINFOA)); RtlZeroMemory(&StartupInfo, sizeof(StartupInfo));
StartupInfo.cb = sizeof(STARTUPINFOA); StartupInfo.cb = sizeof(StartupInfo);
/* Create the process */ /* Create the process */
if (!CreateProcessA(ProgramName, if (!CreateProcessA(ProgramName,
@ -1230,7 +1230,7 @@ WORD DosCreateProcess(DOS_EXEC_TYPE LoadType,
case SCS_WOW_BINARY: case SCS_WOW_BINARY:
{ {
/* Clear the structure */ /* Clear the structure */
ZeroMemory(&CommandInfo, sizeof(CommandInfo)); RtlZeroMemory(&CommandInfo, sizeof(CommandInfo));
/* Initialize the structure members */ /* Initialize the structure members */
CommandInfo.TaskId = SessionId; CommandInfo.TaskId = SessionId;
@ -1362,7 +1362,7 @@ Done:
GetNextVDMCommand(&CommandInfo); GetNextVDMCommand(&CommandInfo);
/* Clear the structure */ /* Clear the structure */
ZeroMemory(&CommandInfo, sizeof(CommandInfo)); RtlZeroMemory(&CommandInfo, sizeof(CommandInfo));
/* Update the VDM state of the task */ /* Update the VDM state of the task */
CommandInfo.TaskId = SessionId; CommandInfo.TaskId = SessionId;
@ -2901,7 +2901,7 @@ BOOLEAN DosKRNLInitialize(VOID)
WCHAR Buffer[256]; WCHAR Buffer[256];
/* Clear the current directory buffer */ /* Clear the current directory buffer */
ZeroMemory(CurrentDirectories, sizeof(CurrentDirectories)); RtlZeroMemory(CurrentDirectories, sizeof(CurrentDirectories));
/* Get the current directory */ /* Get the current directory */
if (!GetCurrentDirectoryA(MAX_PATH, CurrentDirectory)) if (!GetCurrentDirectoryA(MAX_PATH, CurrentDirectory))

View file

@ -665,7 +665,7 @@ VOID MouseBiosUpdateButtons(WORD ButtonState)
BOOLEAN DosMouseInitialize(VOID) BOOLEAN DosMouseInitialize(VOID)
{ {
/* Clear the state */ /* Clear the state */
ZeroMemory(&DriverState, sizeof(DriverState)); RtlZeroMemory(&DriverState, sizeof(DriverState));
/* Initialize the interrupt handler */ /* Initialize the interrupt handler */
RegisterDosInt32(BIOS_MOUSE_INTERRUPT, BiosMouseService); RegisterDosInt32(BIOS_MOUSE_INTERRUPT, BiosMouseService);

View file

@ -428,7 +428,7 @@ VOID CmosInitialize(VOID)
ASSERT(hCmosRam == INVALID_HANDLE_VALUE); ASSERT(hCmosRam == INVALID_HANDLE_VALUE);
/* Clear the CMOS memory */ /* Clear the CMOS memory */
ZeroMemory(&CmosMemory, sizeof(CmosMemory)); RtlZeroMemory(&CmosMemory, sizeof(CmosMemory));
/* Always open (and if needed, create) a RAM file with shared access */ /* Always open (and if needed, create) a RAM file with shared access */
SetLastError(0); // For debugging purposes SetLastError(0); // For debugging purposes
@ -452,7 +452,7 @@ VOID CmosInitialize(VOID)
{ {
/* Bad CMOS Ram file. Reinitialize the CMOS memory. */ /* Bad CMOS Ram file. Reinitialize the CMOS memory. */
DPRINT1("Invalid CMOS file, read bytes %u, expected bytes %u\n", CmosSize, sizeof(CmosMemory)); DPRINT1("Invalid CMOS file, read bytes %u, expected bytes %u\n", CmosSize, sizeof(CmosMemory));
ZeroMemory(&CmosMemory, sizeof(CmosMemory)); RtlZeroMemory(&CmosMemory, sizeof(CmosMemory));
} }
DPRINT1("CMOS loading %s ; GetLastError() = %u\n", Success ? "succeeded" : "failed", GetLastError()); DPRINT1("CMOS loading %s ; GetLastError() = %u\n", Success ? "succeeded" : "failed", GetLastError());
SetFilePointer(hCmosRam, 0, NULL, FILE_BEGIN); SetFilePointer(hCmosRam, 0, NULL, FILE_BEGIN);

View file

@ -12,6 +12,7 @@
#include "mouse.h" #include "mouse.h"
#include "ps2.h" #include "ps2.h"
// #include "pic.h"
// HACK: For the PS/2 bypass and MOUSE.COM driver direct call // HACK: For the PS/2 bypass and MOUSE.COM driver direct call
#include "dos/mouse32.h" #include "dos/mouse32.h"
@ -69,7 +70,7 @@ static VOID MouseReset(VOID)
static VOID MouseGetPacket(PMOUSE_PACKET Packet) static VOID MouseGetPacket(PMOUSE_PACKET Packet)
{ {
/* Clear the packet */ /* Clear the packet */
ZeroMemory(Packet, sizeof(MOUSE_PACKET)); RtlZeroMemory(Packet, sizeof(*Packet));
Packet->Flags |= MOUSE_ALWAYS_SET; Packet->Flags |= MOUSE_ALWAYS_SET;

View file

@ -976,8 +976,8 @@ static BOOL VgaEnterGraphicsMode(PCOORD Resolution)
} }
/* Fill the bitmap info header */ /* Fill the bitmap info header */
ZeroMemory(&BitmapInfo->bmiHeader, sizeof(BITMAPINFOHEADER)); RtlZeroMemory(&BitmapInfo->bmiHeader, sizeof(BitmapInfo->bmiHeader));
BitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); BitmapInfo->bmiHeader.biSize = sizeof(BitmapInfo->bmiHeader);
BitmapInfo->bmiHeader.biWidth = Width; BitmapInfo->bmiHeader.biWidth = Width;
BitmapInfo->bmiHeader.biHeight = Height; BitmapInfo->bmiHeader.biHeight = Height;
BitmapInfo->bmiHeader.biBitCount = 8; BitmapInfo->bmiHeader.biBitCount = 8;
@ -1006,7 +1006,7 @@ static BOOL VgaEnterGraphicsMode(PCOORD Resolution)
ConsoleMutex = GraphicsBufferInfo.hMutex; ConsoleMutex = GraphicsBufferInfo.hMutex;
/* Clear the framebuffer */ /* Clear the framebuffer */
ZeroMemory(ConsoleFramebuffer, BitmapInfo->bmiHeader.biSizeImage); RtlZeroMemory(ConsoleFramebuffer, BitmapInfo->bmiHeader.biSizeImage);
/* Set the active buffer */ /* Set the active buffer */
VgaSetActiveScreenBuffer(GraphicsConsoleBuffer); VgaSetActiveScreenBuffer(GraphicsConsoleBuffer);
@ -1901,7 +1901,7 @@ VOID VgaWriteMemory(DWORD Address, LPBYTE Buffer, DWORD Size)
VOID VgaClearMemory(VOID) VOID VgaClearMemory(VOID)
{ {
ZeroMemory(VgaMemory, sizeof(VgaMemory)); RtlZeroMemory(VgaMemory, sizeof(VgaMemory));
} }
VOID VgaResetPalette(VOID) VOID VgaResetPalette(VOID)

View file

@ -342,7 +342,7 @@ VOID UnregisterIoPort(ULONG Port)
* the hVdd gets unregistered as well as all the handlers. * the hVdd gets unregistered as well as all the handlers.
*/ */
// IoPortProc[Port] = {NULL}; // IoPortProc[Port] = {NULL};
ZeroMemory(&IoPortProc[Port], sizeof(IoPortProc[Port])); RtlZeroMemory(&IoPortProc[Port], sizeof(IoPortProc[Port]));
} }
VOID WINAPI VOID WINAPI
@ -594,7 +594,7 @@ VDDDeInstallIOHook(HANDLE hVdd,
* the hVdd gets unregistered as well as all the handlers. * the hVdd gets unregistered as well as all the handlers.
*/ */
// IoPortProc[i] = {NULL}; // IoPortProc[i] = {NULL};
ZeroMemory(&IoPortProc[i], sizeof(IoPortProc[i])); RtlZeroMemory(&IoPortProc[i], sizeof(IoPortProc[i]));
} }
/* Go to the next range */ /* Go to the next range */