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.

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