mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-14 17:27:18 +00:00
Prevent crashes when DOS program tries to access console and no
Windows console is available.
This commit is contained in:
parent
e0315e4433
commit
c1c346ae0d
|
@ -489,7 +489,10 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context )
|
||||||
{
|
{
|
||||||
BYTE ascii, attr;
|
BYTE ascii, attr;
|
||||||
TRACE("Read Character and Attribute at Cursor Position\n");
|
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_AL( context, ascii );
|
||||||
SET_AH( context, attr );
|
SET_AH( context, attr );
|
||||||
}
|
}
|
||||||
|
@ -845,6 +848,6 @@ void WINAPI DOSVM_PutChar(BYTE ascii)
|
||||||
TRACE("char: 0x%02x(%c)\n", ascii, ascii);
|
TRACE("char: 0x%02x(%c)\n", ascii, ascii);
|
||||||
|
|
||||||
VGA_PutChar(ascii);
|
VGA_PutChar(ascii);
|
||||||
VGA_GetCursorPos(&xpos, &ypos);
|
if(VGA_GetCursorPos(&xpos, &ypos))
|
||||||
BIOS_SetCursorPos(data, 0, xpos, ypos);
|
BIOS_SetCursorPos(data, 0, xpos, ypos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -627,12 +627,17 @@ void VGA_SetCursorPos(unsigned X,unsigned Y)
|
||||||
SetConsoleCursorPosition(VGA_AlphaConsole(),pos);
|
SetConsoleCursorPosition(VGA_AlphaConsole(),pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VGA_GetCursorPos(unsigned*X,unsigned*Y)
|
BOOL VGA_GetCursorPos(unsigned*X,unsigned*Y)
|
||||||
{
|
{
|
||||||
CONSOLE_SCREEN_BUFFER_INFO info;
|
CONSOLE_SCREEN_BUFFER_INFO info;
|
||||||
GetConsoleScreenBufferInfo(VGA_AlphaConsole(),&info);
|
if(!GetConsoleScreenBufferInfo(VGA_AlphaConsole(),&info))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
if (X) *X=info.dwCursorPosition.X;
|
if (X) *X=info.dwCursorPosition.X;
|
||||||
if (Y) *Y=info.dwCursorPosition.Y;
|
if (Y) *Y=info.dwCursorPosition.Y;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VGA_WriteChars(unsigned X,unsigned Y,unsigned ch,int attr,int count)
|
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;
|
unsigned XR, YR;
|
||||||
char *dat;
|
char *dat;
|
||||||
|
|
||||||
|
if(!VGA_GetAlphaMode(&XR, &YR))
|
||||||
|
return;
|
||||||
|
|
||||||
EnterCriticalSection(&vga_lock);
|
EnterCriticalSection(&vga_lock);
|
||||||
|
|
||||||
info.Char.AsciiChar = ch;
|
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.Top=Y;
|
||||||
dest.Bottom=Y;
|
dest.Bottom=Y;
|
||||||
|
|
||||||
VGA_GetAlphaMode(&XR, &YR);
|
|
||||||
dat = VGA_AlphaBuffer() + ((XR*Y + X) * 2);
|
dat = VGA_AlphaBuffer() + ((XR*Y + X) * 2);
|
||||||
while (count--) {
|
while (count--) {
|
||||||
dest.Left = X + count;
|
dest.Left = X + count;
|
||||||
|
@ -688,9 +695,13 @@ void VGA_PutChar(BYTE ascii)
|
||||||
{
|
{
|
||||||
unsigned width, height, x, y, nx, ny;
|
unsigned width, height, x, y, nx, ny;
|
||||||
|
|
||||||
|
if(!VGA_GetAlphaMode(&width, &height)) {
|
||||||
|
WriteFile(VGA_AlphaConsole(), &ascii, 1, NULL, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
EnterCriticalSection(&vga_lock);
|
EnterCriticalSection(&vga_lock);
|
||||||
|
|
||||||
VGA_GetAlphaMode(&width, &height);
|
|
||||||
VGA_GetCursorPos(&x, &y);
|
VGA_GetCursorPos(&x, &y);
|
||||||
|
|
||||||
switch(ascii) {
|
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 */
|
/* return if we fail to get the height and width of the window */
|
||||||
if(!VGA_GetAlphaMode(&width, &height))
|
if(!VGA_GetAlphaMode(&width, &height))
|
||||||
{
|
|
||||||
ERR("failed\n");
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("dat = %p, width = %d, height = %d\n", dat, width, height);
|
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");
|
FIXME("not implemented\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void VGA_GetCharacterAtCursor(BYTE *ascii, BYTE *attr)
|
BOOL VGA_GetCharacterAtCursor(BYTE *ascii, BYTE *attr)
|
||||||
{
|
{
|
||||||
unsigned width, height, x, y;
|
unsigned width, height, x, y;
|
||||||
char *dat;
|
char *dat;
|
||||||
|
|
||||||
VGA_GetAlphaMode(&width, &height);
|
if(!VGA_GetAlphaMode(&width, &height) || !VGA_GetCursorPos(&x, &y))
|
||||||
VGA_GetCursorPos(&x, &y);
|
return FALSE;
|
||||||
|
|
||||||
dat = VGA_AlphaBuffer() + ((width*y + x) * 2);
|
dat = VGA_AlphaBuffer() + ((width*y + x) * 2);
|
||||||
|
|
||||||
*ascii = dat[0];
|
*ascii = dat[0];
|
||||||
*attr = dat[1];
|
*attr = dat[1];
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ int VGA_SetAlphaMode(unsigned Xres,unsigned Yres);
|
||||||
BOOL VGA_GetAlphaMode(unsigned*Xres,unsigned*Yres);
|
BOOL VGA_GetAlphaMode(unsigned*Xres,unsigned*Yres);
|
||||||
void VGA_SetCursorShape(unsigned char start_options,unsigned char end);
|
void VGA_SetCursorShape(unsigned char start_options,unsigned char end);
|
||||||
void VGA_SetCursorPos(unsigned X,unsigned Y);
|
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_WriteChars(unsigned X,unsigned Y,unsigned ch,int attr,int count);
|
||||||
void VGA_PutChar(BYTE ascii);
|
void VGA_PutChar(BYTE ascii);
|
||||||
void VGA_SetTextAttribute(BYTE attr);
|
void VGA_SetTextAttribute(BYTE attr);
|
||||||
|
@ -57,7 +57,7 @@ void VGA_ScrollUpText(unsigned row1, unsigned col1,
|
||||||
void VGA_ScrollDownText(unsigned row1, unsigned col1,
|
void VGA_ScrollDownText(unsigned row1, unsigned col1,
|
||||||
unsigned row2, unsigned col2,
|
unsigned row2, unsigned col2,
|
||||||
unsigned lines, BYTE attr);
|
unsigned lines, BYTE attr);
|
||||||
void VGA_GetCharacterAtCursor(BYTE *ascii, BYTE *attr);
|
BOOL VGA_GetCharacterAtCursor(BYTE *ascii, BYTE *attr);
|
||||||
|
|
||||||
/* control */
|
/* control */
|
||||||
void VGA_ioport_out(WORD port, BYTE val);
|
void VGA_ioport_out(WORD port, BYTE val);
|
||||||
|
|
Loading…
Reference in a new issue