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.

619 lines
15 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. spddfe.c
  5. Abstract:
  6. Top-level file for FarEast-specific language support
  7. module for text mode setup.
  8. Author:
  9. Ted Miller (tedm) 04-July-1995
  10. Revision History:
  11. --*/
  12. #include <precomp.h>
  13. #pragma hdrstop
  14. //
  15. // String contant.
  16. //
  17. PWSTR szKeyboard = L"Keyboard";
  18. PWSTR szKeyboardLayout = L"Keyboard Layout";
  19. PWSTR szNLSSection = L"nls";
  20. PWSTR szAnsiCodePage = L"AnsiCodepage";
  21. PWSTR szJapanese = L"932";
  22. PWSTR szKorean = L"949";
  23. PWSTR szJapaneseIME_NT3x = L"MSIME95.IME";
  24. PWSTR szJapaneseIME_NT40 = L"MSIME97.IME";
  25. PWSTR szKoreanIME_NT3x = L"MSIME95.IME";
  26. PWSTR szKoreanIME_NT40 = L"MSIME95K.IME";
  27. ULONG
  28. DriverEntry(
  29. IN PDRIVER_OBJECT DriverObject,
  30. IN PUNICODE_STRING RegistryPath
  31. )
  32. /*++
  33. Routine Description:
  34. This routine initializes the language-specific portion of
  35. the setup device driver.
  36. Arguments:
  37. DriverObject - Pointer to driver object created by system.
  38. RegistryPath - Pointer to the Unicode name of the registry path
  39. for this driver.
  40. Return Value:
  41. The function value is the final status from the initialization operation.
  42. --*/
  43. {
  44. UNREFERENCED_PARAMETER(DriverObject);
  45. UNREFERENCED_PARAMETER(RegistryPath);
  46. //
  47. // We don't do too much here.
  48. //
  49. return(STATUS_SUCCESS);
  50. }
  51. NTSTATUS
  52. SplangInitializeFontSupport(
  53. IN PCWSTR BootDevicePath,
  54. IN PCWSTR DirectoryOnBootDevice,
  55. IN PVOID BootFontImage OPTIONAL,
  56. IN ULONG BootFontImageLength OPTIONAL
  57. )
  58. /*++
  59. Routine Description:
  60. This routine is called by setupdd.sys to allow the language-specific
  61. font support to be initialized. The language-specific driver should
  62. load any font it requires and perform any additioanl initialization.
  63. Arguments:
  64. BootDevicePath - supplies the path of the device from which the system
  65. booted. This is a full NT-style device path.
  66. DirectoryOnBootDevice - supplies directory relative to root of boot
  67. device.
  68. BootFontImage - Bootfont.bin file memory image passed by the loader
  69. BootFontImageLength - Length of the BootFontImage buffer
  70. Return Value:
  71. NT Status code indicating outcome. If this routine returns a non-success
  72. status code, then setupdd.sys will not switch into non-US character mode.
  73. The implementation of this routine is free to call SpBugCheck or otherwise
  74. inform the user of any errors if it wishes to halt setup if font
  75. initialization fails.
  76. --*/
  77. {
  78. BOOLEAN b;
  79. b = FEDbcsFontInitGlyphs(
  80. BootDevicePath,
  81. DirectoryOnBootDevice,
  82. BootFontImage,
  83. BootFontImageLength
  84. );
  85. return(b ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL);
  86. }
  87. NTSTATUS
  88. SplangTerminateFontSupport(
  89. VOID
  90. )
  91. /*++
  92. Routine Description:
  93. This routine may be called in certain conditions to cause font support
  94. for a particular language to be terminated. The implementation should
  95. clean up any resources allocated during SplangInitializeFontSupport().
  96. Arguments:
  97. None.
  98. Return Value:
  99. NT Status code indicating outcome.
  100. --*/
  101. {
  102. FEDbcsFontFreeGlyphs();
  103. return(STATUS_SUCCESS);
  104. }
  105. PVIDEO_FUNCTION_VECTOR
  106. SplangGetVideoFunctionVector(
  107. IN SpVideoType VideoType,
  108. IN PSP_VIDEO_VARS VideoVariableBlock
  109. )
  110. /*++
  111. Routine Description:
  112. This routine is called by setupdd.sys upon successful return from
  113. SplangInitializeFontSupport, to request a pointer to a vector of
  114. language-specific display support routines for a given display
  115. type (vga or frame buffer).
  116. Arguments:
  117. VideoType - a value from the SpVideoType enum indicating which display
  118. vector is requested. Currently one of SpVideoVga or SpVideoFrameBuffer.
  119. VideoVariableBlock - supplies a pointer to a block of video variables that
  120. are shared between the high-level code in setup\textmode\spvideo.c and
  121. the display-specific code.
  122. Return Value:
  123. Pointer to the language-specific video functions vector to use for
  124. displaying text. NULL if the requested type is not supported. In this case
  125. the display will not be switched into non-US character mode.
  126. --*/
  127. {
  128. VideoVariables = VideoVariableBlock;
  129. switch(VideoType) {
  130. case SpVideoVga:
  131. KdPrint(("SETUP:SpVideoVgaMode\n"));
  132. return(&VgaGraphicsModeVideoVector);
  133. case SpVideoFrameBuffer:
  134. KdPrint(("SETUP:SpVideoFrameBufferMode\n"));
  135. return(&FrameBufferKanjiVideoVector);
  136. default:
  137. return(NULL);
  138. }
  139. }
  140. ULONG
  141. SplangGetColumnCount(
  142. IN PCWSTR String
  143. )
  144. /*++
  145. Routine Description:
  146. This routine is called by setupdd.sys to determine how many columns
  147. on the screen a particular string will occupy. This may be different
  148. than the number of characters in the string due to full/half width
  149. characters in the character set, etc. Full width chars occupy two columns
  150. whereas half-width chars occupy one column. If the font in use is
  151. fixed-pitch or does not support DBCS, the number of columns is by
  152. definition equal to the number of characters in the string.
  153. Arguments:
  154. String - points to unicode string whose width in columns is desired.
  155. Return Value:
  156. Number of columns occupied by the string.
  157. --*/
  158. {
  159. return(FEGetStringColCount(String));
  160. }
  161. PWSTR
  162. SplangPadString(
  163. IN int Size,
  164. IN PCWSTR String
  165. )
  166. /*++
  167. Routine Description:
  168. This routine is called by setupdd.sys to generate a padded string
  169. appropriate for SBCS or DBCS as appropriate.
  170. Arguments:
  171. Size - specifies the length to which to pad the string.
  172. String - points to unicode string that needs to be padded.
  173. Return Value:
  174. Pointer to padded string. Note that this is a static buffer and thus
  175. the caller must duplicate the string if it is needed across multiple
  176. calls to this routine.
  177. --*/
  178. {
  179. return(FEPadString(Size,String));
  180. }
  181. VOID
  182. SplangSelectKeyboard(
  183. IN BOOLEAN UnattendedMode,
  184. IN PVOID UnattendedSifHandle,
  185. IN ENUMUPGRADETYPE NTUpgrade,
  186. IN PVOID SifHandle,
  187. IN PHARDWARE_COMPONENT *HwComponents
  188. )
  189. /*++
  190. Routine Description:
  191. This routine is called by setupdd.sys to allow language-specific processing
  192. for the keyboard selection. The implementation can confirm a keyboard
  193. type at this time.
  194. Arguments:
  195. UnattendedMode - supplies a flag indicating whether we are running in
  196. unattended mode. If so, the implementation may wish to do nothing,
  197. since the user will not be entering any paths.
  198. SifHandle - supplies handle to open setup information file (txtsetup.sif).
  199. HwComponents - supplies the address of the master hardware components
  200. array.
  201. Return Value:
  202. None. If a failure occurs, it is up to the implementation to decide whether
  203. to continue or to SpBugCheck.
  204. --*/
  205. {
  206. BOOLEAN SelectKeyboard = FALSE;
  207. BOOLEAN NoEasySelection = FALSE;
  208. #ifdef _X86_ //NEC98
  209. //
  210. // Keyborad selection is not necessary on NEC98
  211. //
  212. if (!IsNEC_98) {
  213. #endif //NEC98
  214. if(IS_JAPANESE_VERSION(SifHandle)) {
  215. SelectKeyboard = TRUE;
  216. } else if(IS_KOREAN_VERSION(SifHandle)) {
  217. SelectKeyboard = TRUE;
  218. NoEasySelection = TRUE;
  219. }
  220. #ifdef _X86_ //NEC98
  221. }
  222. #endif //NEC98
  223. if(SelectKeyboard) {
  224. if(!UnattendedMode) {
  225. FESelectKeyboard(SifHandle,HwComponents,NoEasySelection,(BOOLEAN) (NTUpgrade == 0xFF));
  226. } else if(NTUpgrade != UpgradeFull) {
  227. FEUnattendSelectKeyboard(UnattendedSifHandle,SifHandle,HwComponents);
  228. }
  229. }
  230. }
  231. VOID
  232. SplangReinitializeKeyboard(
  233. IN BOOLEAN UnattendedMode,
  234. IN PVOID SifHandle,
  235. IN PWSTR Directory,
  236. OUT PVOID *KeyboardVector,
  237. IN PHARDWARE_COMPONENT *HwComponents
  238. )
  239. /*++
  240. Routine Description:
  241. This routine is called by setupdd.sys to allow language-specific processing
  242. for the keyboard. The implementation can reinitialize the keyboard layout
  243. at this time.
  244. This routine will be called before the user is asked to enter any paths
  245. or other text that includes typing anything other than keys such as
  246. ENTER, function keys, backspace, escape, etc.
  247. Arguments:
  248. UnattendedMode - supplies a flag indicating whether we are running in
  249. unattended mode. If so, the implementation may wish to do nothing,
  250. since the user will not be entering any paths.
  251. SifHandle - supplies handle to open setup information file (txtsetup.sif).
  252. Directory - supplies the directory on the boot device from which the
  253. new layout dll is to be loaded.
  254. KeyboardVector - supplies the address of a pointer to the keyboard
  255. vector table. The implementation should overwrite this value with
  256. whatever is returned from SpLoadKbdLayoutDll().
  257. HwComponents - supplies the address of the master hardware components
  258. array.
  259. Return Value:
  260. None. If a failure occurs the implementation must leave the currently active
  261. keybaord in place.
  262. --*/
  263. {
  264. PWSTR KeyboardLayoutDefault = NULL;
  265. BOOLEAN ReloadKeyboard = FALSE;
  266. if(!UnattendedMode) {
  267. if(IS_JAPANESE_VERSION(SifHandle)) {
  268. ReloadKeyboard = TRUE;
  269. KeyboardLayoutDefault = L"KBDJPN.DLL";
  270. } else if(IS_KOREAN_VERSION(SifHandle)) {
  271. ReloadKeyboard = TRUE;
  272. KeyboardLayoutDefault = L"KBDKOR.DLL";
  273. }
  274. if(ReloadKeyboard) {
  275. FEReinitializeKeyboard(SifHandle,Directory,KeyboardVector,HwComponents,KeyboardLayoutDefault);
  276. }
  277. }
  278. }
  279. WCHAR
  280. SplangGetLineDrawChar(
  281. IN LineCharIndex WhichChar
  282. )
  283. /*++
  284. Routine Description:
  285. This routine is called by setupdd.sys to retreive the unicode value for
  286. a particular line drawing character. An implementation must make these
  287. characters available in the character set somehow.
  288. Arguments:
  289. WhichChar - supplies the index of the character desired.
  290. Return Value:
  291. Unicode value for the character in question. Because the character
  292. will be displayed using the language-specific module, the implementation
  293. can materialize this character by playing whatever tricks it needs to,
  294. such as overlaying a hardcoded glyph into the character set, etc.
  295. --*/
  296. {
  297. return(FEGetLineDrawChar(WhichChar));
  298. }
  299. WCHAR
  300. SplangGetCursorChar(
  301. VOID
  302. )
  303. /*++
  304. Routine Description:
  305. This routine is called by setupdd.sys to retreive the unicode value
  306. of a character to be used as the cursor when the user is asked to
  307. enter text.
  308. Arguments:
  309. None.
  310. Return Value:
  311. Unicode value for the character to be used as the cursor.
  312. --*/
  313. {
  314. //
  315. // For FarEast version, we use the underscore character.
  316. // The half-block character used in the US build is not present
  317. // in the FarEast font.
  318. //
  319. return(L'_');
  320. }
  321. NTSTATUS
  322. SplangSetRegistryData(
  323. IN PVOID SifHandle,
  324. IN HANDLE ControlSetKeyHandle,
  325. IN PHARDWARE_COMPONENT *HwComponents,
  326. IN BOOLEAN Upgrade
  327. )
  328. /*++
  329. Routine Description:
  330. This routine is called by setupdd.sys to cause language-specific
  331. information to be written into the current control set in the registry.
  332. Arguments:
  333. SifHandle - supplies a handle to the open setup information file
  334. (txtsetup.sif).
  335. ControlSetKeyHandle - supplies a handle to the current control set
  336. root in the registry (ie, HKEY_LOCAL_MACHINE\CurrentControlSet).
  337. HwComponents - supplies the address of the master hardware components
  338. array.
  339. Return Value:
  340. NT Status value indicating outcome. A non-success status is considered
  341. critical and causes Setup to abort.
  342. --*/
  343. {
  344. BOOLEAN SaveParameter = FALSE;
  345. BOOLEAN UpgradeKeyboardLayout = FALSE;
  346. NTSTATUS Status;
  347. PWSTR UpgradeIMEFrom = NULL;
  348. PWSTR UpgradeIMETo = NULL;
  349. PWSTR UpgradeIMEText = NULL;
  350. WCHAR LayoutDriver[20] = L"";
  351. if(IS_JAPANESE_VERSION(SifHandle)) {
  352. //
  353. // For Japanese version.
  354. //
  355. SaveParameter = TRUE;
  356. //
  357. // Upgrade IME stuff, (if upgrade).
  358. //
  359. UpgradeKeyboardLayout = TRUE;
  360. //
  361. // Set Upgrade IME name.
  362. //
  363. UpgradeIMEFrom = szJapaneseIME_NT3x;
  364. UpgradeIMETo = szJapaneseIME_NT40;
  365. //
  366. // Get default layout text name from INF.
  367. //
  368. UpgradeIMEText = SpGetSectionKeyIndex(SifHandle,szKeyboardLayout,L"E0010411",0);
  369. wcscpy(LayoutDriver,L"LayerDriver JPN");
  370. } else if(IS_KOREAN_VERSION(SifHandle)) {
  371. //
  372. // For Korean version.
  373. //
  374. SaveParameter = TRUE;
  375. //
  376. // Upgrade IME stuff, (if upgrade).
  377. //
  378. UpgradeKeyboardLayout = TRUE;
  379. //
  380. // Set Upgrade IME name.
  381. //
  382. UpgradeIMEFrom = szKoreanIME_NT3x;
  383. UpgradeIMETo = szKoreanIME_NT40;
  384. wcscpy(LayoutDriver,L"LayerDriver KOR");
  385. }
  386. if(IS_JAPANESE_VERSION(SifHandle) && Upgrade) {
  387. Status = FEUpgradeRemoveMO(ControlSetKeyHandle);
  388. }
  389. if(SaveParameter) {
  390. if (Upgrade) {
  391. //
  392. // Upgrade keyboard parameters.
  393. //
  394. Status = FEUpgradeKeyboardParams(SifHandle,ControlSetKeyHandle,HwComponents,LayoutDriver);
  395. if (UpgradeKeyboardLayout) {
  396. //
  397. // Upgrade keyboard layout (HKLM\SYSTEM\CurrentControlSet\Control\KeyboardLayouts)
  398. //
  399. Status = FEUpgradeKeyboardLayout(
  400. ControlSetKeyHandle,
  401. UpgradeIMEFrom,
  402. UpgradeIMETo,
  403. UpgradeIMEText);
  404. }
  405. return(Status);
  406. } else {
  407. //
  408. // Set up keyboard parameters for extra FarEast keyboard layer.
  409. //
  410. return(FESetKeyboardParams(SifHandle,ControlSetKeyHandle,HwComponents,LayoutDriver));
  411. }
  412. } else {
  413. return(STATUS_SUCCESS);
  414. }
  415. }
  416. BOOLEAN
  417. SplangQueryMinimizeExtraSpacing(
  418. VOID
  419. )
  420. /*++
  421. Routine Description:
  422. This routine is called by setupdd.sys to determine whether to
  423. eliminate uses of extra spacing on the screen to set off things
  424. like menus and lists from text. Languages whose text takes up
  425. a lot of room on the screen might opt to eliminate such spacing
  426. to allow menus to display more than a couple of items at a time, etc.
  427. The return value affects numerous screens, such as the partition menu,
  428. upgrade lists, etc.
  429. Arguments:
  430. None.
  431. Return Value:
  432. Boolean value indicating whether the implementation wants unnecessary
  433. spaces eliminated when text, menu, etc, are displayed.
  434. --*/
  435. {
  436. //
  437. // For FarEast version, we want to minimize spacing because text is pretty big
  438. // in places.
  439. //
  440. return(TRUE);
  441. }