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.

328 lines
8.2 KiB

  1. /*++
  2. Copyright (c) 1985 - 1999, Microsoft Corporation
  3. Module Name:
  4. dispatch.c
  5. Abstract:
  6. Author:
  7. KazuM Apr.19.1996
  8. Revision History:
  9. --*/
  10. #include "precomp.h"
  11. #pragma hdrstop
  12. #define WWSB_NOFE
  13. #include "dispatch.h"
  14. #undef WWSB_NOFE
  15. #define WWSB_FE
  16. #include "dispatch.h"
  17. #undef WWSB_FE
  18. #if defined(FE_SB)
  19. NTSTATUS
  20. DoSrvWriteConsole(
  21. IN OUT PCSR_API_MSG m,
  22. IN OUT PCSR_REPLY_STATUS ReplyStatus,
  23. IN PCONSOLE_INFORMATION Console,
  24. IN PHANDLE_DATA HandleData
  25. )
  26. {
  27. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  28. return FE_DoSrvWriteConsole(m,ReplyStatus,Console,HandleData);
  29. else
  30. return SB_DoSrvWriteConsole(m,ReplyStatus,Console,HandleData);
  31. }
  32. NTSTATUS
  33. WriteOutputString(
  34. IN PSCREEN_INFORMATION ScreenInfo,
  35. IN PVOID Buffer,
  36. IN COORD WriteCoord,
  37. IN ULONG StringType,
  38. IN OUT PULONG NumRecords, // this value is valid even for error cases
  39. OUT PULONG NumColumns OPTIONAL
  40. )
  41. {
  42. PCONSOLE_INFORMATION Console = ScreenInfo->Console;
  43. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  44. return FE_WriteOutputString(ScreenInfo, Buffer, WriteCoord, StringType, NumRecords, NumColumns);
  45. else
  46. return SB_WriteOutputString(ScreenInfo, Buffer, WriteCoord, StringType, NumRecords, NumColumns);
  47. }
  48. VOID
  49. WriteRectToScreenBuffer(
  50. PBYTE Source,
  51. COORD SourceSize,
  52. PSMALL_RECT SourceRect,
  53. PSCREEN_INFORMATION ScreenInfo,
  54. COORD TargetPoint,
  55. IN UINT Codepage
  56. )
  57. {
  58. PCONSOLE_INFORMATION Console = ScreenInfo->Console;
  59. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  60. FE_WriteRectToScreenBuffer(Source,SourceSize,SourceRect,ScreenInfo,TargetPoint,Codepage);
  61. else
  62. SB_WriteRectToScreenBuffer(Source,SourceSize,SourceRect,ScreenInfo,TargetPoint,Codepage);
  63. }
  64. VOID
  65. WriteToScreen(
  66. IN PSCREEN_INFORMATION ScreenInfo,
  67. PSMALL_RECT Region // region is inclusive
  68. )
  69. {
  70. PCONSOLE_INFORMATION Console = ScreenInfo->Console;
  71. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  72. FE_WriteToScreen(ScreenInfo, Region);
  73. else
  74. SB_WriteToScreen(ScreenInfo, Region);
  75. }
  76. VOID
  77. WriteRegionToScreen(
  78. IN PSCREEN_INFORMATION ScreenInfo,
  79. IN PSMALL_RECT Region
  80. )
  81. {
  82. PCONSOLE_INFORMATION Console = ScreenInfo->Console;
  83. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  84. FE_WriteRegionToScreen(ScreenInfo, Region);
  85. else
  86. SB_WriteRegionToScreen(ScreenInfo, Region);
  87. }
  88. NTSTATUS
  89. FillOutput(
  90. IN PSCREEN_INFORMATION ScreenInfo,
  91. IN WORD Element,
  92. IN COORD WriteCoord,
  93. IN ULONG ElementType,
  94. IN OUT PULONG Length // this value is valid even for error cases
  95. )
  96. {
  97. PCONSOLE_INFORMATION Console = ScreenInfo->Console;
  98. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  99. return FE_FillOutput(ScreenInfo, Element, WriteCoord, ElementType, Length);
  100. else
  101. return SB_FillOutput(ScreenInfo, Element, WriteCoord, ElementType, Length);
  102. }
  103. VOID
  104. FillRectangle(
  105. IN CHAR_INFO Fill,
  106. IN OUT PSCREEN_INFORMATION ScreenInfo,
  107. IN PSMALL_RECT TargetRect
  108. )
  109. {
  110. PCONSOLE_INFORMATION Console = ScreenInfo->Console;
  111. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  112. FE_FillRectangle(Fill, ScreenInfo, TargetRect);
  113. else
  114. SB_FillRectangle(Fill, ScreenInfo, TargetRect);
  115. }
  116. ULONG
  117. DoWriteConsole(
  118. IN OUT PCSR_API_MSG m,
  119. IN PCONSOLE_INFORMATION Console,
  120. IN PCSR_THREAD Thread
  121. )
  122. {
  123. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  124. return FE_DoWriteConsole(m,Console,Thread);
  125. else
  126. return SB_DoWriteConsole(m,Console,Thread);
  127. }
  128. NTSTATUS
  129. WriteChars(
  130. IN PSCREEN_INFORMATION ScreenInfo,
  131. IN PWCHAR lpBufferBackupLimit,
  132. IN PWCHAR lpBuffer,
  133. IN PWCHAR lpRealUnicodeString,
  134. IN OUT PDWORD NumBytes,
  135. OUT PLONG NumSpaces OPTIONAL,
  136. IN SHORT OriginalXPosition,
  137. IN DWORD dwFlags,
  138. OUT PSHORT ScrollY OPTIONAL
  139. )
  140. {
  141. PCONSOLE_INFORMATION Console = ScreenInfo->Console;
  142. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  143. return FE_WriteChars(ScreenInfo,lpBufferBackupLimit,lpBuffer,lpRealUnicodeString,NumBytes,NumSpaces,OriginalXPosition,dwFlags,ScrollY);
  144. else
  145. return SB_WriteChars(ScreenInfo,lpBufferBackupLimit,lpBuffer,lpRealUnicodeString,NumBytes,NumSpaces,OriginalXPosition,dwFlags,ScrollY);
  146. }
  147. NTSTATUS
  148. AdjustCursorPosition(
  149. IN PSCREEN_INFORMATION ScreenInfo,
  150. IN COORD CursorPosition,
  151. IN BOOL KeepCursorVisible,
  152. OUT PSHORT ScrollY OPTIONAL
  153. )
  154. {
  155. PCONSOLE_INFORMATION Console = ScreenInfo->Console;
  156. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  157. return FE_AdjustCursorPosition(ScreenInfo, CursorPosition, KeepCursorVisible, ScrollY);
  158. else
  159. return SB_AdjustCursorPosition(ScreenInfo, CursorPosition, KeepCursorVisible, ScrollY);
  160. }
  161. NTSTATUS
  162. TranslateOutputToAnsiUnicode(
  163. IN PCONSOLE_INFORMATION Console,
  164. IN OUT PCHAR_INFO OutputBuffer,
  165. IN COORD Size,
  166. IN OUT PCHAR_INFO OutputBufferR
  167. )
  168. {
  169. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  170. return FE_TranslateOutputToAnsiUnicode(Console,OutputBuffer,Size,OutputBufferR);
  171. else
  172. return SB_TranslateOutputToAnsiUnicode(Console,OutputBuffer,Size);
  173. }
  174. NTSTATUS
  175. TranslateOutputToUnicode(
  176. IN PCONSOLE_INFORMATION Console,
  177. IN OUT PCHAR_INFO OutputBuffer,
  178. IN COORD Size)
  179. {
  180. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  181. return FE_TranslateOutputToUnicode(Console,OutputBuffer,Size);
  182. else
  183. return SB_TranslateOutputToUnicode(Console,OutputBuffer,Size);
  184. }
  185. NTSTATUS
  186. TranslateOutputToOemUnicode(
  187. IN PCONSOLE_INFORMATION Console,
  188. IN OUT PCHAR_INFO OutputBuffer,
  189. IN COORD Size,
  190. IN BOOL fRemoveDbcsMark
  191. )
  192. {
  193. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  194. return FE_TranslateOutputToOemUnicode(Console,OutputBuffer,Size,fRemoveDbcsMark);
  195. else
  196. return SB_TranslateOutputToOemUnicode(Console,OutputBuffer,Size);
  197. }
  198. NTSTATUS
  199. TranslateOutputToOem(
  200. IN PCONSOLE_INFORMATION Console,
  201. IN OUT PCHAR_INFO OutputBuffer,
  202. IN COORD Size
  203. )
  204. {
  205. if (CONSOLE_IS_DBCS_OUTPUTCP(Console))
  206. return FE_TranslateOutputToOem(Console,OutputBuffer,Size);
  207. else
  208. return SB_TranslateOutputToOem(Console,OutputBuffer,Size);
  209. }
  210. ULONG
  211. TranslateInputToUnicode(
  212. IN PCONSOLE_INFORMATION Console,
  213. IN OUT PINPUT_RECORD InputRecords,
  214. IN ULONG NumRecords,
  215. IN OUT PINPUT_RECORD DBCSLeadByte
  216. )
  217. {
  218. if (CONSOLE_IS_DBCS_CP(Console))
  219. return FE_TranslateInputToUnicode(Console,InputRecords,NumRecords,DBCSLeadByte);
  220. else
  221. return SB_TranslateInputToUnicode(Console,InputRecords,NumRecords);
  222. }
  223. ULONG
  224. TranslateInputToOem(
  225. IN PCONSOLE_INFORMATION Console,
  226. IN OUT PINPUT_RECORD InputRecords,
  227. IN ULONG NumRecords, // in : ASCII byte count
  228. IN ULONG UnicodeLength, // in : Number of events (char count)
  229. OUT PINPUT_RECORD DbcsLeadInpRec
  230. )
  231. {
  232. if (CONSOLE_IS_DBCS_CP(Console))
  233. return FE_TranslateInputToOem(Console,InputRecords,NumRecords,UnicodeLength,DbcsLeadInpRec);
  234. else
  235. return SB_TranslateInputToOem(Console,InputRecords,NumRecords);
  236. }
  237. WCHAR
  238. CharToWchar(
  239. IN PCONSOLE_INFORMATION Console,
  240. IN UINT Codepage,
  241. IN char *Ch
  242. )
  243. {
  244. WCHAR wc;
  245. if (CONSOLE_IS_DBCS_CP(Console))
  246. {
  247. if (IsDBCSLeadByteConsole(*Ch, &Console->OutputCPInfo))
  248. {
  249. ConvertOutputToUnicode(Console->OutputCP,
  250. Ch,
  251. 2,
  252. &wc,
  253. 1);
  254. }
  255. else
  256. {
  257. ConvertOutputToUnicode(Console->OutputCP,
  258. Ch,
  259. 1,
  260. &wc,
  261. 1);
  262. }
  263. }
  264. else
  265. {
  266. wc = SB_CharToWchar(Codepage, *Ch);
  267. }
  268. return wc;
  269. }
  270. #ifdef i386
  271. VOID
  272. WriteRegionToScreenHW(
  273. IN PSCREEN_INFORMATION ScreenInfo,
  274. IN PSMALL_RECT Region
  275. )
  276. {
  277. if (CONSOLE_IS_DBCS_OUTPUTCP(ScreenInfo->Console))
  278. FE_WriteRegionToScreenHW(ScreenInfo,Region);
  279. else
  280. SB_WriteRegionToScreenHW(ScreenInfo,Region);
  281. }
  282. #endif
  283. #endif