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.

295 lines
13 KiB

  1. #ifndef _PRIVATE_H_
  2. #define _PRIVATE_H_
  3. #define _OLEAUT32_ // get DECLSPEC_IMPORT stuff right for oleaut32.h, we are defing these
  4. #ifdef STRICT
  5. #undef STRICT
  6. #endif
  7. #define STRICT
  8. #pragma warning(disable:4514) // unreferenced inline function has been removed
  9. #include <windows.h>
  10. #include <ole2.h>
  11. #include <advpub.h>
  12. #include <ccstock.h>
  13. #include <port32.h>
  14. #include <debug.h>
  15. #include <inetreg.h>
  16. #include <mlang.h>
  17. #include <urlmon.h> // for JIT stuff
  18. #include "mimedb.h"
  19. #include "enumcp.h"
  20. #include "resource.h"
  21. #include "shfusion.h"
  22. #include "detect.h" // LCDETECT
  23. #include "font.h"
  24. //
  25. // Function prototypes
  26. //
  27. #if defined(__cplusplus)
  28. extern "C" HRESULT WINAPI ConvertINetReset(void);
  29. #else
  30. HRESULT WINAPI ConvertINetReset(void);
  31. #endif
  32. HRESULT WINAPI ConvertINetStringInIStream(LPDWORD lpdwMode, DWORD dwSrcEncoding, DWORD dwDstEncoding, IStream *pstmIn, IStream *pstmOut, DWORD dwFlag, WCHAR *lpFallBack);
  33. HRESULT WINAPI ConvertINetUnicodeToMultiByteEx(LPDWORD lpdwMode, DWORD dwEncoding, LPCWSTR lpSrcStr, LPINT lpnWideCharCount, LPSTR lpDstStr, LPINT lpnMultiCharCount, DWORD dwFlag, WCHAR *lpFallBack);
  34. HRESULT WINAPI ConvertINetMultiByteToUnicodeEx(LPDWORD lpdwMode, DWORD dwEncoding, LPCSTR lpSrcStr, LPINT lpnMultiCharCount, LPWSTR lpDstStr, LPINT lpnWideCharCount, DWORD dwFlag, WCHAR *lpFallBack);
  35. HRESULT WINAPI _DetectInputCodepage(DWORD dwFlag, DWORD uiPrefWinCodepage, CHAR *pSrcStr, INT *pcSrcSize, DetectEncodingInfo *lpEncoding, INT *pnScoores);
  36. HRESULT WINAPI _DetectCodepageInIStream(DWORD dwFlag, DWORD uiPrefWinCodepage, IStream *pstmIn, DetectEncodingInfo *lpEncoding, INT *pnScoores);
  37. void CMLangFontLink_FreeGlobalObjects(void);
  38. int _LoadStringExW(HMODULE, UINT, LPWSTR, int, WORD);
  39. int _LoadStringExA(HMODULE, UINT, LPSTR, int, WORD);
  40. HRESULT RegularizePosLen(long lStrLen, long* plPos, long* plLen);
  41. HRESULT LocaleToCodePage(LCID locale, UINT* puCodePage);
  42. HRESULT StartEndConnection(IUnknown* const pUnkCPC, const IID* const piid, IUnknown* const pUnkSink, DWORD* const pdwCookie, DWORD dwCookie);
  43. HRESULT RegisterServerInfo(void);
  44. HRESULT UnregisterServerInfo(void);
  45. // Legacy registry MIME DB code, keep it for backward compatiblility
  46. BOOL MimeDatabaseInfo(void);
  47. void DllAddRef(void);
  48. void DllRelease(void);
  49. // JIT langpack stuff
  50. HRESULT InstallIEFeature(HWND hWnd, CLSID *clsid, DWORD dwfIODControl);
  51. HRESULT _GetJITClsIDForCodePage(UINT uiCodePage, CLSID *clsid );
  52. HRESULT _AddFontForCP(UINT uiCP);
  53. HRESULT _ValidateCPInfo(UINT uiCP);
  54. HRESULT _InstallNT5Langpack(HWND hwnd, UINT uiCP);
  55. LANGID GetNT5UILanguage(void);
  56. BOOL _IsValidCodePage(UINT uiCodePage);
  57. BOOL _IsKOI8RU(unsigned char *pStr, int nSize);
  58. HRESULT IsNTLangpackAvailable(UINT uiCodePage);
  59. HRESULT _IsCodePageInstallable(UINT uiCodePage);
  60. // String functions
  61. WCHAR *MLStrCpyNW(WCHAR *strDest, const WCHAR *strSource, int nCount);
  62. WCHAR *MLStrCpyW(WCHAR *strDest, const WCHAR *strSource);
  63. int MLStrCmpIW( const wchar_t *string1, const wchar_t *string2 );
  64. int MLStrCmpI(LPCTSTR pwsz1, LPCTSTR pwsz2);
  65. LPTSTR MLPathCombine(LPTSTR szPath, LPTSTR szPath1, LPTSTR szPath2);
  66. LPTSTR MLStrCpyN(LPTSTR pstrDest, const LPTSTR pstrSource, UINT nCount);
  67. LPTSTR MLStrStr(const LPTSTR Str, const LPTSTR subStr);
  68. DWORD HexToNum(LPTSTR lpsz);
  69. LPTSTR MLStrChr( const TCHAR *string, int c );
  70. BOOL AnsiFromUnicode(LPSTR * ppszAnsi, LPCWSTR pwszWide, LPSTR pszBuf, int cchBuf);
  71. int WINAPI MLStrToIntW(LPCWSTR lpSrc);
  72. int WINAPI MLStrToIntA(LPCSTR lpSrc);
  73. int MLStrCmpNI(LPCTSTR pstr1, LPCTSTR pstr2, int nChar);
  74. int MLStrCmpNIA(LPCSTR lpStr1, LPCSTR lpStr2, int nChar);
  75. int MLStrCmpNIW(LPCWSTR lpStr1, LPCWSTR lpStr2, int nChar);
  76. UINT MLGetWindowsDirectory(LPTSTR lpBuffer, UINT uSize);
  77. int LowAsciiStrCmpNIA(LPCSTR lpstr1, LPCSTR lpstr2, int count);
  78. int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX *lpelf, NEWTEXTMETRICEX *lpntm, int iFontType, LPARAM lParam);
  79. INT_PTR CALLBACK LangpackDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  80. DWORD OutBoundDetectPreScan(LPWSTR lpWideCharStr, UINT cchWideChar, WCHAR *pwszCopy, WCHAR *lpBestFit);
  81. void BuildGlobalObjects(void);
  82. HRESULT GetCharCodePagesEx(WCHAR chSrc, DWORD* pdwCodePages, DWORD dwFlags);
  83. HRESULT GetStrCodePagesEx(const WCHAR* pszSrc, long cchSrc, DWORD dwPriorityCodePages, DWORD* pdwCodePages, long* pcchCodePages, DWORD dwFlags);
  84. HRESULT CodePageToCodePagesEx(UINT uCodePage, DWORD* pdwCodePages, DWORD* pdwCodePagesExt);
  85. HRESULT CodePagesToCodePageEx(DWORD dwCodePages, UINT uDefaultCodePage, UINT* puCodePage, BOOL bCodePagesExt);
  86. BOOL NeedToLoadMLangForOutlook(void);
  87. BOOL MLIsOS(DWORD dwOS);
  88. #ifdef UNICODE
  89. #define MLStrToInt MLStrToIntW
  90. #else
  91. #define MLStrToInt MLStrToIntA
  92. #endif
  93. //
  94. // Globals
  95. //
  96. extern HINSTANCE g_hInst;
  97. extern HINSTANCE g_hUrlMon;
  98. extern UINT g_cRfc1766;
  99. extern PRFC1766INFOA g_pRfc1766Reg;
  100. extern CRITICAL_SECTION g_cs;
  101. extern BOOL g_bIsNT5;
  102. extern BOOL g_bIsNT;
  103. extern BOOL g_bIsWin98;
  104. extern UINT g_uACP;
  105. #ifdef __cplusplus
  106. extern LCDetect * g_pLCDetect; // LCDETECT
  107. #endif // __cplusplus
  108. //
  109. // Macros
  110. //
  111. #ifndef ARRAYSIZE
  112. #define ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
  113. #endif
  114. #define VERIFY(f) AssertE(f)
  115. #define ASSIGN_IF_FAILED(hr, exp) {HRESULT hrTemp = (exp); if (FAILED(hrTemp) && SUCCEEDED(hr)) (hr) = hrTemp;}
  116. #define ASSERT_READ_PTR(p) ASSERT(!::IsBadReadPtr((p), sizeof(*p)))
  117. #define ASSERT_READ_PTR_OR_NULL(p) ASSERT(!(p) || !::IsBadReadPtr((p), sizeof(*p)))
  118. #define ASSERT_WRITE_PTR(p) ASSERT(!::IsBadWritePtr((p), sizeof(*p)))
  119. #define ASSERT_WRITE_PTR_OR_NULL(p) ASSERT(!(p) || !::IsBadWritePtr((p), sizeof(*p)))
  120. #define ASSERT_READ_BLOCK(p,s) ASSERT(!::IsBadReadPtr((p), sizeof(*p) * (s)))
  121. #define ASSERT_READ_BLOCK_OR_NULL(p,s) ASSERT(!(p) || !::IsBadReadPtr((p), sizeof(*p) * (s)))
  122. #define ASSERT_WRITE_BLOCK(p,s) ASSERT(!::IsBadWritePtr((p), sizeof(*p) * (s)))
  123. #define ASSERT_WRITE_BLOCK_OR_NULL(p,s) ASSERT(!(p) || !::IsBadWritePtr((p), sizeof(*p) * (s)))
  124. #define ASSERT_TSTR_PTR(p) ASSERT(!::IsBadStringPtr((p), (UINT)-1))
  125. #define ASSERT_TSTR_PTR_OR_NULL(p) ASSERT(!(p) || !::IsBadStringPtr((p), (UINT)-1))
  126. #define ASSERT_WSTR_PTR(p) ASSERT(!::IsBadStringPtrW((p), (UINT)-1))
  127. #define ASSERT_WSTR_PTR_OR_NULL(p) ASSERT(!(p) || !::IsBadStringPtrW((p), (UINT)-1))
  128. #define ASSERT_STR_PTR(p) ASSERT(!::IsBadStringPtrA((p), (UINT)-1))
  129. #define ASSERT_STR_PTR_OR_NULL(p) ASSERT(!(p) || !::IsBadStringPtrA((p), (UINT)-1))
  130. #define ASSERT_CODE_PTR(p) ASSERT(!::IsBadCodePtr((FARPROC)(p)))
  131. #define ASSERT_CODE_PTR_OR_NULL(p) ASSERT(!(p) || !::IsBadCodePtr((FARPROC)(p)))
  132. #define ASSERT_THIS ASSERT_WRITE_PTR(this)
  133. #ifdef NEWMLSTR
  134. // Error Code
  135. #define FACILITY_MLSTR 0x0A15
  136. #define MLSTR_E_ACCESSDENIED MAKE_HRESULT(1, FACILITY_MLSTR, 2001)
  137. #define MLSTR_E_BUSY MAKE_HRESULT(1, FACILITY_MLSTR, 2002)
  138. #define MLSTR_E_TOOMANYNESTOFLOCK MAKE_HRESULT(1, FACILITY_MLSTR, 1003)
  139. #define MLSTR_E_STRBUFNOTAVAILABLE MAKE_HRESULT(1, FACILITY_MLSTR, 1004)
  140. #define MLSTR_LOCK_TIMELIMIT 100
  141. #define MLSTR_CONF_MAX 0x40000000
  142. #define MAX_LOCK_COUNT 4
  143. #endif
  144. #define BIT_HEADER_CHARSET 0x1
  145. #define BIT_BODY_CHARSET 0x2
  146. #define BIT_WEB_CHARSET 0x4
  147. #define BIT_WEB_FIXED_WIDTH_FONT 0x8
  148. #define BIT_PROPORTIONAL_FONT 0x10
  149. #define BIT_DESCRIPTION 0x20
  150. #define BIT_FAMILY 0x40
  151. #define BIT_LEVEL 0x80
  152. #define BIT_ENCODING 0x100
  153. #define BIT_DEL_HEADER_CHARSET 0x10000
  154. #define BIT_DEL_BODY_CHARSET 0x20000
  155. #define BIT_DEL_WEB_CHARSET 0x40000
  156. #define BIT_DEL_WEB_FIXED_WIDTH_FONT 0x80000
  157. #define BIT_DEL_PROPORTIONAL_FONT 0x100000
  158. #define BIT_DEL_DESCRIPTION 0x200000
  159. #define BIT_DEL_FAMILY 0x400000
  160. #define BIT_DEL_LEVEL 0x800000
  161. #define BIT_DEL_ENCODING 0x1000000
  162. #define BIT_CODEPAGE 0x1
  163. #define BIT_INTERNET_ENCODING 0x2
  164. #define BIT_ALIAS_FOR_CHARSET 0x4
  165. #define CPBITS_WINDOWS 0x1
  166. #define CPBITS_EXTENDED 0x2
  167. #define CPBITS_STRICT 0x4
  168. #define DETECTION_MAX_LEN 20*1024 // Limit max auto-detect length to 20k
  169. #define IS_DIGITA(ch) InRange(ch, '0', '9')
  170. #define IS_DIGITW(ch) InRange(ch, L'0', L'9')
  171. #define IS_CHARA(ch) (InRange(ch, 'a', 'z') && InRange(ch, 'A', 'Z'))
  172. #define IS_NLS_DLL_CP(x) (InRange(x, 57002, 57011) || ((x) == CP_18030))
  173. #define IS_HINDI_CHAR(x) (InRange(x, 0x0900, 0x0DFF) || InRange(x, 0x0F00, 0x10FF))
  174. #define IS_PUA_CHAR(x) (InRange(x, 0xE000, 0xF8FF))
  175. #define IS_CJK_CHAR(x) (InRange(x, 0x3000, 0x9FFF) || InRange(x, 0xAC00, 0xD7A3) || InRange(x, 0xF900, 0xFAFF) || InRange(x, 0xFF00, 0xFFEF))
  176. #define IS_CHS_LEADBYTE(x) (InRange(x, 0x81, 0xFE))
  177. #define IS_KOR_LEADBYTE(x) (InRange(x, 0x81, 0xFE))
  178. // Internal define for K1 Hanja support
  179. // In future version of MLang, we might need to update this bit define if there is a conflict with system define
  180. #define FS_MLANG_K1HANJA 0x10000000L
  181. //
  182. // We support following code pages for outbound encoding detection
  183. // Windows : 1252, 1250, 1251, 1253, 1254, 1257, 1258, 1256, 1255, 874, 932, 949, 950, 936
  184. // Unicode : 65001, 65000, 1200
  185. // ISO : 28591, 28592, 20866, 28595, 28597, 28593, 28594, 28596, 28598, 28605, 28599
  186. // Others : 20127, 50220, 51932, 51949, 50225, 52936
  187. //
  188. // Default priorities
  189. // 20127 > Windows > ISO > Others > Unicode
  190. //
  191. // Internal define of extented code pages
  192. #define FS_MLANG_28591 0x00000001L
  193. #define FS_MLANG_28592 0x00000002L
  194. #define FS_MLANG_28595 0x00000004L
  195. #define FS_MLANG_28597 0x00000008L
  196. #define FS_MLANG_28593 0x00000010L
  197. #define FS_MLANG_28598 0x00000020L
  198. #define FS_MLANG_28596 0x00000040L
  199. #define FS_MLANG_28594 0x00000080L
  200. #define FS_MLANG_28599 0x00000200L
  201. #define FS_MLANG_28605 0x00000400L
  202. #define FS_MLANG_20127 0x00000800L
  203. #define FS_MLANG_50220 0x00001000L
  204. #define FS_MLANG_51932 0x00002000L
  205. #define FS_MLANG_51949 0x00004000L
  206. #define FS_MLANG_50225 0x00008000L
  207. #define FS_MLANG_52936 0x00010000L
  208. #define FS_MLANG_65000 0x00020000L
  209. #define FS_MLANG_65001 0x00040000L
  210. #define FS_MLANG_1200 0x00080000L
  211. #define FS_MLANG_20866 0x00100000L
  212. #define FS_MLANG_21866 0x00200000L
  213. #define FS_MLANG_38598 0x00400000L
  214. #define FS_MLANG_50221 0x00800000L
  215. #define FS_MLANG_50222 0x01000000L
  216. #define FS_CJK 0x00000001L
  217. #define FS_HINDI 0x00000002L
  218. #define FS_PUA 0x00000004L
  219. // Returns TRUE/FALSE depending on question
  220. #define OS_WINDOWS 0 // windows vs. NT
  221. #define OS_NT 1 // windows vs. NT
  222. #define OS_WIN95ORGREATER 2 // Win95 or greater
  223. #define OS_NT4ORGREATER 3 // NT4 or greater
  224. // don't use (used to be OS_NT5) 4 // this flag is redundant w/ OS_WIN2000ORGREATER, use that instead ;internal
  225. #define OS_WIN98ORGREATER 5 // Win98 or greater
  226. #define OS_WIN98_GOLD 6 // Win98 Gold (Version 4.10 build 1998)
  227. #define OS_WIN2000ORGREATER 7 // Some derivative of Win2000
  228. // NOTE: these flags are bogus, they check explicitly for (dwMajorVersion == 5) so they will fail when majorversion is bumped to 6
  229. // !!! DO NOT USE THESE FLAGS !!!
  230. #define OS_WIN2000PRO 8 // Windows 2000 Professional (Workstation)
  231. #define OS_WIN2000SERVER 9 // Windows 2000 Server
  232. #define OS_WIN2000ADVSERVER 10 // Windows 2000 Advanced Server
  233. #define OS_WIN2000DATACENTER 11 // Windows 2000 Data Center Server
  234. #define OS_WIN2000TERMINAL 12 // Windows 2000 Terminal Server in "Application Server" mode (now simply called "Terminal Server")
  235. // END bogus flags
  236. #define OS_EMBEDDED 13 // Embedded Windows Edition
  237. #define OS_TERMINALCLIENT 14 // Windows Terminal Client (eg user is comming in via tsclient)
  238. #define OS_TERMINALREMOTEADMIN 15 // Terminal Server in "Remote Administration" mode
  239. #define OS_WIN95_GOLD 16 // Windows 95 Gold (Version 4.0 Build 1995)
  240. #define OS_MILLENNIUMORGREATER 17 // Windows Millennium (Version 5.0)
  241. #define OS_WHISTLERORGREATER 18 // Whistler or greater
  242. #define OS_PERSONAL 19 // Personal (eg NOT Professional, Server, Advanced Server, or Datacenter)
  243. #ifdef UNIX // Add some type that's not defined in UNIX SDK
  244. typedef WORD UWORD;
  245. #endif
  246. #define REG_KEY_NT5LPK TEXT("W2KLpk")
  247. #define REGSTR_PATH_NT5LPK_INSTALL TEXT("System\\CurrentControlSet\\Control\\NLS\\Language Groups")
  248. #endif // _PRIVATE_H_