ReactOS  0.4.15-dev-4921-g25fcdc5
blue.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Console Text-Mode Device Driver
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Driver Management Functions.
5  * COPYRIGHT: Copyright 1999 Boudewijn Dekker
6  * Copyright 1999-2019 Eric Kohl
7  * Copyright 2006 Filip Navara
8  * Copyright 2019 Hermes Belusca-Maito
9  */
10 
11 /* INCLUDES ******************************************************************/
12 
13 #include "blue.h"
14 #include <ndk/inbvfuncs.h>
15 
16 #define NDEBUG
17 #include <debug.h>
18 
19 /* NOTES ******************************************************************/
20 /*
21  * [[character][attribute]][[character][attribute]]....
22  */
23 
24 /* TYPEDEFS ***************************************************************/
25 
26 typedef struct _DEVICE_EXTENSION
27 {
28  PUCHAR VideoMemory; /* Pointer to video memory */
31  PUCHAR ScreenBuffer; /* Pointer to screenbuffer */
37  UCHAR ScanLines; /* Height of a text line */
38  USHORT Rows; /* Number of rows */
39  USHORT Columns; /* Number of columns */
40  USHORT CursorX, CursorY; /* Cursor position */
41  PUCHAR FontBitfield; /* Specifies the font */
43 
44 typedef struct _VGA_REGISTERS
45 {
46  UCHAR CRT[24];
52 
54 {
55  /* CRT Controller Registers */
56  {0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00, 0x47, 0x1E, 0x00,
57  0x00, 0x00, 0x05, 0xF0, 0x9C, 0x8E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3},
58  /* Attribute Controller Registers */
59  {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
60  0x3C, 0x3D, 0x3E, 0x3F, 0x0C, 0x00, 0x0F, 0x08, 0x00},
61  /* Graphics Controller Registers */
62  {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00, 0xFF},
63  /* Sequencer Registers */
64  {0x03, 0x00, 0x03, 0x00, 0x02},
65  /* Misc Output Register */
66  0x67
67 };
68 
69 static const UCHAR DefaultPalette[] =
70 {
71  0, 0, 0,
72  0, 0, 0xC0,
73  0, 0xC0, 0,
74  0, 0xC0, 0xC0,
75  0xC0, 0, 0,
76  0xC0, 0, 0xC0,
77  0xC0, 0xC0, 0,
78  0xC0, 0xC0, 0xC0,
79  0x80, 0x80, 0x80,
80  0, 0, 0xFF,
81  0, 0xFF, 0,
82  0, 0xFF, 0xFF,
83  0xFF, 0, 0,
84  0xFF, 0, 0xFF,
85  0xFF, 0xFF, 0,
86  0xFF, 0xFF, 0xFF
87 };
88 
89 /* INBV MANAGEMENT FUNCTIONS **************************************************/
90 
91 static BOOLEAN
93  _In_ PDEVICE_EXTENSION DeviceExtension,
94  _In_ BOOLEAN FullReset,
96 
100 
101 /*
102  * Reinitialize the display to base VGA mode.
103  *
104  * Returns TRUE if it completely resets the adapter to the given character mode.
105  * Returns FALSE otherwise, indicating that the HAL should perform the VGA mode
106  * reset itself after HwVidResetHw() returns control.
107  *
108  * This callback has been registered with InbvNotifyDisplayOwnershipLost()
109  * and is called by InbvAcquireDisplayOwnership(), typically when the bugcheck
110  * code regains display access. Therefore this routine can be called at any
111  * IRQL, and in particular at IRQL = HIGH_LEVEL. This routine must also reside
112  * completely in non-paged pool, and cannot perform the following actions:
113  * Allocate memory, access pageable memory, use any synchronization mechanisms
114  * or call any routine that must execute at IRQL = DISPATCH_LEVEL or below.
115  */
116 static BOOLEAN
117 NTAPI
120  _In_ ULONG Rows,
121  _In_ BOOLEAN CalledByInbv)
122 {
123  PDEVICE_EXTENSION DeviceExtension;
124 
125  /* Bail out early if we don't have any resettable adapter */
127  return FALSE; // No adapter found: request HAL to perform a full reset.
128 
129  /*
130  * If we have been unexpectedly called via a callback from
131  * InbvAcquireDisplayOwnership(), start monitoring INBV.
132  */
133  if (CalledByInbv)
135 
136  DeviceExtension = ResetDisplayParametersDeviceExtension;
137  ASSERT(DeviceExtension);
138 
139  /* Disable the screen but don't reset all screen settings (OK at high IRQL) */
140  return ScrResetScreen(DeviceExtension, FALSE, FALSE);
141 }
142 
143 /* This callback is registered with InbvNotifyDisplayOwnershipLost() */
144 static BOOLEAN
145 NTAPI
148  _In_ ULONG Rows)
149 {
150  /* Call the extended function, specifying we were called by INBV */
152 }
153 
154 /*
155  * (Adapted for ReactOS/Win2k3 from an original comment
156  * by Gé van Geldorp, June 2003, r4937)
157  *
158  * DISPLAY OWNERSHIP
159  *
160  * So, who owns the physical display and is allowed to write to it?
161  *
162  * In NT 5.x (Win2k/Win2k3), upon boot INBV/BootVid owns the display, unless
163  * /NOGUIBOOT has been specified in the boot command line. Later in the boot
164  * sequence, WIN32K.SYS opens the DISPLAY device. This open call ends up in
165  * VIDEOPRT.SYS. This component takes ownership of the display by calling
166  * InbvNotifyDisplayOwnershipLost() -- effectively telling INBV to release
167  * ownership of the display it previously had. From that moment on, the display
168  * is owned by that component and can be switched to graphics mode. The display
169  * is not supposed to return to text mode, except in case of a bugcheck.
170  * The bugcheck code calls InbvAcquireDisplayOwnership() so as to make INBV
171  * re-take display ownership, and calls back the function previously registered
172  * by VIDEOPRT.SYS with InbvNotifyDisplayOwnershipLost(). After the bugcheck,
173  * execution is halted. So, under NT, the only possible sequence of display
174  * modes is text mode -> graphics mode -> text mode (the latter hopefully
175  * happening very infrequently).
176  *
177  * In ReactOS things are a little bit different. We want to have a functional
178  * interactive text mode. We should be able to switch back and forth from
179  * text mode to graphics mode when a GUI app is started and then finished.
180  * Also, when the system bugchecks in graphics mode we want to switch back to
181  * text mode and show the bugcheck information. Last but not least, when using
182  * KDBG in /DEBUGPORT=SCREEN mode, breaking into the debugger would trigger a
183  * switch to text mode, and the user would expect that by continuing execution
184  * a switch back to graphics mode is done.
185  */
186 static VOID
187 NTAPI
190 {
191  LARGE_INTEGER Delay;
192  USHORT i;
193 
195 
196  while (TRUE)
197  {
198  /*
199  * During one second, check the INBV status each 100 milliseconds,
200  * then revert to 1 second delay.
201  */
202  i = 10;
203  Delay.QuadPart = (LONGLONG)-100*1000*10; // 100 millisecond delay
204  while (!InbvMonitoring)
205  {
207 
208  if ((i > 0) && (--i == 0))
209  Delay.QuadPart = (LONGLONG)-1*1000*1000*10; // 1 second delay
210  }
211 
212  /*
213  * Loop while the display is owned by INBV. We cannot do anything else
214  * than polling since INBV does not offer a proper notification system.
215  *
216  * During one second, check the INBV status each 100 milliseconds,
217  * then revert to 1 second delay.
218  */
219  i = 10;
220  Delay.QuadPart = (LONGLONG)-100*1000*10; // 100 millisecond delay
221  while (InbvCheckDisplayOwnership())
222  {
224 
225  if ((i > 0) && (--i == 0))
226  Delay.QuadPart = (LONGLONG)-1*1000*1000*10; // 1 second delay
227  }
228 
229  /* Reset the monitoring */
231 
232  /*
233  * Somebody released INBV display ownership, usually by invoking
234  * InbvNotifyDisplayOwnershipLost(). However the caller of this
235  * function certainly specified a different callback than ours.
236  * As we are going to be the only owner of the active display,
237  * we need to re-register our own display reset callback.
238  */
240 
241  /* Re-enable the screen, keeping the original screen settings */
244  }
245 
246  // FIXME: See ScrInbvCleanup().
247  // PsTerminateSystemThread(STATUS_SUCCESS);
248 }
249 
250 static NTSTATUS
252 {
253  /* Create the INBV monitoring thread if needed */
254  if (!InbvThreadHandle)
255  {
258 
260  0,
262  NULL,
263  NULL,
265  NULL);
266  if (!NT_SUCCESS(Status))
268  }
269 
270  /* Re-register the display reset callback with INBV */
272 
273  return STATUS_SUCCESS;
274 }
275 
276 static NTSTATUS
278 {
279  // HANDLE ThreadHandle;
280 
281  // ResetDisplayParametersDeviceExtension = NULL;
283  {
286  // or InbvAcquireDisplayOwnership(); ?
287  }
288 
289 #if 0
290  // TODO: Find the best way to communicate the request.
291  /* Signal the INBV monitoring thread and wait for it to terminate */
293  if (ThreadHandle)
294  {
295  ZwWaitForSingleObject(ThreadHandle, Executive, KernelMode, FALSE, NULL);
296  /* Close its handle */
297  ObCloseHandle(ThreadHandle, KernelMode);
298  }
299 #endif
300 
301  return STATUS_SUCCESS;
302 }
303 
304 /* FUNCTIONS **************************************************************/
305 
306 static VOID
307 FASTCALL
309 {
310  UINT32 i;
311 
312  /* Update misc output register */
313  WRITE_PORT_UCHAR(MISC, Registers->Misc);
314 
315  /* Synchronous reset on */
316  WRITE_PORT_UCHAR(SEQ, 0x00);
317  WRITE_PORT_UCHAR(SEQDATA, 0x01);
318 
319  /* Write sequencer registers */
320  for (i = 1; i < sizeof(Registers->Sequencer); i++)
321  {
323  WRITE_PORT_UCHAR(SEQDATA, Registers->Sequencer[i]);
324  }
325 
326  /* Synchronous reset off */
327  WRITE_PORT_UCHAR(SEQ, 0x00);
328  WRITE_PORT_UCHAR(SEQDATA, 0x03);
329 
330  /* Deprotect CRT registers 0-7 */
331  WRITE_PORT_UCHAR(CRTC, 0x11);
332  WRITE_PORT_UCHAR(CRTCDATA, Registers->CRT[0x11] & 0x7f);
333 
334  /* Write CRT registers */
335  for (i = 0; i < sizeof(Registers->CRT); i++)
336  {
338  WRITE_PORT_UCHAR(CRTCDATA, Registers->CRT[i]);
339  }
340 
341  /* Write graphics controller registers */
342  for (i = 0; i < sizeof(Registers->Graphics); i++)
343  {
345  WRITE_PORT_UCHAR(GRAPHICSDATA, Registers->Graphics[i]);
346  }
347 
348  /* Write attribute controller registers */
349  for (i = 0; i < sizeof(Registers->Attribute); i++)
350  {
353  WRITE_PORT_UCHAR(ATTRIB, Registers->Attribute[i]);
354  }
355 
356  /* Set the PEL mask */
357  WRITE_PORT_UCHAR(PELMASK, 0xff);
358 }
359 
360 static VOID
361 FASTCALL
363  _In_ PDEVICE_EXTENSION DeviceExtension)
364 {
365  ULONG Offset;
366 
367  if (!DeviceExtension->VideoMemory)
368  return;
369 
370  Offset = (DeviceExtension->CursorY * DeviceExtension->Columns) + DeviceExtension->CursorX;
371 
372  _disable();
377  _enable();
378 }
379 
380 static VOID
381 FASTCALL
383  _In_ PDEVICE_EXTENSION DeviceExtension)
384 {
385  ULONG size, height;
386  UCHAR data, value;
387 
388  if (!DeviceExtension->VideoMemory)
389  return;
390 
391  height = DeviceExtension->ScanLines;
392  data = (DeviceExtension->CursorVisible) ? 0x00 : 0x20;
393 
394  size = (DeviceExtension->CursorSize * height) / 100;
395  if (size < 1)
396  size = 1;
397 
398  data |= (UCHAR)(height - size);
399 
400  _disable();
404  value = READ_PORT_UCHAR(CRTC_DATA) & 0xE0;
406  _enable();
407 }
408 
409 static VOID
410 FASTCALL
412  _In_ PDEVICE_EXTENSION DeviceExtension)
413 {
414  UCHAR data, value;
415  ULONG offset;
416  ULONG Index;
417 
418  _disable();
419 
421 
422  /* Disable screen and enable palette access */
424  WRITE_PORT_UCHAR(ATTRIB, 0x00);
425 
426  for (Index = 0; Index < sizeof(DefaultPalette) / 3; Index++)
427  {
432  }
433 
434  /* Enable screen and disable palette access */
436  WRITE_PORT_UCHAR(ATTRIB, 0x20);
437 
438  /* Switch blinking characters off */
443  data = data & ~0x08;
447 
448  /* Read screen information from CRT controller */
450  DeviceExtension->Columns = READ_PORT_UCHAR(CRTC_DATA) + 1;
452  DeviceExtension->Rows = READ_PORT_UCHAR(CRTC_DATA);
455  DeviceExtension->Rows |= (((data & 0x02) << 7) | ((data & 0x40) << 3));
456  DeviceExtension->Rows++;
458  DeviceExtension->ScanLines = (READ_PORT_UCHAR(CRTC_DATA) & 0x1F) + 1;
459 
460  /* Retrieve the current output cursor position */
464  offset += (READ_PORT_UCHAR(CRTC_DATA) << 8);
465 
466  /* Show blinking cursor */
467  // FIXME: cursor block? Call ScrSetCursorShape() instead?
469  WRITE_PORT_UCHAR(CRTC_DATA, (DeviceExtension->ScanLines - 1) & 0x1F);
471  data = READ_PORT_UCHAR(CRTC_DATA) & 0xE0;
473  data | ((DeviceExtension->ScanLines - 1) & 0x1F));
474 
475  _enable();
476 
477  /* Calculate number of text rows */
478  DeviceExtension->Rows = DeviceExtension->Rows / DeviceExtension->ScanLines;
479 
480  /* Set the cursor position, clipping it to the screen */
481  DeviceExtension->CursorX = (USHORT)(offset % DeviceExtension->Columns);
482  DeviceExtension->CursorY = (USHORT)(offset / DeviceExtension->Columns);
483  // DeviceExtension->CursorX = min(max(DeviceExtension->CursorX, 0), DeviceExtension->Columns - 1);
484  DeviceExtension->CursorY = min(max(DeviceExtension->CursorY, 0), DeviceExtension->Rows - 1);
485 
486  /* Set the font */
487  if (DeviceExtension->FontBitfield)
488  ScrSetFont(DeviceExtension->FontBitfield);
489 
490  DPRINT("%d Columns %d Rows %d Scanlines\n",
491  DeviceExtension->Columns,
492  DeviceExtension->Rows,
493  DeviceExtension->ScanLines);
494 }
495 
496 static BOOLEAN
498  _In_ PDEVICE_EXTENSION DeviceExtension,
499  _In_ BOOLEAN FullReset,
501 {
502 #define FOREGROUND_LIGHTGRAY (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED)
503 
505 
506  /* Allow resets to the same state only for full resets */
507  if (!FullReset && (Enable == DeviceExtension->Enabled))
508  return FALSE; // STATUS_INVALID_PARAMETER; STATUS_INVALID_DEVICE_REQUEST;
509 
510  if (FullReset)
511  {
512  DeviceExtension->CursorSize = 5; /* FIXME: value correct?? */
513  DeviceExtension->CursorVisible = TRUE;
514 
515  if (DeviceExtension->FontBitfield)
516  {
517  ExFreePoolWithTag(DeviceExtension->FontBitfield, TAG_BLUE);
518  DeviceExtension->FontBitfield = NULL;
519  }
520 
521  /* More initialization */
522  DeviceExtension->CharAttribute = BACKGROUND_BLUE | FOREGROUND_LIGHTGRAY;
523  DeviceExtension->Mode = ENABLE_PROCESSED_OUTPUT |
525  }
526 
527  if (Enable)
528  {
529  ScrAcquireOwnership(DeviceExtension);
530 
531  if (FullReset)
532  {
533  /*
534  * Fully reset the screen and all its settings.
535  */
536 
537  /* Unmap any previously mapped video memory */
538  if (DeviceExtension->VideoMemory)
539  {
540  ASSERT(DeviceExtension->VideoMemorySize != 0);
541  MmUnmapIoSpace(DeviceExtension->VideoMemory, DeviceExtension->VideoMemorySize);
542  }
543  DeviceExtension->VideoMemory = NULL;
544  DeviceExtension->VideoMemorySize = 0;
545 
546  /* Free any previously allocated backup screenbuffer */
547  if (DeviceExtension->ScreenBuffer)
548  {
549  ASSERT(DeviceExtension->ScreenBufferSize != 0);
550  ExFreePoolWithTag(DeviceExtension->ScreenBuffer, TAG_BLUE);
551  }
552  DeviceExtension->ScreenBuffer = NULL;
553  DeviceExtension->ScreenBufferSize = 0;
554 
555  /* Get a pointer to the video memory */
556  DeviceExtension->VideoMemorySize = DeviceExtension->Rows * DeviceExtension->Columns * 2;
557  if (DeviceExtension->VideoMemorySize == 0)
558  return FALSE; // STATUS_INVALID_VIEW_SIZE; STATUS_MAPPED_FILE_SIZE_ZERO;
559 
560  /* Map the video memory */
561  BaseAddress.QuadPart = VIDMEM_BASE;
562  DeviceExtension->VideoMemory =
563  (PUCHAR)MmMapIoSpace(BaseAddress, DeviceExtension->VideoMemorySize, MmNonCached);
564  if (!DeviceExtension->VideoMemory)
565  {
566  DeviceExtension->VideoMemorySize = 0;
567  return FALSE; // STATUS_NONE_MAPPED; STATUS_NOT_MAPPED_VIEW; STATUS_CONFLICTING_ADDRESSES;
568  }
569 
570  /* Initialize the backup screenbuffer in non-paged pool (must be accessible at high IRQL) */
571  DeviceExtension->ScreenBufferSize = DeviceExtension->VideoMemorySize;
572  DeviceExtension->ScreenBuffer =
573  (PUCHAR)ExAllocatePoolWithTag(NonPagedPool, DeviceExtension->ScreenBufferSize, TAG_BLUE);
574  if (!DeviceExtension->ScreenBuffer)
575  {
576  DPRINT1("Could not allocate screenbuffer, ignore...\n");
577  DeviceExtension->ScreenBufferSize = 0;
578  }
579 
580  /* (Re-)initialize INBV */
582  }
583  else
584  {
585  /*
586  * Restore the previously disabled screen.
587  */
588 
589  /* Restore the snapshot of the video memory from the backup screenbuffer */
590  if (DeviceExtension->ScreenBuffer)
591  {
592  ASSERT(DeviceExtension->VideoMemory);
593  ASSERT(DeviceExtension->ScreenBuffer);
594  ASSERT(DeviceExtension->ScreenBufferSize != 0);
595  ASSERT(DeviceExtension->VideoMemorySize == DeviceExtension->ScreenBufferSize);
596 
597  RtlCopyMemory(DeviceExtension->VideoMemory,
598  DeviceExtension->ScreenBuffer,
599  DeviceExtension->VideoMemorySize);
600  }
601 
602  /* Restore the cursor state */
603  ScrSetCursor(DeviceExtension);
604  ScrSetCursorShape(DeviceExtension);
605  }
606  DeviceExtension->Enabled = TRUE;
607  }
608  else
609  {
610  DeviceExtension->Enabled = FALSE;
611  if (FullReset)
612  {
613  /*
614  * Fully disable the screen and reset all its settings.
615  */
616 
617  /* Clean INBV up */
618  ScrInbvCleanup();
619 
620  /* Unmap any previously mapped video memory */
621  if (DeviceExtension->VideoMemory)
622  {
623  ASSERT(DeviceExtension->VideoMemorySize != 0);
624  MmUnmapIoSpace(DeviceExtension->VideoMemory, DeviceExtension->VideoMemorySize);
625  }
626  DeviceExtension->VideoMemory = NULL;
627  DeviceExtension->VideoMemorySize = 0;
628 
629  /* Free any previously allocated backup screenbuffer */
630  if (DeviceExtension->ScreenBuffer)
631  {
632  ASSERT(DeviceExtension->ScreenBufferSize != 0);
633  ExFreePoolWithTag(DeviceExtension->ScreenBuffer, TAG_BLUE);
634  }
635  DeviceExtension->ScreenBuffer = NULL;
636  DeviceExtension->ScreenBufferSize = 0;
637 
638  /* Store dummy values */
639  DeviceExtension->Columns = 1;
640  DeviceExtension->Rows = 1;
641  DeviceExtension->ScanLines = 1;
642  }
643  else
644  {
645  /*
646  * Partially disable the screen such that it can be restored later.
647  */
648 
649  /* Take a snapshot of the video memory into the backup screenbuffer */
650  if (DeviceExtension->ScreenBuffer)
651  {
652  ASSERT(DeviceExtension->VideoMemory);
653  ASSERT(DeviceExtension->ScreenBuffer);
654  ASSERT(DeviceExtension->ScreenBufferSize != 0);
655  ASSERT(DeviceExtension->VideoMemorySize == DeviceExtension->ScreenBufferSize);
656 
657  RtlCopyMemory(DeviceExtension->ScreenBuffer,
658  DeviceExtension->VideoMemory,
659  DeviceExtension->VideoMemorySize);
660  }
661  }
662  }
663 
664  return TRUE; // STATUS_SUCCESS;
665 }
666 
668 static NTSTATUS
669 NTAPI
672  _In_ PIRP Irp)
673 {
675 
677 
678  if (stk->MajorFunction == IRP_MJ_CREATE)
679  Irp->IoStatus.Information = FILE_OPENED;
680  // else: IRP_MJ_CLOSE
681 
682  Irp->IoStatus.Status = STATUS_SUCCESS;
684  return STATUS_SUCCESS;
685 }
686 
688 static NTSTATUS
689 NTAPI
692  _In_ PIRP Irp)
693 {
696  PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
697  PCHAR pch = Irp->UserBuffer;
698  PUCHAR vidmem;
699  ULONG i;
700  ULONG j, offset;
701  USHORT cursorx, cursory;
702  USHORT rows, columns;
703  BOOLEAN processed = !!(DeviceExtension->Mode & ENABLE_PROCESSED_OUTPUT);
704 
705  if (!DeviceExtension->Enabled || !DeviceExtension->VideoMemory)
706  {
707  /* Display is not enabled, we're not allowed to touch it */
709 
710  Irp->IoStatus.Status = Status;
712 
713  return Status;
714  }
715 
716  vidmem = DeviceExtension->VideoMemory;
717  rows = DeviceExtension->Rows;
718  columns = DeviceExtension->Columns;
719  cursorx = DeviceExtension->CursorX;
720  cursory = DeviceExtension->CursorY;
721 
722  if (!processed)
723  {
724  /* Raw output mode */
725 
726  /* Calculate the offset from the cursor position */
727  offset = cursorx + cursory * columns;
728 
729  // FIXME: Does the buffer only contains chars? or chars + attributes?
730  // FIXME2: Fix buffer overflow.
731  RtlCopyMemory(&vidmem[offset * 2], pch, stk->Parameters.Write.Length);
732  offset += (stk->Parameters.Write.Length / 2);
733 
734  /* Set the cursor position, clipping it to the screen */
735  cursorx = (USHORT)(offset % columns);
736  cursory = (USHORT)(offset / columns);
737  // cursorx = min(max(cursorx, 0), columns - 1);
738  cursory = min(max(cursory, 0), rows - 1);
739  }
740  else
741  {
742  /* Cooked output mode */
743  for (i = 0; i < stk->Parameters.Write.Length; i++, pch++)
744  {
745  switch (*pch)
746  {
747  case '\b':
748  {
749  if (cursorx > 0)
750  {
751  cursorx--;
752  }
753  else if (cursory > 0)
754  {
755  cursory--;
756  cursorx = columns - 1;
757  }
758  offset = cursorx + cursory * columns;
759  vidmem[offset * 2] = ' ';
760  vidmem[offset * 2 + 1] = (char)DeviceExtension->CharAttribute;
761  break;
762  }
763 
764  case '\n':
765  cursory++;
766  /* Fall back */
767  case '\r':
768  cursorx = 0;
769  break;
770 
771  case '\t':
772  {
773  offset = TAB_WIDTH - (cursorx % TAB_WIDTH);
774  while (offset--)
775  {
776  vidmem[(cursorx + cursory * columns) * 2] = ' ';
777  cursorx++;
778  if (cursorx >= columns)
779  {
780  cursorx = 0;
781  cursory++;
782  /* We jumped to the next line, stop there */
783  break;
784  }
785  }
786  break;
787  }
788 
789  default:
790  {
791  offset = cursorx + cursory * columns;
792  vidmem[offset * 2] = *pch;
793  vidmem[offset * 2 + 1] = (char)DeviceExtension->CharAttribute;
794  cursorx++;
795  if (cursorx >= columns)
796  {
797  cursorx = 0;
798  cursory++;
799  }
800  break;
801  }
802  }
803 
804  /* Scroll up the contents of the screen if we are at the end */
805  if (cursory >= rows)
806  {
808 
810  &vidmem[columns * 2],
811  columns * (rows - 1) * 2);
812 
813  LinePtr = (PUSHORT)&vidmem[columns * (rows - 1) * 2];
814 
815  for (j = 0; j < columns; j++)
816  {
817  LinePtr[j] = DeviceExtension->CharAttribute << 8;
818  }
819  cursory = rows - 1;
820  for (j = 0; j < columns; j++)
821  {
822  offset = j + cursory * columns;
823  vidmem[offset * 2] = ' ';
824  vidmem[offset * 2 + 1] = (char)DeviceExtension->CharAttribute;
825  }
826  }
827  }
828  }
829 
830  /* Set the cursor position */
831  ASSERT((0 <= cursorx) && (cursorx < DeviceExtension->Columns));
832  ASSERT((0 <= cursory) && (cursory < DeviceExtension->Rows));
833  DeviceExtension->CursorX = cursorx;
834  DeviceExtension->CursorY = cursory;
835  ScrSetCursor(DeviceExtension);
836 
838 
839  Irp->IoStatus.Status = Status;
841 
842  return Status;
843 }
844 
846 static NTSTATUS
847 NTAPI
850  _In_ PIRP Irp)
851 {
854  PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
855 
856  switch (stk->Parameters.DeviceIoControl.IoControlCode)
857  {
859  {
860  BOOLEAN Enable;
861 
862  /* Validate input buffer */
863  if (stk->Parameters.DeviceIoControl.InputBufferLength < sizeof(ULONG))
864  {
866  break;
867  }
868  ASSERT(Irp->AssociatedIrp.SystemBuffer);
869 
870  Enable = !!*(PULONG)Irp->AssociatedIrp.SystemBuffer;
871 
872  /* Fully enable or disable the screen */
873  Status = (ScrResetScreen(DeviceExtension, TRUE, Enable)
875  Irp->IoStatus.Information = 0;
876  break;
877  }
878 
880  {
882  USHORT rows = DeviceExtension->Rows;
883  USHORT columns = DeviceExtension->Columns;
884 
885  /* Validate output buffer */
886  if (stk->Parameters.DeviceIoControl.OutputBufferLength < sizeof(CONSOLE_SCREEN_BUFFER_INFO))
887  {
889  break;
890  }
891  ASSERT(Irp->AssociatedIrp.SystemBuffer);
892 
893  pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
895 
896  pcsbi->dwSize.X = columns;
897  pcsbi->dwSize.Y = rows;
898 
899  pcsbi->dwCursorPosition.X = DeviceExtension->CursorX;
900  pcsbi->dwCursorPosition.Y = DeviceExtension->CursorY;
901 
902  pcsbi->wAttributes = DeviceExtension->CharAttribute;
903 
904  pcsbi->srWindow.Left = 0;
905  pcsbi->srWindow.Right = columns - 1;
906  pcsbi->srWindow.Top = 0;
907  pcsbi->srWindow.Bottom = rows - 1;
908 
909  pcsbi->dwMaximumWindowSize.X = columns;
910  pcsbi->dwMaximumWindowSize.Y = rows;
911 
912  Irp->IoStatus.Information = sizeof(CONSOLE_SCREEN_BUFFER_INFO);
914  break;
915  }
916 
918  {
920 
921  /* Validate input buffer */
922  if (stk->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONSOLE_SCREEN_BUFFER_INFO))
923  {
925  break;
926  }
927  ASSERT(Irp->AssociatedIrp.SystemBuffer);
928 
929  pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
930 
931  if ( pcsbi->dwCursorPosition.X < 0 || pcsbi->dwCursorPosition.X >= DeviceExtension->Columns ||
932  pcsbi->dwCursorPosition.Y < 0 || pcsbi->dwCursorPosition.Y >= DeviceExtension->Rows )
933  {
934  Irp->IoStatus.Information = 0;
936  break;
937  }
938 
939  DeviceExtension->CharAttribute = pcsbi->wAttributes;
940 
941  /* Set the cursor position */
942  ASSERT((0 <= pcsbi->dwCursorPosition.X) && (pcsbi->dwCursorPosition.X < DeviceExtension->Columns));
943  ASSERT((0 <= pcsbi->dwCursorPosition.Y) && (pcsbi->dwCursorPosition.Y < DeviceExtension->Rows));
944  DeviceExtension->CursorX = pcsbi->dwCursorPosition.X;
945  DeviceExtension->CursorY = pcsbi->dwCursorPosition.Y;
946  if (DeviceExtension->Enabled)
947  ScrSetCursor(DeviceExtension);
948 
949  Irp->IoStatus.Information = 0;
951  break;
952  }
953 
955  {
957 
958  /* Validate output buffer */
959  if (stk->Parameters.DeviceIoControl.OutputBufferLength < sizeof(CONSOLE_CURSOR_INFO))
960  {
962  break;
963  }
964  ASSERT(Irp->AssociatedIrp.SystemBuffer);
965 
966  pcci = (PCONSOLE_CURSOR_INFO)Irp->AssociatedIrp.SystemBuffer;
967  RtlZeroMemory(pcci, sizeof(CONSOLE_CURSOR_INFO));
968 
969  pcci->dwSize = DeviceExtension->CursorSize;
970  pcci->bVisible = DeviceExtension->CursorVisible;
971 
972  Irp->IoStatus.Information = sizeof(CONSOLE_CURSOR_INFO);
974  break;
975  }
976 
978  {
980 
981  /* Validate input buffer */
982  if (stk->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONSOLE_CURSOR_INFO))
983  {
985  break;
986  }
987  ASSERT(Irp->AssociatedIrp.SystemBuffer);
988 
989  pcci = (PCONSOLE_CURSOR_INFO)Irp->AssociatedIrp.SystemBuffer;
990 
991  DeviceExtension->CursorSize = pcci->dwSize;
992  DeviceExtension->CursorVisible = pcci->bVisible;
993  if (DeviceExtension->Enabled)
994  ScrSetCursorShape(DeviceExtension);
995 
996  Irp->IoStatus.Information = 0;
998  break;
999  }
1000 
1002  {
1003  PCONSOLE_MODE pcm;
1004 
1005  /* Validate output buffer */
1006  if (stk->Parameters.DeviceIoControl.OutputBufferLength < sizeof(CONSOLE_MODE))
1007  {
1009  break;
1010  }
1011  ASSERT(Irp->AssociatedIrp.SystemBuffer);
1012 
1013  pcm = (PCONSOLE_MODE)Irp->AssociatedIrp.SystemBuffer;
1014  RtlZeroMemory(pcm, sizeof(CONSOLE_MODE));
1015 
1016  pcm->dwMode = DeviceExtension->Mode;
1017 
1018  Irp->IoStatus.Information = sizeof(CONSOLE_MODE);
1020  break;
1021  }
1022 
1024  {
1025  PCONSOLE_MODE pcm;
1026 
1027  /* Validate input buffer */
1028  if (stk->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONSOLE_MODE))
1029  {
1031  break;
1032  }
1033  ASSERT(Irp->AssociatedIrp.SystemBuffer);
1034 
1035  pcm = (PCONSOLE_MODE)Irp->AssociatedIrp.SystemBuffer;
1036  DeviceExtension->Mode = pcm->dwMode;
1037 
1038  Irp->IoStatus.Information = 0;
1040  break;
1041  }
1042 
1044  {
1045  POUTPUT_ATTRIBUTE Buf;
1046  PUCHAR vidmem;
1047  ULONG offset;
1048  ULONG dwCount;
1049  ULONG nMaxLength;
1050 
1051  /* Validate input and output buffers */
1052  if (stk->Parameters.DeviceIoControl.InputBufferLength < sizeof(OUTPUT_ATTRIBUTE) ||
1053  stk->Parameters.DeviceIoControl.OutputBufferLength < sizeof(OUTPUT_ATTRIBUTE))
1054  {
1056  break;
1057  }
1058  ASSERT(Irp->AssociatedIrp.SystemBuffer);
1059 
1060  Buf = (POUTPUT_ATTRIBUTE)Irp->AssociatedIrp.SystemBuffer;
1061  nMaxLength = Buf->nLength;
1062 
1063  Buf->dwTransfered = 0;
1064  Irp->IoStatus.Information = sizeof(OUTPUT_ATTRIBUTE);
1065 
1066  if ( Buf->dwCoord.X < 0 || Buf->dwCoord.X >= DeviceExtension->Columns ||
1067  Buf->dwCoord.Y < 0 || Buf->dwCoord.Y >= DeviceExtension->Rows ||
1068  nMaxLength == 0 )
1069  {
1071  break;
1072  }
1073 
1074  if (DeviceExtension->Enabled && DeviceExtension->VideoMemory)
1075  {
1076  vidmem = DeviceExtension->VideoMemory;
1077  offset = (Buf->dwCoord.X + Buf->dwCoord.Y * DeviceExtension->Columns) * 2 + 1;
1078 
1079  nMaxLength = min(nMaxLength,
1080  (DeviceExtension->Rows - Buf->dwCoord.Y)
1081  * DeviceExtension->Columns - Buf->dwCoord.X);
1082 
1083  for (dwCount = 0; dwCount < nMaxLength; dwCount++)
1084  {
1085  vidmem[offset + (dwCount * 2)] = (char)Buf->wAttribute;
1086  }
1087  Buf->dwTransfered = dwCount;
1088  }
1089 
1091  break;
1092  }
1093 
1095  {
1096  POUTPUT_ATTRIBUTE Buf;
1097  PUSHORT pAttr;
1098  PUCHAR vidmem;
1099  ULONG offset;
1100  ULONG dwCount;
1101  ULONG nMaxLength;
1102 
1103  /* Validate input buffer */
1104  if (stk->Parameters.DeviceIoControl.InputBufferLength < sizeof(OUTPUT_ATTRIBUTE))
1105  {
1107  break;
1108  }
1109  ASSERT(Irp->AssociatedIrp.SystemBuffer);
1110 
1111  Buf = (POUTPUT_ATTRIBUTE)Irp->AssociatedIrp.SystemBuffer;
1112  Irp->IoStatus.Information = 0;
1113 
1114  /* Validate output buffer */
1115  if (stk->Parameters.DeviceIoControl.OutputBufferLength == 0)
1116  {
1118  break;
1119  }
1120  ASSERT(Irp->MdlAddress);
1121  pAttr = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
1122  if (pAttr == NULL)
1123  {
1125  break;
1126  }
1127 
1128  if ( Buf->dwCoord.X < 0 || Buf->dwCoord.X >= DeviceExtension->Columns ||
1129  Buf->dwCoord.Y < 0 || Buf->dwCoord.Y >= DeviceExtension->Rows )
1130  {
1132  break;
1133  }
1134 
1135  nMaxLength = stk->Parameters.DeviceIoControl.OutputBufferLength;
1136  nMaxLength /= sizeof(USHORT);
1137 
1138  if (DeviceExtension->Enabled && DeviceExtension->VideoMemory)
1139  {
1140  vidmem = DeviceExtension->VideoMemory;
1141  offset = (Buf->dwCoord.X + Buf->dwCoord.Y * DeviceExtension->Columns) * 2 + 1;
1142 
1143  nMaxLength = min(nMaxLength,
1144  (DeviceExtension->Rows - Buf->dwCoord.Y)
1145  * DeviceExtension->Columns - Buf->dwCoord.X);
1146 
1147  for (dwCount = 0; dwCount < nMaxLength; dwCount++, pAttr++)
1148  {
1149  *((PCHAR)pAttr) = vidmem[offset + (dwCount * 2)];
1150  }
1151  Irp->IoStatus.Information = dwCount * sizeof(USHORT);
1152  }
1153 
1155  break;
1156  }
1157 
1159  {
1160  COORD dwCoord;
1161  PCOORD pCoord;
1162  PUSHORT pAttr;
1163  PUCHAR vidmem;
1164  ULONG offset;
1165  ULONG dwCount;
1166  ULONG nMaxLength;
1167 
1168  //
1169  // NOTE: For whatever reason no OUTPUT_ATTRIBUTE structure
1170  // is used for this IOCTL.
1171  //
1172 
1173  /* Validate output buffer */
1174  if (stk->Parameters.DeviceIoControl.OutputBufferLength < sizeof(COORD))
1175  {
1177  break;
1178  }
1179  ASSERT(Irp->MdlAddress);
1180  pCoord = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
1181  if (pCoord == NULL)
1182  {
1184  break;
1185  }
1186  /* Capture the input info data */
1187  dwCoord = *pCoord;
1188 
1189  nMaxLength = stk->Parameters.DeviceIoControl.OutputBufferLength - sizeof(COORD);
1190  nMaxLength /= sizeof(USHORT);
1191 
1192  Irp->IoStatus.Information = 0;
1193 
1194  if ( dwCoord.X < 0 || dwCoord.X >= DeviceExtension->Columns ||
1195  dwCoord.Y < 0 || dwCoord.Y >= DeviceExtension->Rows ||
1196  nMaxLength == 0 )
1197  {
1199  break;
1200  }
1201 
1202  pAttr = (PUSHORT)(pCoord + 1);
1203 
1204  if (DeviceExtension->Enabled && DeviceExtension->VideoMemory)
1205  {
1206  vidmem = DeviceExtension->VideoMemory;
1207  offset = (dwCoord.X + dwCoord.Y * DeviceExtension->Columns) * 2 + 1;
1208 
1209  nMaxLength = min(nMaxLength,
1210  (DeviceExtension->Rows - dwCoord.Y)
1211  * DeviceExtension->Columns - dwCoord.X);
1212 
1213  for (dwCount = 0; dwCount < nMaxLength; dwCount++, pAttr++)
1214  {
1215  vidmem[offset + (dwCount * 2)] = *((PCHAR)pAttr);
1216  }
1217  Irp->IoStatus.Information = dwCount * sizeof(USHORT);
1218  }
1219 
1221  break;
1222  }
1223 
1225  {
1226  /* Validate input buffer */
1227  if (stk->Parameters.DeviceIoControl.InputBufferLength < sizeof(USHORT))
1228  {
1230  break;
1231  }
1232  ASSERT(Irp->AssociatedIrp.SystemBuffer);
1233 
1234  DeviceExtension->CharAttribute = *(PUSHORT)Irp->AssociatedIrp.SystemBuffer;
1235 
1236  Irp->IoStatus.Information = 0;
1238  break;
1239  }
1240 
1242  {
1243  POUTPUT_CHARACTER Buf;
1244  PUCHAR vidmem;
1245  ULONG offset;
1246  ULONG dwCount;
1247  ULONG nMaxLength;
1248 
1249  /* Validate input and output buffers */
1250  if (stk->Parameters.DeviceIoControl.InputBufferLength < sizeof(OUTPUT_CHARACTER) ||
1251  stk->Parameters.DeviceIoControl.OutputBufferLength < sizeof(OUTPUT_CHARACTER))
1252  {
1254  break;
1255  }
1256  ASSERT(Irp->AssociatedIrp.SystemBuffer);
1257 
1258  Buf = (POUTPUT_CHARACTER)Irp->AssociatedIrp.SystemBuffer;
1259  nMaxLength = Buf->nLength;
1260 
1261  Buf->dwTransfered = 0;
1262  Irp->IoStatus.Information = sizeof(OUTPUT_CHARACTER);
1263 
1264  if ( Buf->dwCoord.X < 0 || Buf->dwCoord.X >= DeviceExtension->Columns ||
1265  Buf->dwCoord.Y < 0 || Buf->dwCoord.Y >= DeviceExtension->Rows ||
1266  nMaxLength == 0 )
1267  {
1269  break;
1270  }
1271 
1272  if (DeviceExtension->Enabled && DeviceExtension->VideoMemory)
1273  {
1274  vidmem = DeviceExtension->VideoMemory;
1275  offset = (Buf->dwCoord.X + Buf->dwCoord.Y * DeviceExtension->Columns) * 2;
1276 
1277  nMaxLength = min(nMaxLength,
1278  (DeviceExtension->Rows - Buf->dwCoord.Y)
1279  * DeviceExtension->Columns - Buf->dwCoord.X);
1280 
1281  for (dwCount = 0; dwCount < nMaxLength; dwCount++)
1282  {
1283  vidmem[offset + (dwCount * 2)] = (char)Buf->cCharacter;
1284  }
1285  Buf->dwTransfered = dwCount;
1286  }
1287 
1289  break;
1290  }
1291 
1293  {
1294  POUTPUT_CHARACTER Buf;
1295  PCHAR pChar;
1296  PUCHAR vidmem;
1297  ULONG offset;
1298  ULONG dwCount;
1299  ULONG nMaxLength;
1300 
1301  /* Validate input buffer */
1302  if (stk->Parameters.DeviceIoControl.InputBufferLength < sizeof(OUTPUT_CHARACTER))
1303  {
1305  break;
1306  }
1307  ASSERT(Irp->AssociatedIrp.SystemBuffer);
1308 
1309  Buf = (POUTPUT_CHARACTER)Irp->AssociatedIrp.SystemBuffer;
1310  Irp->IoStatus.Information = 0;
1311 
1312  /* Validate output buffer */
1313  if (stk->Parameters.DeviceIoControl.OutputBufferLength == 0)
1314  {
1316  break;
1317  }
1318  ASSERT(Irp->MdlAddress);
1319  pChar = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
1320  if (pChar == NULL)
1321  {
1323  break;
1324  }
1325 
1326  if ( Buf->dwCoord.X < 0 || Buf->dwCoord.X >= DeviceExtension->Columns ||
1327  Buf->dwCoord.Y < 0 || Buf->dwCoord.Y >= DeviceExtension->Rows )
1328  {
1330  break;
1331  }
1332 
1333  nMaxLength = stk->Parameters.DeviceIoControl.OutputBufferLength;
1334 
1335  if (DeviceExtension->Enabled && DeviceExtension->VideoMemory)
1336  {
1337  vidmem = DeviceExtension->VideoMemory;
1338  offset = (Buf->dwCoord.X + Buf->dwCoord.Y * DeviceExtension->Columns) * 2;
1339 
1340  nMaxLength = min(nMaxLength,
1341  (DeviceExtension->Rows - Buf->dwCoord.Y)
1342  * DeviceExtension->Columns - Buf->dwCoord.X);
1343 
1344  for (dwCount = 0; dwCount < nMaxLength; dwCount++, pChar++)
1345  {
1346  *pChar = vidmem[offset + (dwCount * 2)];
1347  }
1348  Irp->IoStatus.Information = dwCount * sizeof(CHAR);
1349  }
1350 
1352  break;
1353  }
1354 
1356  {
1357  COORD dwCoord;
1358  PCOORD pCoord;
1359  PCHAR pChar;
1360  PUCHAR vidmem;
1361  ULONG offset;
1362  ULONG dwCount;
1363  ULONG nMaxLength;
1364 
1365  //
1366  // NOTE: For whatever reason no OUTPUT_CHARACTER structure
1367  // is used for this IOCTL.
1368  //
1369 
1370  /* Validate output buffer */
1371  if (stk->Parameters.DeviceIoControl.OutputBufferLength < sizeof(COORD))
1372  {
1374  break;
1375  }
1376  ASSERT(Irp->MdlAddress);
1377  pCoord = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
1378  if (pCoord == NULL)
1379  {
1381  break;
1382  }
1383  /* Capture the input info data */
1384  dwCoord = *pCoord;
1385 
1386  nMaxLength = stk->Parameters.DeviceIoControl.OutputBufferLength - sizeof(COORD);
1387  Irp->IoStatus.Information = 0;
1388 
1389  if ( dwCoord.X < 0 || dwCoord.X >= DeviceExtension->Columns ||
1390  dwCoord.Y < 0 || dwCoord.Y >= DeviceExtension->Rows ||
1391  nMaxLength == 0 )
1392  {
1394  break;
1395  }
1396 
1397  pChar = (PCHAR)(pCoord + 1);
1398 
1399  if (DeviceExtension->Enabled && DeviceExtension->VideoMemory)
1400  {
1401  vidmem = DeviceExtension->VideoMemory;
1402  offset = (dwCoord.X + dwCoord.Y * DeviceExtension->Columns) * 2;
1403 
1404  nMaxLength = min(nMaxLength,
1405  (DeviceExtension->Rows - dwCoord.Y)
1406  * DeviceExtension->Columns - dwCoord.X);
1407 
1408  for (dwCount = 0; dwCount < nMaxLength; dwCount++, pChar++)
1409  {
1410  vidmem[offset + (dwCount * 2)] = *pChar;
1411  }
1412  Irp->IoStatus.Information = dwCount * sizeof(CHAR);
1413  }
1414 
1416  break;
1417  }
1418 
1419  case IOCTL_CONSOLE_DRAW:
1420  {
1421  CONSOLE_DRAW ConsoleDraw;
1422  PCONSOLE_DRAW pConsoleDraw;
1423  PUCHAR Src, Dest;
1424  UINT32 SrcDelta, DestDelta, i;
1425 
1426  /* Validate output buffer */
1427  if (stk->Parameters.DeviceIoControl.OutputBufferLength < sizeof(CONSOLE_DRAW))
1428  {
1430  break;
1431  }
1432  ASSERT(Irp->MdlAddress);
1433  pConsoleDraw = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
1434  if (pConsoleDraw == NULL)
1435  {
1437  break;
1438  }
1439  /* Capture the input info data */
1440  ConsoleDraw = *pConsoleDraw;
1441 
1442  /* Check whether we have the size for the header plus the data area */
1443  if ((stk->Parameters.DeviceIoControl.OutputBufferLength - sizeof(CONSOLE_DRAW)) / 2
1444  < ((ULONG)ConsoleDraw.SizeX * (ULONG)ConsoleDraw.SizeY))
1445  {
1447  break;
1448  }
1449 
1450  Irp->IoStatus.Information = 0;
1451 
1452  /* Set the cursor position, clipping it to the screen */
1453  DeviceExtension->CursorX = min(max(ConsoleDraw.CursorX, 0), DeviceExtension->Columns - 1);
1454  DeviceExtension->CursorY = min(max(ConsoleDraw.CursorY, 0), DeviceExtension->Rows - 1);
1455  if (DeviceExtension->Enabled)
1456  ScrSetCursor(DeviceExtension);
1457 
1458  // TODO: For the moment if the ConsoleDraw rectangle has borders
1459  // out of the screen-buffer we just bail out. Would it be better
1460  // to actually clip the rectangle within its borders instead?
1461  if ( ConsoleDraw.X < 0 || ConsoleDraw.X >= DeviceExtension->Columns ||
1462  ConsoleDraw.Y < 0 || ConsoleDraw.Y >= DeviceExtension->Rows )
1463  {
1465  break;
1466  }
1467  if ( ConsoleDraw.SizeX > DeviceExtension->Columns - ConsoleDraw.X ||
1468  ConsoleDraw.SizeY > DeviceExtension->Rows - ConsoleDraw.Y )
1469  {
1471  break;
1472  }
1473 
1474  if (DeviceExtension->Enabled && DeviceExtension->VideoMemory)
1475  {
1476  Src = (PUCHAR)(pConsoleDraw + 1);
1477  SrcDelta = ConsoleDraw.SizeX * 2;
1478  Dest = DeviceExtension->VideoMemory +
1479  (ConsoleDraw.X + ConsoleDraw.Y * DeviceExtension->Columns) * 2;
1480  DestDelta = DeviceExtension->Columns * 2;
1481  /* 2 == sizeof(CHAR) + sizeof(BYTE) */
1482 
1483  /* Copy each line */
1484  for (i = 0; i < ConsoleDraw.SizeY; i++)
1485  {
1486  RtlCopyMemory(Dest, Src, SrcDelta);
1487  Src += SrcDelta;
1488  Dest += DestDelta;
1489  }
1490  }
1491 
1493  break;
1494  }
1495 
1497  {
1498  //
1499  // FIXME: For the moment we support only a fixed 256-char 8-bit font.
1500  //
1501 
1502  /* Validate input buffer */
1503  if (stk->Parameters.DeviceIoControl.InputBufferLength < 256 * 8)
1504  {
1506  break;
1507  }
1508  ASSERT(Irp->AssociatedIrp.SystemBuffer);
1509 
1510  if (DeviceExtension->FontBitfield)
1511  ExFreePoolWithTag(DeviceExtension->FontBitfield, TAG_BLUE);
1512  DeviceExtension->FontBitfield = ExAllocatePoolWithTag(NonPagedPool, 256 * 8, TAG_BLUE);
1513  if (!DeviceExtension->FontBitfield)
1514  {
1516  break;
1517  }
1518  RtlCopyMemory(DeviceExtension->FontBitfield, Irp->AssociatedIrp.SystemBuffer, 256 * 8);
1519 
1520  /* Set the font if needed */
1521  if (DeviceExtension->Enabled && DeviceExtension->VideoMemory)
1522  ScrSetFont(DeviceExtension->FontBitfield);
1523 
1524  Irp->IoStatus.Information = 0;
1526  break;
1527  }
1528 
1529  default:
1531  }
1532 
1533  Irp->IoStatus.Status = Status;
1535 
1536  return Status;
1537 }
1538 
1540 static NTSTATUS
1541 NTAPI
1544  _In_ PIRP Irp)
1545 {
1547 
1549 
1550  DPRINT1("ScrDispatch(0x%p): stk->MajorFunction = %lu UNIMPLEMENTED\n",
1551  DeviceObject, stk->MajorFunction);
1552 
1553  Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
1555  return STATUS_NOT_IMPLEMENTED;
1556 }
1557 
1558 /*
1559  * Module entry point
1560  */
1561 NTSTATUS
1562 NTAPI
1566 {
1567  NTSTATUS Status;
1569  UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\BlueScreen");
1570  UNICODE_STRING SymlinkName = RTL_CONSTANT_STRING(L"\\??\\BlueScreen");
1571 
1572  DPRINT("Screen Driver 0.0.6\n");
1573 
1574  DriverObject->MajorFunction[IRP_MJ_CREATE] = ScrCreateClose;
1575  DriverObject->MajorFunction[IRP_MJ_CLOSE] = ScrCreateClose;
1576  DriverObject->MajorFunction[IRP_MJ_READ] = ScrDispatch;
1577  DriverObject->MajorFunction[IRP_MJ_WRITE] = ScrWrite;
1579 
1581  sizeof(DEVICE_EXTENSION),
1582  &DeviceName,
1585  TRUE,
1586  &DeviceObject);
1587  if (!NT_SUCCESS(Status))
1588  {
1589  return Status;
1590  }
1591 
1592  Status = IoCreateSymbolicLink(&SymlinkName, &DeviceName);
1593  if (NT_SUCCESS(Status))
1594  {
1595  /* By default disable the screen (but don't touch INBV: ResetDisplayParametersDeviceExtension is still NULL) */
1596  ScrResetScreen(DeviceObject->DeviceExtension, TRUE, FALSE);
1597  /* Now set ResetDisplayParametersDeviceExtension to enable synchronizing with INBV */
1600  }
1601  else
1602  {
1604  }
1605  return Status;
1606 }
1607 
1608 /* EOF */
#define CRTC_SCANLINES
Definition: blue.h:82
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
struct tagCONSOLE_CURSOR_INFO * PCONSOLE_CURSOR_INFO
#define CRTCDATA
Definition: blue.h:112
signed char * PCHAR
Definition: retypes.h:7
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define GRAPHICSDATA
Definition: blue.h:114
#define max(a, b)
Definition: svc.c:63
PBYTE vidmem
Definition: vgavideo.c:18
static VOID FASTCALL ScrSetCursorShape(_In_ PDEVICE_EXTENSION DeviceExtension)
Definition: blue.c:382
#define IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE
Definition: ntddblue.h:15
Definition: pdh_main.c:93
#define IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO
Definition: ntddblue.h:7
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT SizeX
Definition: ntddblue.h:53
#define FILE_DEVICE_SCREEN
Definition: winioctl.h:134
USHORT CursorX
Definition: blue.c:40
#define IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE
Definition: ntddblue.h:16
static VOID FASTCALL ScrSetCursor(_In_ PDEVICE_EXTENSION DeviceExtension)
Definition: blue.c:362
struct _DEVICE_EXTENSION DEVICE_EXTENSION
static const VGA_REGISTERS VidpMode3Regs
Definition: blue.c:53
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
UCHAR Sequencer[5]
Definition: blue.c:49
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct tagOUTPUT_CHARACTER OUTPUT_CHARACTER
PUCHAR FontBitfield
Definition: blue.c:41
unsigned char * PUCHAR
Definition: retypes.h:3
static BOOLEAN InbvMonitoring
Definition: blue.c:99
void __cdecl _enable(void)
Definition: intrin_arm.h:373
LONG NTSTATUS
Definition: precomp.h:26
struct tagCONSOLE_SCREEN_BUFFER_INFO CONSOLE_SCREEN_BUFFER_INFO
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
#define FILE_OPENED
Definition: nt_native.h:769
static DRIVER_DISPATCH ScrDispatch
Definition: blue.c:1539
PUCHAR ScreenBuffer
Definition: blue.c:31
ULONG CursorSize
Definition: blue.c:33
#define CRTC_CURSORPOSHI
Definition: blue.h:85
#define LOW_REALTIME_PRIORITY
struct tagCONSOLE_MODE * PCONSOLE_MODE
#define ATTRIB
Definition: blue.h:115
struct Line * LinePtr
Definition: ncftp.h:78
#define IOCTL_CONSOLE_SET_CURSOR_INFO
Definition: ntddblue.h:9
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
#define MISC
Definition: blue.h:108
VOID NTAPI InbvNotifyDisplayOwnershipLost(_In_ INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:403
static BOOLEAN ScrResetScreen(_In_ PDEVICE_EXTENSION DeviceExtension, _In_ BOOLEAN FullReset, _In_ BOOLEAN Enable)
Definition: blue.c:497
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
#define PELMASK
Definition: blue.h:117
#define FASTCALL
Definition: nt_native.h:50
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
int32_t INT
Definition: typedefs.h:58
#define pch(ap)
Definition: match.c:418
#define CRTC_ROWS
Definition: blue.h:81
#define IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER
Definition: ntddblue.h:18
PUCHAR VideoMemory
Definition: blue.c:28
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define ENABLE_WRAP_AT_EOL_OUTPUT
Definition: blue.h:54
static const UCHAR DefaultPalette[]
Definition: blue.c:69
return STATUS_NOT_IMPLEMENTED
#define L(x)
Definition: ntvdm.h:50
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
static DRIVER_DISPATCH ScrCreateClose
Definition: blue.c:667
#define CRTC_COLUMNS
Definition: blue.h:79
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
unsigned int UINT32
static DRIVER_DISPATCH ScrWrite
Definition: blue.c:687
#define CRTC_DATA
Definition: blue.h:77
#define VIDMEM_BASE
Definition: blue.h:73
NTSTATUS NTAPI KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Interval OPTIONAL)
Definition: wait.c:283
struct _VGA_REGISTERS * PVGA_REGISTERS
#define ATTRC_INPST1
Definition: blue.h:106
USHORT CursorY
Definition: blue.c:40
#define IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE
Definition: ntddblue.h:13
UCHAR Misc
Definition: blue.c:50
unsigned char BOOLEAN
unsigned char
Definition: typeof.h:29
_In_ ULONG Rows
Definition: haltypes.h:7
USHORT Rows
Definition: blue.c:38
#define _In_
Definition: ms_sal.h:308
#define IoCompleteRequest
Definition: irp.c:1240
#define IOCTL_CONSOLE_GET_CURSOR_INFO
Definition: ntddblue.h:8
UCHAR Graphics[9]
Definition: blue.c:48
#define IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE
Definition: ntddblue.h:14
static VOID FASTCALL ScrAcquireOwnership(_In_ PDEVICE_EXTENSION DeviceExtension)
Definition: blue.c:411
static BOOLEAN NTAPI ScrResetDisplayParametersEx(_In_ ULONG Columns, _In_ ULONG Rows, _In_ BOOLEAN CalledByInbv)
Definition: blue.c:118
#define ATTRC_WRITEREG
Definition: blue.h:104
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
struct _VGA_REGISTERS VGA_REGISTERS
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
Definition: glfuncs.h:250
#define PCHAR
Definition: match.c:90
SHORT Left
Definition: blue.h:32
ULONG X
Definition: bl.h:1339
#define SEQ
Definition: blue.h:109
Status
Definition: gdiplustypes.h:24
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:650
#define TAG_BLUE
Definition: blue.h:14
struct _COORD COORD
int64_t LONGLONG
Definition: typedefs.h:68
#define PELINDEX
Definition: blue.h:118
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
USHORT CursorX
Definition: ntddblue.h:55
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
GLsizeiptr size
Definition: glext.h:5919
SHORT Bottom
Definition: blue.h:35
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
GLintptr offset
Definition: glext.h:5920
_In_ WDFCOLLECTION _In_ ULONG Index
#define IOCTL_CONSOLE_GET_MODE
Definition: ntddblue.h:10
#define STATUS
Definition: blue.h:116
#define CRTC_CURSOREND
Definition: blue.h:84
SHORT Top
Definition: blue.h:33
UCHAR CRT[24]
Definition: blue.c:46
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Definition: ncftp.h:79
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IO_VIDEO_INCREMENT
Definition: iotypes.h:609
static NTSTATUS ScrInbvInitialize(VOID)
Definition: blue.c:251
unsigned char UCHAR
Definition: xmlstorage.h:181
static BOOLEAN NTAPI ScrResetDisplayParameters(_In_ ULONG Columns, _In_ ULONG Rows)
Definition: blue.c:146
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define CRTC_CURSORPOSLO
Definition: blue.h:86
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
UCHAR Attribute[21]
Definition: blue.c:47
USHORT CursorY
Definition: ntddblue.h:56
GLsizei const GLfloat * value
Definition: glext.h:6069
static DRIVER_DISPATCH ScrIoControl
Definition: blue.c:845
#define CRTC
Definition: blue.h:111
#define IOCTL_CONSOLE_RESET_SCREEN
Definition: ntddblue.h:4
DRIVER_DISPATCH(nfs41_FsdDispatch)
#define CRTC_OVERFLOW
Definition: blue.h:80
Definition: bl.h:1337
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
static VOID NTAPI InbvMonitorThread(_In_ PVOID Context)
Definition: blue.c:188
#define IOCTL_CONSOLE_DRAW
Definition: ntddblue.h:22
#define ENABLE_PROCESSED_OUTPUT
Definition: blue.h:53
SIZE_T VideoMemorySize
Definition: blue.c:29
#define SEQDATA
Definition: blue.h:110
static HANDLE InbvThreadHandle
Definition: blue.c:98
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
ULONG dwMode
Definition: ntddblue.h:30
#define FOREGROUND_LIGHTGRAY
USHORT CharAttribute
Definition: blue.c:35
SIZE_T ScreenBufferSize
Definition: blue.c:32
struct tagOUTPUT_CHARACTER * POUTPUT_CHARACTER
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
static NTSTATUS ScrInbvCleanup(VOID)
Definition: blue.c:277
static const COLUMN_LIST Columns[]
Definition: listview.c:19
USHORT SizeY
Definition: ntddblue.h:54
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
Definition: glfuncs.h:248
KPRIORITY NTAPI KeSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
Definition: thrdobj.c:1327
unsigned short USHORT
Definition: pedump.c:61
#define IOCTL_CONSOLE_SET_MODE
Definition: ntddblue.h:11
struct tagCONSOLE_MODE CONSOLE_MODE
#define TAB_WIDTH
Definition: text.h:125
BOOLEAN Enabled
Definition: blue.c:30
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
#define IOCTL_CONSOLE_READ_OUTPUT_CHARACTER
Definition: ntddblue.h:19
unsigned int * PULONG
Definition: retypes.h:1
#define min(a, b)
Definition: monoChain.cc:55
#define CRTC_COMMAND
Definition: blue.h:76
struct tagOUTPUT_ATTRIBUTE * POUTPUT_ATTRIBUTE
#define NULL
Definition: types.h:112
#define IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO
Definition: ntddblue.h:6
#define DPRINT1
Definition: precomp.h:8
#define IRP_MJ_READ
Definition: rdpdr.c:46
ULONG Mode
Definition: blue.c:36
#define IOCTL_CONSOLE_LOADFONT
Definition: ntddblue.h:24
#define GRAPHICS
Definition: blue.h:113
#define PELDATA
Definition: blue.h:119
struct _DEVICE_EXTENSION * PDEVICE_EXTENSION
static int processed(const type_t *type)
Definition: typegen.c:2254
void __cdecl _disable(void)
Definition: intrin_arm.h:365
#define BACKGROUND_BLUE
Definition: blue.h:65
VOID ScrSetFont(_In_ PUCHAR FontBitfield)
Definition: font.c:25
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
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)
Definition: device.c:1031
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
USHORT Columns
Definition: blue.c:39
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define STATUS_SUCCESS
Definition: shellext.h:65
#define IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER
Definition: ntddblue.h:20
#define DPRINT
Definition: sndvol32.h:71
SHORT Right
Definition: blue.h:34
BOOLEAN NTAPI InbvCheckDisplayOwnership(VOID)
Definition: inbv.c:315
#define KeGetCurrentThread
Definition: hal.h:55
struct tagCONSOLE_SCREEN_BUFFER_INFO * PCONSOLE_SCREEN_BUFFER_INFO
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
static VOID FASTCALL ScrSetRegisters(const VGA_REGISTERS *Registers)
Definition: blue.c:308
static PDEVICE_EXTENSION ResetDisplayParametersDeviceExtension
Definition: blue.c:97
ULONG Y
Definition: bl.h:1340
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
INT CursorVisible
Definition: blue.c:34
#define CHAR(Char)
struct tagCONSOLE_CURSOR_INFO CONSOLE_CURSOR_INFO
#define ATTRC_READREG
Definition: blue.h:105
struct tagOUTPUT_ATTRIBUTE OUTPUT_ATTRIBUTE
unsigned short * PUSHORT
Definition: retypes.h:2
#define CRTC_CURSORSTART
Definition: blue.h:83
LONGLONG QuadPart
Definition: typedefs.h:114
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
NTSTATUS NTAPI DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
Definition: blue.c:1563
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
UCHAR ScanLines
Definition: blue.c:37