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.

214 lines
6.4 KiB

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