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.

229 lines
7.0 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright (c) 1994-1998 Microsoft Corporation
  4. //*********************************************************************
  5. //
  6. // HISTORY:
  7. //
  8. // 96/05/23 markdu Created.
  9. // 96/05/26 markdu Update config API.
  10. // 96/05/27 markdu Added lpIcfgGetLastInstallErrorText.
  11. // 96/05/27 markdu Use lpIcfgInstallInetComponents and lpIcfgNeedInetComponents.
  12. #include "wizard.h"
  13. // instance handle must be in per-instance data segment
  14. #pragma data_seg(DATASEG_PERINSTANCE)
  15. // Global variables
  16. HINSTANCE ghInstConfigDll=NULL; // handle to Config dll we load explicitly
  17. DWORD dwCfgRefCount=0;
  18. BOOL fCFGLoaded=FALSE; // TRUE if config function addresses have been loaded
  19. // global function pointers for Config apis
  20. GETSETUPXERRORTEXT lpGetSETUPXErrorText=NULL;
  21. ICFGSETINSTALLSOURCEPATH lpIcfgSetInstallSourcePath=NULL;
  22. ICFGINSTALLSYSCOMPONENTS lpIcfgInstallInetComponents=NULL;
  23. ICFGNEEDSYSCOMPONENTS lpIcfgNeedInetComponents=NULL;
  24. ICFGISGLOBALDNS lpIcfgIsGlobalDNS=NULL;
  25. ICFGREMOVEGLOBALDNS lpIcfgRemoveGlobalDNS=NULL;
  26. ICFGTURNOFFFILESHARING lpIcfgTurnOffFileSharing=NULL;
  27. ICFGISFILESHARINGTURNEDON lpIcfgIsFileSharingTurnedOn=NULL;
  28. ICFGGETLASTINSTALLERRORTEXT lpIcfgGetLastInstallErrorText=NULL;
  29. ICFGSTARTSERVICES lpIcfgStartServices=NULL;
  30. //
  31. // These two calls are only in NT icfg32.dll
  32. //
  33. ICFGNEEDMODEM lpIcfgNeedModem = NULL;
  34. ICFGINSTALLMODEM lpIcfgInstallModem = NULL;
  35. //////////////////////////////////////////////////////
  36. // Config api function names
  37. //////////////////////////////////////////////////////
  38. //static const CHAR szDoGenInstall[] = "DoGenInstall";
  39. static const CHAR szGetSETUPXErrorText[] = "GetSETUPXErrorText";
  40. static const CHAR szIcfgSetInstallSourcePath[] = "IcfgSetInstallSourcePath";
  41. static const CHAR szIcfgInstallInetComponents[] = "IcfgInstallInetComponents";
  42. static const CHAR szIcfgNeedInetComponents[] = "IcfgNeedInetComponents";
  43. static const CHAR szIcfgIsGlobalDNS[] = "IcfgIsGlobalDNS";
  44. static const CHAR szIcfgRemoveGlobalDNS[] = "IcfgRemoveGlobalDNS";
  45. static const CHAR szIcfgTurnOffFileSharing[] = "IcfgTurnOffFileSharing";
  46. static const CHAR szIcfgIsFileSharingTurnedOn[] = "IcfgIsFileSharingTurnedOn";
  47. static const CHAR szIcfgGetLastInstallErrorText[] = "IcfgGetLastInstallErrorText";
  48. static const CHAR szIcfgStartServices[] = "IcfgStartServices";
  49. //
  50. // Available only on NT icfg32.dll
  51. //
  52. static const CHAR szIcfgNeedModem[] = "IcfgNeedModem";
  53. static const CHAR szIcfgInstallModem[] = "IcfgInstallModem";
  54. // API table for function addresses to fetch
  55. #define NUM_CFGAPI_PROCS 12
  56. APIFCN ConfigApiList[NUM_CFGAPI_PROCS] =
  57. {
  58. { (PVOID *) &lpGetSETUPXErrorText, szGetSETUPXErrorText},
  59. { (PVOID *) &lpIcfgSetInstallSourcePath, szIcfgSetInstallSourcePath},
  60. { (PVOID *) &lpIcfgInstallInetComponents, szIcfgInstallInetComponents},
  61. { (PVOID *) &lpIcfgNeedInetComponents, szIcfgNeedInetComponents},
  62. { (PVOID *) &lpIcfgIsGlobalDNS, szIcfgIsGlobalDNS},
  63. { (PVOID *) &lpIcfgRemoveGlobalDNS, szIcfgRemoveGlobalDNS},
  64. { (PVOID *) &lpIcfgTurnOffFileSharing, szIcfgTurnOffFileSharing},
  65. { (PVOID *) &lpIcfgIsFileSharingTurnedOn, szIcfgIsFileSharingTurnedOn},
  66. { (PVOID *) &lpIcfgGetLastInstallErrorText, szIcfgGetLastInstallErrorText},
  67. { (PVOID *) &lpIcfgStartServices, szIcfgStartServices},
  68. //
  69. // These two calls are only in NT icfg32.dll
  70. //
  71. { (PVOID *) &lpIcfgNeedModem, szIcfgNeedModem},
  72. { (PVOID *) &lpIcfgInstallModem, szIcfgInstallModem}
  73. };
  74. #pragma data_seg(DATASEG_DEFAULT)
  75. extern BOOL GetApiProcAddresses(HMODULE hModDLL,APIFCN * pApiProcList,
  76. UINT nApiProcs);
  77. /*******************************************************************
  78. NAME: InitConfig
  79. SYNOPSIS: Loads the Config dll (ICFG32), gets proc addresses,
  80. EXIT: TRUE if successful, or FALSE if fails. Displays its
  81. own error message upon failure.
  82. ********************************************************************/
  83. BOOL InitConfig(HWND hWnd)
  84. {
  85. UINT uiNumCfgApiProcs = 0;
  86. DEBUGMSG("icfgcall.c::InitConfig()");
  87. // only actually do init stuff on first call to this function
  88. // (when reference count is 0), just increase reference count
  89. // for subsequent calls
  90. if (dwCfgRefCount == 0) {
  91. CHAR szConfigDll[SMALL_BUF_LEN];
  92. DEBUGMSG("Loading Config DLL");
  93. // set an hourglass cursor
  94. WAITCURSOR WaitCursor;
  95. if (TRUE == IsNT())
  96. {
  97. //
  98. // On Windows NT get the filename (ICFGNT.DLL) out of resource
  99. //
  100. LoadSz(IDS_CONFIGNTDLL_FILENAME,szConfigDll,sizeof(szConfigDll));
  101. }
  102. else
  103. {
  104. //
  105. // On Windows 95 get the filename (ICFG95.DLL) out of resource
  106. //
  107. LoadSz(IDS_CONFIG95DLL_FILENAME,szConfigDll,sizeof(szConfigDll));
  108. }
  109. // load the Config api dll
  110. ghInstConfigDll = LoadLibrary(szConfigDll);
  111. if (!ghInstConfigDll) {
  112. UINT uErr = GetLastError();
  113. // Normandy 11985 - chrisk
  114. // filenames changed for Win95 and NT
  115. if (TRUE == IsNT())
  116. {
  117. DisplayErrorMessage(hWnd,IDS_ERRLoadConfigDllNT1,uErr,ERRCLS_STANDARD,
  118. MB_ICONSTOP);
  119. }
  120. else
  121. {
  122. DisplayErrorMessage(hWnd,IDS_ERRLoadConfigDll1,uErr,ERRCLS_STANDARD,
  123. MB_ICONSTOP);
  124. }
  125. return FALSE;
  126. }
  127. //
  128. // Cycle through the API table and get proc addresses for all the APIs we
  129. // need - on NT icfg32.dll has 2 extra entry points
  130. //
  131. if (TRUE == IsNT())
  132. uiNumCfgApiProcs = NUM_CFGAPI_PROCS;
  133. else
  134. uiNumCfgApiProcs = NUM_CFGAPI_PROCS - 2;
  135. if (!GetApiProcAddresses(ghInstConfigDll,ConfigApiList,uiNumCfgApiProcs)) {
  136. // Normandy 11985 - chrisk
  137. // filenames changed for Win95 and NT
  138. if (TRUE == IsNT())
  139. {
  140. MsgBox(hWnd,IDS_ERRLoadConfigDllNT2,MB_ICONSTOP,MB_OK);
  141. }
  142. else
  143. {
  144. MsgBox(hWnd,IDS_ERRLoadConfigDll2,MB_ICONSTOP,MB_OK);
  145. }
  146. DeInitConfig();
  147. return FALSE;
  148. }
  149. }
  150. fCFGLoaded = TRUE;
  151. dwCfgRefCount ++;
  152. return TRUE;
  153. }
  154. /*******************************************************************
  155. NAME: DeInitConfig
  156. SYNOPSIS: Unloads Config dll.
  157. ********************************************************************/
  158. VOID DeInitConfig()
  159. {
  160. DEBUGMSG("icfgcall.c::DeInitConfig()");
  161. UINT nIndex;
  162. // decrement reference count
  163. if (dwCfgRefCount)
  164. dwCfgRefCount --;
  165. // when the reference count hits zero, do real deinitialization stuff
  166. if (dwCfgRefCount == 0)
  167. {
  168. if (fCFGLoaded)
  169. {
  170. // set function pointers to NULL
  171. for (nIndex = 0;nIndex<NUM_CFGAPI_PROCS;nIndex++)
  172. *ConfigApiList[nIndex].ppFcnPtr = NULL;
  173. fCFGLoaded = FALSE;
  174. }
  175. // free the Config dll
  176. if (ghInstConfigDll)
  177. {
  178. DEBUGMSG("Unloading Config DLL");
  179. FreeLibrary(ghInstConfigDll);
  180. ghInstConfigDll = NULL;
  181. }
  182. }
  183. }