mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 12:26:09 +00:00
[USETUP] Minor improvements when initializing the console.
- Use NT values for uninitialized handle values. - Cache the STD_INPUT_HANDLE. - Free the console if GetConsoleScreenBufferInfo() fails in CONSOLE_Init().
This commit is contained in:
parent
8b94515bd3
commit
0abff65a55
1 changed files with 13 additions and 4 deletions
|
@ -33,8 +33,8 @@
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
HANDLE StdInput = INVALID_HANDLE_VALUE;
|
HANDLE StdInput = NULL;
|
||||||
HANDLE StdOutput = INVALID_HANDLE_VALUE;
|
HANDLE StdOutput = NULL;
|
||||||
|
|
||||||
SHORT xScreen = 0;
|
SHORT xScreen = 0;
|
||||||
SHORT yScreen = 0;
|
SHORT yScreen = 0;
|
||||||
|
@ -45,15 +45,24 @@ BOOLEAN
|
||||||
CONSOLE_Init(VOID)
|
CONSOLE_Init(VOID)
|
||||||
{
|
{
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
|
||||||
|
/* Allocate a new console */
|
||||||
if (!AllocConsole())
|
if (!AllocConsole())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
StdInput = GetStdHandle(STD_INPUT_HANDLE);
|
/* Get the standard handles */
|
||||||
|
StdInput = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
StdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
StdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
|
/* Retrieve the size of the console */
|
||||||
if (!GetConsoleScreenBufferInfo(StdOutput, &csbi))
|
if (!GetConsoleScreenBufferInfo(StdOutput, &csbi))
|
||||||
|
{
|
||||||
|
FreeConsole();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
xScreen = csbi.dwSize.X;
|
xScreen = csbi.dwSize.X;
|
||||||
yScreen = csbi.dwSize.Y;
|
yScreen = csbi.dwSize.Y;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +184,7 @@ CONSOLE_GetCursorXY(
|
||||||
{
|
{
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
|
||||||
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
|
GetConsoleScreenBufferInfo(StdOutput, &csbi);
|
||||||
|
|
||||||
*x = csbi.dwCursorPosition.X;
|
*x = csbi.dwCursorPosition.X;
|
||||||
*y = csbi.dwCursorPosition.Y;
|
*y = csbi.dwCursorPosition.Y;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue