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.

548 lines
13 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. spddjpn.c
  5. Abstract:
  6. Top-level file for single-byte character set locales support
  7. module for text mode setup.
  8. Author:
  9. Ted Miller (tedm) 04-July-1995
  10. Revision History:
  11. --*/
  12. #include "spprecmp.h"
  13. #pragma hdrstop
  14. #include <hdlsterm.h>
  15. //
  16. // Mapping from line char enum to unicode characters.
  17. //
  18. WCHAR LineCharIndexToUnicodeValue[LineCharMax] =
  19. { 0x2554, // DoubleUpperLeft
  20. 0x2557, // DoubleUpperRight
  21. 0x255a, // DoubleLowerLeft
  22. 0x255d, // DoubleLowerRight
  23. 0x2550, // DoubleHorizontal
  24. 0x2551, // DoubleVertical
  25. 0x250c, // SingleUpperLeft
  26. 0x2510, // SingleUpperRight
  27. 0x2514, // SingleLowerLeft
  28. 0x2518, // SingleLowerRight
  29. 0x2500, // SingleHorizontal
  30. 0x2502, // SingleVertical
  31. 0x255f, // DoubleVerticalToSingleHorizontalRight,
  32. 0x2562 // DoubleVerticalToSingleHorizontalLeft,
  33. };
  34. ULONG
  35. DriverEntry(
  36. IN PDRIVER_OBJECT DriverObject,
  37. IN PUNICODE_STRING RegistryPath
  38. )
  39. /*++
  40. Routine Description:
  41. This routine initializes the language-specific portion of
  42. the setup device driver.
  43. Arguments:
  44. DriverObject - Pointer to driver object created by system.
  45. RegistryPath - Pointer to the Unicode name of the registry path
  46. for this driver.
  47. Return Value:
  48. The function value is the final status from the initialization operation.
  49. --*/
  50. {
  51. UNREFERENCED_PARAMETER(DriverObject);
  52. UNREFERENCED_PARAMETER(RegistryPath);
  53. //
  54. // We don't do too much here.
  55. //
  56. return(STATUS_SUCCESS);
  57. }
  58. NTSTATUS
  59. SplangInitializeFontSupport(
  60. IN PCWSTR BootDevicePath,
  61. IN PCWSTR DirectoryOnBootDevice,
  62. IN PVOID BootFontImage OPTIONAL,
  63. IN ULONG BootFontImageLength OPTIONAL
  64. )
  65. /*++
  66. Routine Description:
  67. This routine is called by setupdd.sys to allow the language-specific
  68. font support to be initialized. The language-specific driver should
  69. load any font it requires and perform any additioanl initialization.
  70. Arguments:
  71. BootDevicePath - supplies the path of the device from which the system
  72. booted. This is a full NT-style device path.
  73. DirectoryOnBootDevice - supplies directory relative to root of boot
  74. device.
  75. BootFontImage - Bootfont.bin file memory image passed by the loader
  76. BootFontImageLength - Length of the BootFontImage buffer
  77. Return Value:
  78. NT Status code indicating outcome. If this routine returns a non-success
  79. status code, then setupdd.sys will not switch into non-US character mode.
  80. The implementation of this routine is free to call SpBugCheck or otherwise
  81. inform the user of any errors if it wishes to halt setup if font
  82. initialization fails.
  83. --*/
  84. {
  85. //
  86. // For SBCS locales we don't do anything other than what the main
  87. // setup module offers. Return failure indicating that we have no
  88. // special video or font requirements.
  89. //
  90. UNREFERENCED_PARAMETER(BootDevicePath);
  91. UNREFERENCED_PARAMETER(DirectoryOnBootDevice);
  92. UNREFERENCED_PARAMETER(BootFontImage);
  93. UNREFERENCED_PARAMETER(BootFontImageLength);
  94. return(STATUS_UNSUCCESSFUL);
  95. }
  96. NTSTATUS
  97. SplangTerminateFontSupport(
  98. VOID
  99. )
  100. /*++
  101. Routine Description:
  102. This routine may be called in certain conditions to cause font support
  103. for a particular language to be terminated. The implementation should
  104. clean up any resources allocated during SplangInitializeFontSupport().
  105. Arguments:
  106. None.
  107. Return Value:
  108. NT Status code indicating outcome.
  109. --*/
  110. {
  111. //
  112. // Never initialized anything so nothing to do.
  113. //
  114. return(STATUS_SUCCESS);
  115. }
  116. PVIDEO_FUNCTION_VECTOR
  117. SplangGetVideoFunctionVector(
  118. IN SpVideoType VideoType,
  119. IN PSP_VIDEO_VARS VideoVariableBlock
  120. )
  121. /*++
  122. Routine Description:
  123. This routine is called by setupdd.sys upon successful return from
  124. SplangInitializeFontSupport, to request a pointer to a vector of
  125. language-specific display support routines for a given display
  126. type (vga or frame buffer).
  127. Arguments:
  128. VideoType - a value from the SpVideoType enum indicating which display
  129. vector is requested. Currently one of SpVideoVga or SpVideoFrameBuffer.
  130. VideoVariableBlock - supplies a pointer to a block of video variables that
  131. are shared between the high-level code in setup\textmode\spvideo.c and
  132. the display-specific code.
  133. Return Value:
  134. Pointer to the language-specific video functions vector to use for
  135. displaying text. NULL if the requested type is not supported. In this case
  136. the display will not be switched into non-US character mode.
  137. --*/
  138. {
  139. //
  140. // Single-byte locales have no special video requirements.
  141. //
  142. return(NULL);
  143. }
  144. ULONG
  145. SplangGetColumnCount(
  146. IN PCWSTR String
  147. )
  148. /*++
  149. Routine Description:
  150. This routine is called by setupdd.sys to determine how many columns
  151. on the screen a particular string will occupy. This may be different
  152. than the number of characters in the string due to full/half width
  153. characters in the character set, etc. Full width chars occupy two columns
  154. whereas half-width chars occupy one column. If the font in use is
  155. fixed-pitch or does not support DBCS, the number of columns is by
  156. definition equal to the number of characters in the string.
  157. Arguments:
  158. String - points to unicode string whose width in columns is desired.
  159. Return Value:
  160. Number of columns occupied by the string.
  161. --*/
  162. {
  163. //
  164. // For sbcs locales the column count is equal to the number of
  165. // characters in the string.
  166. //
  167. return(wcslen(String));
  168. }
  169. PWSTR
  170. SplangPadString(
  171. IN int Size,
  172. IN PCWSTR String
  173. )
  174. /*++
  175. Routine Description:
  176. This routine is called by setupdd.sys to generate a padded string
  177. appropriate for SBCS or DBCS as appropriate.
  178. Arguments:
  179. Size - specifies the length to which to pad the string.
  180. String - points to unicode string that needs to be padded.
  181. Return Value:
  182. Pointer to padded string. Note that this is a static buffer and thus
  183. the caller must duplicate the string if it is needed across multiple
  184. calls to this routine.
  185. --*/
  186. {
  187. //
  188. // Nothing special is done for SBCS locales. Assume the string is
  189. // padded correctly already.
  190. //
  191. UNREFERENCED_PARAMETER(Size);
  192. return((PWSTR)String);
  193. }
  194. VOID
  195. SplangSelectKeyboard(
  196. IN BOOLEAN UnattendedMode,
  197. IN PVOID UnattendedSifHandle,
  198. IN ENUMUPGRADETYPE NTUpgrade,
  199. IN PVOID SifHandle,
  200. IN PHARDWARE_COMPONENT *HwComponents
  201. )
  202. /*++
  203. Routine Description:
  204. This routine is called by setupdd.sys to allow language-specific processing
  205. for the keyboard selection. The implementation can confirm a keyboard
  206. type at this time.
  207. Arguments:
  208. UnattendedMode - supplies a flag indicating whether we are running in
  209. unattended mode. If so, the implementation may wish to do nothing,
  210. since the user will not be entering any paths.
  211. SifHandle - supplies handle to open setup information file (txtsetup.sif).
  212. HwComponents - supplies the address of the master hardware components
  213. array.
  214. Return Value:
  215. None. If a failure occurs, it is up to the implementation to decide whether
  216. to continue or to SpBugCheck.
  217. --*/
  218. {
  219. //
  220. // Nothing to do for SBCS locales.
  221. //
  222. UNREFERENCED_PARAMETER(UnattendedMode);
  223. UNREFERENCED_PARAMETER(UnattendedSifHandle);
  224. UNREFERENCED_PARAMETER(NTUpgrade);
  225. UNREFERENCED_PARAMETER(SifHandle);
  226. UNREFERENCED_PARAMETER(HwComponents);
  227. }
  228. VOID
  229. SplangReinitializeKeyboard(
  230. IN BOOLEAN UnattendedMode,
  231. IN PVOID SifHandle,
  232. IN PWSTR Directory,
  233. OUT PVOID *KeyboardVector,
  234. IN PHARDWARE_COMPONENT *HwComponents
  235. )
  236. /*++
  237. Routine Description:
  238. This routine is called by setupdd.sys to allow language-specific processing
  239. for the keyboard. The implementation can reinitialize the keyboard layout
  240. at this time.
  241. This routine will be called before the user is asked to enter any paths
  242. or other text that includes typing anything other than keys such as
  243. ENTER, function keys, backspace, escape, etc.
  244. Arguments:
  245. UnattendedMode - supplies a flag indicating whether we are running in
  246. unattended mode. If so, the implementation may wish to do nothing,
  247. since the user will not be entering any paths.
  248. SifHandle - supplies handle to open setup information file (txtsetup.sif).
  249. Directory - supplies the directory on the boot device from which the
  250. new layout dll is to be loaded.
  251. KeyboardVector - supplies the address of a pointer to the keyboard
  252. vector table. The implementation should overwrite this value with
  253. whatever is returned from SpLoadKbdLayoutDll().
  254. HwComponents - supplies the address of the master hardware components
  255. array.
  256. Return Value:
  257. None. If a failure occurs the implementation must leave the currently active
  258. keybaord in place.
  259. --*/
  260. {
  261. //
  262. // Nothing to do for SBCS locales.
  263. //
  264. UNREFERENCED_PARAMETER(UnattendedMode);
  265. UNREFERENCED_PARAMETER(SifHandle);
  266. UNREFERENCED_PARAMETER(Directory);
  267. UNREFERENCED_PARAMETER(KeyboardVector);
  268. UNREFERENCED_PARAMETER(HwComponents);
  269. }
  270. WCHAR
  271. SplangGetLineDrawChar(
  272. IN LineCharIndex WhichChar
  273. )
  274. /*++
  275. Routine Description:
  276. This routine is called by setupdd.sys to retreive the unicode value for
  277. a particular line drawing character. An implementation must make these
  278. characters available in the character set somehow.
  279. Arguments:
  280. WhichChar - supplies the index of the character desired.
  281. Return Value:
  282. Unicode value for the character in question. Because the character
  283. will be displayed using the language-specific module, the implementation
  284. can materialize this character by playing whatever tricks it needs to,
  285. such as overlaying a hardcoded glyph into the character set, etc.
  286. --*/
  287. {
  288. ASSERT((ULONG)WhichChar < (ULONG)LineCharMax);
  289. return( ((ULONG)WhichChar < (ULONG)LineCharMax)
  290. ? LineCharIndexToUnicodeValue[WhichChar] : L' '
  291. );
  292. }
  293. WCHAR
  294. SplangGetCursorChar(
  295. VOID
  296. )
  297. /*++
  298. Routine Description:
  299. This routine is called by setupdd.sys to retreive the unicode value
  300. of a character to be used as the cursor when the user is asked to
  301. enter text.
  302. Arguments:
  303. None.
  304. Return Value:
  305. Unicode value for the character to be used as the cursor.
  306. --*/
  307. {
  308. HEADLESS_CMD_ENABLE_TERMINAL Command;
  309. NTSTATUS Status;
  310. Command.Enable = TRUE;
  311. Status = HeadlessDispatch(HeadlessCmdEnableTerminal,
  312. &Command,
  313. sizeof(HEADLESS_CMD_ENABLE_TERMINAL),
  314. NULL,
  315. NULL
  316. );
  317. if (NT_SUCCESS(Status)) {
  318. return(L'_');
  319. }
  320. //
  321. // Lower half-block character (oem char #220 in cp 437)
  322. //
  323. return(0x2584);
  324. }
  325. NTSTATUS
  326. SplangSetRegistryData(
  327. IN PVOID SifHandle,
  328. IN HANDLE ControlSetKeyHandle,
  329. IN PHARDWARE_COMPONENT *HwComponents,
  330. IN BOOLEAN Upgrade
  331. )
  332. /*++
  333. Routine Description:
  334. This routine is called by setupdd.sys to cause language-specific
  335. information to be written into the current control set in the registry.
  336. Arguments:
  337. SifHandle - supplies a handle to the open setup information file
  338. (txtsetup.sif).
  339. ControlSetKeyHandle - supplies a handle to the current control set
  340. root in the registry (ie, HKEY_LOCAL_MACHINE\CurrentControlSet).
  341. HwComponents - supplies the address of the master hardware components
  342. array.
  343. Return Value:
  344. NT Status value indicating outcome. A non-success status is considered
  345. critical and causes Setup to abort.
  346. --*/
  347. {
  348. //
  349. // Nothing to do for SBCS locales.
  350. //
  351. UNREFERENCED_PARAMETER(SifHandle);
  352. UNREFERENCED_PARAMETER(ControlSetKeyHandle);
  353. UNREFERENCED_PARAMETER(HwComponents);
  354. UNREFERENCED_PARAMETER(Upgrade);
  355. return(STATUS_SUCCESS);
  356. }
  357. BOOLEAN
  358. SplangQueryMinimizeExtraSpacing(
  359. VOID
  360. )
  361. /*++
  362. Routine Description:
  363. This routine is called by setupdd.sys to determine whether to
  364. eliminate uses of extra spacing on the screen to set off things
  365. like menus and lists from text. Languages whose text takes up
  366. a lot of room on the screen might opt to eliminate such spacing
  367. to allow menus to display more than a couple of items at a time, etc.
  368. The return value affects numerous screens, such as the partition menu,
  369. upgrade lists, etc.
  370. Arguments:
  371. None.
  372. Return Value:
  373. Boolean value indicating whether the implementation wants unnecessary
  374. spaces eliminated when text, menu, etc, are displayed.
  375. --*/
  376. {
  377. //
  378. // For SBCS locales we want standard spacing.
  379. //
  380. return(FALSE);
  381. }