ReactOS  0.4.14-dev-1007-g90d795b
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 do { \
27  ASSERT((ULONG_PTR)(dChar) != (ULONG_PTR)(sWChar)); \
28  WideCharToMultiByte((Console)->OutputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL); \
29 } while (0)
30 
31 #define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar) \
32 do { \
33  ASSERT((ULONG_PTR)(dWChar) != (ULONG_PTR)(sChar)); \
34  MultiByteToWideChar((Console)->OutputCodePage, 0, (sChar), 1, (dWChar), 1); \
35 } while (0)
36 
37 /* PRIVATE FUNCTIONS **********************************************************/
38 
41 {
42  // return This->Header.Type;
43  return TEXTMODE_BUFFER;
44 }
45 
47 {
49 };
50 
51 
52 /*static*/ VOID
54 
55 
60  IN SIZE_T Size);
61 VOID
63 
64 
69  IN PTEXTMODE_BUFFER_INFO TextModeInfo)
70 {
72  PTEXTMODE_SCREEN_BUFFER NewBuffer = NULL;
73 
75 
76  if (Console == NULL || Buffer == NULL || TextModeInfo == NULL)
78 
79  *Buffer = NULL;
80 
82  Console,
83  &TextVtbl,
84  sizeof(TEXTMODE_SCREEN_BUFFER));
85  if (!NT_SUCCESS(Status)) return Status;
86  NewBuffer->Header.Type = TEXTMODE_BUFFER;
87 
88  NewBuffer->Buffer = ConsoleAllocHeap(HEAP_ZERO_MEMORY,
89  TextModeInfo->ScreenBufferSize.X *
90  TextModeInfo->ScreenBufferSize.Y *
91  sizeof(CHAR_INFO));
92  if (NewBuffer->Buffer == NULL)
93  {
96  }
97 
98  NewBuffer->ScreenBufferSize = NewBuffer->OldScreenBufferSize
99  = TextModeInfo->ScreenBufferSize;
100  NewBuffer->ViewSize = NewBuffer->OldViewSize
101  = Console->ConsoleSize;
102 
103  NewBuffer->ViewOrigin.X = NewBuffer->ViewOrigin.Y = 0;
104  NewBuffer->VirtualY = 0;
105 
106  NewBuffer->CursorBlinkOn = NewBuffer->ForceCursorOff = FALSE;
107  NewBuffer->CursorInfo.bVisible = (TextModeInfo->IsCursorVisible && (TextModeInfo->CursorSize != 0));
108  NewBuffer->CursorInfo.dwSize = min(max(TextModeInfo->CursorSize, 0), 100);
109 
110  NewBuffer->ScreenDefaultAttrib = (TextModeInfo->ScreenAttrib & ~COMMON_LVB_SBCSDBCS);
111  NewBuffer->PopupDefaultAttrib = (TextModeInfo->PopupAttrib & ~COMMON_LVB_SBCSDBCS);
112 
113  /* Initialize buffer to be empty with default attributes */
114  for (NewBuffer->CursorPosition.Y = 0 ; NewBuffer->CursorPosition.Y < NewBuffer->ScreenBufferSize.Y; NewBuffer->CursorPosition.Y++)
115  {
116  ClearLineBuffer(NewBuffer);
117  }
118  NewBuffer->CursorPosition.X = NewBuffer->CursorPosition.Y = 0;
119 
121 
122  *Buffer = (PCONSOLE_SCREEN_BUFFER)NewBuffer;
123  return STATUS_SUCCESS;
124 }
125 
126 VOID
128 {
130 
131  /*
132  * IMPORTANT !! Reinitialize the type so that we don't enter a recursive
133  * infinite loop when calling CONSOLE_SCREEN_BUFFER_Destroy.
134  */
135  Buffer->Header.Type = SCREEN_BUFFER;
136 
137  ConsoleFreeHeap(Buff->Buffer);
138 
140 }
141 
142 
145 {
146  ASSERT(X < Buff->ScreenBufferSize.X);
147  ASSERT(Y < Buff->ScreenBufferSize.Y);
148  return &Buff->Buffer[((Y + Buff->VirtualY) % Buff->ScreenBufferSize.Y) * Buff->ScreenBufferSize.X + X];
149 }
150 
151 /*static*/ VOID
153 {
154  PCHAR_INFO Ptr = ConioCoordToPointer(Buff, 0, Buff->CursorPosition.Y);
155  SHORT Pos;
156 
157  for (Pos = 0; Pos < Buff->ScreenBufferSize.X; Pos++, Ptr++)
158  {
159  /* Fill the cell */
160  Ptr->Char.UnicodeChar = L' ';
161  Ptr->Attributes = Buff->ScreenDefaultAttrib;
162  }
163 }
164 
165 static VOID
168  IN PCOORD Start,
169  IN UINT Length)
170 {
171  if ((UINT)Buff->ScreenBufferSize.X <= Start->X + Length)
172  {
173  UpdateRect->Left = 0;
174  UpdateRect->Right = Buff->ScreenBufferSize.X - 1;
175  }
176  else
177  {
178  UpdateRect->Left = Start->X;
179  UpdateRect->Right = Start->X + Length - 1;
180  }
181  UpdateRect->Top = Start->Y;
182  UpdateRect->Bottom = Start->Y + (Start->X + Length - 1) / Buff->ScreenBufferSize.X;
183  if (Buff->ScreenBufferSize.Y <= UpdateRect->Bottom)
184  {
185  UpdateRect->Bottom = Buff->ScreenBufferSize.Y - 1;
186  }
187 }
188 
189 /*
190  * Copy from one rectangle to another. We must be careful about the order of
191  * operations, to avoid overwriting parts of the source before they are copied.
192  */
193 static VOID
196  IN PSMALL_RECT SrcRegion,
197  IN PCOORD DstOrigin)
198 {
199  UINT Width, Height;
200  SHORT SY, DY;
201  SHORT YDelta;
202  PCHAR_INFO PtrSrc, PtrDst;
203 #if 0
204  SHORT SXOrg, DXOrg;
205  SHORT SX, DX;
206  SHORT XDelta;
207  UINT i, j;
208 #endif
209 
210  if (ConioIsRectEmpty(SrcRegion))
211  return;
212 
213 #if 0
214  ASSERT(SrcRegion->Left >= 0 && SrcRegion->Left < ScreenBuffer->ScreenBufferSize.X);
215  ASSERT(SrcRegion->Right >= 0 && SrcRegion->Right < ScreenBuffer->ScreenBufferSize.X);
216  ASSERT(SrcRegion->Top >= 0 && SrcRegion->Top < ScreenBuffer->ScreenBufferSize.Y);
217  ASSERT(SrcRegion->Bottom >= 0 && SrcRegion->Bottom < ScreenBuffer->ScreenBufferSize.Y);
218  // ASSERT(DstOrigin->X >= 0 && DstOrigin->X < ScreenBuffer->ScreenBufferSize.X);
219  // ASSERT(DstOrigin->Y >= 0 && DstOrigin->Y < ScreenBuffer->ScreenBufferSize.Y);
220 #endif
221 
222  /* If the source and destination regions are the same, just bail out */
223  if ((SrcRegion->Left == DstOrigin->X) && (SrcRegion->Top == DstOrigin->Y))
224  return;
225 
226  SY = SrcRegion->Top;
227  DY = DstOrigin->Y;
228  YDelta = 1;
229  if (SY < DY)
230  {
231  /* Moving down: work from bottom up */
232  SY = SrcRegion->Bottom;
233  DY = DstOrigin->Y + (SrcRegion->Bottom - SrcRegion->Top);
234  YDelta = -1;
235  }
236 
237 #if 0
238  SXOrg = SrcRegion->Left;
239  DXOrg = DstOrigin->X;
240  XDelta = 1;
241  if (SXOrg < DXOrg)
242  {
243  /* Moving right: work from right to left */
244  SXOrg = SrcRegion->Right;
245  DXOrg = DstOrigin->X + (SrcRegion->Right - SrcRegion->Left);
246  XDelta = -1;
247  }
248 #endif
249 
250  /* Loop through the source region */
251  Width = ConioRectWidth(SrcRegion);
252  Height = ConioRectHeight(SrcRegion);
253 #if 0
254  for (i = 0; i < Height; ++i, SY += YDelta, DY += YDelta)
255 #else
256  for (; Height-- > 0; SY += YDelta, DY += YDelta)
257 #endif
258  {
259 #if 0
260  SX = SXOrg;
261  DX = DXOrg;
262 
263  PtrSrc = ConioCoordToPointer(ScreenBuffer, SX, SY);
264  PtrDst = ConioCoordToPointer(ScreenBuffer, DX, DY);
265 #else
266  PtrSrc = ConioCoordToPointer(ScreenBuffer, SrcRegion->Left, SY);
267  PtrDst = ConioCoordToPointer(ScreenBuffer, DstOrigin->X, DY);
268 #endif
269 
270  // TODO: Correctly support copying full-width characters.
271  // By construction the source region is supposed to contain valid
272  // (possibly fullwidth) characters, so for these after the copy
273  // we need to check the characters at the borders and adjust the
274  // attributes accordingly.
275 
276 #if 0
277  for (j = 0; j < Width; ++j, SX += XDelta, DX += XDelta)
278  {
279  *PtrDst = *PtrSrc;
280  PtrSrc += XDelta;
281  PtrDst += XDelta;
282  }
283 #else
284  /* RtlMoveMemory() takes into account for the direction of the copy */
285  RtlMoveMemory(PtrDst, PtrSrc, Width * sizeof(CHAR_INFO));
286 #endif
287  }
288 }
289 
290 static VOID
294  IN PSMALL_RECT ExcludeRegion OPTIONAL,
295  IN CHAR_INFO FillChar)
296 {
297  SHORT X, Y;
298  PCHAR_INFO Ptr;
299  // BOOLEAN bFullwidth;
300 
301  /* Bail out if the region to fill is empty */
303  return;
304 
305  /* Sanitize the exclusion region: if it's empty, ignore the region */
306  if (ExcludeRegion && ConioIsRectEmpty(ExcludeRegion))
307  ExcludeRegion = NULL;
308 
309 #if 0
310  ASSERT(Region->Left >= 0 && Region->Left < ScreenBuffer->ScreenBufferSize.X);
311  ASSERT(Region->Right >= 0 && Region->Right < ScreenBuffer->ScreenBufferSize.X);
312  ASSERT(Region->Top >= 0 && Region->Top < ScreenBuffer->ScreenBufferSize.Y);
313  ASSERT(Region->Bottom >= 0 && Region->Bottom < ScreenBuffer->ScreenBufferSize.Y);
314 
315  if (ExcludeRegion)
316  {
317  ASSERT(ExcludeRegion->Left >= 0 && ExcludeRegion->Left < ScreenBuffer->ScreenBufferSize.X);
318  ASSERT(ExcludeRegion->Right >= 0 && ExcludeRegion->Right < ScreenBuffer->ScreenBufferSize.X);
319  ASSERT(ExcludeRegion->Top >= 0 && ExcludeRegion->Top < ScreenBuffer->ScreenBufferSize.Y);
320  ASSERT(ExcludeRegion->Bottom >= 0 && ExcludeRegion->Bottom < ScreenBuffer->ScreenBufferSize.Y);
321  }
322 #endif
323 
324  // bFullwidth = (ScreenBuffer->Header.Console->IsCJK && IS_FULL_WIDTH(FillChar.Char.UnicodeChar));
325 
326  /* Loop through the destination region */
327  for (Y = Region->Top; Y <= Region->Bottom; ++Y)
328  {
330  for (X = Region->Left; X <= Region->Right; ++X)
331  {
332  // TODO: Correctly support filling with full-width characters.
333 
334  if (!ExcludeRegion ||
335  !(X >= ExcludeRegion->Left && X <= ExcludeRegion->Right &&
336  Y >= ExcludeRegion->Top && Y <= ExcludeRegion->Bottom))
337  {
338  /* We are outside the excluded region, fill the destination */
339  *Ptr = FillChar;
340  // Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
341  }
342 
343  ++Ptr;
344  }
345  }
346 }
347 
348 
349 
350 // FIXME!
354  IN BOOLEAN AppendToEnd,
355  IN PINPUT_RECORD InputRecord,
356  IN ULONG NumEventsToWrite,
357  OUT PULONG NumEventsWritten OPTIONAL);
358 
359 NTSTATUS
362  COORD Size)
363 {
365  PCHAR_INFO Ptr;
366  ULONG_PTR Offset = 0;
367  WORD CurrentAttribute;
368  USHORT CurrentY;
369  PCHAR_INFO OldBuffer;
370  DWORD i;
371  DWORD diff;
372 
373  /* Zero size is invalid */
374  if (Size.X == 0 || Size.Y == 0)
376 
377  /* Buffer size is not allowed to be smaller than the view size */
378  if (Size.X < ScreenBuffer->ViewSize.X || Size.Y < ScreenBuffer->ViewSize.Y)
380 
381  if (Size.X == ScreenBuffer->ScreenBufferSize.X && Size.Y == ScreenBuffer->ScreenBufferSize.Y)
382  {
383  // FIXME: Trigger a buffer resize event ??
384  return STATUS_SUCCESS;
385  }
386 
387  if (Console->FixedSize)
388  {
389  /*
390  * The console is in fixed-size mode, so we cannot resize anything
391  * at the moment. However, keep those settings somewhere so that
392  * we can try to set them up when we will be allowed to do so.
393  */
394  ScreenBuffer->OldScreenBufferSize = Size;
395  return STATUS_NOT_SUPPORTED; // STATUS_SUCCESS
396  }
397 
399  if (!Buffer) return STATUS_NO_MEMORY;
400 
401  DPRINT("Resizing (%d,%d) to (%d,%d)\n", ScreenBuffer->ScreenBufferSize.X, ScreenBuffer->ScreenBufferSize.Y, Size.X, Size.Y);
402 
403  OldBuffer = ScreenBuffer->Buffer;
404 
405  for (CurrentY = 0; CurrentY < ScreenBuffer->ScreenBufferSize.Y && CurrentY < Size.Y; CurrentY++)
406  {
407  Ptr = ConioCoordToPointer(ScreenBuffer, 0, CurrentY);
408 
409  if (Size.X <= ScreenBuffer->ScreenBufferSize.X)
410  {
411  /* Reduce size */
412  RtlCopyMemory(Buffer + Offset, Ptr, Size.X * sizeof(CHAR_INFO));
413  Offset += Size.X;
414 
415  /* If we have cut a trailing full-width character in half, remove it completely */
416  Ptr = Buffer + Offset - 1;
417  if (Ptr->Attributes & COMMON_LVB_LEADING_BYTE)
418  {
419  Ptr->Char.UnicodeChar = L' ';
420  /* Keep all the other original attributes intact */
421  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
422  }
423  }
424  else
425  {
426  /* Enlarge size */
427  RtlCopyMemory(Buffer + Offset, Ptr, ScreenBuffer->ScreenBufferSize.X * sizeof(CHAR_INFO));
428  Offset += ScreenBuffer->ScreenBufferSize.X;
429 
430  /* The attribute to be used is the one of the last cell of the current line */
431  CurrentAttribute = ConioCoordToPointer(ScreenBuffer,
432  ScreenBuffer->ScreenBufferSize.X - 1,
433  CurrentY)->Attributes;
434  CurrentAttribute &= ~COMMON_LVB_SBCSDBCS;
435 
436  diff = Size.X - ScreenBuffer->ScreenBufferSize.X;
437 
438  /* Zero-out the new part of the buffer */
439  for (i = 0; i < diff; i++)
440  {
441  Ptr = Buffer + Offset;
442  Ptr->Char.UnicodeChar = L' ';
443  Ptr->Attributes = CurrentAttribute;
444  ++Offset;
445  }
446  }
447  }
448 
449  if (Size.Y > ScreenBuffer->ScreenBufferSize.Y)
450  {
451  diff = Size.X * (Size.Y - ScreenBuffer->ScreenBufferSize.Y);
452 
453  /* Zero-out the new part of the buffer */
454  for (i = 0; i < diff; i++)
455  {
456  Ptr = Buffer + Offset;
457  Ptr->Char.UnicodeChar = L' ';
458  Ptr->Attributes = ScreenBuffer->ScreenDefaultAttrib;
459  ++Offset;
460  }
461  }
462 
464  ConsoleFreeHeap(OldBuffer);
465  ScreenBuffer->ScreenBufferSize = ScreenBuffer->OldScreenBufferSize = Size;
466  ScreenBuffer->VirtualY = 0;
467 
468  /* Ensure cursor and window are within buffer */
469  if (ScreenBuffer->CursorPosition.X >= Size.X)
470  ScreenBuffer->CursorPosition.X = Size.X - 1;
471  if (ScreenBuffer->CursorPosition.Y >= Size.Y)
472  ScreenBuffer->CursorPosition.Y = Size.Y - 1;
473  if (ScreenBuffer->ViewOrigin.X > Size.X - ScreenBuffer->ViewSize.X)
474  ScreenBuffer->ViewOrigin.X = Size.X - ScreenBuffer->ViewSize.X;
475  if (ScreenBuffer->ViewOrigin.Y > Size.Y - ScreenBuffer->ViewSize.Y)
476  ScreenBuffer->ViewOrigin.Y = Size.Y - ScreenBuffer->ViewSize.Y;
477 
478  /*
479  * Trigger a buffer resize event
480  */
481  if (Console->InputBuffer.Mode & ENABLE_WINDOW_INPUT)
482  {
483  ULONG NumEventsWritten;
484  INPUT_RECORD er;
485 
487  er.Event.WindowBufferSizeEvent.dwSize = ScreenBuffer->ScreenBufferSize;
488 
489  // ConioProcessInputEvent(Console, &er);
491  &Console->InputBuffer,
492  TRUE,
493  &er,
494  1,
495  &NumEventsWritten);
496  }
497 
498  return STATUS_SUCCESS;
499 }
500 
504  IN USHORT NewScreenAttrib,
505  IN USHORT NewPopupAttrib)
506 {
507  USHORT X, Y;
508  PCHAR_INFO Ptr;
509 
510  COORD TopLeft = {0};
511  ULONG NumCodesToWrite;
512  USHORT OldScreenAttrib, OldPopupAttrib;
513 
514  if (Console == NULL || Buffer == NULL)
515  {
517  }
518 
519  /* Validity check */
520  ASSERT(Console == Buffer->Header.Console);
521 
522  /* Sanitize the new attributes */
523  NewScreenAttrib &= ~COMMON_LVB_SBCSDBCS;
524  NewPopupAttrib &= ~COMMON_LVB_SBCSDBCS;
525 
526  NumCodesToWrite = Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y;
527  OldScreenAttrib = Buffer->ScreenDefaultAttrib;
528  OldPopupAttrib = Buffer->PopupDefaultAttrib;
529 
530  for (Y = 0; Y < Buffer->ScreenBufferSize.Y; ++Y)
531  {
533  for (X = 0; X < Buffer->ScreenBufferSize.X; ++X)
534  {
535  /*
536  * Change the current colors only if they are the old ones.
537  */
538 
539  /* Foreground color */
540  if ((Ptr->Attributes & 0x0F) == (OldScreenAttrib & 0x0F))
541  Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewScreenAttrib & 0x0F);
542  if ((Ptr->Attributes & 0x0F) == (OldPopupAttrib & 0x0F))
543  Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewPopupAttrib & 0x0F);
544 
545  /* Background color */
546  if ((Ptr->Attributes & 0xF0) == (OldScreenAttrib & 0xF0))
547  Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewScreenAttrib & 0xF0);
548  if ((Ptr->Attributes & 0xF0) == (OldPopupAttrib & 0xF0))
549  Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewPopupAttrib & 0xF0);
550 
551  ++Ptr;
552  }
553  }
554 
555  /* Save foreground and background attributes for both screen and popup */
556  Buffer->ScreenDefaultAttrib = NewScreenAttrib;
557  Buffer->PopupDefaultAttrib = NewPopupAttrib;
558 
559  /* Refresh the display if needed */
560  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
561  {
563  ConioComputeUpdateRect(Buffer, &UpdateRect, &TopLeft, NumCodesToWrite);
565  }
566 
567  return STATUS_SUCCESS;
568 }
569 
570 
571 /* PUBLIC DRIVER APIS *********************************************************/
572 
576  IN BOOLEAN Unicode,
577  OUT PCHAR_INFO CharInfo/*Buffer*/,
578  IN OUT PSMALL_RECT ReadRegion)
579 {
580  SHORT X, Y;
582  PCHAR_INFO CurCharInfo;
583  SMALL_RECT CapturedReadRegion;
584  PCHAR_INFO Ptr;
585 
586  if (Console == NULL || Buffer == NULL || CharInfo == NULL || ReadRegion == NULL)
587  {
589  }
590 
591  /* Validity check */
592  ASSERT(Console == Buffer->Header.Console);
593 
594  CapturedReadRegion = *ReadRegion;
595 
596  /* Make sure ReadRegion is inside the screen buffer */
598  Buffer->ScreenBufferSize.Y - 1,
599  Buffer->ScreenBufferSize.X - 1);
600  if (!ConioGetIntersection(&CapturedReadRegion, &CapturedReadRegion, &ScreenBuffer))
601  {
602  /*
603  * It is okay to have a ReadRegion completely outside
604  * the screen buffer. No data is read then.
605  */
606  return STATUS_SUCCESS;
607  }
608 
609  CurCharInfo = CharInfo;
610 
611  for (Y = CapturedReadRegion.Top; Y <= CapturedReadRegion.Bottom; ++Y)
612  {
613  Ptr = ConioCoordToPointer(Buffer, CapturedReadRegion.Left, Y);
614  for (X = CapturedReadRegion.Left; X <= CapturedReadRegion.Right; ++X)
615  {
616  if (Unicode)
617  {
618  CurCharInfo->Char.UnicodeChar = Ptr->Char.UnicodeChar;
619  }
620  else
621  {
622  // ConsoleOutputUnicodeToAnsiChar(Console, &CurCharInfo->Char.AsciiChar, &Ptr->Char.UnicodeChar);
623  WideCharToMultiByte(Console->OutputCodePage, 0, &Ptr->Char.UnicodeChar, 1,
624  &CurCharInfo->Char.AsciiChar, 1, NULL, NULL);
625  }
626 #if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
627  /* NOTE: Windows < 8 compatibility: DBCS flags are filtered out */
628  CurCharInfo->Attributes = (Ptr->Attributes & ~COMMON_LVB_SBCSDBCS);
629 #else
630  CurCharInfo->Attributes = Ptr->Attributes;
631 #endif
632  ++Ptr;
633  ++CurCharInfo;
634  }
635  }
636 
637  *ReadRegion = CapturedReadRegion;
638 
639  return STATUS_SUCCESS;
640 }
641 
645  IN BOOLEAN Unicode,
646  IN PCHAR_INFO CharInfo/*Buffer*/,
647  IN OUT PSMALL_RECT WriteRegion)
648 {
649  SHORT X, Y;
651  PCHAR_INFO CurCharInfo;
652  SMALL_RECT CapturedWriteRegion;
653  PCHAR_INFO Ptr;
654 
655  if (Console == NULL || Buffer == NULL || CharInfo == NULL || WriteRegion == NULL)
656  {
658  }
659 
660  /* Validity check */
661  ASSERT(Console == Buffer->Header.Console);
662 
663  CapturedWriteRegion = *WriteRegion;
664 
665  /* Make sure WriteRegion is inside the screen buffer */
667  Buffer->ScreenBufferSize.Y - 1,
668  Buffer->ScreenBufferSize.X - 1);
669  if (!ConioGetIntersection(&CapturedWriteRegion, &CapturedWriteRegion, &ScreenBuffer))
670  {
671  /*
672  * It is okay to have a WriteRegion completely outside
673  * the screen buffer. No data is written then.
674  */
675  return STATUS_SUCCESS;
676  }
677 
678  CurCharInfo = CharInfo;
679 
680  for (Y = CapturedWriteRegion.Top; Y <= CapturedWriteRegion.Bottom; ++Y)
681  {
682  Ptr = ConioCoordToPointer(Buffer, CapturedWriteRegion.Left, Y);
683  for (X = CapturedWriteRegion.Left; X <= CapturedWriteRegion.Right; ++X)
684  {
685  if (Unicode)
686  {
687  Ptr->Char.UnicodeChar = CurCharInfo->Char.UnicodeChar;
688  }
689  else
690  {
691  ConsoleOutputAnsiToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char.AsciiChar);
692  }
693  // TODO: Sanitize DBCS attributes?
694  Ptr->Attributes = CurCharInfo->Attributes;
695  ++Ptr;
696  ++CurCharInfo;
697  }
698  }
699 
700  TermDrawRegion(Console, &CapturedWriteRegion);
701 
702  *WriteRegion = CapturedWriteRegion;
703 
704  return STATUS_SUCCESS;
705 }
706 
707 /*
708  * NOTE: This function is strongly inspired by ConDrvWriteConsoleOutput...
709  * FIXME: This function MUST be moved into consrv/conoutput.c because only
710  * consrv knows how to manipulate VDM screenbuffers.
711  */
715  IN PCHAR_CELL CharInfo/*Buffer*/,
716  IN COORD CharInfoSize,
717  IN PSMALL_RECT WriteRegion)
718 {
719  SHORT X, Y;
721  PCHAR_CELL CurCharInfo;
722  SMALL_RECT CapturedWriteRegion;
723  PCHAR_INFO Ptr;
724 
725  if (Console == NULL || Buffer == NULL || CharInfo == NULL || WriteRegion == NULL)
726  {
728  }
729 
730  /* Validity check */
731  ASSERT(Console == Buffer->Header.Console);
732 
733  CapturedWriteRegion = *WriteRegion;
734 
735  /* Make sure WriteRegion is inside the screen buffer */
737  Buffer->ScreenBufferSize.Y - 1,
738  Buffer->ScreenBufferSize.X - 1);
739  if (!ConioGetIntersection(&CapturedWriteRegion, &CapturedWriteRegion, &ScreenBuffer))
740  {
741  /*
742  * It is okay to have a WriteRegion completely outside
743  * the screen buffer. No data is written then.
744  */
745  return STATUS_SUCCESS;
746  }
747 
748  // CurCharInfo = CharInfo;
749 
750  for (Y = CapturedWriteRegion.Top; Y <= CapturedWriteRegion.Bottom; ++Y)
751  {
752  CurCharInfo = CharInfo + Y * CharInfoSize.X + CapturedWriteRegion.Left;
753 
754  Ptr = ConioCoordToPointer(Buffer, CapturedWriteRegion.Left, Y);
755  for (X = CapturedWriteRegion.Left; X <= CapturedWriteRegion.Right; ++X)
756  {
757  ConsoleOutputAnsiToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char);
758  Ptr->Attributes = CurCharInfo->Attributes;
759  ++Ptr;
760  ++CurCharInfo;
761  }
762  }
763 
764  return STATUS_SUCCESS;
765 }
766 
770  IN BOOLEAN Unicode,
772  IN ULONG NumCharsToWrite,
773  OUT PULONG NumCharsWritten OPTIONAL)
774 {
776  PWCHAR Buffer = NULL;
777  ULONG Written = 0;
778  ULONG Length;
779 
780  if (Console == NULL || ScreenBuffer == NULL /* || StringBuffer == NULL */)
782 
783  /* Validity checks */
784  ASSERT(Console == ScreenBuffer->Header.Console);
785  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCharsToWrite == 0));
786 
787  /* Stop here if the console is paused */
788  if (Console->UnpauseEvent != NULL) return STATUS_PENDING;
789 
790  /* Convert the string to UNICODE */
791  if (Unicode)
792  {
794  }
795  else
796  {
797  Length = MultiByteToWideChar(Console->OutputCodePage, 0,
799  NumCharsToWrite,
800  NULL, 0);
801  Buffer = ConsoleAllocHeap(0, Length * sizeof(WCHAR));
802  if (Buffer)
803  {
804  MultiByteToWideChar(Console->OutputCodePage, 0,
806  NumCharsToWrite,
807  (PWCHAR)Buffer, Length);
808  }
809  else
810  {
812  }
813  }
814 
815  /* Send it */
816  if (Buffer)
817  {
818  if (NT_SUCCESS(Status))
819  {
821  ScreenBuffer,
822  Buffer,
823  NumCharsToWrite,
824  TRUE);
825  if (NT_SUCCESS(Status))
826  {
827  Written = NumCharsToWrite;
828  }
829  }
830 
831  if (!Unicode) ConsoleFreeHeap(Buffer);
832  }
833 
834  if (NumCharsWritten) *NumCharsWritten = Written;
835 
836  return Status;
837 }
838 
839 static NTSTATUS
844  IN BOOLEAN Unicode,
845  IN ULONG NumCodesToRead,
846  IN PCOORD ReadCoord,
847  OUT PULONG NumCodesRead OPTIONAL)
848 {
849  ULONG CodeSize;
851  SHORT X, Y;
852  SHORT XStart = ReadCoord->X;
853  ULONG nNumChars = 0;
854  PCHAR_INFO Ptr;
855  BOOLEAN bCJK = Console->IsCJK;
856 
857  CodeSize = (Unicode ? RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar)
858  : RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar));
859 
860  for (Y = ReadCoord->Y; Y < Buffer->ScreenBufferSize.Y; ++Y)
861  {
862  Ptr = ConioCoordToPointer(Buffer, XStart, Y);
863  for (X = XStart; X < Buffer->ScreenBufferSize.X; ++X)
864  {
865  if (nNumChars >= NumCodesToRead)
866  goto Quit;
867 
868  /*
869  * For Chinese, Japanese and Korean.
870  * For full-width characters: copy only the character specified
871  * in the leading-byte cell, skipping the trailing-byte cell.
872  */
873  if (bCJK && (Ptr->Attributes & COMMON_LVB_TRAILING_BYTE))
874  {
875  /*
876  * Windows "compensates" for the fact this is a full-width
877  * character by reducing the amount of characters to be read.
878  * The understanding being that the specified amount of
879  * characters is also in "units" of (half-width) cells.
880  */
881  if (NumCodesToRead > 0) --NumCodesToRead;
882  ++Ptr;
883  continue;
884  }
885 
886  if (Unicode)
887  *(PWCHAR)ReadBuffer = Ptr->Char.UnicodeChar;
888  else
890 
891  ++Ptr;
892 
893  ReadBuffer += CodeSize;
894  ++nNumChars;
895  }
896  /* Restart at the beginning of the next line */
897  XStart = 0;
898  }
899 Quit:
900 
901  if (NumCodesRead)
902  *NumCodesRead = nNumChars;
903 
904  return STATUS_SUCCESS;
905 }
906 
907 static NTSTATUS
912  IN ULONG NumCodesToRead,
913  IN PCOORD ReadCoord,
914  OUT PULONG NumCodesRead OPTIONAL)
915 {
916  SHORT X, Y;
917  SHORT XStart = ReadCoord->X;
918  ULONG nNumChars = 0;
919  PCHAR_INFO Ptr;
920 
921  for (Y = ReadCoord->Y; Y < Buffer->ScreenBufferSize.Y; ++Y)
922  {
923  Ptr = ConioCoordToPointer(Buffer, XStart, Y);
924  for (X = XStart; X < Buffer->ScreenBufferSize.X; ++X)
925  {
926  if (nNumChars >= NumCodesToRead)
927  goto Quit;
928 
929  *StringBuffer = Ptr->Attributes;
930  ++Ptr;
931 
932  ++StringBuffer;
933  ++nNumChars;
934  }
935  /* Restart at the beginning of the next line */
936  XStart = 0;
937  }
938 Quit:
939 
940  if (NumCodesRead)
941  *NumCodesRead = nNumChars;
942 
943  return STATUS_SUCCESS;
944 }
945 
950  IN CODE_TYPE CodeType,
952  IN ULONG NumCodesToRead,
953  IN PCOORD ReadCoord,
954  OUT PULONG NumCodesRead OPTIONAL)
955 {
956  if (Console == NULL || Buffer == NULL || ReadCoord == NULL /* || EndCoord == NULL */)
957  {
959  }
960 
961  /* Validity checks */
962  ASSERT(Console == Buffer->Header.Console);
963  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCodesToRead == 0));
964 
965  if (NumCodesRead)
966  *NumCodesRead = 0;
967 
968  if (!StringBuffer || (NumCodesToRead == 0))
969  return STATUS_SUCCESS; // Nothing to do!
970 
971  /* Do nothing if the reading starting point is outside of the screen buffer */
972  if ( ReadCoord->X < 0 || ReadCoord->X >= Buffer->ScreenBufferSize.X ||
973  ReadCoord->Y < 0 || ReadCoord->Y >= Buffer->ScreenBufferSize.Y )
974  {
975  return STATUS_SUCCESS;
976  }
977 
978  NumCodesToRead = min(NumCodesToRead, (ULONG)Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y);
979 
980  switch (CodeType)
981  {
982  case CODE_ASCII:
983  {
985  Buffer,
986  StringBuffer,
987  FALSE,
988  NumCodesToRead,
989  ReadCoord,
990  NumCodesRead);
991  }
992 
993  case CODE_UNICODE:
994  {
996  Buffer,
997  StringBuffer,
998  TRUE,
999  NumCodesToRead,
1000  ReadCoord,
1001  NumCodesRead);
1002  }
1003 
1004  case CODE_ATTRIBUTE:
1005  {
1006  C_ASSERT(RTL_FIELD_SIZE(CODE_ELEMENT, Attribute) == sizeof(WORD));
1008  Buffer,
1010  NumCodesToRead,
1011  ReadCoord,
1012  NumCodesRead);
1013  }
1014 
1015  default:
1016  return STATUS_INVALID_PARAMETER;
1017  }
1018 }
1019 
1020 static NTSTATUS
1025  IN BOOLEAN Unicode,
1026  IN ULONG NumCodesToWrite,
1027  IN PCOORD WriteCoord,
1028  OUT PULONG NumCodesWritten OPTIONAL)
1029 {
1032  PWCHAR tmpString = NULL;
1033  ULONG Length;
1034  SHORT X, Y;
1035  SHORT XStart = WriteCoord->X;
1036  ULONG nNumChars = 0;
1037  PCHAR_INFO Ptr;
1038  BOOLEAN bCJK = Console->IsCJK;
1039 
1040  /* Convert the string to UNICODE */
1041  if (Unicode)
1042  {
1044  }
1045  else
1046  {
1047  /* Convert the ASCII string into Unicode before writing it to the console */
1048  Length = MultiByteToWideChar(Console->OutputCodePage, 0,
1050  NumCodesToWrite,
1051  NULL, 0);
1052  tmpString = ConsoleAllocHeap(0, Length * sizeof(WCHAR));
1053  if (!tmpString)
1054  {
1056  goto Quit;
1057  }
1058 
1059  MultiByteToWideChar(Console->OutputCodePage, 0,
1061  NumCodesToWrite,
1062  tmpString, Length);
1063 
1064  NumCodesToWrite = Length;
1065  WriteBuffer = tmpString;
1066  }
1067 
1068  for (Y = WriteCoord->Y; Y < Buffer->ScreenBufferSize.Y; ++Y)
1069  {
1070  Ptr = ConioCoordToPointer(Buffer, XStart, Y);
1071  for (X = XStart; X < Buffer->ScreenBufferSize.X; ++X)
1072  {
1073  if (nNumChars >= NumCodesToWrite)
1074  goto Quit;
1075 
1076  /* For Chinese, Japanese and Korean */
1077  if (bCJK && IS_FULL_WIDTH(*WriteBuffer))
1078  {
1079  /* A full-width character cannot cross a line boundary */
1080  if (X >= Buffer->ScreenBufferSize.X - 1)
1081  {
1082  /* Go to next line */
1083  break; // Break the X-loop only.
1084  }
1085 
1086  /* Set the leading byte */
1087  Ptr->Char.UnicodeChar = *WriteBuffer;
1088  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
1089  Ptr->Attributes |= COMMON_LVB_LEADING_BYTE;
1090  ++Ptr;
1091 
1092  /* Set the trailing byte */
1093  Ptr->Char.UnicodeChar = L' ';
1094  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
1095  Ptr->Attributes |= COMMON_LVB_TRAILING_BYTE;
1096  }
1097  else
1098  {
1099  Ptr->Char.UnicodeChar = *WriteBuffer;
1100  }
1101 
1102  ++Ptr;
1103 
1104  ++WriteBuffer;
1105  ++nNumChars;
1106  }
1107  /* Restart at the beginning of the next line */
1108  XStart = 0;
1109  }
1110 Quit:
1111 
1112  if (tmpString)
1113  {
1114  ASSERT(!Unicode);
1115  ConsoleFreeHeap(tmpString);
1116  }
1117 
1118  if (NumCodesWritten)
1119  *NumCodesWritten = nNumChars;
1120 
1121  return Status;
1122 }
1123 
1124 static NTSTATUS
1129  IN ULONG NumCodesToWrite,
1130  IN PCOORD WriteCoord,
1131  OUT PULONG NumCodesWritten OPTIONAL)
1132 {
1133  SHORT X, Y;
1134  SHORT XStart = WriteCoord->X;
1135  ULONG nNumChars = 0;
1136  PCHAR_INFO Ptr;
1137 
1138  for (Y = WriteCoord->Y; Y < Buffer->ScreenBufferSize.Y; ++Y)
1139  {
1140  Ptr = ConioCoordToPointer(Buffer, XStart, Y);
1141  for (X = XStart; X < Buffer->ScreenBufferSize.X; ++X)
1142  {
1143  if (nNumChars >= NumCodesToWrite)
1144  goto Quit;
1145 
1146  Ptr->Attributes &= COMMON_LVB_SBCSDBCS;
1147  Ptr->Attributes |= (*StringBuffer & ~COMMON_LVB_SBCSDBCS);
1148 
1149  ++Ptr;
1150 
1151  ++StringBuffer;
1152  ++nNumChars;
1153  }
1154  /* Restart at the beginning of the next line */
1155  XStart = 0;
1156  }
1157 Quit:
1158 
1159  if (NumCodesWritten)
1160  *NumCodesWritten = nNumChars;
1161 
1162  return STATUS_SUCCESS;
1163 }
1164 
1169  IN CODE_TYPE CodeType,
1171  IN ULONG NumCodesToWrite,
1172  IN PCOORD WriteCoord,
1173  OUT PULONG NumCodesWritten OPTIONAL)
1174 {
1175  NTSTATUS Status;
1176 
1177  if (Console == NULL || Buffer == NULL || WriteCoord == NULL /* || EndCoord == NULL */)
1178  {
1179  return STATUS_INVALID_PARAMETER;
1180  }
1181 
1182  /* Validity checks */
1183  ASSERT(Console == Buffer->Header.Console);
1184  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCodesToWrite == 0));
1185 
1186  if (NumCodesWritten)
1187  *NumCodesWritten = 0;
1188 
1189  if (!StringBuffer || (NumCodesToWrite == 0))
1190  return STATUS_SUCCESS; // Nothing to do!
1191 
1192  /* Do nothing if the writing starting point is outside of the screen buffer */
1193  if ( WriteCoord->X < 0 || WriteCoord->X >= Buffer->ScreenBufferSize.X ||
1194  WriteCoord->Y < 0 || WriteCoord->Y >= Buffer->ScreenBufferSize.Y )
1195  {
1196  return STATUS_SUCCESS;
1197  }
1198 
1199  NumCodesToWrite = min(NumCodesToWrite, (ULONG)Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y);
1200 
1201  switch (CodeType)
1202  {
1203  case CODE_ASCII:
1204  {
1205  C_ASSERT(RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar) == sizeof(CHAR));
1207  Buffer,
1208  StringBuffer,
1209  FALSE,
1210  NumCodesToWrite,
1211  WriteCoord,
1212  NumCodesWritten);
1213  break;
1214  }
1215 
1216  case CODE_UNICODE:
1217  {
1218  C_ASSERT(RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar) == sizeof(WCHAR));
1220  Buffer,
1221  StringBuffer,
1222  TRUE,
1223  NumCodesToWrite,
1224  WriteCoord,
1225  NumCodesWritten);
1226  break;
1227  }
1228 
1229  case CODE_ATTRIBUTE:
1230  {
1231  C_ASSERT(RTL_FIELD_SIZE(CODE_ELEMENT, Attribute) == sizeof(WORD));
1233  Buffer,
1235  NumCodesToWrite,
1236  WriteCoord,
1237  NumCodesWritten);
1238  break;
1239  }
1240 
1241  default:
1242  return STATUS_INVALID_PARAMETER;
1243  }
1244 
1245  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1246  {
1248  ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, NumCodesToWrite);
1250  }
1251 
1252  return Status;
1253 }
1254 
1258  IN CODE_TYPE CodeType,
1260  IN ULONG NumCodesToWrite,
1261  IN PCOORD WriteCoord,
1262  OUT PULONG NumCodesWritten OPTIONAL)
1263 {
1264  SHORT X, Y;
1265  SHORT XStart;
1266  ULONG nNumChars = 0;
1267  PCHAR_INFO Ptr;
1268  BOOLEAN bLead, bFullwidth;
1269 
1270  if (Console == NULL || Buffer == NULL || WriteCoord == NULL)
1271  {
1272  return STATUS_INVALID_PARAMETER;
1273  }
1274 
1275  /* Validity check */
1276  ASSERT(Console == Buffer->Header.Console);
1277 
1278  if (NumCodesWritten)
1279  *NumCodesWritten = 0;
1280 
1281  if (NumCodesToWrite == 0)
1282  return STATUS_SUCCESS; // Nothing to do!
1283 
1284  /* Do nothing if the writing starting point is outside of the screen buffer */
1285  if ( WriteCoord->X < 0 || WriteCoord->X >= Buffer->ScreenBufferSize.X ||
1286  WriteCoord->Y < 0 || WriteCoord->Y >= Buffer->ScreenBufferSize.Y )
1287  {
1288  return STATUS_SUCCESS;
1289  }
1290 
1291  NumCodesToWrite = min(NumCodesToWrite, (ULONG)Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y);
1292 
1293  if (CodeType == CODE_ASCII)
1294  {
1295  /* Conversion from the ASCII char to the UNICODE char */
1296  CODE_ELEMENT tmp;
1298  Code = tmp;
1299  }
1300 
1301  XStart = WriteCoord->X;
1302 
1303  /* For Chinese, Japanese and Korean */
1304  X = XStart;
1305  Y = WriteCoord->Y;
1306  bLead = TRUE;
1307  bFullwidth = FALSE;
1308  if (Console->IsCJK)
1309  {
1310  bFullwidth = IS_FULL_WIDTH(Code.UnicodeChar);
1311  if (X > 0)
1312  {
1313  Ptr = ConioCoordToPointer(Buffer, X - 1, Y);
1314  if (Ptr->Attributes & COMMON_LVB_LEADING_BYTE)
1315  {
1316  Ptr->Char.UnicodeChar = L' ';
1317  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
1318  }
1319  }
1320  }
1321 
1322  for (Y = WriteCoord->Y; Y < Buffer->ScreenBufferSize.Y; ++Y)
1323  {
1324  Ptr = ConioCoordToPointer(Buffer, XStart, Y);
1325  for (X = XStart; X < Buffer->ScreenBufferSize.X; ++X)
1326  {
1327  if (nNumChars >= NumCodesToWrite)
1328  goto Quit;
1329 
1330  switch (CodeType)
1331  {
1332  case CODE_ASCII:
1333  case CODE_UNICODE:
1334  Ptr->Char.UnicodeChar = Code.UnicodeChar;
1335  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
1336  if (bFullwidth)
1337  {
1338  if (bLead)
1339  Ptr->Attributes |= COMMON_LVB_LEADING_BYTE;
1340  else
1341  Ptr->Attributes |= COMMON_LVB_TRAILING_BYTE;
1342  }
1343  bLead = !bLead;
1344  break;
1345 
1346  case CODE_ATTRIBUTE:
1347  Ptr->Attributes &= COMMON_LVB_SBCSDBCS;
1348  Ptr->Attributes |= (Code.Attribute & ~COMMON_LVB_SBCSDBCS);
1349  break;
1350  }
1351 
1352  ++Ptr;
1353 
1354  ++nNumChars;
1355  }
1356  /* Restart at the beginning of the next line */
1357  XStart = 0;
1358  }
1359 Quit:
1360 
1361  if ((nNumChars & 1) & bFullwidth)
1362  {
1363  if (X + Y * Buffer->ScreenBufferSize.X > 0)
1364  {
1365  Ptr = ConioCoordToPointer(Buffer, X - 1, Y);
1366  Ptr->Char.UnicodeChar = L' ';
1367  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
1368  }
1369  }
1370 
1371  if (NumCodesWritten)
1372  *NumCodesWritten = nNumChars;
1373 
1374  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1375  {
1377  ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, nNumChars);
1379  }
1380 
1381  return STATUS_SUCCESS;
1382 }
1383 
1387  OUT PCOORD ScreenBufferSize,
1388  OUT PCOORD CursorPosition,
1389  OUT PCOORD ViewOrigin,
1391  OUT PCOORD MaximumViewSize,
1393 {
1394  COORD LargestWindowSize;
1395 
1396  if (Console == NULL || Buffer == NULL || ScreenBufferSize == NULL ||
1397  CursorPosition == NULL || ViewOrigin == NULL || ViewSize == NULL ||
1398  MaximumViewSize == NULL || Attributes == NULL)
1399  {
1400  return STATUS_INVALID_PARAMETER;
1401  }
1402 
1403  /* Validity check */
1404  ASSERT(Console == Buffer->Header.Console);
1405 
1406  *ScreenBufferSize = Buffer->ScreenBufferSize;
1407  *CursorPosition = Buffer->CursorPosition;
1408  *ViewOrigin = Buffer->ViewOrigin;
1409  *ViewSize = Buffer->ViewSize;
1410  *Attributes = Buffer->ScreenDefaultAttrib;
1411 
1412  /*
1413  * Retrieve the largest possible console window size, taking
1414  * into account the size of the console screen buffer.
1415  */
1416  TermGetLargestConsoleWindowSize(Console, &LargestWindowSize);
1417  LargestWindowSize.X = min(LargestWindowSize.X, Buffer->ScreenBufferSize.X);
1418  LargestWindowSize.Y = min(LargestWindowSize.Y, Buffer->ScreenBufferSize.Y);
1419  *MaximumViewSize = LargestWindowSize;
1420 
1421  return STATUS_SUCCESS;
1422 }
1423 
1427  IN WORD Attributes)
1428 {
1429  if (Console == NULL || Buffer == NULL)
1430  return STATUS_INVALID_PARAMETER;
1431 
1432  /* Validity check */
1433  ASSERT(Console == Buffer->Header.Console);
1434 
1435  Buffer->ScreenDefaultAttrib = (Attributes & ~COMMON_LVB_SBCSDBCS);
1436  return STATUS_SUCCESS;
1437 }
1438 
1442  IN PCOORD Size)
1443 {
1444  NTSTATUS Status;
1445 
1446  if (Console == NULL || Buffer == NULL || Size == NULL)
1447  return STATUS_INVALID_PARAMETER;
1448 
1449  /* Validity check */
1450  ASSERT(Console == Buffer->Header.Console);
1451 
1454 
1455  return Status;
1456 }
1457 
1462  IN BOOLEAN Unicode,
1463  IN PSMALL_RECT ScrollRectangle,
1464  IN BOOLEAN UseClipRectangle,
1465  IN PSMALL_RECT ClipRectangle OPTIONAL,
1466  IN PCOORD DestinationOrigin,
1467  IN CHAR_INFO FillChar)
1468 {
1469  COORD CapturedDestinationOrigin;
1471  SMALL_RECT CapturedClipRectangle;
1472  SMALL_RECT SrcRegion;
1473  SMALL_RECT DstRegion;
1474  SMALL_RECT UpdateRegion;
1475 
1476  if (Console == NULL || Buffer == NULL || ScrollRectangle == NULL ||
1477  (UseClipRectangle && (ClipRectangle == NULL)) || DestinationOrigin == NULL)
1478  {
1479  return STATUS_INVALID_PARAMETER;
1480  }
1481 
1482  /* Validity check */
1483  ASSERT(Console == Buffer->Header.Console);
1484 
1485  CapturedDestinationOrigin = *DestinationOrigin;
1486 
1487  /* Make sure the source rectangle is inside the screen buffer */
1488  ConioInitRect(&ScreenBuffer, 0, 0,
1489  Buffer->ScreenBufferSize.Y - 1,
1490  Buffer->ScreenBufferSize.X - 1);
1491  if (!ConioGetIntersection(&SrcRegion, ScrollRectangle, &ScreenBuffer))
1492  {
1493  return STATUS_SUCCESS;
1494  }
1495 
1496  /* If the source was clipped on the left or top, adjust the destination accordingly */
1497  if (ScrollRectangle->Left < 0)
1498  CapturedDestinationOrigin.X -= ScrollRectangle->Left;
1499  if (ScrollRectangle->Top < 0)
1500  CapturedDestinationOrigin.Y -= ScrollRectangle->Top;
1501 
1502  /*
1503  * If a clip rectangle is provided, clip it to the screen buffer,
1504  * otherwise use the latter one as the clip rectangle.
1505  */
1506  if (UseClipRectangle)
1507  {
1508  CapturedClipRectangle = *ClipRectangle;
1509  if (!ConioGetIntersection(&CapturedClipRectangle, &CapturedClipRectangle, &ScreenBuffer))
1510  {
1511  return STATUS_SUCCESS;
1512  }
1513  }
1514  else
1515  {
1516  CapturedClipRectangle = ScreenBuffer;
1517  }
1518 
1519  /*
1520  * Windows compatibility: Do nothing if the intersection of the source region
1521  * with the clip rectangle is empty, even if the intersection of destination
1522  * region with the clip rectangle is NOT empty and therefore it would have
1523  * been possible to copy contents to it...
1524  */
1525  if (!ConioGetIntersection(&UpdateRegion, &SrcRegion, &CapturedClipRectangle))
1526  {
1527  return STATUS_SUCCESS;
1528  }
1529 
1530  /* Initialize the destination rectangle, of same size as the source rectangle */
1531  ConioInitRect(&DstRegion,
1532  CapturedDestinationOrigin.Y,
1533  CapturedDestinationOrigin.X,
1534  CapturedDestinationOrigin.Y + ConioRectHeight(&SrcRegion) - 1,
1535  CapturedDestinationOrigin.X + ConioRectWidth(&SrcRegion ) - 1);
1536 
1537  if (ConioGetIntersection(&DstRegion, &DstRegion, &CapturedClipRectangle))
1538  {
1539  /*
1540  * Build the region image, within the source region,
1541  * of the destination region we should copy into.
1542  */
1543  SrcRegion.Left += DstRegion.Left - CapturedDestinationOrigin.X;
1544  SrcRegion.Top += DstRegion.Top - CapturedDestinationOrigin.Y;
1545  SrcRegion.Right = SrcRegion.Left + (DstRegion.Right - DstRegion.Left);
1546  SrcRegion.Bottom = SrcRegion.Top + (DstRegion.Bottom - DstRegion.Top);
1547 
1548  /* Do the copy */
1549  CapturedDestinationOrigin.X = DstRegion.Left;
1550  CapturedDestinationOrigin.Y = DstRegion.Top;
1551  ConioCopyRegion(Buffer, &SrcRegion, &CapturedDestinationOrigin);
1552  }
1553 
1554  if (!Unicode)
1555  {
1556  /* Conversion from the ASCII char to the UNICODE char */
1557  WCHAR tmp;
1558  ConsoleOutputAnsiToUnicodeChar(Console, &tmp, &FillChar.Char.AsciiChar);
1559  FillChar.Char.UnicodeChar = tmp;
1560  }
1561  /* Sanitize the attribute */
1562  FillChar.Attributes &= ~COMMON_LVB_SBCSDBCS;
1563 
1564  /*
1565  * Fill the intersection (== UpdateRegion) of the source region with the
1566  * clip rectangle, excluding the destination region.
1567  */
1568  ConioFillRegion(Buffer, &UpdateRegion, &DstRegion, FillChar);
1569 
1570  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1571  {
1572  ConioGetUnion(&UpdateRegion, &UpdateRegion, &DstRegion);
1573  if (ConioGetIntersection(&UpdateRegion, &UpdateRegion, &CapturedClipRectangle))
1574  {
1575  /* Draw update region */
1576  TermDrawRegion(Console, &UpdateRegion);
1577  }
1578  }
1579 
1580  return STATUS_SUCCESS;
1581 }
1582 
1586  IN BOOLEAN Absolute,
1587  IN PSMALL_RECT WindowRect)
1588 {
1589  SMALL_RECT CapturedWindowRect;
1590  COORD LargestWindowSize;
1591 
1592  if (Console == NULL || Buffer == NULL || WindowRect == NULL)
1593  return STATUS_INVALID_PARAMETER;
1594 
1595  /* Validity check */
1596  ASSERT(Console == Buffer->Header.Console);
1597 
1598  CapturedWindowRect = *WindowRect;
1599 
1600  if (!Absolute)
1601  {
1602  /* Relative positions are given, transform them to absolute ones */
1603  CapturedWindowRect.Left += Buffer->ViewOrigin.X;
1604  CapturedWindowRect.Top += Buffer->ViewOrigin.Y;
1605  CapturedWindowRect.Right += Buffer->ViewOrigin.X + Buffer->ViewSize.X - 1;
1606  CapturedWindowRect.Bottom += Buffer->ViewOrigin.Y + Buffer->ViewSize.Y - 1;
1607  }
1608 
1609  /*
1610  * The MSDN documentation on SetConsoleWindowInfo() is partially wrong about
1611  * the performed checks this API performs. While it is correct that the
1612  * 'Right'/'Bottom' members cannot be strictly smaller than the 'Left'/'Top'
1613  * members (the rectangle cannot be empty), they can be equal (describe one cell).
1614  * Also, if the 'Left' or 'Top' members are negative, this is automatically
1615  * corrected for, and the window rectangle coordinates are shifted accordingly.
1616  */
1617  if (ConioIsRectEmpty(&CapturedWindowRect))
1618  {
1619  return STATUS_INVALID_PARAMETER;
1620  }
1621 
1622  /*
1623  * Forbid window sizes larger than the largest allowed console window size,
1624  * taking into account the size of the console screen buffer.
1625  */
1626  TermGetLargestConsoleWindowSize(Console, &LargestWindowSize);
1627  LargestWindowSize.X = min(LargestWindowSize.X, Buffer->ScreenBufferSize.X);
1628  LargestWindowSize.Y = min(LargestWindowSize.Y, Buffer->ScreenBufferSize.Y);
1629  if ((ConioRectWidth(&CapturedWindowRect) > LargestWindowSize.X) ||
1630  (ConioRectHeight(&CapturedWindowRect) > LargestWindowSize.Y))
1631  {
1632  return STATUS_INVALID_PARAMETER;
1633  }
1634 
1635  /* Shift the window rectangle coordinates if 'Left' or 'Top' are negative */
1636  if (CapturedWindowRect.Left < 0)
1637  {
1638  CapturedWindowRect.Right -= CapturedWindowRect.Left;
1639  CapturedWindowRect.Left = 0;
1640  }
1641  if (CapturedWindowRect.Top < 0)
1642  {
1643  CapturedWindowRect.Bottom -= CapturedWindowRect.Top;
1644  CapturedWindowRect.Top = 0;
1645  }
1646 
1647  /* Clip the window rectangle to the screen buffer */
1648  CapturedWindowRect.Right = min(CapturedWindowRect.Right , Buffer->ScreenBufferSize.X);
1649  CapturedWindowRect.Bottom = min(CapturedWindowRect.Bottom, Buffer->ScreenBufferSize.Y);
1650 
1651  Buffer->ViewOrigin.X = CapturedWindowRect.Left;
1652  Buffer->ViewOrigin.Y = CapturedWindowRect.Top;
1653 
1654  Buffer->ViewSize.X = ConioRectWidth(&CapturedWindowRect);
1655  Buffer->ViewSize.Y = ConioRectHeight(&CapturedWindowRect);
1656 
1658 
1659  return STATUS_SUCCESS;
1660 }
1661 
1662 /* 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:502
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define IN
Definition: typedefs.h:39
#define max(a, b)
Definition: svc.c:63
static NTSTATUS IntReadConsoleOutputStringChars(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PVOID StringBuffer, IN BOOLEAN Unicode, IN ULONG NumCodesToRead, IN PCOORD ReadCoord, OUT PULONG NumCodesRead OPTIONAL)
Definition: text.c:840
NTSTATUS NTAPI ConDrvSetConsoleTextAttribute(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN WORD Attributes)
Definition: text.c:1425
#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:643
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
static VOID ConioFillRegion(IN PTEXTMODE_SCREEN_BUFFER ScreenBuffer, IN PSMALL_RECT Region, IN PSMALL_RECT ExcludeRegion OPTIONAL, IN CHAR_INFO FillChar)
Definition: text.c:291
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:185
#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:144
#define WINDOW_BUFFER_SIZE_EVENT
Definition: wincon.h:130
WCHAR UnicodeChar
Definition: conmsg.h:525
VOID TEXTMODE_BUFFER_Destroy(IN OUT PCONSOLE_SCREEN_BUFFER Buffer)
Definition: text.c:127
WCHAR UnicodeChar
Definition: wincon.h:184
char CHAR
Definition: xmlstorage.h:175
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
LONG NTSTATUS
Definition: precomp.h:26
#define ReadBuffer(BaseIoAddress, Buffer, Count)
Definition: atapi.h:339
#define COMMON_LVB_SBCSDBCS
Definition: wincon.h:56
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:280
uint16_t * PWCHAR
Definition: typedefs.h:55
#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:166
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:574
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
CONSOLE_IO_OBJECT Header
Definition: conio.h:82
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
Definition: text.c:31
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:768
#define ENABLE_WRAP_AT_EOL_OUTPUT
Definition: blue.h:54
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DX
Definition: i386-dis.c:416
unsigned char * LPBYTE
Definition: typedefs.h:53
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
static NTSTATUS IntWriteConsoleOutputStringChars(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PVOID StringBuffer, IN BOOLEAN Unicode, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
Definition: text.c:1021
static NTSTATUS IntReadConsoleOutputStringAttributes(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PWORD StringBuffer, IN ULONG NumCodesToRead, IN PCOORD ReadCoord, OUT PULONG NumCodesRead OPTIONAL)
Definition: text.c:908
short SHORT
Definition: pedump.c:59
#define ConioRectWidth(Rect)
Definition: readwrite.c:24
X(int i_=0)
NTSTATUS TEXTMODE_BUFFER_Initialize(OUT PCONSOLE_SCREEN_BUFFER *Buffer, IN PCONSOLE Console, IN HANDLE ProcessHandle, IN PTEXTMODE_BUFFER_INFO TextModeInfo)
Definition: text.c:66
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
#define C_ASSERT(e)
Definition: intsafe.h:79
VOID CONSOLE_SCREEN_BUFFER_Destroy(IN OUT PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:55
static VOID ConioCopyRegion(IN PTEXTMODE_SCREEN_BUFFER ScreenBuffer, IN PSMALL_RECT SrcRegion, IN PCOORD DstOrigin)
Definition: text.c:194
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
SHORT Left
Definition: blue.h:32
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
#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:1385
SHORT Bottom
Definition: blue.h:35
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:187
#define TermGetLargestConsoleWindowSize(Console, pSize)
Definition: term.h:34
union _CHAR_INFO::@3171 Char
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
SHORT Top
Definition: blue.h:33
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:1256
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Definition: partlist.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
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:1440
#define ENABLE_WINDOW_INPUT
Definition: wincon.h:81
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:947
static NTSTATUS IntWriteConsoleOutputStringAttribute(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PWORD StringBuffer, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
Definition: text.c:1125
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:713
BOOLEAN ForceCursorOff
Definition: conio.h:100
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
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:53
ULONG_PTR SIZE_T
Definition: typedefs.h:79
_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:360
unsigned short USHORT
Definition: pedump.c:61
static CONSOLE_SCREEN_BUFFER_VTBL TextVtbl
Definition: text.c:46
#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:330
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MultiByteToWideChar
Definition: compat.h:100
CConsole Console
WORD EventType
Definition: wincon.h:276
#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:40
#define COMMON_LVB_LEADING_BYTE
Definition: wincon.h:48
_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:1584
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:1459
#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:1166
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
#define COMMON_LVB_TRAILING_BYTE
Definition: wincon.h:49
VOID ClearLineBuffer(PTEXTMODE_SCREEN_BUFFER Buff)
Definition: text.c:152
#define ConioIsRectEmpty(Rect)
Definition: rect.h:28
SHORT Right
Definition: blue.h:34
union _INPUT_RECORD::@3173 Event
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
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
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
#define IS_FULL_WIDTH(wch)
Definition: conio.h:378
CONSOLE_IO_OBJECT_TYPE TEXTMODE_BUFFER_GetType(PCONSOLE_SCREEN_BUFFER This)
Definition: text.c:40
#define X(b, s)
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68