16#define ESC ((UCHAR)0x1b)
44 SizeLeft =
sizeof(DeviceExtension->SendBuffer) - DeviceExtension->SendBufferPosition;
45 if (SizeLeft < NumberOfChars * 2 || NumberOfChars == 0)
51 DeviceExtension->SendBuffer, DeviceExtension->SendBufferPosition,
57 DPRINT1(
"IoBuildSynchronousFsdRequest() failed. Unable to flush output buffer\n");
68 DeviceExtension->SendBufferPosition = 0;
69 SizeLeft =
sizeof(DeviceExtension->SendBuffer);
73 while (NumberOfChars-- > 0)
79 CurrentChar = (
UCHAR)CurrentInt;
82 if (CurrentChar == 0xff) CurrentChar =
' ';
84 DeviceExtension->SendBuffer[DeviceExtension->SendBufferPosition++] = CurrentChar;
87 else if (CurrentInt == 0)
89 DeviceExtension->SendBuffer[DeviceExtension->SendBufferPosition++] =
'0';
94 CurrentInt = -CurrentInt;
98 DeviceExtension->SendBuffer[DeviceExtension->SendBufferPosition++] =
99 (CurrentInt / 10) % 10 +
'0';
102 DeviceExtension->SendBuffer[DeviceExtension->SendBufferPosition++] =
103 CurrentInt % 10 +
'0';
131 DPRINT(
"ScreenInitialize() called\n");
145 DPRINT(
"Attaching to old blue\n");
160 DPRINT(
"IoCreateDevice() failed with status 0x%08lx\n",
Status);
174 DPRINT(
"IoAttachDevice() failed with status 0x%08lx\n",
Status);
177 PreviousBlue = LowerDevice;
190 DPRINT(
"IoCreateDevice() failed with status 0x%08lx\n",
Status);
204 DPRINT(
"IoCreateDevice() failed with status 0x%08lx\n",
Status);
221 DeviceExtension->
Rows = 25;
228 DPRINT(
"ExAllocatePool() failed\n");
244 Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
274 ULONG VideoMemorySize;
277 ULONG CursorX, CursorY;
282 DPRINT(
"ScreenWrite() called\n");
322 AddToSendBuffer(DeviceExtension, 6,
ESC,
'[', -(
int)CursorY,
';', -(
int)CursorX,
'H');
324 AddToSendBuffer(DeviceExtension, 6,
ESC,
'[', -(
int)CursorY,
';', -(
int)CursorX,
'H');
326 else if (CursorY > 1)
330 AddToSendBuffer(DeviceExtension, 6,
ESC,
'[', -(
int)CursorY,
';', -(
int)CursorX,
'H');
357 AddToSendBuffer(DeviceExtension, 6,
ESC,
'[', -(
int)CursorY,
';', -(
int)CursorX,
'H');
372 AddToSendBuffer(DeviceExtension, 6,
ESC,
'[', -(
int)CursorY,
';', -(
int)CursorX,
'H');
379 DPRINT(
"Y: %lu -> %lu\n", CursorY, CursorY + 1);
388 DPRINT(
"Y: %lu -> %lu\n", CursorY, CursorY - 1);
392 AddToSendBuffer(DeviceExtension, 6,
ESC,
'[', -(
int)CursorY,
';', -(
int)CursorX,
'H');
427 switch (
Stack->Parameters.DeviceIoControl.IoControlCode)
433 DPRINT(
"IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO\n");
460 DPRINT(
"IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO\n");
464 { pcsbi->dwCursorPosition.Y++; }
465 ASSERT(pcsbi->dwCursorPosition.X >= 1);
466 ASSERT(pcsbi->dwCursorPosition.Y >= 1);
467 ASSERT(pcsbi->dwCursorPosition.X <= DeviceExtension->
Columns);
468 ASSERT(pcsbi->dwCursorPosition.Y <= DeviceExtension->
Rows);
471 (pcsbi->dwCursorPosition.Y-1) * DeviceExtension->
Columns +
472 (pcsbi->dwCursorPosition.X-1)) * 2;
474 -(
int)pcsbi->dwCursorPosition.Y,
';',
475 -(
int)pcsbi->dwCursorPosition.X,
'H');
482 Irp->IoStatus.Information = 0;
489 DPRINT(
"IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_CURSOR_INFO\n");
501 DPRINT(
"IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_MODE\n");
512 DPRINT(
"IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_MODE\n");
516 Irp->IoStatus.Information = 0;
522 DPRINT1(
"IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE\n");
528 DPRINT1(
"IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE\n");
534 DPRINT1(
"IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE\n");
540 DPRINT(
"IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE\n");
543 Irp->IoStatus.Information = 0;
549 DPRINT1(
"IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER\n");
555 DPRINT1(
"IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_READ_OUTPUT_CHARACTER\n");
561 DPRINT1(
"IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER\n");
571 DPRINT(
"IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_DRAW\n");
574 { ConsoleDraw->
X++; ConsoleDraw->
CursorX++; }
575 { ConsoleDraw->
Y++; ConsoleDraw->
CursorY++; }
577 ConsoleDraw->
X, ConsoleDraw->
Y,
593 if (ConsoleDraw->
X == 1
594 && ConsoleDraw->
Y == 1
596 && ConsoleDraw->
SizeY == DeviceExtension->
Rows)
599 DoOptimization =
TRUE;
600 Video = (
PUCHAR)(ConsoleDraw + 1);
602 while (DoOptimization && x < DeviceExtension->
Columns * DeviceExtension->
Rows)
604 if (Video[
x++] !=
' ')
606 DoOptimization =
FALSE;
620 for (
y = 0;
y < ConsoleDraw->
SizeY;
y++)
623 -(
int)(ConsoleDraw->
Y +
y),
';',
624 -(
int)(ConsoleDraw->
X),
'H');
625 Video = (
PUCHAR)(ConsoleDraw + 1);
626 Video = &Video[((ConsoleDraw->
Y +
y) * ConsoleDraw->
X) * 2];
627 for (
x = 0;
x < ConsoleDraw->
SizeX;
x++)
638 -(
int)(ConsoleDraw->
CursorY),
';',
639 -(
int)(ConsoleDraw->
CursorX),
'H');
644 Irp->IoStatus.Information = 0;
651 DPRINT1(
"IRP_MJ_DEVICE_CONTROL / unknown ioctl code 0x%lx\n",
652 Stack->Parameters.DeviceIoControl.IoControlCode);
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
static const COLUMN_LIST Columns[]
#define ENABLE_WRAP_AT_EOL_OUTPUT
#define ENABLE_PROCESSED_OUTPUT
struct tagCONSOLE_SCREEN_BUFFER_INFO CONSOLE_SCREEN_BUFFER_INFO
struct tagCONSOLE_CURSOR_INFO CONSOLE_CURSOR_INFO
struct tagCONSOLE_CURSOR_INFO * PCONSOLE_CURSOR_INFO
struct tagCONSOLE_SCREEN_BUFFER_INFO * PCONSOLE_SCREEN_BUFFER_INFO
#define FILE_DEVICE_SECURE_OPEN
#define STATUS_NOT_SUPPORTED
#define STATUS_NOT_IMPLEMENTED
#define NT_SUCCESS(StatCode)
static void cleanup(void)
#define ExAllocatePool(type, size)
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
struct _GREEN_DEVICE_EXTENSION * PGREEN_DEVICE_EXTENSION
struct _GREEN_DRIVER_EXTENSION * PGREEN_DRIVER_EXTENSION
struct _COMMON_FDO_DEVICE_EXTENSION * PCOMMON_FDO_DEVICE_EXTENSION
struct _SCREEN_DEVICE_EXTENSION * PSCREEN_DEVICE_EXTENSION
NTSTATUS ScreenWrite(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS ScreenAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
NTSTATUS ScreenDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
static VOID AddToSendBuffer(IN PSCREEN_DEVICE_EXTENSION DeviceExtension, IN ULONG NumberOfChars,...)
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
#define IOCTL_CONSOLE_DRAW
#define IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE
#define IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER
#define IOCTL_CONSOLE_GET_MODE
#define IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER
#define IOCTL_CONSOLE_READ_OUTPUT_CHARACTER
#define IOCTL_CONSOLE_SET_MODE
#define IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE
struct tagCONSOLE_MODE CONSOLE_MODE
struct tagCONSOLE_DRAW * PCONSOLE_DRAW
#define IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE
struct tagCONSOLE_MODE * PCONSOLE_MODE
#define IOCTL_CONSOLE_GET_CURSOR_INFO
#define IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO
#define IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO
#define IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE
_In_ ULONG _In_ ULONG Offset
#define IoSkipCurrentIrpStackLocation(Irp)
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
NTSTATUS NTAPI IoAttachDevice(PDEVICE_OBJECT SourceDevice, PUNICODE_STRING TargetDeviceName, PDEVICE_OBJECT *AttachedDevice)
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
#define IoCompleteRequest
#define FILE_DEVICE_SCREEN
PDEVICE_OBJECT LowerDevice
COMMON_FDO_DEVICE_EXTENSION Common
PDEVICE_OBJECT PreviousBlue
COORD dwMaximumWindowSize
#define RTL_CONSTANT_STRING(s)
#define RtlZeroMemory(Destination, Length)
#define STATUS_OBJECT_NAME_COLLISION
#define STATUS_INSUFFICIENT_RESOURCES
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
_Must_inspect_result_ _In_ WDFDEVICE Fdo
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
#define MmGetSystemAddressForMdl(Mdl)