1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-08 20:06:18 +00:00

Prevent crashes when DOS program tries to access console and no

Windows console is available.
This commit is contained in:
Jukka Heinonen 2002-10-31 03:41:20 +00:00 committed by Alexandre Julliard
parent e0315e4433
commit c1c346ae0d
3 changed files with 31 additions and 17 deletions

View File

@ -489,7 +489,10 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context )
{
BYTE ascii, attr;
TRACE("Read Character and Attribute at Cursor Position\n");
VGA_GetCharacterAtCursor(&ascii, &attr);
if(!VGA_GetCharacterAtCursor(&ascii, &attr)) {
ascii = 0;
attr = 0;
}
SET_AL( context, ascii );
SET_AH( context, attr );
}
@ -845,6 +848,6 @@ void WINAPI DOSVM_PutChar(BYTE ascii)
TRACE("char: 0x%02x(%c)\n", ascii, ascii);
VGA_PutChar(ascii);
VGA_GetCursorPos(&xpos, &ypos);
BIOS_SetCursorPos(data, 0, xpos, ypos);
if(VGA_GetCursorPos(&xpos, &ypos))
BIOS_SetCursorPos(data, 0, xpos, ypos);
}

View File

@ -627,12 +627,17 @@ void VGA_SetCursorPos(unsigned X,unsigned Y)
SetConsoleCursorPosition(VGA_AlphaConsole(),pos);
}
void VGA_GetCursorPos(unsigned*X,unsigned*Y)
BOOL VGA_GetCursorPos(unsigned*X,unsigned*Y)
{
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(VGA_AlphaConsole(),&info);
if (X) *X=info.dwCursorPosition.X;
if (Y) *Y=info.dwCursorPosition.Y;
if(!GetConsoleScreenBufferInfo(VGA_AlphaConsole(),&info))
{
return FALSE;
} else {
if (X) *X=info.dwCursorPosition.X;
if (Y) *Y=info.dwCursorPosition.Y;
return TRUE;
}
}
void VGA_WriteChars(unsigned X,unsigned Y,unsigned ch,int attr,int count)
@ -643,6 +648,9 @@ void VGA_WriteChars(unsigned X,unsigned Y,unsigned ch,int attr,int count)
unsigned XR, YR;
char *dat;
if(!VGA_GetAlphaMode(&XR, &YR))
return;
EnterCriticalSection(&vga_lock);
info.Char.AsciiChar = ch;
@ -654,7 +662,6 @@ void VGA_WriteChars(unsigned X,unsigned Y,unsigned ch,int attr,int count)
dest.Top=Y;
dest.Bottom=Y;
VGA_GetAlphaMode(&XR, &YR);
dat = VGA_AlphaBuffer() + ((XR*Y + X) * 2);
while (count--) {
dest.Left = X + count;
@ -688,9 +695,13 @@ void VGA_PutChar(BYTE ascii)
{
unsigned width, height, x, y, nx, ny;
if(!VGA_GetAlphaMode(&width, &height)) {
WriteFile(VGA_AlphaConsole(), &ascii, 1, NULL, NULL);
return;
}
EnterCriticalSection(&vga_lock);
VGA_GetAlphaMode(&width, &height);
VGA_GetCursorPos(&x, &y);
switch(ascii) {
@ -753,10 +764,7 @@ BOOL VGA_ClearText(unsigned row1, unsigned col1,
/* return if we fail to get the height and width of the window */
if(!VGA_GetAlphaMode(&width, &height))
{
ERR("failed\n");
return FALSE;
}
TRACE("dat = %p, width = %d, height = %d\n", dat, width, height);
@ -794,17 +802,20 @@ void VGA_ScrollDownText(unsigned row1, unsigned col1,
FIXME("not implemented\n");
}
void VGA_GetCharacterAtCursor(BYTE *ascii, BYTE *attr)
BOOL VGA_GetCharacterAtCursor(BYTE *ascii, BYTE *attr)
{
unsigned width, height, x, y;
char *dat;
VGA_GetAlphaMode(&width, &height);
VGA_GetCursorPos(&x, &y);
if(!VGA_GetAlphaMode(&width, &height) || !VGA_GetCursorPos(&x, &y))
return FALSE;
dat = VGA_AlphaBuffer() + ((width*y + x) * 2);
*ascii = dat[0];
*attr = dat[1];
return TRUE;
}

View File

@ -44,7 +44,7 @@ int VGA_SetAlphaMode(unsigned Xres,unsigned Yres);
BOOL VGA_GetAlphaMode(unsigned*Xres,unsigned*Yres);
void VGA_SetCursorShape(unsigned char start_options,unsigned char end);
void VGA_SetCursorPos(unsigned X,unsigned Y);
void VGA_GetCursorPos(unsigned*X,unsigned*Y);
BOOL VGA_GetCursorPos(unsigned*X,unsigned*Y);
void VGA_WriteChars(unsigned X,unsigned Y,unsigned ch,int attr,int count);
void VGA_PutChar(BYTE ascii);
void VGA_SetTextAttribute(BYTE attr);
@ -57,7 +57,7 @@ void VGA_ScrollUpText(unsigned row1, unsigned col1,
void VGA_ScrollDownText(unsigned row1, unsigned col1,
unsigned row2, unsigned col2,
unsigned lines, BYTE attr);
void VGA_GetCharacterAtCursor(BYTE *ascii, BYTE *attr);
BOOL VGA_GetCharacterAtCursor(BYTE *ascii, BYTE *attr);
/* control */
void VGA_ioport_out(WORD port, BYTE val);