ReactOS  0.4.13-dev-259-g5ca9c9c
text.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Console Driver DLL
4  * FILE: win32ss/user/winsrv/consrv/condrv/text.c
5  * PURPOSE: Console Output Functions for text-mode screen-buffers
6  * PROGRAMMERS: Jeffrey Morlan
7  * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8  */
9 
10 /* INCLUDES *******************************************************************/
11 
12 #include <consrv.h>
13 
14 #define NDEBUG
15 #include <debug.h>
16 
17 /* GLOBALS ********************************************************************/
18 
19 /*
20  * From MSDN:
21  * "The lpMultiByteStr and lpWideCharStr pointers must not be the same.
22  * If they are the same, the function fails, and GetLastError returns
23  * ERROR_INVALID_PARAMETER."
24  */
25 #define ConsoleOutputUnicodeToAnsiChar(Console, dChar, sWChar) \
26  ASSERT((ULONG_PTR)dChar != (ULONG_PTR)sWChar); \
27  WideCharToMultiByte((Console)->OutputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL)
28 
29 #define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar) \
30  ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \
31  MultiByteToWideChar((Console)->OutputCodePage, 0, (sChar), 1, (dWChar), 1)
32 
33 /* PRIVATE FUNCTIONS **********************************************************/
34 
37 {
38  // return This->Header.Type;
39  return TEXTMODE_BUFFER;
40 }
41 
43 {
45 };
46 
47 
48 /*static*/ VOID
50 
51 
56  IN SIZE_T Size);
57 VOID
59 
60 
65  IN PTEXTMODE_BUFFER_INFO TextModeInfo)
66 {
68  PTEXTMODE_SCREEN_BUFFER NewBuffer = NULL;
69 
71 
72  if (Console == NULL || Buffer == NULL || TextModeInfo == NULL)
74 
75  *Buffer = NULL;
76 
78  Console,
79  &TextVtbl,
80  sizeof(TEXTMODE_SCREEN_BUFFER));
81  if (!NT_SUCCESS(Status)) return Status;
82  NewBuffer->Header.Type = TEXTMODE_BUFFER;
83 
84  NewBuffer->Buffer = ConsoleAllocHeap(HEAP_ZERO_MEMORY,
85  TextModeInfo->ScreenBufferSize.X *
86  TextModeInfo->ScreenBufferSize.Y *
87  sizeof(CHAR_INFO));
88  if (NewBuffer->Buffer == NULL)
89  {
92  }
93 
94  NewBuffer->ScreenBufferSize = NewBuffer->OldScreenBufferSize
95  = TextModeInfo->ScreenBufferSize;
96  NewBuffer->ViewSize = NewBuffer->OldViewSize
97  = Console->ConsoleSize;
98 
99  NewBuffer->ViewOrigin.X = NewBuffer->ViewOrigin.Y = 0;
100  NewBuffer->VirtualY = 0;
101 
102  NewBuffer->CursorBlinkOn = NewBuffer->ForceCursorOff = FALSE;
103  NewBuffer->CursorInfo.bVisible = (TextModeInfo->IsCursorVisible && (TextModeInfo->CursorSize != 0));
104  NewBuffer->CursorInfo.dwSize = min(max(TextModeInfo->CursorSize, 0), 100);
105 
106  NewBuffer->ScreenDefaultAttrib = TextModeInfo->ScreenAttrib;
107  NewBuffer->PopupDefaultAttrib = TextModeInfo->PopupAttrib;
108 
109  /* Initialize buffer to be empty with default attributes */
110  for (NewBuffer->CursorPosition.Y = 0 ; NewBuffer->CursorPosition.Y < NewBuffer->ScreenBufferSize.Y; NewBuffer->CursorPosition.Y++)
111  {
112  ClearLineBuffer(NewBuffer);
113  }
114  NewBuffer->CursorPosition.X = NewBuffer->CursorPosition.Y = 0;
115 
117 
118  *Buffer = (PCONSOLE_SCREEN_BUFFER)NewBuffer;
119  return STATUS_SUCCESS;
120 }
121 
122 VOID
124 {
126 
127  /*
128  * IMPORTANT !! Reinitialize the type so that we don't enter a recursive
129  * infinite loop when calling CONSOLE_SCREEN_BUFFER_Destroy.
130  */
131  Buffer->Header.Type = SCREEN_BUFFER;
132 
133  ConsoleFreeHeap(Buff->Buffer);
134 
136 }
137 
138 
141 {
142  return &Buff->Buffer[((Y + Buff->VirtualY) % Buff->ScreenBufferSize.Y) * Buff->ScreenBufferSize.X + X];
143 }
144 
145 /*static*/ VOID
147 {
148  PCHAR_INFO Ptr = ConioCoordToPointer(Buff, 0, Buff->CursorPosition.Y);
149  SHORT Pos;
150 
151  for (Pos = 0; Pos < Buff->ScreenBufferSize.X; Pos++, Ptr++)
152  {
153  /* Fill the cell */
154  Ptr->Char.UnicodeChar = L' ';
155  Ptr->Attributes = Buff->ScreenDefaultAttrib;
156  }
157 }
158 
159 static VOID
162  IN PCOORD Start,
163  IN UINT Length)
164 {
165  if ((UINT)Buff->ScreenBufferSize.X <= Start->X + Length)
166  {
167  UpdateRect->Left = 0;
168  UpdateRect->Right = Buff->ScreenBufferSize.X - 1;
169  }
170  else
171  {
172  UpdateRect->Left = Start->X;
173  UpdateRect->Right = Start->X + Length - 1;
174  }
175  UpdateRect->Top = Start->Y;
176  UpdateRect->Bottom = Start->Y + (Start->X + Length - 1) / Buff->ScreenBufferSize.X;
177  if (Buff->ScreenBufferSize.Y <= UpdateRect->Bottom)
178  {
179  UpdateRect->Bottom = Buff->ScreenBufferSize.Y - 1;
180  }
181 }
182 
183 /*
184  * Move from one rectangle to another. We must be careful about the order that
185  * this is done, to avoid overwriting parts of the source before they are moved.
186  */
187 static VOID
189  PSMALL_RECT SrcRegion,
190  PSMALL_RECT DstRegion,
191  PSMALL_RECT ClipRegion,
192  CHAR_INFO FillChar)
193 {
194  int Width = ConioRectWidth(SrcRegion);
195  int Height = ConioRectHeight(SrcRegion);
196  int SX, SY;
197  int DX, DY;
198  int XDelta, YDelta;
199  int i, j;
200 
201  SY = SrcRegion->Top;
202  DY = DstRegion->Top;
203  YDelta = 1;
204  if (SY < DY)
205  {
206  /* Moving down: work from bottom up */
207  SY = SrcRegion->Bottom;
208  DY = DstRegion->Bottom;
209  YDelta = -1;
210  }
211  for (i = 0; i < Height; i++)
212  {
215 
216  SX = SrcRegion->Left;
217  DX = DstRegion->Left;
218  XDelta = 1;
219  if (SX < DX)
220  {
221  /* Moving right: work from right to left */
222  SX = SrcRegion->Right;
223  DX = DstRegion->Right;
224  XDelta = -1;
225  }
226  for (j = 0; j < Width; j++)
227  {
228  CHAR_INFO Cell = SRow[SX];
229  if (SX >= ClipRegion->Left && SX <= ClipRegion->Right &&
230  SY >= ClipRegion->Top && SY <= ClipRegion->Bottom)
231  {
232  SRow[SX] = FillChar;
233  }
234  if (DX >= ClipRegion->Left && DX <= ClipRegion->Right &&
235  DY >= ClipRegion->Top && DY <= ClipRegion->Bottom)
236  {
237  DRow[DX] = Cell;
238  }
239  SX += XDelta;
240  DX += XDelta;
241  }
242  SY += YDelta;
243  DY += YDelta;
244  }
245 }
246 
247 // FIXME!
251  IN BOOLEAN AppendToEnd,
252  IN PINPUT_RECORD InputRecord,
253  IN ULONG NumEventsToWrite,
254  OUT PULONG NumEventsWritten OPTIONAL);
255 
256 NTSTATUS
259  COORD Size)
260 {
262  DWORD Offset = 0;
263  PCHAR_INFO ptr;
264  WORD CurrentAttribute;
265  USHORT CurrentY;
266  PCHAR_INFO OldBuffer;
267  DWORD i;
268  DWORD diff;
269 
270  /* Buffer size is not allowed to be smaller than the view size */
271  if (Size.X < ScreenBuffer->ViewSize.X || Size.Y < ScreenBuffer->ViewSize.Y)
273 
274  if (Size.X == ScreenBuffer->ScreenBufferSize.X && Size.Y == ScreenBuffer->ScreenBufferSize.Y)
275  {
276  // FIXME: Trigger a buffer resize event ??
277  return STATUS_SUCCESS;
278  }
279 
280  if (Console->FixedSize)
281  {
282  /*
283  * The console is in fixed-size mode, so we cannot resize anything
284  * at the moment. However, keep those settings somewhere so that
285  * we can try to set them up when we will be allowed to do so.
286  */
287  ScreenBuffer->OldScreenBufferSize = Size;
288  return STATUS_NOT_SUPPORTED; // STATUS_SUCCESS
289  }
290 
292  if (!Buffer) return STATUS_NO_MEMORY;
293 
294  DPRINT("Resizing (%d,%d) to (%d,%d)\n", ScreenBuffer->ScreenBufferSize.X, ScreenBuffer->ScreenBufferSize.Y, Size.X, Size.Y);
295  OldBuffer = ScreenBuffer->Buffer;
296 
297  for (CurrentY = 0; CurrentY < ScreenBuffer->ScreenBufferSize.Y && CurrentY < Size.Y; CurrentY++)
298  {
299  ptr = ConioCoordToPointer(ScreenBuffer, 0, CurrentY);
300  if (Size.X <= ScreenBuffer->ScreenBufferSize.X)
301  {
302  /* Reduce size */
303  RtlCopyMemory(Buffer + Offset, ptr, Size.X * sizeof(CHAR_INFO));
304  Offset += Size.X;
305  }
306  else
307  {
308  /* Enlarge size */
309  RtlCopyMemory(Buffer + Offset, ptr, ScreenBuffer->ScreenBufferSize.X * sizeof(CHAR_INFO));
310  Offset += ScreenBuffer->ScreenBufferSize.X;
311 
312  /* The attribute to be used is the one of the last cell of the current line */
313  CurrentAttribute = ConioCoordToPointer(ScreenBuffer,
314  ScreenBuffer->ScreenBufferSize.X - 1,
315  CurrentY)->Attributes;
316 
317  diff = Size.X - ScreenBuffer->ScreenBufferSize.X;
318 
319  /* Zero-out the new part of the buffer */
320  for (i = 0; i < diff; i++)
321  {
322  ptr = Buffer + Offset;
323  ptr->Char.UnicodeChar = L' ';
324  ptr->Attributes = CurrentAttribute;
325  ++Offset;
326  }
327  }
328  }
329 
330  if (Size.Y > ScreenBuffer->ScreenBufferSize.Y)
331  {
332  diff = Size.X * (Size.Y - ScreenBuffer->ScreenBufferSize.Y);
333 
334  /* Zero-out the new part of the buffer */
335  for (i = 0; i < diff; i++)
336  {
337  ptr = Buffer + Offset;
338  ptr->Char.UnicodeChar = L' ';
339  ptr->Attributes = ScreenBuffer->ScreenDefaultAttrib;
340  ++Offset;
341  }
342  }
343 
345  ConsoleFreeHeap(OldBuffer);
346  ScreenBuffer->ScreenBufferSize = ScreenBuffer->OldScreenBufferSize = Size;
347  ScreenBuffer->VirtualY = 0;
348 
349  /* Ensure cursor and window are within buffer */
350  if (ScreenBuffer->CursorPosition.X >= Size.X)
351  ScreenBuffer->CursorPosition.X = Size.X - 1;
352  if (ScreenBuffer->CursorPosition.Y >= Size.Y)
353  ScreenBuffer->CursorPosition.Y = Size.Y - 1;
354  if (ScreenBuffer->ViewOrigin.X > Size.X - ScreenBuffer->ViewSize.X)
355  ScreenBuffer->ViewOrigin.X = Size.X - ScreenBuffer->ViewSize.X;
356  if (ScreenBuffer->ViewOrigin.Y > Size.Y - ScreenBuffer->ViewSize.Y)
357  ScreenBuffer->ViewOrigin.Y = Size.Y - ScreenBuffer->ViewSize.Y;
358 
359  /*
360  * Trigger a buffer resize event
361  */
362  if (Console->InputBuffer.Mode & ENABLE_WINDOW_INPUT)
363  {
364  ULONG NumEventsWritten;
365  INPUT_RECORD er;
366 
368  er.Event.WindowBufferSizeEvent.dwSize = ScreenBuffer->ScreenBufferSize;
369 
370  // ConioProcessInputEvent(Console, &er);
372  &Console->InputBuffer,
373  TRUE,
374  &er,
375  1,
376  &NumEventsWritten);
377  }
378 
379  return STATUS_SUCCESS;
380 }
381 
385  IN USHORT NewScreenAttrib,
386  IN USHORT NewPopupAttrib)
387 {
388  ULONG X, Y, Length;
389  PCHAR_INFO Ptr;
390 
391  COORD TopLeft = {0};
392  ULONG NumCodesToWrite;
393  USHORT OldScreenAttrib, OldPopupAttrib;
394 
395  if (Console == NULL || Buffer == NULL)
396  {
398  }
399 
400  /* Validity check */
401  ASSERT(Console == Buffer->Header.Console);
402 
403  NumCodesToWrite = Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y;
404  OldScreenAttrib = Buffer->ScreenDefaultAttrib;
405  OldPopupAttrib = Buffer->PopupDefaultAttrib;
406 
407  X = TopLeft.X;
408  Y = (TopLeft.Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
409  Length = NumCodesToWrite;
410 
411  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work
412  // Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X]; // May work
413 
414  while (Length--)
415  {
416  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work either
417  Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X];
418 
419  /*
420  * Change the current colors only if they are the old ones.
421  */
422 
423  /* Foreground color */
424  if ((Ptr->Attributes & 0x0F) == (OldScreenAttrib & 0x0F))
425  Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewScreenAttrib & 0x0F);
426  if ((Ptr->Attributes & 0x0F) == (OldPopupAttrib & 0x0F))
427  Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewPopupAttrib & 0x0F);
428 
429  /* Background color */
430  if ((Ptr->Attributes & 0xF0) == (OldScreenAttrib & 0xF0))
431  Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewScreenAttrib & 0xF0);
432  if ((Ptr->Attributes & 0xF0) == (OldPopupAttrib & 0xF0))
433  Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewPopupAttrib & 0xF0);
434 
435  // ++Ptr;
436 
437  if (++X == Buffer->ScreenBufferSize.X)
438  {
439  X = 0;
440 
441  if (++Y == Buffer->ScreenBufferSize.Y)
442  {
443  Y = 0;
444  }
445  }
446  }
447 
448  /* Save foreground and background colors for both screen and popup */
449  Buffer->ScreenDefaultAttrib = (NewScreenAttrib & 0x00FF);
450  Buffer->PopupDefaultAttrib = (NewPopupAttrib & 0x00FF);
451 
452  /* Refresh the display if needed */
453  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
454  {
456  ConioComputeUpdateRect(Buffer, &UpdateRect, &TopLeft, NumCodesToWrite);
458  }
459 
460  return STATUS_SUCCESS;
461 }
462 
463 
464 /* PUBLIC DRIVER APIS *********************************************************/
465 
469  IN BOOLEAN Unicode,
470  OUT PCHAR_INFO CharInfo/*Buffer*/,
471  IN OUT PSMALL_RECT ReadRegion)
472 {
473  SHORT X, Y;
475  PCHAR_INFO CurCharInfo;
476  SMALL_RECT CapturedReadRegion;
477  PCHAR_INFO Ptr;
478 
479  if (Console == NULL || Buffer == NULL || CharInfo == NULL || ReadRegion == NULL)
480  {
482  }
483 
484  /* Validity check */
485  ASSERT(Console == Buffer->Header.Console);
486 
487  CapturedReadRegion = *ReadRegion;
488 
489  /* Make sure ReadRegion is inside the screen buffer */
491  Buffer->ScreenBufferSize.Y - 1,
492  Buffer->ScreenBufferSize.X - 1);
493  if (!ConioGetIntersection(&CapturedReadRegion, &ScreenBuffer, &CapturedReadRegion))
494  {
495  /*
496  * It is okay to have a ReadRegion completely outside
497  * the screen buffer. No data is read then.
498  */
499  return STATUS_SUCCESS;
500  }
501 
502  CurCharInfo = CharInfo;
503 
504  for (Y = CapturedReadRegion.Top; Y <= CapturedReadRegion.Bottom; ++Y)
505  {
506  Ptr = ConioCoordToPointer(Buffer, CapturedReadRegion.Left, Y);
507  for (X = CapturedReadRegion.Left; X <= CapturedReadRegion.Right; ++X)
508  {
509  if (Unicode)
510  {
511  CurCharInfo->Char.UnicodeChar = Ptr->Char.UnicodeChar;
512  }
513  else
514  {
515  // ConsoleOutputUnicodeToAnsiChar(Console, &CurCharInfo->Char.AsciiChar, &Ptr->Char.UnicodeChar);
516  WideCharToMultiByte(Console->OutputCodePage, 0, &Ptr->Char.UnicodeChar, 1,
517  &CurCharInfo->Char.AsciiChar, 1, NULL, NULL);
518  }
519  CurCharInfo->Attributes = Ptr->Attributes;
520  ++Ptr;
521  ++CurCharInfo;
522  }
523  }
524 
525  *ReadRegion = CapturedReadRegion;
526 
527  return STATUS_SUCCESS;
528 }
529 
533  IN BOOLEAN Unicode,
534  IN PCHAR_INFO CharInfo/*Buffer*/,
535  IN OUT PSMALL_RECT WriteRegion)
536 {
537  SHORT X, Y;
539  PCHAR_INFO CurCharInfo;
540  SMALL_RECT CapturedWriteRegion;
541  PCHAR_INFO Ptr;
542 
543  if (Console == NULL || Buffer == NULL || CharInfo == NULL || WriteRegion == NULL)
544  {
546  }
547 
548  /* Validity check */
549  ASSERT(Console == Buffer->Header.Console);
550 
551  CapturedWriteRegion = *WriteRegion;
552 
553  /* Make sure WriteRegion is inside the screen buffer */
555  Buffer->ScreenBufferSize.Y - 1,
556  Buffer->ScreenBufferSize.X - 1);
557  if (!ConioGetIntersection(&CapturedWriteRegion, &ScreenBuffer, &CapturedWriteRegion))
558  {
559  /*
560  * It is okay to have a WriteRegion completely outside
561  * the screen buffer. No data is written then.
562  */
563  return STATUS_SUCCESS;
564  }
565 
566  CurCharInfo = CharInfo;
567 
568  for (Y = CapturedWriteRegion.Top; Y <= CapturedWriteRegion.Bottom; ++Y)
569  {
570  Ptr = ConioCoordToPointer(Buffer, CapturedWriteRegion.Left, Y);
571  for (X = CapturedWriteRegion.Left; X <= CapturedWriteRegion.Right; ++X)
572  {
573  if (Unicode)
574  {
575  Ptr->Char.UnicodeChar = CurCharInfo->Char.UnicodeChar;
576  }
577  else
578  {
579  ConsoleOutputAnsiToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char.AsciiChar);
580  }
581  Ptr->Attributes = CurCharInfo->Attributes;
582  ++Ptr;
583  ++CurCharInfo;
584  }
585  }
586 
587  TermDrawRegion(Console, &CapturedWriteRegion);
588 
589  *WriteRegion = CapturedWriteRegion;
590 
591  return STATUS_SUCCESS;
592 }
593 
594 /*
595  * NOTE: This function is strongly inspired by ConDrvWriteConsoleOutput...
596  * FIXME: This function MUST be moved into consrv/conoutput.c because only
597  * consrv knows how to manipulate VDM screenbuffers.
598  */
602  IN PCHAR_CELL CharInfo/*Buffer*/,
603  IN COORD CharInfoSize,
604  IN PSMALL_RECT WriteRegion)
605 {
606  SHORT X, Y;
608  PCHAR_CELL CurCharInfo;
609  SMALL_RECT CapturedWriteRegion;
610  PCHAR_INFO Ptr;
611 
612  if (Console == NULL || Buffer == NULL || CharInfo == NULL || WriteRegion == NULL)
613  {
615  }
616 
617  /* Validity check */
618  ASSERT(Console == Buffer->Header.Console);
619 
620  CapturedWriteRegion = *WriteRegion;
621 
622  /* Make sure WriteRegion is inside the screen buffer */
624  Buffer->ScreenBufferSize.Y - 1,
625  Buffer->ScreenBufferSize.X - 1);
626  if (!ConioGetIntersection(&CapturedWriteRegion, &ScreenBuffer, &CapturedWriteRegion))
627  {
628  /*
629  * It is okay to have a WriteRegion completely outside
630  * the screen buffer. No data is written then.
631  */
632  return STATUS_SUCCESS;
633  }
634 
635  // CurCharInfo = CharInfo;
636 
637  for (Y = CapturedWriteRegion.Top; Y <= CapturedWriteRegion.Bottom; ++Y)
638  {
639  CurCharInfo = CharInfo + Y * CharInfoSize.X + CapturedWriteRegion.Left;
640 
641  Ptr = ConioCoordToPointer(Buffer, CapturedWriteRegion.Left, Y);
642  for (X = CapturedWriteRegion.Left; X <= CapturedWriteRegion.Right; ++X)
643  {
644  ConsoleOutputAnsiToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char);
645  Ptr->Attributes = CurCharInfo->Attributes;
646  ++Ptr;
647  ++CurCharInfo;
648  }
649  }
650 
651  return STATUS_SUCCESS;
652 }
653 
657  IN BOOLEAN Unicode,
659  IN ULONG NumCharsToWrite,
660  OUT PULONG NumCharsWritten OPTIONAL)
661 {
663  PWCHAR Buffer = NULL;
664  ULONG Written = 0;
665  ULONG Length;
666 
667  if (Console == NULL || ScreenBuffer == NULL /* || StringBuffer == NULL */)
669 
670  /* Validity checks */
671  ASSERT(Console == ScreenBuffer->Header.Console);
672  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCharsToWrite == 0));
673 
674  /* Stop here if the console is paused */
675  if (Console->UnpauseEvent != NULL) return STATUS_PENDING;
676 
677  /* Convert the string to UNICODE */
678  if (Unicode)
679  {
681  }
682  else
683  {
684  Length = MultiByteToWideChar(Console->OutputCodePage, 0,
686  NumCharsToWrite,
687  NULL, 0);
688  Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length * sizeof(WCHAR));
689  if (Buffer)
690  {
691  MultiByteToWideChar(Console->OutputCodePage, 0,
693  NumCharsToWrite,
694  (PWCHAR)Buffer, Length);
695  }
696  else
697  {
699  }
700  }
701 
702  /* Send it */
703  if (Buffer)
704  {
705  if (NT_SUCCESS(Status))
706  {
708  ScreenBuffer,
709  Buffer,
710  NumCharsToWrite,
711  TRUE);
712  if (NT_SUCCESS(Status))
713  {
714  Written = NumCharsToWrite;
715  }
716  }
717 
718  if (!Unicode) RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
719  }
720 
721  if (NumCharsWritten) *NumCharsWritten = Written;
722 
723  return Status;
724 }
725 
729  IN CODE_TYPE CodeType,
731  IN ULONG NumCodesToRead,
732  IN PCOORD ReadCoord,
733  // OUT PCOORD EndCoord,
734  OUT PULONG NumCodesRead OPTIONAL)
735 {
736  SHORT Xpos, Ypos;
738  ULONG i;
739  ULONG CodeSize;
740  PCHAR_INFO Ptr;
741 
742  if (Console == NULL || Buffer == NULL || ReadCoord == NULL /* || EndCoord == NULL */)
743  {
745  }
746 
747  /* Validity checks */
748  ASSERT(Console == Buffer->Header.Console);
749  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCodesToRead == 0));
750 
751  //
752  // FIXME: Make overflow checks on ReadCoord !!!!!!
753  //
754 
755  if (NumCodesRead) *NumCodesRead = 0;
756 
757  switch (CodeType)
758  {
759  case CODE_ASCII:
760  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
761  break;
762 
763  case CODE_UNICODE:
764  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
765  break;
766 
767  case CODE_ATTRIBUTE:
768  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
769  break;
770 
771  default:
773  }
774 
776  Xpos = ReadCoord->X;
777  Ypos = (ReadCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
778 
779  /*
780  * MSDN (ReadConsoleOutputAttribute and ReadConsoleOutputCharacter) :
781  *
782  * If the number of attributes (resp. characters) to be read from extends
783  * beyond the end of the specified screen buffer row, attributes (resp.
784  * characters) are read from the next row. If the number of attributes
785  * (resp. characters) to be read from extends beyond the end of the console
786  * screen buffer, attributes (resp. characters) up to the end of the console
787  * screen buffer are read.
788  *
789  * TODO: Do NOT loop up to NumCodesToRead, but stop before
790  * if we are going to overflow...
791  */
792  // Ptr = ConioCoordToPointer(Buffer, Xpos, Ypos); // Doesn't work
793  for (i = 0; i < min(NumCodesToRead, (ULONG)Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y); ++i)
794  {
795  // Ptr = ConioCoordToPointer(Buffer, Xpos, Ypos); // Doesn't work either
796  Ptr = &Buffer->Buffer[Xpos + Ypos * Buffer->ScreenBufferSize.X];
797 
798  switch (CodeType)
799  {
800  case CODE_ASCII:
802  break;
803 
804  case CODE_UNICODE:
805  *(PWCHAR)ReadBuffer = Ptr->Char.UnicodeChar;
806  break;
807 
808  case CODE_ATTRIBUTE:
809  *(PWORD)ReadBuffer = Ptr->Attributes;
810  break;
811  }
812  ReadBuffer = (PVOID)((ULONG_PTR)ReadBuffer + CodeSize);
813  // ++Ptr;
814 
815  Xpos++;
816 
817  if (Xpos == Buffer->ScreenBufferSize.X)
818  {
819  Xpos = 0;
820  Ypos++;
821 
822  if (Ypos == Buffer->ScreenBufferSize.Y)
823  {
824  Ypos = 0;
825  }
826  }
827  }
828 
829  // EndCoord->X = Xpos;
830  // EndCoord->Y = (Ypos - Buffer->VirtualY + Buffer->ScreenBufferSize.Y) % Buffer->ScreenBufferSize.Y;
831 
832  if (NumCodesRead)
833  *NumCodesRead = (ULONG)((ULONG_PTR)ReadBuffer - (ULONG_PTR)StringBuffer) / CodeSize;
834  // <= NumCodesToRead
835 
836  return STATUS_SUCCESS;
837 }
838 
842  IN CODE_TYPE CodeType,
844  IN ULONG NumCodesToWrite,
845  IN PCOORD WriteCoord,
846  // OUT PCOORD EndCoord,
847  OUT PULONG NumCodesWritten OPTIONAL)
848 {
851  PWCHAR tmpString = NULL;
852  ULONG X, Y, Length; // , Written = 0;
853  ULONG CodeSize;
854  PCHAR_INFO Ptr;
855 
856  if (Console == NULL || Buffer == NULL || WriteCoord == NULL /* || EndCoord == NULL */)
857  {
859  }
860 
861  /* Validity checks */
862  ASSERT(Console == Buffer->Header.Console);
863  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCodesToWrite == 0));
864 
865  //
866  // FIXME: Make overflow checks on WriteCoord !!!!!!
867  //
868 
869  if (NumCodesWritten) *NumCodesWritten = 0;
870 
871  switch (CodeType)
872  {
873  case CODE_ASCII:
874  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
875  break;
876 
877  case CODE_UNICODE:
878  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
879  break;
880 
881  case CODE_ATTRIBUTE:
882  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
883  break;
884 
885  default:
887  }
888 
889  if (CodeType == CODE_ASCII)
890  {
891  /* Convert the ASCII string into Unicode before writing it to the console */
892  Length = MultiByteToWideChar(Console->OutputCodePage, 0,
894  NumCodesToWrite,
895  NULL, 0);
896  tmpString = WriteBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length * sizeof(WCHAR));
897  if (WriteBuffer)
898  {
899  MultiByteToWideChar(Console->OutputCodePage, 0,
901  NumCodesToWrite,
903  }
904  else
905  {
907  }
908 
909  // FIXME: Quick fix: fix the CodeType and CodeSize since the
910  // ASCII string was converted into UNICODE.
911  // A proper fix needs to be written.
912  CodeType = CODE_UNICODE;
913  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
914  }
915  else
916  {
917  /* For CODE_UNICODE or CODE_ATTRIBUTE, we are already OK */
919  }
920 
921  if (WriteBuffer == NULL || !NT_SUCCESS(Status)) goto Cleanup;
922 
923  X = WriteCoord->X;
924  Y = (WriteCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
925  Length = NumCodesToWrite;
926  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work
927  // Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X]; // May work
928 
929  while (Length--)
930  {
931  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work either
932  Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X];
933 
934  switch (CodeType)
935  {
936  case CODE_ASCII:
937  case CODE_UNICODE:
938  Ptr->Char.UnicodeChar = *(PWCHAR)WriteBuffer;
939  break;
940 
941  case CODE_ATTRIBUTE:
942  Ptr->Attributes = *(PWORD)WriteBuffer;
943  break;
944  }
945  WriteBuffer = (PVOID)((ULONG_PTR)WriteBuffer + CodeSize);
946  // ++Ptr;
947 
948  // Written++;
949  if (++X == Buffer->ScreenBufferSize.X)
950  {
951  X = 0;
952 
953  if (++Y == Buffer->ScreenBufferSize.Y)
954  {
955  Y = 0;
956  }
957  }
958  }
959 
960  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
961  {
963  ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, NumCodesToWrite);
965  }
966 
967  // EndCoord->X = X;
968  // EndCoord->Y = (Y + Buffer->ScreenBufferSize.Y - Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
969 
970 Cleanup:
971  if (tmpString) RtlFreeHeap(RtlGetProcessHeap(), 0, tmpString);
972 
973  if (NumCodesWritten) *NumCodesWritten = NumCodesToWrite; // Written;
974  return Status;
975 }
976 
980  IN CODE_TYPE CodeType,
982  IN ULONG NumCodesToWrite,
983  IN PCOORD WriteCoord,
984  OUT PULONG NumCodesWritten OPTIONAL)
985 {
986  ULONG X, Y, Length; // , Written = 0;
987  PCHAR_INFO Ptr;
988 
989  if (Console == NULL || Buffer == NULL || WriteCoord == NULL)
990  {
992  }
993 
994  /* Validity check */
995  ASSERT(Console == Buffer->Header.Console);
996 
997  //
998  // FIXME: Make overflow checks on WriteCoord !!!!!!
999  //
1000 
1001  if (NumCodesWritten) *NumCodesWritten = 0;
1002 
1003  if (CodeType == CODE_ASCII)
1004  {
1005  /* Conversion from the ASCII char to the UNICODE char */
1006  CODE_ELEMENT tmp;
1008  Code = tmp;
1009  }
1010 
1011  X = WriteCoord->X;
1012  Y = (WriteCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
1013  Length = NumCodesToWrite;
1014  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work
1015  // Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X]; // May work
1016 
1017  while (Length--)
1018  {
1019  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work either
1020  Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X];
1021 
1022  switch (CodeType)
1023  {
1024  case CODE_ASCII:
1025  case CODE_UNICODE:
1026  Ptr->Char.UnicodeChar = Code.UnicodeChar;
1027  break;
1028 
1029  case CODE_ATTRIBUTE:
1030  Ptr->Attributes = Code.Attribute;
1031  break;
1032  }
1033  // ++Ptr;
1034 
1035  // Written++;
1036  if (++X == Buffer->ScreenBufferSize.X)
1037  {
1038  X = 0;
1039 
1040  if (++Y == Buffer->ScreenBufferSize.Y)
1041  {
1042  Y = 0;
1043  }
1044  }
1045  }
1046 
1047  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1048  {
1050  ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, NumCodesToWrite);
1052  }
1053 
1054  if (NumCodesWritten) *NumCodesWritten = NumCodesToWrite; // Written;
1055  return STATUS_SUCCESS;
1056 }
1057 
1061  OUT PCOORD ScreenBufferSize,
1062  OUT PCOORD CursorPosition,
1063  OUT PCOORD ViewOrigin,
1065  OUT PCOORD MaximumViewSize,
1067 {
1068  COORD LargestWindowSize;
1069 
1070  if (Console == NULL || Buffer == NULL || ScreenBufferSize == NULL ||
1071  CursorPosition == NULL || ViewOrigin == NULL || ViewSize == NULL ||
1072  MaximumViewSize == NULL || Attributes == NULL)
1073  {
1074  return STATUS_INVALID_PARAMETER;
1075  }
1076 
1077  /* Validity check */
1078  ASSERT(Console == Buffer->Header.Console);
1079 
1080  *ScreenBufferSize = Buffer->ScreenBufferSize;
1081  *CursorPosition = Buffer->CursorPosition;
1082  *ViewOrigin = Buffer->ViewOrigin;
1083  *ViewSize = Buffer->ViewSize;
1084  *Attributes = Buffer->ScreenDefaultAttrib;
1085 
1086  /*
1087  * Retrieve the largest possible console window size, taking
1088  * into account the size of the console screen buffer.
1089  */
1090  TermGetLargestConsoleWindowSize(Console, &LargestWindowSize);
1091  LargestWindowSize.X = min(LargestWindowSize.X, Buffer->ScreenBufferSize.X);
1092  LargestWindowSize.Y = min(LargestWindowSize.Y, Buffer->ScreenBufferSize.Y);
1093  *MaximumViewSize = LargestWindowSize;
1094 
1095  return STATUS_SUCCESS;
1096 }
1097 
1101  IN WORD Attributes)
1102 {
1103  if (Console == NULL || Buffer == NULL)
1104  return STATUS_INVALID_PARAMETER;
1105 
1106  /* Validity check */
1107  ASSERT(Console == Buffer->Header.Console);
1108 
1109  Buffer->ScreenDefaultAttrib = Attributes;
1110  return STATUS_SUCCESS;
1111 }
1112 
1116  IN PCOORD Size)
1117 {
1118  NTSTATUS Status;
1119 
1120  if (Console == NULL || Buffer == NULL || Size == NULL)
1121  return STATUS_INVALID_PARAMETER;
1122 
1123  /* Validity check */
1124  ASSERT(Console == Buffer->Header.Console);
1125 
1128 
1129  return Status;
1130 }
1131 
1135  IN BOOLEAN Unicode,
1136  IN PSMALL_RECT ScrollRectangle,
1137  IN BOOLEAN UseClipRectangle,
1138  IN PSMALL_RECT ClipRectangle OPTIONAL,
1139  IN PCOORD DestinationOrigin,
1140  IN CHAR_INFO FillChar)
1141 {
1142  COORD CapturedDestinationOrigin;
1144  SMALL_RECT SrcRegion;
1145  SMALL_RECT DstRegion;
1146  SMALL_RECT UpdateRegion;
1147  SMALL_RECT CapturedClipRectangle;
1148 
1149  if (Console == NULL || Buffer == NULL || ScrollRectangle == NULL ||
1150  (UseClipRectangle ? ClipRectangle == NULL : FALSE) || DestinationOrigin == NULL)
1151  {
1152  return STATUS_INVALID_PARAMETER;
1153  }
1154 
1155  /* Validity check */
1156  ASSERT(Console == Buffer->Header.Console);
1157 
1158  CapturedDestinationOrigin = *DestinationOrigin;
1159 
1160  /* Make sure the source rectangle is inside the screen buffer */
1161  ConioInitRect(&ScreenBuffer, 0, 0,
1162  Buffer->ScreenBufferSize.Y - 1,
1163  Buffer->ScreenBufferSize.X - 1);
1164  if (!ConioGetIntersection(&SrcRegion, &ScreenBuffer, ScrollRectangle))
1165  {
1166  return STATUS_SUCCESS;
1167  }
1168 
1169  /* If the source was clipped on the left or top, adjust the destination accordingly */
1170  if (ScrollRectangle->Left < 0)
1171  {
1172  CapturedDestinationOrigin.X -= ScrollRectangle->Left;
1173  }
1174  if (ScrollRectangle->Top < 0)
1175  {
1176  CapturedDestinationOrigin.Y -= ScrollRectangle->Top;
1177  }
1178 
1179  if (UseClipRectangle)
1180  {
1181  CapturedClipRectangle = *ClipRectangle;
1182  if (!ConioGetIntersection(&CapturedClipRectangle, &CapturedClipRectangle, &ScreenBuffer))
1183  {
1184  return STATUS_SUCCESS;
1185  }
1186  }
1187  else
1188  {
1189  CapturedClipRectangle = ScreenBuffer;
1190  }
1191 
1192  ConioInitRect(&DstRegion,
1193  CapturedDestinationOrigin.Y,
1194  CapturedDestinationOrigin.X,
1195  CapturedDestinationOrigin.Y + ConioRectHeight(&SrcRegion) - 1,
1196  CapturedDestinationOrigin.X + ConioRectWidth(&SrcRegion ) - 1);
1197 
1198  if (!Unicode)
1199  {
1200  WCHAR tmp;
1201  ConsoleOutputAnsiToUnicodeChar(Console, &tmp, &FillChar.Char.AsciiChar);
1202  FillChar.Char.UnicodeChar = tmp;
1203  }
1204 
1205  ConioMoveRegion(Buffer, &SrcRegion, &DstRegion, &CapturedClipRectangle, FillChar);
1206 
1207  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1208  {
1209  ConioGetUnion(&UpdateRegion, &SrcRegion, &DstRegion);
1210  if (ConioGetIntersection(&UpdateRegion, &UpdateRegion, &CapturedClipRectangle))
1211  {
1212  /* Draw update region */
1213  TermDrawRegion(Console, &UpdateRegion);
1214  }
1215  }
1216 
1217  return STATUS_SUCCESS;
1218 }
1219 
1223  IN BOOLEAN Absolute,
1224  IN PSMALL_RECT WindowRect)
1225 {
1226  SMALL_RECT CapturedWindowRect;
1227  COORD LargestWindowSize;
1228 
1229  if (Console == NULL || Buffer == NULL || WindowRect == NULL)
1230  return STATUS_INVALID_PARAMETER;
1231 
1232  /* Validity check */
1233  ASSERT(Console == Buffer->Header.Console);
1234 
1235  CapturedWindowRect = *WindowRect;
1236 
1237  if (!Absolute)
1238  {
1239  /* Relative positions are given, transform them to absolute ones */
1240  CapturedWindowRect.Left += Buffer->ViewOrigin.X;
1241  CapturedWindowRect.Top += Buffer->ViewOrigin.Y;
1242  CapturedWindowRect.Right += Buffer->ViewOrigin.X + Buffer->ViewSize.X - 1;
1243  CapturedWindowRect.Bottom += Buffer->ViewOrigin.Y + Buffer->ViewSize.Y - 1;
1244  }
1245 
1246  /*
1247  * The MSDN documentation on SetConsoleWindowInfo is partially wrong about
1248  * the performed checks this API performs. While it is correct that the
1249  * 'Right'/'Bottom' members cannot be strictly smaller than the 'Left'/'Top'
1250  * members, they can be equal.
1251  * Also, if the 'Left' or 'Top' members are negative, this is automatically
1252  * corrected for, and the window rectangle coordinates are shifted accordingly.
1253  */
1254  if ((CapturedWindowRect.Right < CapturedWindowRect.Left) ||
1255  (CapturedWindowRect.Bottom < CapturedWindowRect.Top))
1256  {
1257  return STATUS_INVALID_PARAMETER;
1258  }
1259 
1260  /*
1261  * Forbid window sizes larger than the largest allowed console window size,
1262  * taking into account the size of the console screen buffer.
1263  */
1264  TermGetLargestConsoleWindowSize(Console, &LargestWindowSize);
1265  LargestWindowSize.X = min(LargestWindowSize.X, Buffer->ScreenBufferSize.X);
1266  LargestWindowSize.Y = min(LargestWindowSize.Y, Buffer->ScreenBufferSize.Y);
1267  if ((CapturedWindowRect.Right - CapturedWindowRect.Left + 1 > LargestWindowSize.X) ||
1268  (CapturedWindowRect.Bottom - CapturedWindowRect.Top + 1 > LargestWindowSize.Y))
1269  {
1270  return STATUS_INVALID_PARAMETER;
1271  }
1272 
1273  /* Shift the window rectangle coordinates if 'Left' or 'Top' are negative */
1274  if (CapturedWindowRect.Left < 0)
1275  {
1276  CapturedWindowRect.Right -= CapturedWindowRect.Left;
1277  CapturedWindowRect.Left = 0;
1278  }
1279  if (CapturedWindowRect.Top < 0)
1280  {
1281  CapturedWindowRect.Bottom -= CapturedWindowRect.Top;
1282  CapturedWindowRect.Top = 0;
1283  }
1284 
1285  /* Clip the window rectangle to the screen buffer */
1286  CapturedWindowRect.Right = min(CapturedWindowRect.Right , Buffer->ScreenBufferSize.X);
1287  CapturedWindowRect.Bottom = min(CapturedWindowRect.Bottom, Buffer->ScreenBufferSize.Y);
1288 
1289  Buffer->ViewOrigin.X = CapturedWindowRect.Left;
1290  Buffer->ViewOrigin.Y = CapturedWindowRect.Top;
1291 
1292  Buffer->ViewSize.X = CapturedWindowRect.Right - CapturedWindowRect.Left + 1;
1293  Buffer->ViewSize.Y = CapturedWindowRect.Bottom - CapturedWindowRect.Top + 1;
1294 
1296 
1297  return STATUS_SUCCESS;
1298 }
1299 
1300 /* EOF */
signed char * PCHAR
Definition: retypes.h:7
NTSTATUS NTAPI ConDrvChangeScreenBufferAttributes(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN USHORT NewScreenAttrib, IN USHORT NewPopupAttrib)
Definition: text.c:383
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define IN
Definition: typedefs.h:38
#define max(a, b)
Definition: svc.c:63
NTSTATUS NTAPI ConDrvSetConsoleTextAttribute(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN WORD Attributes)
Definition: text.c:1099
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
NTSTATUS NTAPI ConDrvWriteConsoleOutput(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, IN PCHAR_INFO CharInfo, IN OUT PSMALL_RECT WriteRegion)
Definition: text.c:531
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
union _CHAR_INFO::@3143 Char
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
CHAR AsciiChar
Definition: wincon.h:170
#define WideCharToMultiByte
Definition: compat.h:101
#define Y(I)
BOOLEAN CursorBlinkOn
Definition: conio.h:99
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:140
#define WINDOW_BUFFER_SIZE_EVENT
Definition: wincon.h:124
WCHAR UnicodeChar
Definition: conmsg.h:525
VOID TEXTMODE_BUFFER_Destroy(IN OUT PCONSOLE_SCREEN_BUFFER Buffer)
Definition: text.c:123
WCHAR UnicodeChar
Definition: wincon.h:169
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
#define ReadBuffer(BaseIoAddress, Buffer, Count)
Definition: atapi.h:339
COORD CursorPosition
Definition: conio.h:98
ush Pos
Definition: deflate.h:92
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
#define TermDrawRegion(Console, Region)
Definition: term.h:22
#define ConsoleOutputUnicodeToAnsiChar(Console, dChar, sWChar)
Definition: text.c:25
#define TermResizeTerminal(Console)
Definition: term.h:28
WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent
Definition: wincon.h:265
uint16_t * PWCHAR
Definition: typedefs.h:54
#define TEXTMODE_BUFFER
Definition: pccons.c:21
static VOID ConioComputeUpdateRect(IN PTEXTMODE_SCREEN_BUFFER Buff, IN OUT PSMALL_RECT UpdateRect, IN PCOORD Start, IN UINT Length)
Definition: text.c:160
COORD OldScreenBufferSize
Definition: conio.h:90
CHAR InputBuffer[80]
Definition: conmgr.c:33
NTSTATUS NTAPI ConDrvReadConsoleOutput(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, OUT PCHAR_INFO CharInfo, IN OUT PSMALL_RECT ReadRegion)
Definition: text.c:467
SHORT Right
Definition: wincon.h:178
SHORT Left
Definition: wincon.h:176
CONSOLE_IO_OBJECT Header
Definition: conio.h:82
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
Definition: text.c:29
BYTE Attributes
Definition: svga.h:393
NTSTATUS NTAPI ConDrvWriteConsole(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER ScreenBuffer, IN BOOLEAN Unicode, IN PVOID StringBuffer, IN ULONG NumCharsToWrite, OUT PULONG NumCharsWritten OPTIONAL)
Definition: text.c:655
#define ENABLE_WRAP_AT_EOL_OUTPUT
Definition: blue.h:45
while(1)
Definition: macro.lex.yy.c:740
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
#define DX
Definition: i386-dis.c:416
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
COORD ScreenBufferSize
Definition: conio.h:87
short SHORT
Definition: pedump.c:59
#define ConioRectWidth(Rect)
Definition: readwrite.c:24
X(int i_=0)
static PVOID ptr
Definition: dispmode.c:27
NTSTATUS TEXTMODE_BUFFER_Initialize(OUT PCONSOLE_SCREEN_BUFFER *Buffer, IN PCONSOLE Console, IN HANDLE ProcessHandle, IN PTEXTMODE_BUFFER_INFO TextModeInfo)
Definition: text.c:62
struct _CONSOLE_SCREEN_BUFFER * PCONSOLE_SCREEN_BUFFER
Definition: conio.h:70
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define ConioRectHeight(Rect)
Definition: readwrite.c:22
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
VOID CONSOLE_SCREEN_BUFFER_Destroy(IN OUT PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:55
void * PVOID
Definition: retypes.h:9
struct zzzz Cell
union _INPUT_RECORD::@3145 Event
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
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
SHORT Left
Definition: blue.h:25
ULONG X
Definition: bl.h:1340
WORD * PWORD
Definition: pedump.c:67
#define Code
Definition: deflate.h:80
NTSTATUS CONSOLE_SCREEN_BUFFER_Initialize(OUT PCONSOLE_SCREEN_BUFFER *Buffer, IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER_VTBL Vtbl, IN SIZE_T Size)
Definition: conoutput.c:37
CHAR Char
Definition: svga.h:392
BOOLEAN bVisible
Definition: blue.h:41
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
NTSTATUS NTAPI ConDrvGetConsoleScreenBufferInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PCOORD ScreenBufferSize, OUT PCOORD CursorPosition, OUT PCOORD ViewOrigin, OUT PCOORD ViewSize, OUT PCOORD MaximumViewSize, OUT PWORD Attributes)
Definition: text.c:1059
SHORT Bottom
Definition: blue.h:28
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
WORD Attributes
Definition: wincon.h:172
#define TermGetLargestConsoleWindowSize(Console, pSize)
Definition: term.h:34
Definition: bzip2.c:1694
unsigned short WORD
Definition: ntddk_ex.h:93
#define for
Definition: utility.h:88
unsigned long DWORD
Definition: ntddk_ex.h:95
SHORT Top
Definition: blue.h:26
NTSTATUS NTAPI ConDrvFillConsoleOutput(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, IN CODE_ELEMENT Code, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
Definition: text.c:978
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Definition: partlist.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
SHORT Bottom
Definition: wincon.h:179
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI ConDrvSetConsoleScreenBufferSize(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCOORD Size)
Definition: text.c:1114
#define ENABLE_WINDOW_INPUT
Definition: wincon.h:78
NTSTATUS NTAPI ConDrvReadConsoleOutputString(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, OUT PVOID StringBuffer, IN ULONG NumCodesToRead, IN PCOORD ReadCoord, OUT PULONG NumCodesRead OPTIONAL)
Definition: text.c:727
NTSTATUS NTAPI ConDrvWriteConsoleOutputVDM(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCHAR_CELL CharInfo, IN COORD CharInfoSize, IN PSMALL_RECT WriteRegion)
Definition: text.c:600
BOOLEAN ForceCursorOff
Definition: conio.h:100
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
static const WCHAR Cleanup[]
Definition: register.c:80
Definition: bl.h:1338
#define ConioInitRect(Rect, top, left, bottom, right)
Definition: rect.h:20
Status
Definition: gdiplustypes.h:24
static __inline BOOLEAN ConioGetUnion(OUT PSMALL_RECT Union, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: text.c:176
#define ENABLE_PROCESSED_OUTPUT
Definition: blue.h:44
SHORT Top
Definition: wincon.h:177
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
static LPHIST_ENTRY Bottom
Definition: history.c:54
NTSTATUS ConioResizeBuffer(PCONSOLE Console, PTEXTMODE_SCREEN_BUFFER ScreenBuffer, COORD Size)
Definition: text.c:257
unsigned short USHORT
Definition: pedump.c:61
static CONSOLE_SCREEN_BUFFER_VTBL TextVtbl
Definition: text.c:42
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
unsigned int * PULONG
Definition: retypes.h:1
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
NTSTATUS NTAPI ConDrvWriteConsoleInput(IN PCONSOLE Console, IN PCONSOLE_INPUT_BUFFER InputBuffer, IN BOOLEAN AppendToEnd, IN PINPUT_RECORD InputRecord, IN ULONG NumEventsToWrite, OUT PULONG NumEventsWritten OPTIONAL)
Definition: coninput.c:325
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MultiByteToWideChar
Definition: compat.h:100
CConsole Console
WORD EventType
Definition: wincon.h:261
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
PCHAR_INFO Buffer
Definition: conio.h:154
HANDLE ScreenBuffer
Definition: notevil.c:37
#define OUT
Definition: typedefs.h:39
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:404
CONSOLE_IO_OBJECT_TYPE Type
Definition: conio.h:50
NTSTATUS NTAPI ConDrvSetConsoleWindowInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Absolute, IN PSMALL_RECT WindowRect)
Definition: text.c:1221
NTSTATUS NTAPI ConDrvScrollConsoleScreenBuffer(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, IN PSMALL_RECT ScrollRectangle, IN BOOLEAN UseClipRectangle, IN PSMALL_RECT ClipRectangle OPTIONAL, IN PCOORD DestinationOrigin, IN CHAR_INFO FillChar)
Definition: text.c:1133
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI ConDrvWriteConsoleOutputString(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, IN PVOID StringBuffer, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
Definition: text.c:840
#define ULONG_PTR
Definition: config.h:101
static VOID ConioMoveRegion(PTEXTMODE_SCREEN_BUFFER ScreenBuffer, PSMALL_RECT SrcRegion, PSMALL_RECT DstRegion, PSMALL_RECT ClipRegion, CHAR_INFO FillChar)
Definition: text.c:188
static __inline BOOLEAN ConioGetIntersection(OUT PSMALL_RECT Intersection, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: text.c:150
#define TermWriteStream(Console, ScreenBuffer, Buffer, Length, Attrib)
Definition: term.h:17
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529
VOID ClearLineBuffer(PTEXTMODE_SCREEN_BUFFER Buff)
Definition: text.c:146
SHORT Right
Definition: blue.h:27
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
return STATUS_SUCCESS
Definition: btrfs.c:2745
CONSOLE_CURSOR_INFO CursorInfo
Definition: conio.h:102
ULONG Y
Definition: bl.h:1341
enum _CONSOLE_IO_OBJECT_TYPE CONSOLE_IO_OBJECT_TYPE
WCHAR StringBuffer[156]
Definition: ldrinit.c:41
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER
enum _CODE_TYPE CODE_TYPE
#define WriteBuffer(BaseIoAddress, Buffer, Count)
Definition: atapi.h:344
CONSOLE_IO_OBJECT_TYPE TEXTMODE_BUFFER_GetType(PCONSOLE_SCREEN_BUFFER This)
Definition: text.c:36
#define X(b, s)
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68