Source code of Windows XP (NT5)
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.

170 lines
3.5 KiB

  1. /*++
  2. *
  3. * WOW v1.0
  4. *
  5. * Copyright (c) 1994, Microsoft Corporation
  6. *
  7. * WWMMAN.C
  8. * WOW32 16-bit WifeMan API support (manually-coded thunks)
  9. *
  10. * History:
  11. * Created 17-May-1994 by hiroh
  12. * Rewrote 12-May-1995 by hideyukn
  13. *
  14. --*/
  15. #include "precomp.h"
  16. #pragma hdrstop
  17. #ifdef FE_SB
  18. #include "wowwife.h"
  19. #include "wwmman.h"
  20. MODNAME(wwmman.c);
  21. STATIC LPSTR SkipSpaces(LPSTR lpch)
  22. {
  23. if (lpch == NULL) return(NULL);
  24. for ( ; ; lpch++ ) {
  25. switch (*lpch) {
  26. case ' ':
  27. case '\t':
  28. case '\r':
  29. case '\n':
  30. break;
  31. case '\0':
  32. // fall through...
  33. default:
  34. return(lpch);
  35. }
  36. }
  37. }
  38. #define EUDC_RANGE_KEY \
  39. (LPSTR) "SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage\\EUDCCodeRange"
  40. ULONG FASTCALL WWM32MiscGetEUDCLeadByteRange(PVDMFRAME pFrame)
  41. {
  42. unsigned short usEUDCRange = 0;
  43. unsigned char chEUDCStart = 0, chEUDCEnd = 0;
  44. HKEY hKey;
  45. ULONG ulRet;
  46. CHAR achACP[10];
  47. CHAR achRange[256];
  48. DWORD dwType;
  49. DWORD dwRangeSize = sizeof(achRange);
  50. UNREFERENCED_PARAMETER(pFrame);
  51. //
  52. // Get EUDC Range
  53. //
  54. // In Win32, We support multiple EUDC Range, but for
  55. // Win16, we just return only first EUDC range to
  56. // keep backward compatibility...
  57. //
  58. ulRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, EUDC_RANGE_KEY,
  59. (DWORD) 0, KEY_QUERY_VALUE, &hKey);
  60. if (ulRet != ERROR_SUCCESS) {
  61. #if DBG
  62. LOGDEBUG(0,("WOW32:RegOpenKeyExA(EUDC_RANGE_KEY) fail\n"));
  63. #endif
  64. return 0;
  65. }
  66. //
  67. // Convert ACP to string..
  68. //
  69. RtlIntegerToChar(GetACP(),10,sizeof(achACP),achACP);
  70. ulRet = RegQueryValueExA(hKey, achACP, (LPDWORD)NULL, (LPDWORD)&dwType,
  71. (LPBYTE)achRange, &dwRangeSize);
  72. if (ulRet != ERROR_SUCCESS) {
  73. #if DBG
  74. LOGDEBUG(0,("WOW32:RegQueryValueExA(CP_ACP) fail\n"));
  75. #endif
  76. RegCloseKey(hKey);
  77. return 0;
  78. }
  79. RegCloseKey(hKey);
  80. //
  81. // Perse the data.
  82. //
  83. {
  84. LPSTR pszData = achRange;
  85. USHORT usStart, usEnd;
  86. pszData = SkipSpaces(pszData);
  87. if ((*pszData) == '\0') {
  88. #if DBG
  89. LOGDEBUG(0,("WOW32:Parse First Data fail\n"));
  90. #endif
  91. return 0;
  92. }
  93. usStart = (USHORT)strtoul(pszData,&pszData,16);
  94. if ((pszData = WOW32_strchr(pszData,'-')) == NULL) {
  95. #if DBG
  96. LOGDEBUG(0,("WOW32:Find End Data fail\n"));
  97. #endif
  98. return 0;
  99. }
  100. //
  101. // Skip '-'..
  102. //
  103. pszData++;
  104. pszData = SkipSpaces(pszData);
  105. if ((*pszData) == '\0') {
  106. #if DBG
  107. LOGDEBUG(0,("WOW32:Parse End Data fail\n"));
  108. #endif
  109. return 0;
  110. }
  111. usEnd = (USHORT)strtoul(pszData,&pszData,16);
  112. //
  113. // Confirm the data sort order is correct
  114. //
  115. if (usStart > usEnd) {
  116. #if DBG
  117. LOGDEBUG(0,("WOW32:Invalid EUDC Range Order\n"));
  118. #endif
  119. return 0;
  120. }
  121. //
  122. // Get EUDC Start, End LeadByte...
  123. //
  124. chEUDCStart = HIBYTE(usStart);
  125. chEUDCEnd = HIBYTE(usEnd);
  126. }
  127. //
  128. // Setup return value.
  129. //
  130. usEUDCRange = ((unsigned short)chEUDCEnd << 8) |
  131. ((unsigned short)chEUDCStart );
  132. #if DBG
  133. LOGDEBUG(10,("WOW32:EUDC Range = %x\n",usEUDCRange));
  134. #endif
  135. RETURN(usEUDCRange);
  136. }
  137. #endif // FE_SB