mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[BLUE] Code formatting, add SAL2 annotations, and update file source headers.
This commit is contained in:
parent
c917c442ad
commit
d684f90632
4 changed files with 747 additions and 728 deletions
|
@ -1,11 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* PROJECT: ReactOS Console Text-Mode Device Driver
|
||||||
* PROJECT: ReactOS kernel
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||||
* FILE: services/dd/blue/blue.c
|
* PURPOSE: Driver Management Functions.
|
||||||
* PURPOSE: Console (blue screen) device driver
|
* COPYRIGHT: Copyright 1999 Boudewijn Dekker
|
||||||
* PROGRAMMER: Eric Kohl
|
* Copyright 1999-2019 Eric Kohl
|
||||||
* UPDATE HISTORY:
|
* Copyright 2006 Filip Navara
|
||||||
* ??? Created
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
@ -20,7 +19,6 @@
|
||||||
* [[character][attribute]][[character][attribute]]....
|
* [[character][attribute]][[character][attribute]]....
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* TYPEDEFS ***************************************************************/
|
/* TYPEDEFS ***************************************************************/
|
||||||
|
|
||||||
typedef struct _DEVICE_EXTENSION
|
typedef struct _DEVICE_EXTENSION
|
||||||
|
@ -82,7 +80,8 @@ static const UCHAR DefaultPalette[] =
|
||||||
|
|
||||||
/* FUNCTIONS **************************************************************/
|
/* FUNCTIONS **************************************************************/
|
||||||
|
|
||||||
static VOID FASTCALL
|
static VOID
|
||||||
|
FASTCALL
|
||||||
ScrSetRegisters(const VGA_REGISTERS *Registers)
|
ScrSetRegisters(const VGA_REGISTERS *Registers)
|
||||||
{
|
{
|
||||||
UINT32 i;
|
UINT32 i;
|
||||||
|
@ -96,7 +95,7 @@ ScrSetRegisters(const VGA_REGISTERS *Registers)
|
||||||
|
|
||||||
/* Write sequencer registers */
|
/* Write sequencer registers */
|
||||||
for (i = 1; i < sizeof(Registers->Sequencer); i++)
|
for (i = 1; i < sizeof(Registers->Sequencer); i++)
|
||||||
{
|
{
|
||||||
WRITE_PORT_UCHAR(SEQ, i);
|
WRITE_PORT_UCHAR(SEQ, i);
|
||||||
WRITE_PORT_UCHAR(SEQDATA, Registers->Sequencer[i]);
|
WRITE_PORT_UCHAR(SEQDATA, Registers->Sequencer[i]);
|
||||||
}
|
}
|
||||||
|
@ -131,20 +130,22 @@ ScrSetRegisters(const VGA_REGISTERS *Registers)
|
||||||
WRITE_PORT_UCHAR(ATTRIB, Registers->Attribute[i]);
|
WRITE_PORT_UCHAR(ATTRIB, Registers->Attribute[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the PEL mask. */
|
/* Set the PEL mask */
|
||||||
WRITE_PORT_UCHAR(PELMASK, 0xff);
|
WRITE_PORT_UCHAR(PELMASK, 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID FASTCALL
|
static VOID
|
||||||
ScrAcquireOwnership(PDEVICE_EXTENSION DeviceExtension)
|
FASTCALL
|
||||||
|
ScrAcquireOwnership(
|
||||||
|
_In_ PDEVICE_EXTENSION DeviceExtension)
|
||||||
{
|
{
|
||||||
unsigned int offset;
|
ULONG offset;
|
||||||
UCHAR data, value;
|
UCHAR data, value;
|
||||||
ULONG Index;
|
ULONG Index;
|
||||||
|
|
||||||
ScrSetRegisters(&VidpMode3Regs);
|
ScrSetRegisters(&VidpMode3Regs);
|
||||||
|
|
||||||
/* Disable screen and enable palette access. */
|
/* Disable screen and enable palette access */
|
||||||
READ_PORT_UCHAR(STATUS);
|
READ_PORT_UCHAR(STATUS);
|
||||||
WRITE_PORT_UCHAR(ATTRIB, 0x00);
|
WRITE_PORT_UCHAR(ATTRIB, 0x00);
|
||||||
|
|
||||||
|
@ -156,47 +157,47 @@ ScrAcquireOwnership(PDEVICE_EXTENSION DeviceExtension)
|
||||||
WRITE_PORT_UCHAR(PELDATA, DefaultPalette[Index * 3 + 2] >> 2);
|
WRITE_PORT_UCHAR(PELDATA, DefaultPalette[Index * 3 + 2] >> 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable screen and disable palette access. */
|
/* Enable screen and disable palette access */
|
||||||
READ_PORT_UCHAR(STATUS);
|
READ_PORT_UCHAR(STATUS);
|
||||||
WRITE_PORT_UCHAR(ATTRIB, 0x20);
|
WRITE_PORT_UCHAR(ATTRIB, 0x20);
|
||||||
|
|
||||||
/* get current output position */
|
/* Get current output position */
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORPOSLO);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORPOSLO);
|
||||||
offset = READ_PORT_UCHAR (CRTC_DATA);
|
offset = READ_PORT_UCHAR(CRTC_DATA);
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORPOSHI);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORPOSHI);
|
||||||
offset += (READ_PORT_UCHAR (CRTC_DATA) << 8);
|
offset += (READ_PORT_UCHAR(CRTC_DATA) << 8);
|
||||||
|
|
||||||
/* switch blinking characters off */
|
/* Switch blinking characters off */
|
||||||
READ_PORT_UCHAR (ATTRC_INPST1);
|
READ_PORT_UCHAR(ATTRC_INPST1);
|
||||||
value = READ_PORT_UCHAR (ATTRC_WRITEREG);
|
value = READ_PORT_UCHAR(ATTRC_WRITEREG);
|
||||||
WRITE_PORT_UCHAR (ATTRC_WRITEREG, 0x10);
|
WRITE_PORT_UCHAR(ATTRC_WRITEREG, 0x10);
|
||||||
data = READ_PORT_UCHAR (ATTRC_READREG);
|
data = READ_PORT_UCHAR(ATTRC_READREG);
|
||||||
data = data & ~0x08;
|
data = data & ~0x08;
|
||||||
WRITE_PORT_UCHAR (ATTRC_WRITEREG, data);
|
WRITE_PORT_UCHAR(ATTRC_WRITEREG, data);
|
||||||
WRITE_PORT_UCHAR (ATTRC_WRITEREG, value);
|
WRITE_PORT_UCHAR(ATTRC_WRITEREG, value);
|
||||||
READ_PORT_UCHAR (ATTRC_INPST1);
|
READ_PORT_UCHAR(ATTRC_INPST1);
|
||||||
|
|
||||||
/* read screen information from crt controller */
|
/* Read screen information from CRT controller */
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_COLUMNS);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_COLUMNS);
|
||||||
DeviceExtension->Columns = READ_PORT_UCHAR (CRTC_DATA) + 1;
|
DeviceExtension->Columns = READ_PORT_UCHAR(CRTC_DATA) + 1;
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_ROWS);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_ROWS);
|
||||||
DeviceExtension->Rows = READ_PORT_UCHAR (CRTC_DATA);
|
DeviceExtension->Rows = READ_PORT_UCHAR(CRTC_DATA);
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_OVERFLOW);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_OVERFLOW);
|
||||||
data = READ_PORT_UCHAR (CRTC_DATA);
|
data = READ_PORT_UCHAR(CRTC_DATA);
|
||||||
DeviceExtension->Rows |= (((data & 0x02) << 7) | ((data & 0x40) << 3));
|
DeviceExtension->Rows |= (((data & 0x02) << 7) | ((data & 0x40) << 3));
|
||||||
DeviceExtension->Rows++;
|
DeviceExtension->Rows++;
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_SCANLINES);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_SCANLINES);
|
||||||
DeviceExtension->ScanLines = (READ_PORT_UCHAR (CRTC_DATA) & 0x1F) + 1;
|
DeviceExtension->ScanLines = (READ_PORT_UCHAR(CRTC_DATA) & 0x1F) + 1;
|
||||||
|
|
||||||
/* show blinking cursor */
|
/* Show blinking cursor */
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORSTART);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORSTART);
|
||||||
WRITE_PORT_UCHAR (CRTC_DATA, (DeviceExtension->ScanLines - 1) & 0x1F);
|
WRITE_PORT_UCHAR(CRTC_DATA, (DeviceExtension->ScanLines - 1) & 0x1F);
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSOREND);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSOREND);
|
||||||
data = READ_PORT_UCHAR (CRTC_DATA) & 0xE0;
|
data = READ_PORT_UCHAR(CRTC_DATA) & 0xE0;
|
||||||
WRITE_PORT_UCHAR (CRTC_DATA,
|
WRITE_PORT_UCHAR(CRTC_DATA,
|
||||||
data | ((DeviceExtension->ScanLines - 1) & 0x1F));
|
data | ((DeviceExtension->ScanLines - 1) & 0x1F));
|
||||||
|
|
||||||
/* calculate number of text rows */
|
/* Calculate number of text rows */
|
||||||
DeviceExtension->Rows =
|
DeviceExtension->Rows =
|
||||||
DeviceExtension->Rows / DeviceExtension->ScanLines;
|
DeviceExtension->Rows / DeviceExtension->ScanLines;
|
||||||
#ifdef BOCHS_30ROWS
|
#ifdef BOCHS_30ROWS
|
||||||
|
@ -206,20 +207,21 @@ ScrAcquireOwnership(PDEVICE_EXTENSION DeviceExtension)
|
||||||
/* Upload a default font for the default codepage 437 */
|
/* Upload a default font for the default codepage 437 */
|
||||||
ScrLoadFontTable(437);
|
ScrLoadFontTable(437);
|
||||||
|
|
||||||
DPRINT ("%d Columns %d Rows %d Scanlines\n",
|
DPRINT("%d Columns %d Rows %d Scanlines\n",
|
||||||
DeviceExtension->Columns,
|
DeviceExtension->Columns,
|
||||||
DeviceExtension->Rows,
|
DeviceExtension->Rows,
|
||||||
DeviceExtension->ScanLines);
|
DeviceExtension->ScanLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
|
||||||
DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath);
|
|
||||||
|
|
||||||
static DRIVER_DISPATCH ScrCreate;
|
static DRIVER_DISPATCH ScrCreate;
|
||||||
static NTSTATUS NTAPI
|
static NTSTATUS
|
||||||
ScrCreate(PDEVICE_OBJECT DeviceObject,
|
NTAPI
|
||||||
PIRP Irp)
|
ScrCreate(
|
||||||
|
_In_ PDEVICE_OBJECT DeviceObject,
|
||||||
|
_In_ PIRP Irp)
|
||||||
{
|
{
|
||||||
|
#define FOREGROUND_LIGHTGRAY (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED)
|
||||||
|
|
||||||
PDEVICE_EXTENSION DeviceExtension;
|
PDEVICE_EXTENSION DeviceExtension;
|
||||||
PHYSICAL_ADDRESS BaseAddress;
|
PHYSICAL_ADDRESS BaseAddress;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -230,14 +232,14 @@ ScrCreate(PDEVICE_OBJECT DeviceObject,
|
||||||
{
|
{
|
||||||
ScrAcquireOwnership(DeviceExtension);
|
ScrAcquireOwnership(DeviceExtension);
|
||||||
|
|
||||||
/* get pointer to video memory */
|
/* Get a pointer to the video memory */
|
||||||
BaseAddress.QuadPart = VIDMEM_BASE;
|
BaseAddress.QuadPart = VIDMEM_BASE;
|
||||||
DeviceExtension->VideoMemory =
|
DeviceExtension->VideoMemory =
|
||||||
(PUCHAR)MmMapIoSpace (BaseAddress, DeviceExtension->Rows * DeviceExtension->Columns * 2, MmNonCached);
|
(PUCHAR)MmMapIoSpace(BaseAddress, DeviceExtension->Rows * DeviceExtension->Columns * 2, MmNonCached);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* store dummy values here */
|
/* Store dummy values */
|
||||||
DeviceExtension->Columns = 1;
|
DeviceExtension->Columns = 1;
|
||||||
DeviceExtension->Rows = 1;
|
DeviceExtension->Rows = 1;
|
||||||
DeviceExtension->ScanLines = 1;
|
DeviceExtension->ScanLines = 1;
|
||||||
|
@ -246,34 +248,35 @@ ScrCreate(PDEVICE_OBJECT DeviceObject,
|
||||||
DeviceExtension->CursorSize = 5; /* FIXME: value correct?? */
|
DeviceExtension->CursorSize = 5; /* FIXME: value correct?? */
|
||||||
DeviceExtension->CursorVisible = TRUE;
|
DeviceExtension->CursorVisible = TRUE;
|
||||||
|
|
||||||
/* more initialization */
|
/* More initialization */
|
||||||
DeviceExtension->CharAttribute = 0x17; /* light grey on blue */
|
DeviceExtension->CharAttribute = BACKGROUND_BLUE | FOREGROUND_LIGHTGRAY;
|
||||||
DeviceExtension->Mode = ENABLE_PROCESSED_OUTPUT |
|
DeviceExtension->Mode = ENABLE_PROCESSED_OUTPUT |
|
||||||
ENABLE_WRAP_AT_EOL_OUTPUT;
|
ENABLE_WRAP_AT_EOL_OUTPUT;
|
||||||
|
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
return Status;
|
||||||
return (Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DRIVER_DISPATCH ScrWrite;
|
static DRIVER_DISPATCH ScrWrite;
|
||||||
static NTSTATUS NTAPI
|
static NTSTATUS
|
||||||
ScrWrite(PDEVICE_OBJECT DeviceObject,
|
NTAPI
|
||||||
PIRP Irp)
|
ScrWrite(
|
||||||
|
_In_ PDEVICE_OBJECT DeviceObject,
|
||||||
|
_In_ PIRP Irp)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION stk = IoGetCurrentIrpStackLocation (Irp);
|
PIO_STACK_LOCATION stk = IoGetCurrentIrpStackLocation(Irp);
|
||||||
PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
|
PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
char *pch = Irp->UserBuffer;
|
PCHAR pch = Irp->UserBuffer;
|
||||||
PUCHAR vidmem;
|
PUCHAR vidmem;
|
||||||
unsigned int i;
|
ULONG i;
|
||||||
int j, offset;
|
ULONG j, offset;
|
||||||
int cursorx, cursory;
|
USHORT cursorx, cursory;
|
||||||
int rows, columns;
|
USHORT rows, columns;
|
||||||
int processed = DeviceExtension->Mode & ENABLE_PROCESSED_OUTPUT;
|
BOOLEAN processed = !!(DeviceExtension->Mode & ENABLE_PROCESSED_OUTPUT);
|
||||||
|
|
||||||
if (InbvCheckDisplayOwnership())
|
if (InbvCheckDisplayOwnership())
|
||||||
{
|
{
|
||||||
|
@ -281,7 +284,7 @@ ScrWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -291,28 +294,32 @@ ScrWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
columns = DeviceExtension->Columns;
|
columns = DeviceExtension->Columns;
|
||||||
|
|
||||||
_disable();
|
_disable();
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORPOSHI);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORPOSHI);
|
||||||
offset = READ_PORT_UCHAR (CRTC_DATA)<<8;
|
offset = READ_PORT_UCHAR(CRTC_DATA)<<8;
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORPOSLO);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORPOSLO);
|
||||||
offset += READ_PORT_UCHAR (CRTC_DATA);
|
offset += READ_PORT_UCHAR(CRTC_DATA);
|
||||||
_enable();
|
_enable();
|
||||||
|
|
||||||
cursory = offset / columns;
|
cursory = (USHORT)(offset / columns);
|
||||||
cursorx = offset % columns;
|
cursorx = (USHORT)(offset % columns);
|
||||||
if( processed == 0 )
|
if (!processed)
|
||||||
{
|
{
|
||||||
/* raw output mode */
|
/* Raw output mode */
|
||||||
// FIXME: Does the buffer only contains chars? or chars + attributes?
|
// FIXME: Does the buffer only contains chars? or chars + attributes?
|
||||||
// FIXME2: Fix buffer overflow.
|
// FIXME2: Fix buffer overflow.
|
||||||
memcpy( &vidmem[(cursorx * 2) + (cursory * columns * 2)], pch, stk->Parameters.Write.Length );
|
RtlCopyMemory(&vidmem[(cursorx * 2) + (cursory * columns * 2)],
|
||||||
|
pch, stk->Parameters.Write.Length);
|
||||||
offset += (stk->Parameters.Write.Length / 2);
|
offset += (stk->Parameters.Write.Length / 2);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
|
/* Cooked output mode */
|
||||||
for (i = 0; i < stk->Parameters.Write.Length; i++, pch++)
|
for (i = 0; i < stk->Parameters.Write.Length; i++, pch++)
|
||||||
{
|
{
|
||||||
switch (*pch)
|
switch (*pch)
|
||||||
{
|
{
|
||||||
case '\b':
|
case '\b':
|
||||||
|
{
|
||||||
if (cursorx > 0)
|
if (cursorx > 0)
|
||||||
{
|
{
|
||||||
cursorx--;
|
cursorx--;
|
||||||
|
@ -323,8 +330,9 @@ ScrWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
cursory--;
|
cursory--;
|
||||||
}
|
}
|
||||||
vidmem[(cursorx * 2) + (cursory * columns * 2)] = ' ';
|
vidmem[(cursorx * 2) + (cursory * columns * 2)] = ' ';
|
||||||
vidmem[(cursorx * 2) + (cursory * columns * 2) + 1] = (char) DeviceExtension->CharAttribute;
|
vidmem[(cursorx * 2) + (cursory * columns * 2) + 1] = (char)DeviceExtension->CharAttribute;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
cursory++;
|
cursory++;
|
||||||
|
@ -336,6 +344,7 @@ ScrWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\t':
|
case '\t':
|
||||||
|
{
|
||||||
offset = TAB_WIDTH - (cursorx % TAB_WIDTH);
|
offset = TAB_WIDTH - (cursorx % TAB_WIDTH);
|
||||||
for (j = 0; j < offset; j++)
|
for (j = 0; j < offset; j++)
|
||||||
{
|
{
|
||||||
|
@ -349,10 +358,12 @@ ScrWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
vidmem[(cursorx * 2) + (cursory * columns * 2)] = *pch;
|
vidmem[(cursorx * 2) + (cursory * columns * 2)] = *pch;
|
||||||
vidmem[(cursorx * 2) + (cursory * columns * 2) + 1] = (char) DeviceExtension->CharAttribute;
|
vidmem[(cursorx * 2) + (cursory * columns * 2) + 1] = (char)DeviceExtension->CharAttribute;
|
||||||
cursorx++;
|
cursorx++;
|
||||||
if (cursorx >= columns)
|
if (cursorx >= columns)
|
||||||
{
|
{
|
||||||
|
@ -361,17 +372,18 @@ ScrWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Scroll up the contents of the screen if we are at the end */
|
/* Scroll up the contents of the screen if we are at the end */
|
||||||
if (cursory >= rows)
|
if (cursory >= rows)
|
||||||
{
|
{
|
||||||
unsigned short *LinePtr;
|
PUSHORT LinePtr;
|
||||||
|
|
||||||
memcpy (vidmem,
|
RtlCopyMemory(vidmem,
|
||||||
&vidmem[columns * 2],
|
&vidmem[columns * 2],
|
||||||
columns * (rows - 1) * 2);
|
columns * (rows - 1) * 2);
|
||||||
|
|
||||||
LinePtr = (unsigned short *) &vidmem[columns * (rows - 1) * 2];
|
LinePtr = (PUSHORT)&vidmem[columns * (rows - 1) * 2];
|
||||||
|
|
||||||
for (j = 0; j < columns; j++)
|
for (j = 0; j < columns; j++)
|
||||||
{
|
{
|
||||||
|
@ -390,29 +402,31 @@ ScrWrite(PDEVICE_OBJECT DeviceObject,
|
||||||
offset = (cursory * columns) + cursorx;
|
offset = (cursory * columns) + cursorx;
|
||||||
}
|
}
|
||||||
_disable();
|
_disable();
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORPOSLO);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORPOSLO);
|
||||||
WRITE_PORT_UCHAR (CRTC_DATA, offset);
|
WRITE_PORT_UCHAR(CRTC_DATA, offset);
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORPOSHI);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORPOSHI);
|
||||||
offset >>= 8;
|
offset >>= 8;
|
||||||
WRITE_PORT_UCHAR (CRTC_DATA, offset);
|
WRITE_PORT_UCHAR(CRTC_DATA, offset);
|
||||||
_enable();
|
_enable();
|
||||||
|
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DRIVER_DISPATCH ScrIoControl;
|
static DRIVER_DISPATCH ScrIoControl;
|
||||||
static NTSTATUS NTAPI
|
static NTSTATUS
|
||||||
ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
NTAPI
|
||||||
PIRP Irp)
|
ScrIoControl(
|
||||||
|
_In_ PDEVICE_OBJECT DeviceObject,
|
||||||
|
_In_ PIRP Irp)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION stk = IoGetCurrentIrpStackLocation (Irp);
|
|
||||||
PDEVICE_EXTENSION DeviceExtension;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PIO_STACK_LOCATION stk = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
PDEVICE_EXTENSION DeviceExtension;
|
||||||
|
|
||||||
DeviceExtension = DeviceObject->DeviceExtension;
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
switch (stk->Parameters.DeviceIoControl.IoControlCode)
|
switch (stk->Parameters.DeviceIoControl.IoControlCode)
|
||||||
|
@ -420,18 +434,18 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
case IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO:
|
case IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO:
|
||||||
{
|
{
|
||||||
PCONSOLE_SCREEN_BUFFER_INFO pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
|
PCONSOLE_SCREEN_BUFFER_INFO pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
|
||||||
int rows = DeviceExtension->Rows;
|
USHORT rows = DeviceExtension->Rows;
|
||||||
int columns = DeviceExtension->Columns;
|
USHORT columns = DeviceExtension->Columns;
|
||||||
unsigned int offset;
|
ULONG offset;
|
||||||
|
|
||||||
if (!InbvCheckDisplayOwnership())
|
if (!InbvCheckDisplayOwnership())
|
||||||
{
|
{
|
||||||
/* read cursor position from crtc */
|
/* read cursor position from crtc */
|
||||||
_disable();
|
_disable();
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORPOSLO);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORPOSLO);
|
||||||
offset = READ_PORT_UCHAR (CRTC_DATA);
|
offset = READ_PORT_UCHAR(CRTC_DATA);
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORPOSHI);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORPOSHI);
|
||||||
offset += (READ_PORT_UCHAR (CRTC_DATA) << 8);
|
offset += (READ_PORT_UCHAR(CRTC_DATA) << 8);
|
||||||
_enable();
|
_enable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -455,15 +469,15 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
pcsbi->dwMaximumWindowSize.X = columns;
|
pcsbi->dwMaximumWindowSize.X = columns;
|
||||||
pcsbi->dwMaximumWindowSize.Y = rows;
|
pcsbi->dwMaximumWindowSize.Y = rows;
|
||||||
|
|
||||||
Irp->IoStatus.Information = sizeof (CONSOLE_SCREEN_BUFFER_INFO);
|
Irp->IoStatus.Information = sizeof(CONSOLE_SCREEN_BUFFER_INFO);
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO:
|
case IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO:
|
||||||
{
|
{
|
||||||
PCONSOLE_SCREEN_BUFFER_INFO pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
|
PCONSOLE_SCREEN_BUFFER_INFO pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
|
||||||
unsigned int offset;
|
ULONG Offset;
|
||||||
|
|
||||||
if ( pcsbi->dwCursorPosition.X < 0 || pcsbi->dwCursorPosition.X >= DeviceExtension->Columns ||
|
if ( pcsbi->dwCursorPosition.X < 0 || pcsbi->dwCursorPosition.X >= DeviceExtension->Columns ||
|
||||||
pcsbi->dwCursorPosition.Y < 0 || pcsbi->dwCursorPosition.Y >= DeviceExtension->Rows )
|
pcsbi->dwCursorPosition.Y < 0 || pcsbi->dwCursorPosition.Y >= DeviceExtension->Rows )
|
||||||
|
@ -474,23 +488,24 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceExtension->CharAttribute = pcsbi->wAttributes;
|
DeviceExtension->CharAttribute = pcsbi->wAttributes;
|
||||||
offset = (pcsbi->dwCursorPosition.Y * DeviceExtension->Columns) +
|
|
||||||
|
Offset = (pcsbi->dwCursorPosition.Y * DeviceExtension->Columns) +
|
||||||
pcsbi->dwCursorPosition.X;
|
pcsbi->dwCursorPosition.X;
|
||||||
|
|
||||||
if (!InbvCheckDisplayOwnership())
|
if (!InbvCheckDisplayOwnership())
|
||||||
{
|
{
|
||||||
_disable();
|
_disable();
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORPOSLO);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORPOSLO);
|
||||||
WRITE_PORT_UCHAR (CRTC_DATA, offset);
|
WRITE_PORT_UCHAR(CRTC_DATA, Offset);
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORPOSHI);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORPOSHI);
|
||||||
WRITE_PORT_UCHAR (CRTC_DATA, offset>>8);
|
WRITE_PORT_UCHAR(CRTC_DATA, Offset >> 8);
|
||||||
_enable();
|
_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IOCTL_CONSOLE_GET_CURSOR_INFO:
|
case IOCTL_CONSOLE_GET_CURSOR_INFO:
|
||||||
{
|
{
|
||||||
|
@ -499,10 +514,10 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
pcci->dwSize = DeviceExtension->CursorSize;
|
pcci->dwSize = DeviceExtension->CursorSize;
|
||||||
pcci->bVisible = DeviceExtension->CursorVisible;
|
pcci->bVisible = DeviceExtension->CursorVisible;
|
||||||
|
|
||||||
Irp->IoStatus.Information = sizeof (CONSOLE_CURSOR_INFO);
|
Irp->IoStatus.Information = sizeof(CONSOLE_CURSOR_INFO);
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IOCTL_CONSOLE_SET_CURSOR_INFO:
|
case IOCTL_CONSOLE_SET_CURSOR_INFO:
|
||||||
{
|
{
|
||||||
|
@ -520,26 +535,23 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
size = (pcci->dwSize * height) / 100;
|
size = (pcci->dwSize * height) / 100;
|
||||||
if (size < 1)
|
if (size < 1)
|
||||||
{
|
|
||||||
size = 1;
|
size = 1;
|
||||||
}
|
|
||||||
|
|
||||||
data |= (UCHAR)(height - size);
|
data |= (UCHAR)(height - size);
|
||||||
|
|
||||||
_disable();
|
_disable();
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORSTART);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORSTART);
|
||||||
WRITE_PORT_UCHAR (CRTC_DATA, data);
|
WRITE_PORT_UCHAR(CRTC_DATA, data);
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSOREND);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSOREND);
|
||||||
value = READ_PORT_UCHAR (CRTC_DATA) & 0xE0;
|
value = READ_PORT_UCHAR(CRTC_DATA) & 0xE0;
|
||||||
WRITE_PORT_UCHAR (CRTC_DATA, value | (height - 1));
|
WRITE_PORT_UCHAR(CRTC_DATA, value | (height - 1));
|
||||||
|
|
||||||
_enable();
|
_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IOCTL_CONSOLE_GET_MODE:
|
case IOCTL_CONSOLE_GET_MODE:
|
||||||
{
|
{
|
||||||
|
@ -549,8 +561,8 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
Irp->IoStatus.Information = sizeof(CONSOLE_MODE);
|
Irp->IoStatus.Information = sizeof(CONSOLE_MODE);
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IOCTL_CONSOLE_SET_MODE:
|
case IOCTL_CONSOLE_SET_MODE:
|
||||||
{
|
{
|
||||||
|
@ -560,8 +572,8 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE:
|
case IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE:
|
||||||
{
|
{
|
||||||
|
@ -592,7 +604,7 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
for (dwCount = 0; dwCount < nMaxLength; dwCount++)
|
for (dwCount = 0; dwCount < nMaxLength; dwCount++)
|
||||||
{
|
{
|
||||||
vidmem[offset + (dwCount * 2)] = (char) Buf->wAttribute;
|
vidmem[offset + (dwCount * 2)] = (char)Buf->wAttribute;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,8 +612,8 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE:
|
case IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE:
|
||||||
{
|
{
|
||||||
|
@ -633,7 +645,7 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
for (dwCount = 0; dwCount < nMaxLength; dwCount++, pAttr++)
|
for (dwCount = 0; dwCount < nMaxLength; dwCount++, pAttr++)
|
||||||
{
|
{
|
||||||
*((char *)pAttr) = vidmem[offset + (dwCount * 2)];
|
*((PCHAR)pAttr) = vidmem[offset + (dwCount * 2)];
|
||||||
}
|
}
|
||||||
|
|
||||||
Buf->dwTransfered = dwCount;
|
Buf->dwTransfered = dwCount;
|
||||||
|
@ -645,13 +657,13 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
Irp->IoStatus.Information = sizeof(OUTPUT_ATTRIBUTE);
|
Irp->IoStatus.Information = sizeof(OUTPUT_ATTRIBUTE);
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE:
|
case IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE:
|
||||||
{
|
{
|
||||||
COORD *pCoord = (COORD *)MmGetSystemAddressForMdl(Irp->MdlAddress);
|
PCOORD pCoord = (PCOORD)MmGetSystemAddressForMdl(Irp->MdlAddress);
|
||||||
CHAR *pAttr = (CHAR *)(pCoord + 1);
|
PCHAR pAttr = (PCHAR)(pCoord + 1);
|
||||||
PUCHAR vidmem;
|
PUCHAR vidmem;
|
||||||
int offset;
|
int offset;
|
||||||
ULONG dwCount;
|
ULONG dwCount;
|
||||||
|
@ -683,8 +695,8 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE:
|
case IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE:
|
||||||
DeviceExtension->CharAttribute = (USHORT)*(PUSHORT)Irp->AssociatedIrp.SystemBuffer;
|
DeviceExtension->CharAttribute = (USHORT)*(PUSHORT)Irp->AssociatedIrp.SystemBuffer;
|
||||||
|
@ -721,7 +733,7 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
for (dwCount = 0; dwCount < nMaxLength; dwCount++)
|
for (dwCount = 0; dwCount < nMaxLength; dwCount++)
|
||||||
{
|
{
|
||||||
vidmem[offset + (dwCount * 2)] = (char) Buf->cCharacter;
|
vidmem[offset + (dwCount * 2)] = (char)Buf->cCharacter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -729,13 +741,13 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IOCTL_CONSOLE_READ_OUTPUT_CHARACTER:
|
case IOCTL_CONSOLE_READ_OUTPUT_CHARACTER:
|
||||||
{
|
{
|
||||||
POUTPUT_CHARACTER Buf = (POUTPUT_CHARACTER)Irp->AssociatedIrp.SystemBuffer;
|
POUTPUT_CHARACTER Buf = (POUTPUT_CHARACTER)Irp->AssociatedIrp.SystemBuffer;
|
||||||
LPSTR pChar = (LPSTR)MmGetSystemAddressForMdl(Irp->MdlAddress);
|
PCHAR pChar = (PCHAR)MmGetSystemAddressForMdl(Irp->MdlAddress);
|
||||||
PUCHAR vidmem;
|
PUCHAR vidmem;
|
||||||
int offset;
|
int offset;
|
||||||
ULONG dwCount;
|
ULONG dwCount;
|
||||||
|
@ -774,13 +786,13 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
Irp->IoStatus.Information = sizeof(OUTPUT_ATTRIBUTE);
|
Irp->IoStatus.Information = sizeof(OUTPUT_ATTRIBUTE);
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER:
|
case IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER:
|
||||||
{
|
{
|
||||||
COORD *pCoord = (COORD *)MmGetSystemAddressForMdl(Irp->MdlAddress);
|
PCOORD pCoord = (PCOORD)MmGetSystemAddressForMdl(Irp->MdlAddress);
|
||||||
LPSTR pChar = (CHAR *)(pCoord + 1);
|
PCHAR pChar = (PCHAR)(pCoord + 1);
|
||||||
PUCHAR vidmem;
|
PUCHAR vidmem;
|
||||||
int offset;
|
int offset;
|
||||||
ULONG dwCount;
|
ULONG dwCount;
|
||||||
|
@ -812,8 +824,8 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IOCTL_CONSOLE_DRAW:
|
case IOCTL_CONSOLE_DRAW:
|
||||||
{
|
{
|
||||||
|
@ -841,21 +853,21 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
ConsoleDraw->CursorX;
|
ConsoleDraw->CursorX;
|
||||||
|
|
||||||
_disable();
|
_disable();
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORPOSLO);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORPOSLO);
|
||||||
WRITE_PORT_UCHAR (CRTC_DATA, Offset);
|
WRITE_PORT_UCHAR(CRTC_DATA, Offset);
|
||||||
WRITE_PORT_UCHAR (CRTC_COMMAND, CRTC_CURSORPOSHI);
|
WRITE_PORT_UCHAR(CRTC_COMMAND, CRTC_CURSORPOSHI);
|
||||||
WRITE_PORT_UCHAR (CRTC_DATA, Offset >> 8);
|
WRITE_PORT_UCHAR(CRTC_DATA, Offset >> 8);
|
||||||
_enable();
|
_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IOCTL_CONSOLE_LOADFONT:
|
case IOCTL_CONSOLE_LOADFONT:
|
||||||
{
|
{
|
||||||
UINT32 CodePage = (UINT32)*(PULONG)Irp->AssociatedIrp.SystemBuffer;
|
ULONG CodePage = *(PULONG)Irp->AssociatedIrp.SystemBuffer;
|
||||||
|
|
||||||
if (!InbvCheckDisplayOwnership())
|
if (!InbvCheckDisplayOwnership())
|
||||||
{
|
{
|
||||||
|
@ -865,26 +877,28 @@ ScrIoControl(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Status = STATUS_NOT_IMPLEMENTED;
|
Status = STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DRIVER_DISPATCH ScrDispatch;
|
static DRIVER_DISPATCH ScrDispatch;
|
||||||
static NTSTATUS NTAPI
|
static NTSTATUS
|
||||||
ScrDispatch(PDEVICE_OBJECT DeviceObject,
|
NTAPI
|
||||||
PIRP Irp)
|
ScrDispatch(
|
||||||
|
_In_ PDEVICE_OBJECT DeviceObject,
|
||||||
|
_In_ PIRP Irp)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION stk = IoGetCurrentIrpStackLocation(Irp);
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PIO_STACK_LOCATION stk = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
switch (stk->MajorFunction)
|
switch (stk->MajorFunction)
|
||||||
{
|
{
|
||||||
|
@ -897,51 +911,50 @@ ScrDispatch(PDEVICE_OBJECT DeviceObject,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Module entry point
|
* Module entry point
|
||||||
*/
|
*/
|
||||||
NTSTATUS NTAPI
|
NTSTATUS
|
||||||
DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
NTAPI
|
||||||
|
DriverEntry(
|
||||||
|
_In_ PDRIVER_OBJECT DriverObject,
|
||||||
|
_In_ PUNICODE_STRING RegistryPath)
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT DeviceObject;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PDEVICE_OBJECT DeviceObject;
|
||||||
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\BlueScreen");
|
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\BlueScreen");
|
||||||
UNICODE_STRING SymlinkName = RTL_CONSTANT_STRING(L"\\??\\BlueScreen");
|
UNICODE_STRING SymlinkName = RTL_CONSTANT_STRING(L"\\??\\BlueScreen");
|
||||||
|
|
||||||
DPRINT ("Screen Driver 0.0.6\n");
|
DPRINT("Screen Driver 0.0.6\n");
|
||||||
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = ScrCreate;
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = ScrCreate;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = ScrDispatch;
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = ScrDispatch;
|
||||||
DriverObject->MajorFunction[IRP_MJ_READ] = ScrDispatch;
|
DriverObject->MajorFunction[IRP_MJ_READ] = ScrDispatch;
|
||||||
DriverObject->MajorFunction[IRP_MJ_WRITE] = ScrWrite;
|
DriverObject->MajorFunction[IRP_MJ_WRITE] = ScrWrite;
|
||||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL ] = ScrIoControl;
|
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ScrIoControl;
|
||||||
|
|
||||||
Status = IoCreateDevice (DriverObject,
|
Status = IoCreateDevice(DriverObject,
|
||||||
sizeof(DEVICE_EXTENSION),
|
sizeof(DEVICE_EXTENSION),
|
||||||
&DeviceName,
|
&DeviceName,
|
||||||
FILE_DEVICE_SCREEN,
|
FILE_DEVICE_SCREEN,
|
||||||
FILE_DEVICE_SECURE_OPEN,
|
FILE_DEVICE_SECURE_OPEN,
|
||||||
TRUE,
|
TRUE,
|
||||||
&DeviceObject);
|
&DeviceObject);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = IoCreateSymbolicLink (&SymlinkName, &DeviceName);
|
Status = IoCreateSymbolicLink(&SymlinkName, &DeviceName);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
|
DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||||
else
|
else
|
||||||
IoDeleteDevice (DeviceObject);
|
IoDeleteDevice(DeviceObject);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS Setup Driver
|
* PROJECT: ReactOS Console Text-Mode Device Driver
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||||
* FILE: drivers/setup/blue/font.h
|
* PURPOSE: Main Header File.
|
||||||
* PURPOSE: Loading specific fonts into VGA
|
* COPYRIGHT: Copyright 1999 Boudewijn Dekker
|
||||||
* PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
|
* Copyright 1999-2019 Eric Kohl
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _BLUE_PCH_
|
#ifndef _BLUE_PCH_
|
||||||
|
@ -11,24 +11,32 @@
|
||||||
|
|
||||||
#include <wdm.h>
|
#include <wdm.h>
|
||||||
|
|
||||||
|
#define TAG_BLUE 'EULB'
|
||||||
|
|
||||||
|
#define TAB_WIDTH 8
|
||||||
|
#define MAX_PATH 260
|
||||||
|
|
||||||
typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES;
|
typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES;
|
||||||
|
|
||||||
// Define material that normally comes from PSDK
|
// Define material that normally comes from PSDK
|
||||||
// This is mandatory to prevent any inclusion of
|
// This is mandatory to prevent any inclusion of
|
||||||
// user-mode stuff.
|
// user-mode stuff.
|
||||||
typedef struct tagCOORD {
|
typedef struct tagCOORD
|
||||||
|
{
|
||||||
SHORT X;
|
SHORT X;
|
||||||
SHORT Y;
|
SHORT Y;
|
||||||
} COORD, *PCOORD;
|
} COORD, *PCOORD;
|
||||||
|
|
||||||
typedef struct tagSMALL_RECT {
|
typedef struct tagSMALL_RECT
|
||||||
|
{
|
||||||
SHORT Left;
|
SHORT Left;
|
||||||
SHORT Top;
|
SHORT Top;
|
||||||
SHORT Right;
|
SHORT Right;
|
||||||
SHORT Bottom;
|
SHORT Bottom;
|
||||||
} SMALL_RECT;
|
} SMALL_RECT;
|
||||||
|
|
||||||
typedef struct tagCONSOLE_SCREEN_BUFFER_INFO {
|
typedef struct tagCONSOLE_SCREEN_BUFFER_INFO
|
||||||
|
{
|
||||||
COORD dwSize;
|
COORD dwSize;
|
||||||
COORD dwCursorPosition;
|
COORD dwCursorPosition;
|
||||||
USHORT wAttributes;
|
USHORT wAttributes;
|
||||||
|
@ -36,9 +44,10 @@ typedef struct tagCONSOLE_SCREEN_BUFFER_INFO {
|
||||||
COORD dwMaximumWindowSize;
|
COORD dwMaximumWindowSize;
|
||||||
} CONSOLE_SCREEN_BUFFER_INFO, *PCONSOLE_SCREEN_BUFFER_INFO;
|
} CONSOLE_SCREEN_BUFFER_INFO, *PCONSOLE_SCREEN_BUFFER_INFO;
|
||||||
|
|
||||||
typedef struct tagCONSOLE_CURSOR_INFO {
|
typedef struct tagCONSOLE_CURSOR_INFO
|
||||||
|
{
|
||||||
ULONG dwSize;
|
ULONG dwSize;
|
||||||
BOOLEAN bVisible;
|
INT bVisible; // BOOL
|
||||||
} CONSOLE_CURSOR_INFO, *PCONSOLE_CURSOR_INFO;
|
} CONSOLE_CURSOR_INFO, *PCONSOLE_CURSOR_INFO;
|
||||||
|
|
||||||
#define ENABLE_PROCESSED_OUTPUT 0x0001
|
#define ENABLE_PROCESSED_OUTPUT 0x0001
|
||||||
|
@ -47,7 +56,17 @@ typedef struct tagCONSOLE_CURSOR_INFO {
|
||||||
#include <blue/ntddblue.h>
|
#include <blue/ntddblue.h>
|
||||||
#include <ndk/inbvfuncs.h>
|
#include <ndk/inbvfuncs.h>
|
||||||
|
|
||||||
#define TAG_BLUE 'EULB'
|
/*
|
||||||
|
* Color attributes for text and screen background
|
||||||
|
*/
|
||||||
|
#define FOREGROUND_BLUE 0x0001
|
||||||
|
#define FOREGROUND_GREEN 0x0002
|
||||||
|
#define FOREGROUND_RED 0x0004
|
||||||
|
#define FOREGROUND_INTENSITY 0x0008
|
||||||
|
#define BACKGROUND_BLUE 0x0010
|
||||||
|
#define BACKGROUND_GREEN 0x0020
|
||||||
|
#define BACKGROUND_RED 0x0040
|
||||||
|
#define BACKGROUND_INTENSITY 0x0080
|
||||||
|
|
||||||
typedef struct _CFHEADER
|
typedef struct _CFHEADER
|
||||||
{
|
{
|
||||||
|
@ -113,10 +132,6 @@ typedef struct _CFFILE
|
||||||
#define ATTRC_READREG ((PUCHAR)0x3c1)
|
#define ATTRC_READREG ((PUCHAR)0x3c1)
|
||||||
#define ATTRC_INPST1 ((PUCHAR)0x3da)
|
#define ATTRC_INPST1 ((PUCHAR)0x3da)
|
||||||
|
|
||||||
#define TAB_WIDTH 8
|
|
||||||
|
|
||||||
#define MAX_PATH 260
|
|
||||||
|
|
||||||
#define MISC (PUCHAR)0x3c2
|
#define MISC (PUCHAR)0x3c2
|
||||||
#define SEQ (PUCHAR)0x3c4
|
#define SEQ (PUCHAR)0x3c4
|
||||||
#define SEQDATA (PUCHAR)0x3c5
|
#define SEQDATA (PUCHAR)0x3c5
|
||||||
|
@ -130,7 +145,6 @@ typedef struct _CFFILE
|
||||||
#define PELINDEX (PUCHAR)0x3c8
|
#define PELINDEX (PUCHAR)0x3c8
|
||||||
#define PELDATA (PUCHAR)0x3c9
|
#define PELDATA (PUCHAR)0x3c9
|
||||||
|
|
||||||
void ScrLoadFontTable(UINT32 CodePage);
|
VOID ScrLoadFontTable(_In_ ULONG CodePage);
|
||||||
NTSTATUS ExtractFont(UINT32 CodePage, PUCHAR FontBitField);
|
|
||||||
|
|
||||||
#endif /* _BLUE_PCH_ */
|
#endif /* _BLUE_PCH_ */
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS Setup Driver
|
* PROJECT: ReactOS Console Text-Mode Device Driver
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||||
* FILE: drivers/setup/blue/font.c
|
* PURPOSE: Loading specific fonts into VGA.
|
||||||
* PURPOSE: Loading specific fonts into VGA
|
* COPYRIGHT: Copyright 2008-2019 Aleksey Bragin (aleksey@reactos.org)
|
||||||
* PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
|
* Copyright 2008-2019 Colin Finck (mail@colinfinck.de)
|
||||||
* Colin Finck (mail@colinfinck.de)
|
* Copyright 2008-2019 Christoph von Wittich (christoph_vw@reactos.org)
|
||||||
* Christoph von Wittich (christoph_vw@reactos.org)
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES ***************************************************************/
|
/* INCLUDES ***************************************************************/
|
||||||
|
|
||||||
|
@ -17,15 +16,16 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
VOID OpenBitPlane();
|
NTSTATUS ExtractFont(_In_ ULONG CodePage, _In_ PUCHAR FontBitField);
|
||||||
VOID CloseBitPlane();
|
VOID OpenBitPlane(VOID);
|
||||||
VOID LoadFont(PUCHAR Bitplane, PUCHAR FontBitfield);
|
VOID CloseBitPlane(VOID);
|
||||||
|
VOID LoadFont(_In_ PUCHAR Bitplane, _In_ PUCHAR FontBitfield);
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
ScrLoadFontTable(
|
ScrLoadFontTable(
|
||||||
UINT32 CodePage)
|
_In_ ULONG CodePage)
|
||||||
{
|
{
|
||||||
PHYSICAL_ADDRESS BaseAddress;
|
PHYSICAL_ADDRESS BaseAddress;
|
||||||
PUCHAR Bitplane;
|
PUCHAR Bitplane;
|
||||||
|
@ -67,8 +67,8 @@ ScrLoadFontTable(
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
ExtractFont(
|
ExtractFont(
|
||||||
UINT32 CodePage,
|
_In_ ULONG CodePage,
|
||||||
PUCHAR FontBitField)
|
_In_ PUCHAR FontBitField)
|
||||||
{
|
{
|
||||||
BOOLEAN bFoundFile = FALSE;
|
BOOLEAN bFoundFile = FALSE;
|
||||||
HANDLE Handle;
|
HANDLE Handle;
|
||||||
|
@ -299,8 +299,8 @@ CloseBitPlane(VOID)
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
LoadFont(
|
LoadFont(
|
||||||
PUCHAR Bitplane,
|
_In_ PUCHAR Bitplane,
|
||||||
PUCHAR FontBitfield)
|
_In_ PUCHAR FontBitfield)
|
||||||
{
|
{
|
||||||
UINT32 i, j;
|
UINT32 i, j;
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,11 @@
|
||||||
#define IOCTL_CONSOLE_GET_MODE CTL_CODE(FILE_DEVICE_SCREEN, 0x805, METHOD_BUFFERED, FILE_READ_ACCESS)
|
#define IOCTL_CONSOLE_GET_MODE CTL_CODE(FILE_DEVICE_SCREEN, 0x805, METHOD_BUFFERED, FILE_READ_ACCESS)
|
||||||
#define IOCTL_CONSOLE_SET_MODE CTL_CODE(FILE_DEVICE_SCREEN, 0x806, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
#define IOCTL_CONSOLE_SET_MODE CTL_CODE(FILE_DEVICE_SCREEN, 0x806, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
||||||
|
|
||||||
|
|
||||||
#define IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x810, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
#define IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x810, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
||||||
#define IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x811, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
#define IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x811, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
||||||
#define IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x812, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
|
#define IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x812, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
|
||||||
#define IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x813, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
#define IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE CTL_CODE(FILE_DEVICE_SCREEN, 0x813, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
||||||
|
|
||||||
|
|
||||||
#define IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER CTL_CODE(FILE_DEVICE_SCREEN, 0x820, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
#define IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER CTL_CODE(FILE_DEVICE_SCREEN, 0x820, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
||||||
#define IOCTL_CONSOLE_READ_OUTPUT_CHARACTER CTL_CODE(FILE_DEVICE_SCREEN, 0x821, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
#define IOCTL_CONSOLE_READ_OUTPUT_CHARACTER CTL_CODE(FILE_DEVICE_SCREEN, 0x821, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
||||||
#define IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER CTL_CODE(FILE_DEVICE_SCREEN, 0x822, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
|
#define IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER CTL_CODE(FILE_DEVICE_SCREEN, 0x822, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
|
||||||
|
@ -23,16 +21,13 @@
|
||||||
|
|
||||||
#define IOCTL_CONSOLE_LOADFONT CTL_CODE(FILE_DEVICE_SCREEN, 0x840, METHOD_IN_DIRECT, FILE_WRITE_ACCESS)
|
#define IOCTL_CONSOLE_LOADFONT CTL_CODE(FILE_DEVICE_SCREEN, 0x840, METHOD_IN_DIRECT, FILE_WRITE_ACCESS)
|
||||||
|
|
||||||
|
|
||||||
/* TYPEDEFS **************************************************************/
|
/* TYPEDEFS **************************************************************/
|
||||||
|
|
||||||
|
|
||||||
typedef struct tagCONSOLE_MODE
|
typedef struct tagCONSOLE_MODE
|
||||||
{
|
{
|
||||||
ULONG dwMode;
|
ULONG dwMode;
|
||||||
} CONSOLE_MODE, *PCONSOLE_MODE;
|
} CONSOLE_MODE, *PCONSOLE_MODE;
|
||||||
|
|
||||||
|
|
||||||
typedef struct tagOUTPUT_ATTRIBUTE
|
typedef struct tagOUTPUT_ATTRIBUTE
|
||||||
{
|
{
|
||||||
USHORT wAttribute;
|
USHORT wAttribute;
|
||||||
|
@ -41,7 +36,6 @@ typedef struct tagOUTPUT_ATTRIBUTE
|
||||||
ULONG dwTransfered;
|
ULONG dwTransfered;
|
||||||
} OUTPUT_ATTRIBUTE, *POUTPUT_ATTRIBUTE;
|
} OUTPUT_ATTRIBUTE, *POUTPUT_ATTRIBUTE;
|
||||||
|
|
||||||
|
|
||||||
typedef struct tagOUTPUT_CHARACTER
|
typedef struct tagOUTPUT_CHARACTER
|
||||||
{
|
{
|
||||||
CHAR cCharacter;
|
CHAR cCharacter;
|
||||||
|
@ -50,7 +44,6 @@ typedef struct tagOUTPUT_CHARACTER
|
||||||
ULONG dwTransfered;
|
ULONG dwTransfered;
|
||||||
} OUTPUT_CHARACTER, *POUTPUT_CHARACTER;
|
} OUTPUT_CHARACTER, *POUTPUT_CHARACTER;
|
||||||
|
|
||||||
|
|
||||||
typedef struct tagCONSOLE_DRAW
|
typedef struct tagCONSOLE_DRAW
|
||||||
{
|
{
|
||||||
ULONG X; /* Origin */
|
ULONG X; /* Origin */
|
||||||
|
@ -62,5 +55,4 @@ typedef struct tagCONSOLE_DRAW
|
||||||
/* Followed by screen buffer in char/attrib format */
|
/* Followed by screen buffer in char/attrib format */
|
||||||
} CONSOLE_DRAW, *PCONSOLE_DRAW;
|
} CONSOLE_DRAW, *PCONSOLE_DRAW;
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NTDDBLUE_H_INCLUDED_ */
|
#endif /* _NTDDBLUE_H_INCLUDED_ */
|
||||||
|
|
Loading…
Reference in a new issue