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.

388 lines
12 KiB

  1. #ifndef __MUISETUP_H_
  2. #define __MUISETUP_H_
  3. #include <nt.h>
  4. #include <ntrtl.h>
  5. #include <nturtl.h>
  6. #include <windows.h>
  7. #include <commctrl.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <tchar.h>
  12. #include <winnls.h>
  13. #include "installer.h"
  14. #include "resource.h"
  15. #include "sxsapi.h"
  16. #define SUPPORT_PSEUDO_BUILD
  17. //#define IGNORE_COPY_ERRORS
  18. #define MUISETUP_HELP_FILENAME TEXT("muisetup.hlp")
  19. #define MUISETUP_EXECUTION_FILENAME TEXT("muisetup.exe")
  20. #define MUISETUP_ASSEMBLY_INSTALLATION_LOG_FILENAME TEXT("muisetup.log.") // langid would be ext
  21. #define MUISETUP_ASSEMBLY_INSTALLATION_REFERENCE_IDENTIFIER TEXT("MUISETUP installation");
  22. #define MUISETUP_PATH_SEPARATOR TEXT("\\")
  23. #define MUISETUP_FORWARDCALL_TAG TEXT("/$_transfer_$")
  24. #define MUI_FILLER_CHAR TEXT('?')
  25. //
  26. // Context Help IDs for Muisetup
  27. //
  28. #define IDH_COMM_GROUPBOX 28548
  29. #define IDH_MUISETUP_UILANGUAGE_LIST 3000
  30. #define IDH_MUISETUP_UILANGUAGECOMBO 3001
  31. #define IDH_MUISETUP_COMMANDLINE 3002
  32. #define IDH_MUISETUP_CHECKLOCALE 3003
  33. #define IDH_MUISETUP_MATCHUIFONT 3004
  34. #define MAX_UI_LANG_GROUPS 64
  35. #define INSTALLED_FILES 1500
  36. #define MAX_MUI_LANGUAGES 32
  37. #define MESSAGEBOX(hWnd, lpText, lpCaption, uiType) (g_bSilent? IDNO : MessageBox(hWnd, lpText, lpCaption, uiType))
  38. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  39. #define BUFFER_SIZE 1024
  40. #define MUI_MATCH_LOCALE 0x0001
  41. #define MUI_MATCH_UIFONT 0x0002
  42. #define REGSTR_MUI_SETTING TEXT("System\\CurrentControlSet\\Control\\NLS\\MUILanguages")
  43. #define REGSTR_VALUE_MATCH_LOCALE TEXT("MatchSystemLocale")
  44. #define REGSTR_VALUE_MATCH_UIFONT TEXT("UIFontSubstitute")
  45. #define IS_FE_LANGPACK(lcid) (((lcid) == 0x0804) || ((lcid) == 0x0404) || ((lcid)==0x0411) || ((lcid)==0x0412))
  46. //
  47. // MUI Language Info attached to listview item
  48. //
  49. typedef struct _MUILANGIINFO_structtag
  50. {
  51. LGRPID lgrpid; // MUI's Lang Group
  52. LCID lcid; // MUI's Lang LCID
  53. LPTSTR lpszLcid; // MUI's LCID name
  54. TCHAR szDisplayName[BUFFER_SIZE]; // The display for this language.
  55. int cd_number;
  56. INT64 ulLPKSize; // Size of LPK for this LCID
  57. INT64 ulUISize; // Size of MUI Resource files for this LCID
  58. } MUILANGINFO, *PMUILANGINFO;
  59. typedef struct _INSTALL_LANG_GROUP_Structtag
  60. {
  61. LGRPID lgrpid[MAX_MUI_LANGUAGES]; // MUI Lang Group to install
  62. int iCount; // count of MUI lang group to install
  63. BOOL bFontLinkRegistryTouched; // We have touched font link registry
  64. int NotDeleted;
  65. } INSTALL_LANG_GROUP, *PINSTALL_LANG_GROUP;
  66. typedef struct UI_LangGroup_Structtag
  67. {
  68. int iCount;
  69. LCID lcid[MAX_UI_LANG_GROUPS];
  70. } UILANGUAGEGROUP, *PUILANGUAGEGROUP;
  71. typedef struct _FILERENAME_TABLE_Structtag
  72. {
  73. TCHAR szSource[MAX_PATH+1];
  74. TCHAR szDest [MAX_PATH+1];
  75. } FILERENAME_TABLE,*PFILERENAME_TABLE;
  76. typedef struct _TYPENOTFALLBACK_TABLE_Structtag
  77. {
  78. TCHAR szSource[MAX_PATH+1];
  79. } TYPENOTFALLBACK_TABLE,*PTYPENOTFALLBACK_TABLE;
  80. //
  81. //...Macro for ListView checkboxes
  82. //
  83. #ifndef ListView_SetCheckState
  84. #define ListView_SetCheckState(hwndLV, i, fCheck) \
  85. ListView_SetItemState(hwndLV, i, \
  86. INDEXTOSTATEIMAGEMASK((fCheck)+1), LVIS_STATEIMAGEMASK)
  87. #endif
  88. #define LOG_FILE TEXT("\\muisetup.log")
  89. #define REG_MUI_PATH TEXT("System\\CurrentControlSet\\Control\\Nls\\MUILanguages")
  90. #define REG_FILEVERSION_PATH TEXT("System\\CurrentControlSet\\Control\\Nls\\MUILanguages\\FileVersions")
  91. #define MUI_LANG_GROUP_FILE TEXT("muilang.txt")
  92. extern UINT (WINAPI *pfnGetWindowsDir)(LPWSTR pBuf, UINT uSize);
  93. BOOL DeleteSideBySideMUIAssemblyIfExisted(LPTSTR Languages, TCHAR buf[BUFFER_SIZE]);
  94. BOOL CheckMultipleInstances(void);
  95. void InitGlobals(void);
  96. void Muisetup_Cleanup();
  97. void SetSourcePath(LPTSTR lpszPath);
  98. LPTSTR NextCommandTag(LPTSTR lpcmd);
  99. BOOL InitializePFNs();
  100. void Muisetup_RebootTheSystem(void);
  101. BOOL CheckForReboot(HWND hwnd, PINSTALL_LANG_GROUP pInstallLangGroup);
  102. BOOL CheckDefault(HWND hwndDlg);
  103. BOOL CheckLangGroupCommandLine(PINSTALL_LANG_GROUP pInstallLangGroup, LPTSTR lpArg);
  104. BOOL DeleteFiles(LPTSTR Languages,int *lpNotDeleted);
  105. int EnumSelectedLanguages(HWND hList, LPTSTR lpAddLanguages);
  106. int EnumUnselectedLanguages(HWND hList, LPTSTR lpRemoveLanguages);
  107. BOOL HaveFiles(LPTSTR lpBuffer, BOOL bCheckDir = TRUE);
  108. BOOL InitializeInstallDialog(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  109. BOOL InitializeListView(HWND hList);
  110. BOOL UpdateFontLinkRegistry(LPTSTR Languages,BOOL *lpbFontLinkRegistryTouched);
  111. BOOL IsInstalled(LPTSTR lpUILang);
  112. DWORD GetInstalledMUILanguages(LPTSTR lpUninstall, int cch);
  113. BOOL ListViewChanged(HWND hDlg, int iID, NM_LISTVIEW *pLV);
  114. BOOL ListViewChanging(HWND hDlg, int iID, NM_LISTVIEW *pLv);
  115. BOOL RunRegionalOptionsApplet(LPTSTR pCommands);
  116. BOOL ParseCommandLine(LPTSTR lpCommandLine);
  117. BOOL StartGUISetup(HWND hwndDlg);
  118. BOOL SelectInstalledLanguages(HWND hList);
  119. BOOL SetDefault(HWND hCombo);
  120. BOOL SetUserDefaultLanguage(LANGID langID, BOOL bApplyCurrentUser, BOOL bApplyAllUsers);
  121. BOOL UninstallUpdateRegistry(LPTSTR Languages);
  122. BOOL UpdateCombo(HWND hwndDlg);
  123. INT_PTR CALLBACK DialogFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  124. INT_PTR CALLBACK ProgressDialogFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  125. BOOL GetMuiLangInfoFromListView(HWND hList, int i, PMUILANGINFO *ppMuiLangInfo);
  126. int Muisetup_GetLocaleLanguageInfo(LCID lcid, PTSTR pBuf, int iLen, BOOL fCountryName);
  127. HKEY OpenMuiKey(REGSAM samDesired);
  128. BOOL GetLcidItemIndexFromListView(HWND hList, LCID lcid, int *piIndex);
  129. int CopyArgument(LPTSTR dest, LPTSTR src);
  130. int InsertLanguageInListView(HWND hList, LPTSTR lpLanguage, BOOL bCheckState);
  131. int InstallSelected (LPTSTR Languages,BOOL *lpbFontLinkRegistryTouched);
  132. int UninstallSelected(LPTSTR Languages,int *lpNotDeleted);
  133. PTCHAR SkipBlanks(PTCHAR pszText);
  134. void DisplayHelpWindow(void);
  135. void ListViewCustomDraw(HWND hDlg, LPNMLVCUSTOMDRAW pDraw);
  136. // Language Group Installation
  137. BOOL CALLBACK EnumLanguageGroupsProc(
  138. LGRPID LanguageGroup,
  139. LPTSTR lpLanguageGroupString,
  140. LPTSTR lpLanguageGroupNameString,
  141. DWORD dwFlags,
  142. LONG_PTR lParam);
  143. LGRPID GetLanguageGroup( LCID lcid );
  144. BOOL EnumLanguageGroupLocalesProc(
  145. LGRPID langGroupId,
  146. LCID lcid,
  147. LPTSTR lpszLocale,
  148. LONG_PTR lParam);
  149. BOOL DetectLanguageGroups(HWND hwndDlg);
  150. BOOL ConvertMUILangToLangGroup(HWND hwndDlg, PINSTALL_LANG_GROUP pInstallLangGroup);
  151. BOOL AddMUILangGroup(PINSTALL_LANG_GROUP pInstallLangGroup, LGRPID lgrpid);
  152. BOOL InstallLanguageGroups(PINSTALL_LANG_GROUP pInstallLangGroup);
  153. BOOL CheckVolumeChange();
  154. BOOL StartFromTSClient();
  155. BOOL CheckLanguageIsQualified(LPTSTR lpLanguage);
  156. BOOL CALLBACK Region_EnumUILanguagesProc(PWSTR pwszUILanguage,LONG_PTR lParam);
  157. BOOL MUIGetAllInstalledUILanguages();
  158. BOOL GetUIFileSize_commandline(LPTSTR lpszLcid, INT64 *ulUISize,INT64 *ulLPKSize);
  159. BOOL GetUIFileSize(PMUILANGINFO pMuiLangInfo);
  160. BOOL IsSpaceEnough(HWND hList,INT64 *ulSizeNeed,INT64 *ulSizeAvailable);
  161. BOOL CopyRemoveMuiItself(BOOL bInstall);
  162. BOOL RemoveFileReadOnlyAttribute(LPTSTR lpszFileName);
  163. BOOL MUI_DeleteFile(LPTSTR lpszFileName);
  164. void Set_SourcePath_FromForward(LPCTSTR lpszPath);
  165. BOOL MUIShouldSwitchToNewVersion(LPTSTR lpszCommandLine);
  166. BOOL MUI_TransferControlToNewVersion(LPTSTR lpszExecutable,LPTSTR lpszCommandLine);
  167. void ExitFromOutOfMemory();
  168. void NotifyKernel(
  169. LPTSTR LangList,
  170. ULONG Flags
  171. );
  172. BOOL WelcomeDialog(HWND hWndParent);
  173. BOOL DoSetup(
  174. HWND hwnd,
  175. int UninstallLangCount, LPTSTR lpUninstall,
  176. INSTALL_LANG_GROUP installLangGroup,
  177. int InstallLangCount, LPTSTR lpInstall,
  178. LPTSTR lpDefaultUILang,
  179. BOOL fAllowReboot, BOOL bInteractive);
  180. //
  181. // Utility functions
  182. //
  183. BOOL IsAdmin(void);
  184. DWORD_PTR TransNum(LPTSTR lpsz);
  185. LANGID GetDotDefaultUILanguage();
  186. //
  187. // Log functions
  188. //
  189. HANDLE OpenLogFile(void);
  190. void BeginLog(void);
  191. BOOL LogMessage(LPCTSTR lpMessage);
  192. BOOL LogFormattedMessage(HINSTANCE hInstance, int messageID, LONG_PTR* lppArgs);
  193. //
  194. // Resource utility functions
  195. //
  196. int DoMessageBox(HWND hwndParent, UINT uIdString, UINT uIdCaption, UINT uType);
  197. int DoMessageBoxFromResource(HWND hwndParent, HMODULE hInstance, UINT uIdString, LONG_PTR* lppArgs, UINT uIdCaption, UINT uType);
  198. LPTSTR FormatStringFromResource(LPTSTR pszBuffer, UINT bufferSize, HMODULE hInstance, int messageID, LONG_PTR* lppArgs);
  199. void SetWindowTitleFromResource(HWND hwnd, int resourceID);
  200. //
  201. // Registry utility functions
  202. //
  203. DWORD DeleteRegTree(HKEY hStartKey, LPTSTR pKeyName);
  204. //
  205. // External data refereces
  206. //
  207. extern BOOL gbError;
  208. extern HINSTANCE ghInstance;
  209. extern HWND ghProgress;
  210. extern HWND ghProgDialog;
  211. typedef
  212. NTSTATUS
  213. (NTAPI *pfnNtSetDefaultUILanguage)(
  214. LANGID DefaultUILanguageId
  215. );
  216. typedef
  217. LANGID
  218. (WINAPI *pfnGetUserDefaultUILanguage)(
  219. void
  220. );
  221. typedef
  222. LANGID
  223. (WINAPI *pfnGetSystemDefaultUILanguage)(
  224. void
  225. );
  226. typedef
  227. BOOL
  228. (WINAPI *pfnIsValidLanguageGroup)(
  229. LGRPID LanguageGroup,
  230. DWORD dwFlags
  231. );
  232. typedef
  233. BOOL
  234. (WINAPI *pfnEnumLanguageGroupLocalesW)(
  235. LANGGROUPLOCALE_ENUMPROCW lpLangGroupLocaleEnumProc,
  236. LGRPID LanguageGroup,
  237. DWORD dwFlags,
  238. LONG_PTR lParam
  239. );
  240. typedef
  241. BOOL
  242. (WINAPI *pfnEnumSystemLanguageGroupsW)(
  243. LANGUAGEGROUP_ENUMPROCW lpLanguageGroupEnumProc,
  244. DWORD dwFlags,
  245. LONG_PTR lParam
  246. );
  247. typedef
  248. NTSTATUS
  249. (NTAPI *pfnRtlAdjustPrivilege)(
  250. ULONG Privilege,
  251. BOOLEAN Enable,
  252. BOOLEAN Client,PBOOLEAN WasEnabled
  253. );
  254. typedef
  255. BOOL
  256. (WINAPI *pfnGetDefaultUserProfileDirectoryW)(
  257. LPWSTR lpProfileDir,
  258. LPDWORD lpcchSize
  259. );
  260. typedef
  261. BOOL (WINAPI *pfnMUI_InstallMFLFiles)(
  262. TCHAR* pMUIInstallLanguage
  263. );
  264. typedef
  265. BOOL
  266. (WINAPI *pfnProcessIdToSessionId)(
  267. DWORD_PTR dwProcessId,
  268. DWORD_PTR *pSessionId
  269. );
  270. typedef
  271. INT
  272. (WINAPI *pfnLaunchINFSection)(
  273. HWND hWnd,
  274. HINSTANCE hInstance,
  275. PSTR pParams,
  276. INT flags
  277. );
  278. typedef BOOL (*UILANGUAGE_ENUMPROC)(LPTSTR, LONG_PTR);
  279. typedef BOOL (*pfnEnumUILanguages)(UILANGUAGE_ENUMPROC, DWORD, LONG_PTR);
  280. extern pfnNtSetDefaultUILanguage gpfnNtSetDefaultUILanguage;
  281. extern pfnGetUserDefaultUILanguage gpfnGetUserDefaultUILanguage;
  282. extern pfnGetSystemDefaultUILanguage gpfnGetSystemDefaultUILanguage;
  283. extern pfnIsValidLanguageGroup gpfnIsValidLanguageGroup;
  284. extern pfnEnumLanguageGroupLocalesW gpfnEnumLanguageGroupLocalesW;
  285. extern pfnEnumSystemLanguageGroupsW gpfnEnumSystemLanguageGroupsW;
  286. extern pfnRtlAdjustPrivilege gpfnRtlAdjustPrivilege;
  287. extern pfnProcessIdToSessionId gpfnProcessIdToSessionId;
  288. extern pfnGetDefaultUserProfileDirectoryW gpfnGetDefaultUserProfileDirectoryW;
  289. extern pfnLaunchINFSection gpfnLaunchINFSection;
  290. extern PSXS_INSTALL_W gpfnSxsInstallW;
  291. extern PSXS_UNINSTALL_ASSEMBLYW gpfnSxsUninstallW;
  292. extern TCHAR g_szPlatformPath[];
  293. extern TCHAR g_AddLanguages[];
  294. extern TCHAR g_szMUIInfoFilePath[];
  295. extern TCHAR g_szMUISetupFolder[];
  296. extern TCHAR g_szMuisetupPath[];
  297. extern TCHAR g_szMUIHelpFilePath[];
  298. extern TCHAR g_szWinDir[];
  299. extern BOOL g_InstallCancelled;
  300. extern BOOL g_IECopyError;
  301. extern BOOL gbIsWorkStation,gbIsServer,gbIsAdvanceServer,gbIsDataCenter,gbIsDomainController;
  302. extern PFILERENAME_TABLE g_pFileRenameTable;
  303. extern int g_nFileRename;
  304. extern PTYPENOTFALLBACK_TABLE g_pNotFallBackTable;
  305. extern int g_nNotFallBack;
  306. extern LPTSTR g_SpecialFiles[];
  307. extern int gNumLanguages_Install;
  308. extern UILANGUAGEGROUP g_UILanguageGroup;
  309. extern LANGID gUserUILangId, gSystemUILangId;
  310. BOOL GetLanguageGroupDisplayName(LANGID LangId, LPTSTR lpBuffer, int nSize);
  311. BOOL CheckMUIRegSetting(DWORD dwFlag);
  312. BOOL SetMUIRegSetting(DWORD dwFlag, BOOL bEnable);
  313. BOOL AddExtraLangGroupsFromINF(LPTSTR lpszLcid, PINSTALL_LANG_GROUP pInstallLangGroup);
  314. BOOL InstallExternalComponents(LPTSTR Languages);
  315. VOID UninstallExternalComponents(LPTSTR Languages);
  316. #endif //__MUISETUP_H_