ReactOS  0.4.14-dev-593-g1793dcc
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_new/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 #include "include/conio.h"
14 #include "include/conio2.h"
15 #include "conoutput.h"
16 #include "handle.h"
17 
18 #define NDEBUG
19 #include <debug.h>
20 
21 
22 /* GLOBALS ********************************************************************/
23 
24 #define TAB_WIDTH 8
25 
26 
27 /* PRIVATE FUNCTIONS **********************************************************/
28 
31 {
32  // return This->Header.Type;
33  return TEXTMODE_BUFFER;
34 }
35 
37 {
39 };
40 
41 
42 static VOID FASTCALL
44 
45 
49  IN SIZE_T Size);
50 VOID
52 
53 
57  IN PTEXTMODE_BUFFER_INFO TextModeInfo)
58 {
60  PTEXTMODE_SCREEN_BUFFER NewBuffer = NULL;
61 
62  if (Console == NULL || Buffer == NULL || TextModeInfo == NULL)
64 
65  *Buffer = NULL;
66 
68  Console,
69  sizeof(TEXTMODE_SCREEN_BUFFER));
70  if (!NT_SUCCESS(Status)) return Status;
71  NewBuffer->Header.Type = TEXTMODE_BUFFER;
72  NewBuffer->Vtbl = &TextVtbl;
73 
74  NewBuffer->Buffer = ConsoleAllocHeap(HEAP_ZERO_MEMORY,
75  TextModeInfo->ScreenBufferSize.X *
76  TextModeInfo->ScreenBufferSize.Y *
77  sizeof(CHAR_INFO));
78  if (NewBuffer->Buffer == NULL)
79  {
82  }
83 
84  NewBuffer->ScreenBufferSize = NewBuffer->OldScreenBufferSize
85  = TextModeInfo->ScreenBufferSize;
86  NewBuffer->ViewSize = NewBuffer->OldViewSize
87  = Console->ConsoleSize;
88 
89  NewBuffer->ViewOrigin.X = NewBuffer->ViewOrigin.Y = 0;
90  NewBuffer->VirtualY = 0;
91 
92  NewBuffer->CursorBlinkOn = NewBuffer->ForceCursorOff = FALSE;
93  NewBuffer->CursorInfo.bVisible = (TextModeInfo->IsCursorVisible && (TextModeInfo->CursorSize != 0));
94  NewBuffer->CursorInfo.dwSize = min(max(TextModeInfo->CursorSize, 0), 100);
95 
96  NewBuffer->ScreenDefaultAttrib = TextModeInfo->ScreenAttrib;
97  NewBuffer->PopupDefaultAttrib = TextModeInfo->PopupAttrib;
98 
99  /* Initialize buffer to be empty with default attributes */
100  for (NewBuffer->CursorPosition.Y = 0 ; NewBuffer->CursorPosition.Y < NewBuffer->ScreenBufferSize.Y; NewBuffer->CursorPosition.Y++)
101  {
102  ClearLineBuffer(NewBuffer);
103  }
104  NewBuffer->CursorPosition.X = NewBuffer->CursorPosition.Y = 0;
105 
107 
108  *Buffer = (PCONSOLE_SCREEN_BUFFER)NewBuffer;
109  return STATUS_SUCCESS;
110 }
111 
112 VOID
114 {
116 
117  /*
118  * IMPORTANT !! Reinitialize the type so that we don't enter a recursive
119  * infinite loop when calling CONSOLE_SCREEN_BUFFER_Destroy.
120  */
121  Buffer->Header.Type = SCREEN_BUFFER;
122 
123  ConsoleFreeHeap(Buff->Buffer);
124 
126 }
127 
128 
131 {
132  return &Buff->Buffer[((Y + Buff->VirtualY) % Buff->ScreenBufferSize.Y) * Buff->ScreenBufferSize.X + X];
133 }
134 
135 static VOID FASTCALL
137 {
138  PCHAR_INFO Ptr = ConioCoordToPointer(Buff, 0, Buff->CursorPosition.Y);
139  SHORT Pos;
140 
141  for (Pos = 0; Pos < Buff->ScreenBufferSize.X; Pos++, Ptr++)
142  {
143  /* Fill the cell */
144  Ptr->Char.UnicodeChar = L' ';
145  Ptr->Attributes = Buff->ScreenDefaultAttrib;
146  }
147 }
148 
149 static __inline BOOLEAN
151  IN PSMALL_RECT Rect1,
152  IN PSMALL_RECT Rect2)
153 {
154  if ( ConioIsRectEmpty(Rect1) ||
155  ConioIsRectEmpty(Rect2) ||
156  (Rect1->Top > Rect2->Bottom) ||
157  (Rect1->Left > Rect2->Right) ||
158  (Rect1->Bottom < Rect2->Top) ||
159  (Rect1->Right < Rect2->Left) )
160  {
161  /* The rectangles do not intersect */
162  ConioInitRect(Intersection, 0, -1, 0, -1);
163  return FALSE;
164  }
165 
166  ConioInitRect(Intersection,
167  max(Rect1->Top , Rect2->Top ),
168  max(Rect1->Left , Rect2->Left ),
169  min(Rect1->Bottom, Rect2->Bottom),
170  min(Rect1->Right , Rect2->Right ));
171 
172  return TRUE;
173 }
174 
175 static __inline BOOLEAN
177  IN PSMALL_RECT Rect1,
178  IN PSMALL_RECT Rect2)
179 {
180  if (ConioIsRectEmpty(Rect1))
181  {
182  if (ConioIsRectEmpty(Rect2))
183  {
184  ConioInitRect(Union, 0, -1, 0, -1);
185  return FALSE;
186  }
187  else
188  {
189  *Union = *Rect2;
190  }
191  }
192  else if (ConioIsRectEmpty(Rect2))
193  {
194  *Union = *Rect1;
195  }
196  else
197  {
198  ConioInitRect(Union,
199  min(Rect1->Top , Rect2->Top ),
200  min(Rect1->Left , Rect2->Left ),
201  max(Rect1->Bottom, Rect2->Bottom),
202  max(Rect1->Right , Rect2->Right ));
203  }
204 
205  return TRUE;
206 }
207 
208 static VOID FASTCALL
211  IN PCOORD Start,
212  IN UINT Length)
213 {
214  if (Buff->ScreenBufferSize.X <= Start->X + Length)
215  {
216  UpdateRect->Left = 0;
217  }
218  else
219  {
220  UpdateRect->Left = Start->X;
221  }
222  if (Buff->ScreenBufferSize.X <= Start->X + Length)
223  {
224  UpdateRect->Right = Buff->ScreenBufferSize.X - 1;
225  }
226  else
227  {
228  UpdateRect->Right = Start->X + Length - 1;
229  }
230  UpdateRect->Top = Start->Y;
231  UpdateRect->Bottom = Start->Y + (Start->X + Length - 1) / Buff->ScreenBufferSize.X;
232  if (Buff->ScreenBufferSize.Y <= UpdateRect->Bottom)
233  {
234  UpdateRect->Bottom = Buff->ScreenBufferSize.Y - 1;
235  }
236 }
237 
238 /*
239  * Move from one rectangle to another. We must be careful about the order that
240  * this is done, to avoid overwriting parts of the source before they are moved.
241  */
242 static VOID FASTCALL
244  PSMALL_RECT SrcRegion,
245  PSMALL_RECT DstRegion,
246  PSMALL_RECT ClipRegion,
247  CHAR_INFO FillChar)
248 {
249  int Width = ConioRectWidth(SrcRegion);
250  int Height = ConioRectHeight(SrcRegion);
251  int SX, SY;
252  int DX, DY;
253  int XDelta, YDelta;
254  int i, j;
255 
256  SY = SrcRegion->Top;
257  DY = DstRegion->Top;
258  YDelta = 1;
259  if (SY < DY)
260  {
261  /* Moving down: work from bottom up */
262  SY = SrcRegion->Bottom;
263  DY = DstRegion->Bottom;
264  YDelta = -1;
265  }
266  for (i = 0; i < Height; i++)
267  {
270 
271  SX = SrcRegion->Left;
272  DX = DstRegion->Left;
273  XDelta = 1;
274  if (SX < DX)
275  {
276  /* Moving right: work from right to left */
277  SX = SrcRegion->Right;
278  DX = DstRegion->Right;
279  XDelta = -1;
280  }
281  for (j = 0; j < Width; j++)
282  {
283  CHAR_INFO Cell = SRow[SX];
284  if (SX >= ClipRegion->Left && SX <= ClipRegion->Right &&
285  SY >= ClipRegion->Top && SY <= ClipRegion->Bottom)
286  {
287  SRow[SX] = FillChar;
288  }
289  if (DX >= ClipRegion->Left && DX <= ClipRegion->Right &&
290  DY >= ClipRegion->Top && DY <= ClipRegion->Bottom)
291  {
292  DRow[DX] = Cell;
293  }
294  SX += XDelta;
295  DX += XDelta;
296  }
297  SY += YDelta;
298  DY += YDelta;
299  }
300 }
301 
304 {
305  DWORD Size = (Console->ActiveBuffer->CursorInfo.dwSize * Scale + 99) / 100;
306  /* If line input in progress, perhaps adjust for insert toggle */
307  if (Console->LineBuffer && !Console->LineComplete && Console->LineInsertToggle)
308  return (Size * 2 <= Scale) ? (Size * 2) : (Size / 2);
309  return Size;
310 }
311 
312 NTSTATUS
315  COORD Size)
316 {
318  DWORD Offset = 0;
319  PCHAR_INFO ptr;
320  WORD CurrentAttribute;
321  USHORT CurrentY;
322  PCHAR_INFO OldBuffer;
323  DWORD i;
324  DWORD diff;
325 
326  /* Buffer size is not allowed to be smaller than the view size */
327  if (Size.X < ScreenBuffer->ViewSize.X || Size.Y < ScreenBuffer->ViewSize.Y)
329 
330  if (Size.X == ScreenBuffer->ScreenBufferSize.X && Size.Y == ScreenBuffer->ScreenBufferSize.Y)
331  {
332  // FIXME: Trigger a buffer resize event ??
333  return STATUS_SUCCESS;
334  }
335 
336  if (Console->FixedSize)
337  {
338  /*
339  * The console is in fixed-size mode, so we cannot resize anything
340  * at the moment. However, keep those settings somewhere so that
341  * we can try to set them up when we will be allowed to do so.
342  */
343  ScreenBuffer->OldScreenBufferSize = Size;
344  return STATUS_NOT_SUPPORTED; // STATUS_SUCCESS
345  }
346 
348  if (!Buffer) return STATUS_NO_MEMORY;
349 
350  DPRINT1("Resizing (%d,%d) to (%d,%d)\n", ScreenBuffer->ScreenBufferSize.X, ScreenBuffer->ScreenBufferSize.Y, Size.X, Size.Y);
351  OldBuffer = ScreenBuffer->Buffer;
352 
353  for (CurrentY = 0; CurrentY < ScreenBuffer->ScreenBufferSize.Y && CurrentY < Size.Y; CurrentY++)
354  {
355  ptr = ConioCoordToPointer(ScreenBuffer, 0, CurrentY);
356  if (Size.X <= ScreenBuffer->ScreenBufferSize.X)
357  {
358  /* Reduce size */
359  RtlCopyMemory(Buffer + Offset, ptr, Size.X * sizeof(CHAR_INFO));
360  Offset += Size.X;
361  }
362  else
363  {
364  /* Enlarge size */
365  RtlCopyMemory(Buffer + Offset, ptr, ScreenBuffer->ScreenBufferSize.X * sizeof(CHAR_INFO));
366  Offset += ScreenBuffer->ScreenBufferSize.X;
367 
368  /* The attribute to be used is the one of the last cell of the current line */
369  CurrentAttribute = ConioCoordToPointer(ScreenBuffer,
370  ScreenBuffer->ScreenBufferSize.X - 1,
371  CurrentY)->Attributes;
372 
373  diff = Size.X - ScreenBuffer->ScreenBufferSize.X;
374 
375  /* Zero-out the new part of the buffer */
376  for (i = 0; i < diff; i++)
377  {
378  ptr = Buffer + Offset;
379  ptr->Char.UnicodeChar = L' ';
380  ptr->Attributes = CurrentAttribute;
381  ++Offset;
382  }
383  }
384  }
385 
386  if (Size.Y > ScreenBuffer->ScreenBufferSize.Y)
387  {
388  diff = Size.X * (Size.Y - ScreenBuffer->ScreenBufferSize.Y);
389 
390  /* Zero-out the new part of the buffer */
391  for (i = 0; i < diff; i++)
392  {
393  ptr = Buffer + Offset;
394  ptr->Char.UnicodeChar = L' ';
395  ptr->Attributes = ScreenBuffer->ScreenDefaultAttrib;
396  ++Offset;
397  }
398  }
399 
401  ConsoleFreeHeap(OldBuffer);
402  ScreenBuffer->ScreenBufferSize = ScreenBuffer->OldScreenBufferSize = Size;
403  ScreenBuffer->VirtualY = 0;
404 
405  /* Ensure cursor and window are within buffer */
406  if (ScreenBuffer->CursorPosition.X >= Size.X)
407  ScreenBuffer->CursorPosition.X = Size.X - 1;
408  if (ScreenBuffer->CursorPosition.Y >= Size.Y)
409  ScreenBuffer->CursorPosition.Y = Size.Y - 1;
410  if (ScreenBuffer->ViewOrigin.X > Size.X - ScreenBuffer->ViewSize.X)
411  ScreenBuffer->ViewOrigin.X = Size.X - ScreenBuffer->ViewSize.X;
412  if (ScreenBuffer->ViewOrigin.Y > Size.Y - ScreenBuffer->ViewSize.Y)
413  ScreenBuffer->ViewOrigin.Y = Size.Y - ScreenBuffer->ViewSize.Y;
414 
415  /*
416  * Trigger a buffer resize event
417  */
418  if (Console->InputBuffer.Mode & ENABLE_WINDOW_INPUT)
419  {
420  INPUT_RECORD er;
421 
423  er.Event.WindowBufferSizeEvent.dwSize = ScreenBuffer->ScreenBufferSize;
424 
426  }
427 
428  return STATUS_SUCCESS;
429 }
430 
431 static VOID FASTCALL
433 {
434  /* If we hit bottom, slide the viewable screen */
435  if (++Buff->CursorPosition.Y == Buff->ScreenBufferSize.Y)
436  {
437  Buff->CursorPosition.Y--;
438  if (++Buff->VirtualY == Buff->ScreenBufferSize.Y)
439  {
440  Buff->VirtualY = 0;
441  }
442  (*ScrolledLines)++;
443  ClearLineBuffer(Buff);
444  if (UpdateRect->Top != 0)
445  {
446  UpdateRect->Top--;
447  }
448  }
449  UpdateRect->Left = 0;
450  UpdateRect->Right = Buff->ScreenBufferSize.X - 1;
451  UpdateRect->Bottom = Buff->CursorPosition.Y;
452 }
453 
454 NTSTATUS
457  PWCHAR Buffer,
458  DWORD Length,
459  BOOL Attrib)
460 {
461  UINT i;
462  PCHAR_INFO Ptr;
464  SHORT CursorStartX, CursorStartY;
465  UINT ScrolledLines;
466 
467  CursorStartX = Buff->CursorPosition.X;
468  CursorStartY = Buff->CursorPosition.Y;
469  UpdateRect.Left = Buff->ScreenBufferSize.X;
470  UpdateRect.Top = Buff->CursorPosition.Y;
471  UpdateRect.Right = -1;
472  UpdateRect.Bottom = Buff->CursorPosition.Y;
473  ScrolledLines = 0;
474 
475  for (i = 0; i < Length; i++)
476  {
477  /*
478  * If we are in processed mode, interpret special characters and
479  * display them correctly. Otherwise, just put them into the buffer.
480  */
481  if (Buff->Mode & ENABLE_PROCESSED_OUTPUT)
482  {
483  /* --- CR --- */
484  if (Buffer[i] == L'\r')
485  {
486  Buff->CursorPosition.X = 0;
487  UpdateRect.Left = min(UpdateRect.Left, Buff->CursorPosition.X);
488  UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X);
489  continue;
490  }
491  /* --- LF --- */
492  else if (Buffer[i] == L'\n')
493  {
494  Buff->CursorPosition.X = 0;
495  ConioNextLine(Buff, &UpdateRect, &ScrolledLines);
496  continue;
497  }
498  /* --- BS --- */
499  else if (Buffer[i] == L'\b')
500  {
501  /* Only handle BS if we're not on the first pos of the first line */
502  if (0 != Buff->CursorPosition.X || 0 != Buff->CursorPosition.Y)
503  {
504  if (0 == Buff->CursorPosition.X)
505  {
506  /* slide virtual position up */
507  Buff->CursorPosition.X = Buff->ScreenBufferSize.X - 1;
508  Buff->CursorPosition.Y--;
509  UpdateRect.Top = min(UpdateRect.Top, Buff->CursorPosition.Y);
510  }
511  else
512  {
513  Buff->CursorPosition.X--;
514  }
515  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
516  Ptr->Char.UnicodeChar = L' ';
517  Ptr->Attributes = Buff->ScreenDefaultAttrib;
518  UpdateRect.Left = min(UpdateRect.Left, Buff->CursorPosition.X);
519  UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X);
520  }
521  continue;
522  }
523  /* --- TAB --- */
524  else if (Buffer[i] == L'\t')
525  {
526  UINT EndX;
527 
528  UpdateRect.Left = min(UpdateRect.Left, Buff->CursorPosition.X);
529  EndX = (Buff->CursorPosition.X + TAB_WIDTH) & ~(TAB_WIDTH - 1);
530  EndX = min(EndX, (UINT)Buff->ScreenBufferSize.X);
531  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
532  while (Buff->CursorPosition.X < EndX)
533  {
534  Ptr->Char.UnicodeChar = L' ';
535  Ptr->Attributes = Buff->ScreenDefaultAttrib;
536  ++Ptr;
537  Buff->CursorPosition.X++;
538  }
539  UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X - 1);
540  if (Buff->CursorPosition.X == Buff->ScreenBufferSize.X)
541  {
542  if (Buff->Mode & ENABLE_WRAP_AT_EOL_OUTPUT)
543  {
544  Buff->CursorPosition.X = 0;
545  ConioNextLine(Buff, &UpdateRect, &ScrolledLines);
546  }
547  else
548  {
549  Buff->CursorPosition.X--;
550  }
551  }
552  continue;
553  }
554  // /* --- BEL ---*/
555  // else if (Buffer[i] == L'\a')
556  // {
557  // // FIXME: This MUST BE moved to the terminal emulator frontend!!
558  // DPRINT1("Bell\n");
559  // // SendNotifyMessage(Console->hWindow, PM_CONSOLE_BEEP, 0, 0);
560  // continue;
561  // }
562  }
563  UpdateRect.Left = min(UpdateRect.Left, Buff->CursorPosition.X);
564  UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X);
565 
566  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
567  Ptr->Char.UnicodeChar = Buffer[i];
568  if (Attrib) Ptr->Attributes = Buff->ScreenDefaultAttrib;
569 
570  Buff->CursorPosition.X++;
571  if (Buff->CursorPosition.X == Buff->ScreenBufferSize.X)
572  {
573  if (Buff->Mode & ENABLE_WRAP_AT_EOL_OUTPUT)
574  {
575  Buff->CursorPosition.X = 0;
576  ConioNextLine(Buff, &UpdateRect, &ScrolledLines);
577  }
578  else
579  {
580  Buff->CursorPosition.X = CursorStartX;
581  }
582  }
583  }
584 
585  if (!ConioIsRectEmpty(&UpdateRect) && (PCONSOLE_SCREEN_BUFFER)Buff == Console->ActiveBuffer)
586  {
587  ConioWriteStream(Console, &UpdateRect, CursorStartX, CursorStartY,
588  ScrolledLines, Buffer, Length);
589  }
590 
591  return STATUS_SUCCESS;
592 }
593 
594 
595 /* PUBLIC DRIVER APIS *********************************************************/
596 
600  IN BOOLEAN Unicode,
601  OUT PCHAR_INFO CharInfo/*Buffer*/,
603  IN PCOORD BufferCoord,
604  IN OUT PSMALL_RECT ReadRegion)
605 {
606  PCHAR_INFO CurCharInfo;
607  SHORT SizeX, SizeY;
608  SMALL_RECT CapturedReadRegion;
609  SMALL_RECT ScreenRect;
610  DWORD i;
611  PCHAR_INFO Ptr;
612  LONG X, Y;
613  UINT CodePage;
614 
615  if (Console == NULL || Buffer == NULL || CharInfo == NULL ||
616  BufferSize == NULL || BufferCoord == NULL || ReadRegion == NULL)
617  {
619  }
620 
621  /* Validity check */
622  ASSERT(Console == Buffer->Header.Console);
623 
624  CapturedReadRegion = *ReadRegion;
625 
626  /* FIXME: Is this correct? */
627  CodePage = Console->OutputCodePage;
628 
629  SizeX = min(BufferSize->X - BufferCoord->X, ConioRectWidth(&CapturedReadRegion));
630  SizeY = min(BufferSize->Y - BufferCoord->Y, ConioRectHeight(&CapturedReadRegion));
631  CapturedReadRegion.Right = CapturedReadRegion.Left + SizeX;
632  CapturedReadRegion.Bottom = CapturedReadRegion.Top + SizeY;
633 
634  ConioInitRect(&ScreenRect, 0, 0, Buffer->ScreenBufferSize.Y, Buffer->ScreenBufferSize.X);
635  if (!ConioGetIntersection(&CapturedReadRegion, &ScreenRect, &CapturedReadRegion))
636  {
637  return STATUS_SUCCESS;
638  }
639 
640  for (i = 0, Y = CapturedReadRegion.Top; Y < CapturedReadRegion.Bottom; ++i, ++Y)
641  {
642  CurCharInfo = CharInfo + (i * BufferSize->X);
643 
644  Ptr = ConioCoordToPointer(Buffer, CapturedReadRegion.Left, Y);
645  for (X = CapturedReadRegion.Left; X < CapturedReadRegion.Right; ++X)
646  {
647  if (Unicode)
648  {
649  CurCharInfo->Char.UnicodeChar = Ptr->Char.UnicodeChar;
650  }
651  else
652  {
653  // ConsoleUnicodeCharToAnsiChar(Console, &CurCharInfo->Char.AsciiChar, &Ptr->Char.UnicodeChar);
654  WideCharToMultiByte(CodePage, 0, &Ptr->Char.UnicodeChar, 1,
655  &CurCharInfo->Char.AsciiChar, 1, NULL, NULL);
656  }
657  CurCharInfo->Attributes = Ptr->Attributes;
658  ++Ptr;
659  ++CurCharInfo;
660  }
661  }
662 
663  ReadRegion->Left = CapturedReadRegion.Left;
664  ReadRegion->Top = CapturedReadRegion.Top ;
665  ReadRegion->Right = CapturedReadRegion.Left + SizeX - 1;
666  ReadRegion->Bottom = CapturedReadRegion.Top + SizeY - 1;
667 
668  return STATUS_SUCCESS;
669 }
670 
674  IN BOOLEAN Unicode,
675  IN PCHAR_INFO CharInfo/*Buffer*/,
677  IN PCOORD BufferCoord,
678  IN OUT PSMALL_RECT WriteRegion)
679 {
680  SHORT i, X, Y, SizeX, SizeY;
682  PCHAR_INFO CurCharInfo;
683  SMALL_RECT CapturedWriteRegion;
684  PCHAR_INFO Ptr;
685 
686  if (Console == NULL || Buffer == NULL || CharInfo == NULL ||
687  BufferSize == NULL || BufferCoord == NULL || WriteRegion == NULL)
688  {
690  }
691 
692  /* Validity check */
693  ASSERT(Console == Buffer->Header.Console);
694 
695  CapturedWriteRegion = *WriteRegion;
696 
697  SizeX = min(BufferSize->X - BufferCoord->X, ConioRectWidth(&CapturedWriteRegion));
698  SizeY = min(BufferSize->Y - BufferCoord->Y, ConioRectHeight(&CapturedWriteRegion));
699  CapturedWriteRegion.Right = CapturedWriteRegion.Left + SizeX - 1;
700  CapturedWriteRegion.Bottom = CapturedWriteRegion.Top + SizeY - 1;
701 
702  /* Make sure WriteRegion is inside the screen buffer */
703  ConioInitRect(&ScreenBuffer, 0, 0, Buffer->ScreenBufferSize.Y - 1, Buffer->ScreenBufferSize.X - 1);
704  if (!ConioGetIntersection(&CapturedWriteRegion, &ScreenBuffer, &CapturedWriteRegion))
705  {
706  /*
707  * It is okay to have a WriteRegion completely outside
708  * the screen buffer. No data is written then.
709  */
710  return STATUS_SUCCESS;
711  }
712 
713  for (i = 0, Y = CapturedWriteRegion.Top; Y <= CapturedWriteRegion.Bottom; i++, Y++)
714  {
715  CurCharInfo = CharInfo + (i + BufferCoord->Y) * BufferSize->X + BufferCoord->X;
716 
717  Ptr = ConioCoordToPointer(Buffer, CapturedWriteRegion.Left, Y);
718  for (X = CapturedWriteRegion.Left; X <= CapturedWriteRegion.Right; X++)
719  {
720  if (Unicode)
721  {
722  Ptr->Char.UnicodeChar = CurCharInfo->Char.UnicodeChar;
723  }
724  else
725  {
726  ConsoleAnsiCharToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char.AsciiChar);
727  }
728  Ptr->Attributes = CurCharInfo->Attributes;
729  ++Ptr;
730  ++CurCharInfo;
731  }
732  }
733 
734  ConioDrawRegion(Console, &CapturedWriteRegion);
735 
736  WriteRegion->Left = CapturedWriteRegion.Left;
737  WriteRegion->Top = CapturedWriteRegion.Top ;
738  WriteRegion->Right = CapturedWriteRegion.Left + SizeX - 1;
739  WriteRegion->Bottom = CapturedWriteRegion.Top + SizeY - 1;
740 
741  return STATUS_SUCCESS;
742 }
743 
747  IN BOOLEAN Unicode,
749  IN ULONG NumCharsToWrite,
750  OUT PULONG NumCharsWritten OPTIONAL)
751 {
753  PWCHAR Buffer = NULL;
754  ULONG Written = 0;
755  ULONG Length;
756 
757  if (Console == NULL || ScreenBuffer == NULL /* || StringBuffer == NULL */)
759 
760  /* Validity checks */
761  ASSERT(Console == ScreenBuffer->Header.Console);
762  ASSERT( (StringBuffer != NULL && NumCharsToWrite >= 0) ||
763  (StringBuffer == NULL && NumCharsToWrite == 0) );
764 
765  // if (Console->PauseFlags & (PAUSED_FROM_KEYBOARD | PAUSED_FROM_SCROLLBAR | PAUSED_FROM_SELECTION))
766  if (Console->PauseFlags && Console->UnpauseEvent != NULL)
767  {
768  return STATUS_PENDING;
769  }
770 
771  if (Unicode)
772  {
774  }
775  else
776  {
777  Length = MultiByteToWideChar(Console->OutputCodePage, 0,
779  NumCharsToWrite,
780  NULL, 0);
781  Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length * sizeof(WCHAR));
782  if (Buffer)
783  {
784  MultiByteToWideChar(Console->OutputCodePage, 0,
786  NumCharsToWrite,
787  (PWCHAR)Buffer, Length);
788  }
789  else
790  {
792  }
793  }
794 
795  if (Buffer)
796  {
797  if (NT_SUCCESS(Status))
798  {
800  ScreenBuffer,
801  Buffer,
802  NumCharsToWrite,
803  TRUE);
804  if (NT_SUCCESS(Status))
805  {
806  Written = NumCharsToWrite;
807  }
808  }
809 
810  if (!Unicode) RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
811  }
812 
813  if (NumCharsWritten) *NumCharsWritten = Written;
814 
815  return Status;
816 }
817 
821  IN CODE_TYPE CodeType,
823  IN ULONG NumCodesToRead,
824  IN PCOORD ReadCoord,
825  OUT PCOORD EndCoord,
826  OUT PULONG CodesRead)
827 {
828  SHORT Xpos, Ypos;
830  ULONG i;
831  ULONG CodeSize;
832  PCHAR_INFO Ptr;
833 
834  if (Console == NULL || Buffer == NULL ||
835  ReadCoord == NULL || EndCoord == NULL || CodesRead == NULL)
836  {
838  }
839 
840  /* Validity checks */
841  ASSERT(Console == Buffer->Header.Console);
842  ASSERT( (StringBuffer != NULL && NumCodesToRead >= 0) ||
843  (StringBuffer == NULL && NumCodesToRead == 0) );
844 
845  switch (CodeType)
846  {
847  case CODE_ASCII:
848  CodeSize = sizeof(CHAR);
849  break;
850 
851  case CODE_UNICODE:
852  CodeSize = sizeof(WCHAR);
853  break;
854 
855  case CODE_ATTRIBUTE:
856  CodeSize = sizeof(WORD);
857  break;
858 
859  default:
861  }
862 
864  Xpos = ReadCoord->X;
865  Ypos = (ReadCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
866 
867  /*
868  * MSDN (ReadConsoleOutputAttribute and ReadConsoleOutputCharacter) :
869  *
870  * If the number of attributes (resp. characters) to be read from extends
871  * beyond the end of the specified screen buffer row, attributes (resp.
872  * characters) are read from the next row. If the number of attributes
873  * (resp. characters) to be read from extends beyond the end of the console
874  * screen buffer, attributes (resp. characters) up to the end of the console
875  * screen buffer are read.
876  *
877  * TODO: Do NOT loop up to NumCodesToRead, but stop before
878  * if we are going to overflow...
879  */
880  // Ptr = ConioCoordToPointer(Buffer, Xpos, Ypos); // Doesn't work
881  for (i = 0; i < min(NumCodesToRead, Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y); ++i)
882  {
883  // Ptr = ConioCoordToPointer(Buffer, Xpos, Ypos); // Doesn't work either
884  Ptr = &Buffer->Buffer[Xpos + Ypos * Buffer->ScreenBufferSize.X];
885 
886  switch (CodeType)
887  {
888  case CODE_ASCII:
890  break;
891 
892  case CODE_UNICODE:
893  *(PWCHAR)ReadBuffer = Ptr->Char.UnicodeChar;
894  break;
895 
896  case CODE_ATTRIBUTE:
897  *(PWORD)ReadBuffer = Ptr->Attributes;
898  break;
899  }
900  ReadBuffer = (PVOID)((ULONG_PTR)ReadBuffer + CodeSize);
901  // ++Ptr;
902 
903  Xpos++;
904 
905  if (Xpos == Buffer->ScreenBufferSize.X)
906  {
907  Xpos = 0;
908  Ypos++;
909 
910  if (Ypos == Buffer->ScreenBufferSize.Y)
911  {
912  Ypos = 0;
913  }
914  }
915  }
916 
917  // switch (CodeType)
918  // {
919  // case CODE_UNICODE:
920  // *(PWCHAR)ReadBuffer = 0;
921  // break;
922 
923  // case CODE_ASCII:
924  // *(PCHAR)ReadBuffer = 0;
925  // break;
926 
927  // case CODE_ATTRIBUTE:
928  // *(PWORD)ReadBuffer = 0;
929  // break;
930  // }
931 
932  EndCoord->X = Xpos;
933  EndCoord->Y = (Ypos - Buffer->VirtualY + Buffer->ScreenBufferSize.Y) % Buffer->ScreenBufferSize.Y;
934 
935  *CodesRead = (ULONG)((ULONG_PTR)ReadBuffer - (ULONG_PTR)StringBuffer) / CodeSize;
936  // <= NumCodesToRead
937 
938  return STATUS_SUCCESS;
939 }
940 
944  IN CODE_TYPE CodeType,
946  IN ULONG NumCodesToWrite,
947  IN PCOORD WriteCoord /*,
948  OUT PCOORD EndCoord,
949  OUT PULONG CodesWritten */)
950 {
953  PWCHAR tmpString = NULL;
954  DWORD X, Y, Length; // , Written = 0;
955  ULONG CodeSize;
957  PCHAR_INFO Ptr;
958 
959  if (Console == NULL || Buffer == NULL ||
960  WriteCoord == NULL /* || EndCoord == NULL || CodesWritten == NULL */)
961  {
963  }
964 
965  /* Validity checks */
966  ASSERT(Console == Buffer->Header.Console);
967  ASSERT( (StringBuffer != NULL && NumCodesToWrite >= 0) ||
968  (StringBuffer == NULL && NumCodesToWrite == 0) );
969 
970  switch (CodeType)
971  {
972  case CODE_ASCII:
973  CodeSize = sizeof(CHAR);
974  break;
975 
976  case CODE_UNICODE:
977  CodeSize = sizeof(WCHAR);
978  break;
979 
980  case CODE_ATTRIBUTE:
981  CodeSize = sizeof(WORD);
982  break;
983 
984  default:
986  }
987 
988  if (CodeType == CODE_ASCII)
989  {
990  /* Convert the ASCII string into Unicode before writing it to the console */
991  Length = MultiByteToWideChar(Console->OutputCodePage, 0,
993  NumCodesToWrite,
994  NULL, 0);
995  tmpString = WriteBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length * sizeof(WCHAR));
996  if (WriteBuffer)
997  {
998  MultiByteToWideChar(Console->OutputCodePage, 0,
1000  NumCodesToWrite,
1002  }
1003  else
1004  {
1006  }
1007  }
1008  else
1009  {
1010  /* For CODE_UNICODE or CODE_ATTRIBUTE, we are already OK */
1012  }
1013 
1014  if (WriteBuffer == NULL || !NT_SUCCESS(Status)) goto Cleanup;
1015 
1016  X = WriteCoord->X;
1017  Y = (WriteCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
1018  Length = NumCodesToWrite;
1019  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work
1020  // Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X]; // May work
1021 
1022  while (Length--)
1023  {
1024  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work either
1025  Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X];
1026 
1027  switch (CodeType)
1028  {
1029  case CODE_ASCII:
1030  case CODE_UNICODE:
1031  Ptr->Char.UnicodeChar = *(PWCHAR)WriteBuffer;
1032  break;
1033 
1034  case CODE_ATTRIBUTE:
1035  Ptr->Attributes = *(PWORD)WriteBuffer;
1036  break;
1037  }
1038  WriteBuffer = (PVOID)((ULONG_PTR)WriteBuffer + CodeSize);
1039  // ++Ptr;
1040 
1041  // Written++;
1042  if (++X == Buffer->ScreenBufferSize.X)
1043  {
1044  X = 0;
1045 
1046  if (++Y == Buffer->ScreenBufferSize.Y)
1047  {
1048  Y = 0;
1049  }
1050  }
1051  }
1052 
1053  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1054  {
1055  ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, NumCodesToWrite);
1057  }
1058 
1059  // EndCoord->X = X;
1060  // EndCoord->Y = (Y + Buffer->ScreenBufferSize.Y - Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
1061 
1062 Cleanup:
1063  if (tmpString) RtlFreeHeap(RtlGetProcessHeap(), 0, tmpString);
1064 
1065  // CodesWritten = Written;
1066  return Status;
1067 }
1068 
1072  IN CODE_TYPE CodeType,
1073  IN PVOID Code,
1074  IN ULONG NumCodesToWrite,
1075  IN PCOORD WriteCoord /*,
1076  OUT PULONG CodesWritten */)
1077 {
1078  DWORD X, Y, Length; // , Written = 0;
1079  PCHAR_INFO Ptr;
1081 
1082  if (Console == NULL || Buffer == NULL || Code == NULL ||
1083  WriteCoord == NULL /* || CodesWritten == NULL */)
1084  {
1085  return STATUS_INVALID_PARAMETER;
1086  }
1087 
1088  /* Validity check */
1089  ASSERT(Console == Buffer->Header.Console);
1090 
1091 #if 0
1092  switch (CodeType)
1093  {
1094  case CODE_ASCII:
1095  /* On-place conversion from the ASCII char to the UNICODE char */
1096  ConsoleAnsiCharToUnicodeChar(Console, &Code->UnicodeChar, &Code->AsciiChar);
1097  /* Fall through */
1098  case CODE_UNICODE:
1099  Code = &Code->UnicodeChar;
1100  break;
1101 
1102  case CODE_ATTRIBUTE:
1103  Code = &Code->Attribute;
1104  break;
1105  }
1106 #else
1107  if (CodeType == CODE_ASCII)
1108  {
1109  /* On-place conversion from the ASCII char to the UNICODE char */
1110  // FIXME: What if Code points to an invalid memory zone ??
1112  }
1113 #endif
1114 
1115  X = WriteCoord->X;
1116  Y = (WriteCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
1117  Length = NumCodesToWrite;
1118  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work
1119  // Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X]; // May work
1120 
1121  while (Length--)
1122  {
1123  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work either
1124  Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X];
1125 
1126  switch (CodeType)
1127  {
1128  case CODE_ASCII:
1129  case CODE_UNICODE:
1130  Ptr->Char.UnicodeChar = *(PWCHAR)Code;
1131  break;
1132 
1133  case CODE_ATTRIBUTE:
1134  Ptr->Attributes = *(PWORD)Code;
1135  break;
1136  }
1137  // ++Ptr;
1138 
1139  // Written++;
1140  if (++X == Buffer->ScreenBufferSize.X)
1141  {
1142  X = 0;
1143 
1144  if (++Y == Buffer->ScreenBufferSize.Y)
1145  {
1146  Y = 0;
1147  }
1148  }
1149  }
1150 
1151  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1152  {
1153  ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, NumCodesToWrite);
1155  }
1156 
1157  // CodesWritten = Written; // NumCodesToWrite;
1158  return STATUS_SUCCESS;
1159 }
1160 
1165 {
1166  if (Console == NULL || Buffer == NULL || ScreenBufferInfo == NULL)
1167  return STATUS_INVALID_PARAMETER;
1168 
1169  /* Validity check */
1170  ASSERT(Console == Buffer->Header.Console);
1171 
1172  ScreenBufferInfo->dwSize = Buffer->ScreenBufferSize;
1173  ScreenBufferInfo->dwCursorPosition = Buffer->CursorPosition;
1174  ScreenBufferInfo->wAttributes = Buffer->ScreenDefaultAttrib;
1175  ScreenBufferInfo->srWindow.Left = Buffer->ViewOrigin.X;
1176  ScreenBufferInfo->srWindow.Top = Buffer->ViewOrigin.Y;
1177  ScreenBufferInfo->srWindow.Right = Buffer->ViewOrigin.X + Buffer->ViewSize.X - 1;
1178  ScreenBufferInfo->srWindow.Bottom = Buffer->ViewOrigin.Y + Buffer->ViewSize.Y - 1;
1179 
1180  // FIXME: Refine the computation
1181  ScreenBufferInfo->dwMaximumWindowSize = Buffer->ScreenBufferSize;
1182 
1183  return STATUS_SUCCESS;
1184 }
1185 
1189  IN WORD Attribute)
1190 {
1191  if (Console == NULL || Buffer == NULL)
1192  return STATUS_INVALID_PARAMETER;
1193 
1194  /* Validity check */
1195  ASSERT(Console == Buffer->Header.Console);
1196 
1197  Buffer->ScreenDefaultAttrib = Attribute;
1198  return STATUS_SUCCESS;
1199 }
1200 
1204  IN PCOORD Size)
1205 {
1206  NTSTATUS Status;
1207 
1208  if (Console == NULL || Buffer == NULL || Size == NULL)
1209  return STATUS_INVALID_PARAMETER;
1210 
1211  /* Validity check */
1212  ASSERT(Console == Buffer->Header.Console);
1213 
1216 
1217  return Status;
1218 }
1219 
1223  IN BOOLEAN Unicode,
1224  IN PSMALL_RECT ScrollRectangle,
1225  IN BOOLEAN UseClipRectangle,
1226  IN PSMALL_RECT ClipRectangle OPTIONAL,
1227  IN PCOORD DestinationOrigin,
1228  IN CHAR_INFO FillChar)
1229 {
1230  COORD CapturedDestinationOrigin;
1232  SMALL_RECT SrcRegion;
1233  SMALL_RECT DstRegion;
1234  SMALL_RECT UpdateRegion;
1235  SMALL_RECT CapturedClipRectangle;
1236 
1237  if (Console == NULL || Buffer == NULL || ScrollRectangle == NULL ||
1238  (UseClipRectangle ? ClipRectangle == NULL : FALSE) || DestinationOrigin == NULL)
1239  {
1240  return STATUS_INVALID_PARAMETER;
1241  }
1242 
1243  /* Validity check */
1244  ASSERT(Console == Buffer->Header.Console);
1245 
1246  CapturedDestinationOrigin = *DestinationOrigin;
1247 
1248  /* Make sure the source rectangle is inside the screen buffer */
1249  ConioInitRect(&ScreenBuffer, 0, 0, Buffer->ScreenBufferSize.Y - 1, Buffer->ScreenBufferSize.X - 1);
1250  if (!ConioGetIntersection(&SrcRegion, &ScreenBuffer, ScrollRectangle))
1251  {
1252  return STATUS_SUCCESS;
1253  }
1254 
1255  /* If the source was clipped on the left or top, adjust the destination accordingly */
1256  if (ScrollRectangle->Left < 0)
1257  {
1258  CapturedDestinationOrigin.X -= ScrollRectangle->Left;
1259  }
1260  if (ScrollRectangle->Top < 0)
1261  {
1262  CapturedDestinationOrigin.Y -= ScrollRectangle->Top;
1263  }
1264 
1265  if (UseClipRectangle)
1266  {
1267  CapturedClipRectangle = *ClipRectangle;
1268  if (!ConioGetIntersection(&CapturedClipRectangle, &CapturedClipRectangle, &ScreenBuffer))
1269  {
1270  return STATUS_SUCCESS;
1271  }
1272  }
1273  else
1274  {
1275  CapturedClipRectangle = ScreenBuffer;
1276  }
1277 
1278  ConioInitRect(&DstRegion,
1279  CapturedDestinationOrigin.Y,
1280  CapturedDestinationOrigin.X,
1281  CapturedDestinationOrigin.Y + ConioRectHeight(&SrcRegion) - 1,
1282  CapturedDestinationOrigin.X + ConioRectWidth(&SrcRegion ) - 1);
1283 
1284  if (!Unicode)
1285  ConsoleAnsiCharToUnicodeChar(Console, &FillChar.Char.UnicodeChar, &FillChar.Char.AsciiChar);
1286 
1287  ConioMoveRegion(Buffer, &SrcRegion, &DstRegion, &CapturedClipRectangle, FillChar);
1288 
1289  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1290  {
1291  ConioGetUnion(&UpdateRegion, &SrcRegion, &DstRegion);
1292  if (ConioGetIntersection(&UpdateRegion, &UpdateRegion, &CapturedClipRectangle))
1293  {
1294  /* Draw update region */
1295  ConioDrawRegion(Console, &UpdateRegion);
1296  }
1297  }
1298 
1299  return STATUS_SUCCESS;
1300 }
1301 
1305  IN BOOLEAN Absolute,
1306  IN PSMALL_RECT WindowRect)
1307 {
1308  SMALL_RECT CapturedWindowRect;
1309 
1310  if (Console == NULL || Buffer == NULL || WindowRect == NULL)
1311  return STATUS_INVALID_PARAMETER;
1312 
1313  /* Validity check */
1314  ASSERT(Console == Buffer->Header.Console);
1315 
1316  CapturedWindowRect = *WindowRect;
1317 
1318  if (Absolute == FALSE)
1319  {
1320  /* Relative positions given. Transform them to absolute ones */
1321  CapturedWindowRect.Left += Buffer->ViewOrigin.X;
1322  CapturedWindowRect.Top += Buffer->ViewOrigin.Y;
1323  CapturedWindowRect.Right += Buffer->ViewOrigin.X + Buffer->ViewSize.X - 1;
1324  CapturedWindowRect.Bottom += Buffer->ViewOrigin.Y + Buffer->ViewSize.Y - 1;
1325  }
1326 
1327  /* See MSDN documentation on SetConsoleWindowInfo about the performed checks */
1328  if ( (CapturedWindowRect.Left < 0) || (CapturedWindowRect.Top < 0) ||
1329  (CapturedWindowRect.Right >= Buffer->ScreenBufferSize.X) ||
1330  (CapturedWindowRect.Bottom >= Buffer->ScreenBufferSize.Y) ||
1331  (CapturedWindowRect.Right <= CapturedWindowRect.Left) ||
1332  (CapturedWindowRect.Bottom <= CapturedWindowRect.Top) )
1333  {
1334  return STATUS_INVALID_PARAMETER;
1335  }
1336 
1337  Buffer->ViewOrigin.X = CapturedWindowRect.Left;
1338  Buffer->ViewOrigin.Y = CapturedWindowRect.Top;
1339 
1340  Buffer->ViewSize.X = CapturedWindowRect.Right - CapturedWindowRect.Left + 1;
1341  Buffer->ViewSize.Y = CapturedWindowRect.Bottom - CapturedWindowRect.Top + 1;
1342 
1343  return STATUS_SUCCESS;
1344 }
1345 
1346 /* EOF */
signed char * PCHAR
Definition: retypes.h:7
#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 ConioDrawRegion(Console, Region)
Definition: conio2.h:13
#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 ConsoleAnsiCharToUnicodeChar(Console, dWChar, sChar)
Definition: conio.h:361
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
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
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo
Definition: notevil.c:38
static VOID FASTCALL ConioNextLine(PTEXTMODE_SCREEN_BUFFER Buff, PSMALL_RECT UpdateRect, PUINT ScrolledLines)
Definition: text.c:432
#define WideCharToMultiByte
Definition: compat.h:101
#define Y(I)
#define ConsoleUnicodeCharToAnsiChar(Console, dChar, sWChar)
Definition: conio.h:358
BOOLEAN CursorBlinkOn
Definition: conio.h:99
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static CONSOLE_SCREEN_BUFFER_VTBL TextVtbl
Definition: text.c:36
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:140
#define WINDOW_BUFFER_SIZE_EVENT
Definition: wincon.h:124
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:606
#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
NTSTATUS ConioWriteConsole(PCONSOLE Console, PTEXTMODE_SCREEN_BUFFER Buff, PWCHAR Buffer, DWORD Length, BOOL Attrib)
Definition: text.c:455
WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent
Definition: wincon.h:265
uint16_t * PWCHAR
Definition: typedefs.h:54
static ULONG SizeX
Definition: display.c:138
#define TEXTMODE_BUFFER
Definition: pccons.c:21
union _INPUT_RECORD::@3177 Event
#define FASTCALL
Definition: nt_native.h:50
COORD OldScreenBufferSize
Definition: conio.h:90
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
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
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
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
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
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:588
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
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 ConioWriteStream(Console, Block, CurStartX, CurStartY, ScrolledLines, Buffer, Length)
Definition: conio2.h:15
#define BufferSize
Definition: classpnp.h:419
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
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
#define TAB_WIDTH
Definition: text.c:24
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 VOID FASTCALL ConioMoveRegion(PTEXTMODE_SCREEN_BUFFER ScreenBuffer, PSMALL_RECT SrcRegion, PSMALL_RECT DstRegion, PSMALL_RECT ClipRegion, CHAR_INFO FillChar)
Definition: text.c:243
#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
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
DWORD FASTCALL ConioEffectiveCursorSize(PCONSOLE Console, DWORD Scale)
Definition: text.c:303
#define MultiByteToWideChar
Definition: compat.h:100
CConsole Console
WORD EventType
Definition: wincon.h:261
#define DPRINT1
Definition: precomp.h:8
#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
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 __inline BOOLEAN ConioGetIntersection(OUT PSMALL_RECT Intersection, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: text.c:150
PCONSOLE_SCREEN_BUFFER_VTBL Vtbl
Definition: conio.h:83
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529
VOID ClearLineBuffer(PTEXTMODE_SCREEN_BUFFER Buff)
Definition: text.c:146
#define ConioIsRectEmpty(Rect)
Definition: rect.h:28
SHORT Right
Definition: blue.h:27
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
union _CHAR_INFO::@3175 Char
return STATUS_SUCCESS
Definition: btrfs.c:2938
CONSOLE_CURSOR_INFO CursorInfo
Definition: conio.h:102
ULONG Y
Definition: bl.h:1341
enum _CONSOLE_IO_OBJECT_TYPE CONSOLE_IO_OBJECT_TYPE
#define CHAR(Char)
WCHAR StringBuffer[156]
Definition: ldrinit.c:41
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER
#define ConioResizeTerminal(Console)
Definition: conio2.h:22
enum _CODE_TYPE CODE_TYPE
#define WriteBuffer(BaseIoAddress, Buffer, Count)
Definition: atapi.h:344
NTSTATUS ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:195
static VOID FASTCALL ConioComputeUpdateRect(IN PTEXTMODE_SCREEN_BUFFER Buff, IN OUT PSMALL_RECT UpdateRect, IN PCOORD Start, IN UINT Length)
Definition: text.c:209
unsigned int * PUINT
Definition: ndis.h:50
static ULONG SizeY
Definition: display.c:139
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