--- mstools/samples/console/readout.c 2018/08/09 18:20:36 1.1.1.1 +++ mstools/samples/console/readout.c 2018/08/09 18:23:15 1.1.1.3 @@ -1,3 +1,14 @@ + +/******************************************************************************\ +* This is a part of the Microsoft Source Code Samples. +* Copyright (C) 1993 Microsoft Corporation. +* All rights reserved. +* This source code is only intended as a supplement to +* Microsoft Development Tools and/or WinHelp documentation. +* See these sources for detailed information regarding the +* Microsoft samples programs. +\******************************************************************************/ + #include #include #include @@ -36,7 +47,7 @@ void invertRectangle(HANDLE hConOut, COO /* get the width of the selected area */ dwBoxWidth = right - left + 1; /* allocate a buffer for the attributes read from the console */ - awLineAttr = (PWORD) malloc(getConX(hConOut)); + awLineAttr = (PWORD) malloc(getConX(hConOut) * sizeof(DWORD)); PERR(awLineAttr, "malloc"); /* for each line in the selected area */ while (coordStart.Y <= coordCur.Y) @@ -99,7 +110,7 @@ void demoReadConOut(HANDLE hConOut) "of the buffer to the screen at the current cursor location.\n" "Hit ESC to return.\n\n"); hStdIn = GetStdHandle(STD_INPUT_HANDLE); - PERR((int) hStdIn != -1,"GetStdHandle"); + PERR(hStdIn != INVALID_HANDLE_VALUE, "GetStdHandle"); /* save the console mode */ bSuccess = GetConsoleMode(hStdIn, &dwStdInMode); PERR(bSuccess, "GetConsoleMode");