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.

148 lines
3.9 KiB

  1. #include "miginf.h"
  2. #include "migutil.h"
  3. #include "basetypes.h"
  4. #include "utiltypes.h"
  5. #include "objstr.h"
  6. extern "C" {
  7. #include "ism.h"
  8. }
  9. #include "modules.h"
  10. #ifndef ARRAYSIZE
  11. #define ARRAYSIZE(x) ((sizeof(x)) / (sizeof(x[0])))
  12. #endif
  13. HINF g_hMigWizInf = INVALID_HANDLE_VALUE;
  14. POBJLIST g_HTMLApps;
  15. BOOL OpenAppInf (LPTSTR pszFileName)
  16. {
  17. if (g_hMigWizInf != INVALID_HANDLE_VALUE) {
  18. return TRUE;
  19. }
  20. if (!pszFileName)
  21. {
  22. TCHAR szFileName[MAX_PATH];
  23. PTSTR psz;
  24. if (!GetModuleFileName (NULL, szFileName, ARRAYSIZE(szFileName))) {
  25. return FALSE;
  26. }
  27. szFileName [ARRAYSIZE(szFileName) - 1] = 0;
  28. psz = _tcsrchr (szFileName, TEXT('\\'));
  29. if (!psz) {
  30. return FALSE;
  31. }
  32. lstrcpy (psz + 1, TEXT("migwiz.inf"));
  33. pszFileName = szFileName;
  34. }
  35. g_hMigWizInf = SetupOpenInfFile (pszFileName, NULL, INF_STYLE_WIN4|INF_STYLE_OLDNT, NULL);
  36. return g_hMigWizInf != INVALID_HANDLE_VALUE;
  37. }
  38. VOID CloseAppInf (VOID)
  39. {
  40. if (g_hMigWizInf != INVALID_HANDLE_VALUE) {
  41. SetupCloseInfFile (g_hMigWizInf);
  42. g_hMigWizInf = INVALID_HANDLE_VALUE;
  43. }
  44. }
  45. BOOL IsComponentEnabled (UINT uType, PCTSTR szComponent)
  46. {
  47. BOOL bResult = FALSE;
  48. INFCONTEXT ic;
  49. //
  50. // script-based entries start with $, while module-based entries don't.
  51. // This ensures script components do not collide with anything else.
  52. // Remove the $ to simplify [Single Floppy] or [Multiple Floppy].
  53. //
  54. if (_tcsnextc (szComponent) == TEXT('$')) {
  55. szComponent = _tcsinc (szComponent);
  56. }
  57. if (g_hMigWizInf != INVALID_HANDLE_VALUE) {
  58. switch (uType) {
  59. case MIGINF_SELECT_OOBE:
  60. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("OOBE"), szComponent, &ic);
  61. break;
  62. case MIGINF_SELECT_SETTINGS:
  63. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("Settings Only"), szComponent, &ic);
  64. if (!g_fStoreToFloppy && !bResult)
  65. {
  66. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("Settings Only.Ext"), szComponent, &ic);
  67. }
  68. break;
  69. case MIGINF_SELECT_FILES:
  70. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("Files Only"), szComponent, &ic);
  71. if (!g_fStoreToFloppy && !bResult)
  72. {
  73. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("Files Only.Ext"), szComponent, &ic);
  74. }
  75. break;
  76. case MIGINF_SELECT_BOTH:
  77. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("Files and Settings"), szComponent, &ic);
  78. if (!g_fStoreToFloppy && !bResult)
  79. {
  80. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("Files and Settings.Ext"), szComponent, &ic);
  81. }
  82. break;
  83. default:
  84. bResult = TRUE;
  85. break;
  86. }
  87. }
  88. return bResult;
  89. }
  90. BOOL
  91. GetAppsToInstall (
  92. VOID
  93. )
  94. {
  95. INFCONTEXT ic;
  96. POBJLIST objList = NULL;
  97. BOOL fResult;
  98. LPTSTR p;
  99. MIG_COMPONENT_ENUM mce;
  100. _FreeObjectList(g_HTMLApps);
  101. g_HTMLApps = NULL;
  102. if (IsmEnumFirstComponent (&mce, COMPONENTENUM_ALIASES | COMPONENTENUM_ENABLED |
  103. COMPONENTENUM_PREFERRED_ONLY, COMPONENT_NAME)) {
  104. do {
  105. if (IsmIsComponentSelected (mce.ComponentString, 0)) {
  106. p = _tcsinc(mce.ComponentString);
  107. if (SetupFindFirstLine (g_hMigWizInf, TEXT("AppsToInstallOnDest"), p, &ic)) {
  108. objList = _AllocateObjectList (mce.LocalizedAlias);
  109. objList->Next = g_HTMLApps;
  110. g_HTMLApps = objList;
  111. }
  112. }
  113. } while (IsmEnumNextComponent (&mce));
  114. }
  115. return (objList != NULL);
  116. }