Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

243 lines
7.9 KiB

  1. /***************************** Module Header ******************************\
  2. * Module Name: priv.h
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * Performance critical routine for Single Binary
  7. *
  8. * Each function will be created with two flavors FE and non FE
  9. *
  10. * 30-May-1997 Hiroyama Moved from private.c
  11. \**************************************************************************/
  12. #define WWSB_NEUTRAL_FILE 1
  13. #if !defined(FE_SB)
  14. #error This header file should be included with FE_SB
  15. #endif
  16. #if !defined(WWSB_FE) && !defined(WWSB_NOFE)
  17. #error Either WWSB_FE and WWSB_NOFE must be defined.
  18. #endif
  19. #if defined(WWSB_FE) && defined(WWSB_NOFE)
  20. #error Both WWSB_FE and WWSB_NOFE defined.
  21. #endif
  22. #include "dispatch.h" // get the FE_ prototypes for alloc_text()
  23. #ifdef WWSB_FE
  24. #pragma alloc_text(FE_TEXT, FE_WriteRegionToScreenHW)
  25. #endif
  26. #if defined(WWSB_NOFE)
  27. VOID
  28. SB_WriteRegionToScreenHW(
  29. IN PSCREEN_INFORMATION ScreenInfo,
  30. IN PSMALL_RECT Region
  31. )
  32. #else
  33. VOID
  34. FE_WriteRegionToScreenHW(
  35. IN PSCREEN_INFORMATION ScreenInfo,
  36. IN PSMALL_RECT Region
  37. )
  38. #endif
  39. {
  40. SHORT ScreenY,ScreenX;
  41. SHORT WindowY,WindowX,WindowSizeX;
  42. PCHAR_INFO ScreenBufPtr,ScreenBufPtrTmp; // points to place to read in screen buffer
  43. PCHAR_INFO ScreenBufSrc;
  44. COORD TargetSize,SourcePoint;
  45. SMALL_RECT Target;
  46. COORD WindowOrigin;
  47. #ifdef WWSB_FE
  48. PCHAR_IMAGE_INFO CharImageBufPtr,CharImageBufPtrTmp;
  49. PCHAR_IMAGE_INFO CharImageBufSrc;
  50. PFONT_IMAGE FontImage;
  51. #endif
  52. ULONG ModeIndex = ScreenInfo->BufferInfo.TextInfo.ModeIndex;
  53. COORD FsFontSize1 = RegModeFontPairs[ModeIndex].FontSize;
  54. COORD FsFontSize2 = FsFontSize1;
  55. NTSTATUS Status;
  56. #ifdef WWSB_FE
  57. SMALL_RECT CaTextRect;
  58. PCONVERSIONAREA_INFORMATION ConvAreaInfo = ScreenInfo->ConvScreenInfo;
  59. PSCREEN_INFORMATION CurrentScreenBuffer = ScreenInfo->Console->CurrentScreenBuffer;
  60. #endif
  61. FsFontSize2.X *= 2;
  62. #ifdef WWSB_NOFE
  63. if (ScreenInfo->Console->FontCacheInformation == NULL) {
  64. Status = SetRAMFontCodePage(ScreenInfo);
  65. if (!NT_SUCCESS(Status)) {
  66. return;
  67. }
  68. }
  69. #endif
  70. if (ScreenInfo->Console->Flags & CONSOLE_VDM_REGISTERED) {
  71. return;
  72. }
  73. #ifdef WWSB_FE
  74. if (ConvAreaInfo) {
  75. CaTextRect.Left = Region->Left - CurrentScreenBuffer->Window.Left - ConvAreaInfo->CaInfo.coordConView.X;
  76. CaTextRect.Right = CaTextRect.Left + (Region->Right - Region->Left);
  77. CaTextRect.Top = Region->Top - CurrentScreenBuffer->Window.Top - ConvAreaInfo->CaInfo.coordConView.Y;
  78. CaTextRect.Bottom = CaTextRect.Top + (Region->Bottom - Region->Top);
  79. }
  80. #endif
  81. TargetSize.X = Region->Right - Region->Left + 1;
  82. TargetSize.Y = Region->Bottom - Region->Top + 1;
  83. ScreenBufPtrTmp = ScreenBufPtr = ConsoleHeapAlloc(TMP_TAG, sizeof(CHAR_INFO) * TargetSize.X * TargetSize.Y);
  84. if (ScreenBufPtr == NULL) {
  85. return;
  86. }
  87. #ifdef WWSB_FE
  88. CharImageBufPtrTmp = CharImageBufPtr = ConsoleHeapAlloc(TMP_TAG, sizeof(CHAR_IMAGE_INFO) * TargetSize.X * TargetSize.Y);
  89. if (CharImageBufPtr == NULL) {
  90. ConsoleHeapFree(ScreenBufPtrTmp);
  91. return;
  92. }
  93. if (ConvAreaInfo) {
  94. SourcePoint.X = CaTextRect.Left;
  95. SourcePoint.Y = CaTextRect.Top;
  96. } else {
  97. SourcePoint.X = Region->Left;
  98. SourcePoint.Y = Region->Top;
  99. }
  100. #else
  101. SourcePoint.X = Region->Left;
  102. SourcePoint.Y = Region->Top;
  103. #endif
  104. Target.Left = 0;
  105. Target.Top = 0;
  106. Target.Right = TargetSize.X-1;
  107. Target.Bottom = TargetSize.Y-1;
  108. ReadRectFromScreenBuffer(ScreenInfo,
  109. SourcePoint,
  110. ScreenBufPtr,
  111. TargetSize,
  112. &Target
  113. );
  114. //
  115. // make sure region lies within window
  116. //
  117. if (Region->Bottom > ScreenInfo->Window.Bottom) {
  118. WindowOrigin.X = 0;
  119. WindowOrigin.Y = Region->Bottom - ScreenInfo->Window.Bottom;
  120. SetWindowOrigin(ScreenInfo, FALSE, WindowOrigin);
  121. }
  122. #ifdef WWSB_FE
  123. if (ConvAreaInfo) {
  124. WindowY = Region->Top - CurrentScreenBuffer->Window.Top;
  125. WindowX = Region->Left - CurrentScreenBuffer->Window.Left;
  126. }
  127. else {
  128. WindowY = Region->Top - ScreenInfo->Window.Top;
  129. WindowX = Region->Left - ScreenInfo->Window.Left;
  130. }
  131. #else
  132. WindowY = Region->Top - ScreenInfo->Window.Top;
  133. WindowX = Region->Left - ScreenInfo->Window.Left;
  134. #endif
  135. WindowSizeX = CONSOLE_WINDOW_SIZE_X(ScreenInfo);
  136. for (ScreenY = Region->Top;
  137. ScreenY <= Region->Bottom;
  138. ScreenY++, WindowY++) {
  139. #ifdef WWSB_FE
  140. CharImageBufSrc = CharImageBufPtr;
  141. SetRAMFont(ScreenInfo, ScreenBufPtr, WINDOW_SIZE_X(Region));
  142. #else
  143. ULONG CurFrameBufPtr; // offset in frame buffer
  144. CurFrameBufPtr = SCREEN_BUFFER_POINTER(WindowX,
  145. WindowY,
  146. WindowSizeX,
  147. sizeof(VGA_CHAR));
  148. #endif
  149. ScreenBufSrc = ScreenBufPtr;
  150. for (ScreenX = Region->Left;
  151. ScreenX <= Region->Right;
  152. ScreenX++, ScreenBufPtr++) {
  153. #ifdef WWSB_FE
  154. CharImageBufPtr->CharInfo = *ScreenBufPtr;
  155. Status = GetFontImagePointer(ScreenInfo->Console->FontCacheInformation,
  156. ScreenBufPtr->Char.UnicodeChar,
  157. ScreenBufPtr->Attributes & COMMON_LVB_SBCSDBCS ?
  158. FsFontSize2 : FsFontSize1,
  159. &FontImage);
  160. if (! NT_SUCCESS(Status))
  161. {
  162. CharImageBufPtr->FontImageInfo.FontSize.X = 0;
  163. CharImageBufPtr->FontImageInfo.FontSize.Y = 0;
  164. CharImageBufPtr->FontImageInfo.ImageBits = NULL;
  165. }
  166. else
  167. {
  168. CharImageBufPtr->FontImageInfo.FontSize = FontImage->FontSize;
  169. CharImageBufPtr->FontImageInfo.ImageBits = FontImage->ImageBits;
  170. }
  171. CharImageBufPtr++;
  172. #else
  173. //
  174. // if the char is > 127, we have to convert it back to OEM.
  175. //
  176. if (ScreenBufPtr->Char.UnicodeChar > 127) {
  177. ScreenBufPtr->Char.AsciiChar = WcharToChar(
  178. ScreenInfo->Console->OutputCP,
  179. ScreenBufPtr->Char.UnicodeChar);
  180. }
  181. #endif
  182. }
  183. #ifdef WWSB_FE
  184. {
  185. FSCNTL_SCREEN_INFO FsCntl;
  186. FsCntl.Position.X = WindowX;
  187. FsCntl.Position.Y = WindowY;
  188. FsCntl.ScreenSize.X = WindowSizeX;
  189. FsCntl.ScreenSize.Y = CONSOLE_WINDOW_SIZE_Y(ScreenInfo);
  190. FsCntl.nNumberOfChars = WINDOW_SIZE_X(Region);
  191. GdiFullscreenControl(FullscreenControlWriteToFrameBufferDB,
  192. CharImageBufSrc,
  193. (Region->Right - Region->Left + 1) *
  194. sizeof(CHAR_IMAGE_INFO),
  195. &FsCntl,
  196. (PULONG)sizeof(FsCntl));
  197. }
  198. #else
  199. GdiFullscreenControl(FullscreenControlWriteToFrameBuffer,
  200. ScreenBufSrc,
  201. (Region->Right - Region->Left + 1) *
  202. sizeof(CHAR_INFO),
  203. (PULONG) CurFrameBufPtr,
  204. (PULONG) ((Region->Right - Region->Left + 1) *
  205. sizeof(VGA_CHAR)));
  206. #endif
  207. }
  208. ConsoleHeapFree(ScreenBufPtrTmp);
  209. #ifdef WWSB_FE
  210. ConsoleHeapFree(CharImageBufPtrTmp);
  211. #endif
  212. ReverseMousePointer(ScreenInfo, Region);
  213. }